//main.js - provide essential main javascript functions.

function show (id) {
	document.getElementById(id).style.display="block";
}
function hide (id) {
	document.getElementById(id).style.display="none";
}

//for closing siteMessages. (it looks kludgey because I test with sqzzy.loc, and I didn't want to have to set the domain.
function closeSiteMessage(id, stamp) {

	var date = new Date();
	date.setTime(date.getTime()+(30*24*60*60*1000));
	var expires = " expires="+date.toGMTString();
	var d = document.location.href;
	d = d.substr(d.indexOf("://")+3);
	d = d.substring(0,d.indexOf("/"));
	var tld = d.substr(d.lastIndexOf(".")+1);
	d = d.substring(0,d.lastIndexOf("."));
	var maindomain = d.substr(d.lastIndexOf(".")+1);
	d = d.substring(0,d.lastIndexOf("."));
	d = maindomain+"."+tld;
	if (id=='pix') {
		var c = 'StatBarPix=1; '+expires+'; path=/; domain=.'+d;

	} else if (id=='profile') {
		var c = 'StatBarProfile=1; '+expires+'; path=/; domain=.'+d;

	} else {
		var c = 'StatBar='+stamp+'; '+expires+'; path=/; domain=.'+d;
	}
	document.cookie = c;
	hide("siteMsg_"+id);
}



function xhGET(url, stateHandler,typey,id,up) {
  	var xmlhttp;
  	stateHandler(xmlhttp,1,typey,id,up);
  	if(window.XMLHttpRequest) {
  		xmlhttp = new XMLHttpRequest();
  		xmlhttp.onreadystatechange = function() {stateHandler(xmlhttp,xmlhttp.readyState,typey,id,up);}
  		xmlhttp.open("GET", url, true);
  		xmlhttp.send(null);
  	}
  	else if(window.ActiveXObject) {
  		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  		if(xmlhttp) {
  				xmlhttp.onreadystatechange = function() {stateHandler(xmlhttp,xmlhttp.readyState,typey,id,up);}
  				xmlhttp.open("GET", url, true);
  				xmlhttp.send();
  		}
  	}
}