function setPointer() { 
    if (document.all) for (var i=0;i < document.all.length; i++) document.all(i).style.cursor = 'wait'; 
    if (top.contentFrame.document.all) for (var i=0;i < top.contentFrame.document.all.length; i++) top.contentFrame.document.all(i).style.cursor = 'wait'; 
} 
function resetPointer() { 
    if (top.document.all) for (var i=0;i < top.document.all.length; i++) top.document.all(i).style.cursor = ''; 
    if (top.contentFrame.document.all) for (var i=0;i < top.contentFrame.document.all.length; i++) top.contentFrame.document.all(i).style.cursor = ''; 
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function playSample(song_id) {
		var pop_width = 502;
		var pop_height = 351;
		var playerURL = "Player.cfm?song_id="+song_id;
		
		if (screen.width && screen.height) {
			pop_left = (screen.width) ? (screen.width - pop_width)/2 : 0;
			pop_top = (screen.height) ? (screen.height - pop_height)/2 : 0;
			newwin=window.open(playerURL,'wma','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,height='+pop_height+',width='+pop_width+',top='+pop_top+',left='+pop_left);
		}
		
		/*if (window.screen && (screen.availWidth - pop_width)>=1 && (screen.availHeight - pop_height)>=1) {		// have screen information, so open in center
			pop_left = Math.floor((screen.availWidth - pop_width)/2);
			pop_top = Math.floor((screen.availHeight - pop_height)/2);
			 newwin=window.open(playerURL,'wma','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,height='+pop_height+',width='+pop_width+',top='+pop_top+',left='+pop_left);
		}*/
		
		else {
			var newwin=window.open(playerURL,'wma','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,height='+pop_height+', width='+pop_width);
		}

		// set the form fields and submit them to the popup window that we already opened
		//document.sample.src.value=song_src;

		newwin.focus();
}

function NewWindow(mypage,myname,w,h,scroll){
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
		settings =
		'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
		win = window.open(mypage,myname,settings)
		if(win.window.focus){win.window.focus();}
}


function XplaySample(song_id)	{
		
	var media_player='win_low';
	if (media_player=='' || window.parent.frmSearch.document.searchform.new_player.value!='')	{
		media_player=window.parent.frmSearch.document.searchform.new_player.value;
	}
	
	// determine sample path and filename based on media player preference
	var player=media_player.split('_');  // split the preference into the array 'player': player[0]=media type; player[1]=compression;
	
	// RealMedia samples go here
	if (player[0]=='real')	{
		var song_src=""+song_id+"_"+player[1]+".ra";
		// play the sample
	location.href=song_src;
	}
	// Windows Media samples go here (default)
	//if (player[0]=='win')	{
	else {
		//var song_src='http://207.229.94.48/'+song_id+'_'+player[1]+'.wma';
		// open an empty popup window
		var pop_width = 500;
		var pop_height = 344;
		if (window.screen && (screen.availWidth - pop_width)>=1 && (screen.availHeight - pop_height)>=1) {		// have screen information, so open in center
			pop_left = Math.floor((screen.availWidth - pop_width)/2);
			pop_top = Math.floor((screen.availHeight - pop_height)/2);
			var newwin=window.open('','wma','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,height='+pop_height+',width='+pop_width+',top='+pop_top+',left='+pop_left);
		}
		else {
			var newwin=window.open('','wma','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=0,height='+pop_height+', width='+pop_width);
		}

		// set the form fields and submit them to the popup window that we already opened
		//document.sample.src.value=song_src;

		newwin.focus();
		document.sample.song_id.value=song_id;
		document.sample.submit();
	}
	
}


function popup_plainscroll(url,w,h) {
	window.open(url,"_blank","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=" + w + ",height=" + h);
	//window.open(newloc,"popup","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,top=1,left=1,height=540, width=780")
}

function confirmDelete()	{
	var response=window.confirm("Click 'OK' if you are sure you want to permanently delete the comments.");
	if (response)	{
		document.forms[0].action.value='delete';
		document.forms[0].submit();
	}
}
function saveComments()	{
	if (document.forms[0].comments.value=='')	{
		alert('Comments cannot be blank.');
	}
	else	{
		document.forms[0].action.value='save';
		document.forms[0].submit();
	}
}
function redirectPrefs(song_id)	{
	if (window.parent.frmSearch.document.searchform.new_player.value!='')	{
		// play the sample if player preference has been saved (the 'play_sample' field gets populated when preference is saved)
		playSample(song_id);
	}
	else	{
		var newloc='preferences.cfm?song_id='+song_id;
		location.href=newloc;
	}
}

function autoplay()	{
// check to see if a sample should be played
	if (window.parent.frmSearch.document.searchform.play_sample.value!='')	{
		// play sample
		playSample(window.parent.frmSearch.document.searchform.play_sample.value);
		// clear the sample field so it won't keep playing by itself
		window.parent.frmSearch.document.searchform.play_sample.value='';
	}
}

//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

