var http = false;http = new XMLHttpRequest();var countdown=0;var lastsearch='';var lastcolor='';
var primary = document.getElementById("primary");var secondary = primary.nextSibling;
var outbox = secondary.firstChild.childNodes[0];var logolink = outbox.childNodes[0];var logo = logolink.firstChild;var urllink = outbox.childNodes[1];var nowlink = outbox.lastChild;
var usagebox = secondary.firstChild.childNodes[1];var aelv = usagebox.firstChild;var bookmark = usagebox.lastChild.firstChild;
var ratebox = secondary.lastChild;var chart = ratebox.firstChild;var ratediv = ratebox.lastChild;
var searchbox = document.getElementById("searchbox");

function stripe() {
var alt=0;
var t = document.getElementById('ctable');
var i = t.rows.length-1;
while (i--) { if(alt===0) { t.rows[i+1].style.backgroundColor = "#E8E8E8"; alt=1; } else { t.rows[i+1].style.backgroundColor = "#FFFFFF"; alt=0; } }
}

function select(id,sid) {
http.abort();
logo.src = '/images/logos/'+sid+'.png';
http.open("GET", "/ajax/select.php?id="+id, true);
http.onreadystatechange=function() {
	if(http.readyState == 4) { eval(http.responseText); primary.style.display = "none"; secondary.style.display = "block"; }
}
http.send(null);
nowlink.innerHTML="[use now]";
stripe();
document.getElementById(id).style.backgroundColor = "#FCAA9A";
lastcolor = "#FCAA9A";
}

function page(p,d,s) {
q = searchbox.value;
http.open("GET", "/ajax/page.php?p="+p+"&q="+q+"&d="+d+"&s="+s, true);
http.onreadystatechange=function() {
	if(http.readyState == 4) { eval(http.responseText);stripe(); }
}
http.send(null);
}

function ls(s,v) {
clearTimeout(countdown);
if(s.length > 1 && s!=lastsearch) countdown = setTimeout("livesearch('"+escape(s)+"','"+v+"')", 300);
}

function livesearch(s,v) {
http.abort();
var loading = document.getElementById("loading");
http.open("GET", '/ajax/search.php?s='+s+'&v='+v, true);
http.onreadystatechange=function() { if(http.readyState == 4) { eval(http.responseText); loading.innerHTML = ""; } }
http.send(null);
loading.innerHTML = 'loading...';
}

function rate(id,ud) {
http.open("GET", "/ajax/rate.php?id="+id+"&ud="+ud, true);
http.onreadystatechange=function() { if(http.readyState == 4) eval(http.responseText); }
http.send(null);
}

function bkmk(id, a) {
http.open('GET', '/ajax/bookmark.php?id='+id+'&a='+a, true);
http.onreadystatechange=function() { if(http.readyState == 4) bookmark.innerHTML = http.responseText; }
http.send(null);
bookmark.setAttribute("onClick","javascript:bkmk("+id+","+(1-a)+");");
}

function showhide(name, a){
document.cookie = name+'='+a+'; expires=Fri, 06 Apr 2012 00:00:00 GMT; path=/';
var alt1="none";var alt2="block";var label="[show]";
if(a===1){alt1="block";alt2="none";label="[hide]";}
document.getElementById(name+'contents').style.display = alt1;
document.getElementById(name+'teaser').style.display = alt2;
var showhide = document.getElementById(name);
showhide.setAttribute("onClick","javascript:showhide('"+name+"',"+(1-a)+");");
showhide.innerHTML = label;
}

function on(i){lastcolor=i.style.backgroundColor;i.style.backgroundColor='#FDD0B9';}

function off(i){i.style.backgroundColor=lastcolor;}

function emailme(button,store){
var email = button.previousSibling;
http.open('GET', '/ajax/subscribe.php?s='+store+'&e='+escape(email.value), true);
http.onreadystatechange=function() { if(http.readyState == 4) button.nextSibling.innerHTML = http.responseText; }
http.send(null); email.value = '';
}

function dropin(select) {
select.parentNode.removeAttribute("onMouseOver");
var otemp = document.createElement('option');
http.open("GET", "/ajax/dropdown.php", true);
	http.onreadystatechange = function() {
		if (http.readyState == 4) {
		var s = http.responseXML.getElementsByTagName("s"); var o;
		var i=s.length; while(i--) { o = otemp.cloneNode(true); o.text=s[i].firstChild.firstChild.nodeValue; o.value=s[i].lastChild.firstChild.nodeValue; select.add(o,null); }
		select.remove(1);
		}
	}
http.send(null);
}