var interval;
var mozop;
var xmlHttp;
var TDiv;

function init1()
{
//Even up sidebars with main document
var main=document.getElementById("main_content").offsetHeight;
var shift=97+main;
document.getElementById("left_side").style.height=shift+"px";
document.getElementById("right_side").style.height=shift+"px";
}

function scrollPos()
{
//Get scroll position
if (self.pageYOffset) {	
	yScroll = self.pageYOffset; 
	xScroll = self.pageXOffset;} 
else if (document.documentElement && document.documentElement.scrollTop){// Explorer 6 Strict
	yScroll = document.documentElement.scrollTop; 
	xScroll = document.documentElement.scrollLeft;}
else if (document.body) {// all other Explorers
	yScroll = document.body.scrollTop;
	xScroll = document.body.scrollLeft;}
var array=new Array(xScroll,yScroll);
return array;
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4||xmlHttp.readyState=="complete")
 { 
 document.getElementById("ajax").innerHTML=xmlHttp.responseText;
 } 
}

function openPopup(page,high,wide)
{
if(high==null){high=400;}
if(wide==null){wide=400;}
var bg=document.getElementById("bg");
var popup=document.getElementById("popup");
var ajax=document.getElementById("ajax");
mozop=0.00;

//Get dimensions of viewable window
if( typeof(window.innerWidth)=='number') {
    //Non-IE
    myWidth=window.innerWidth;
    myHeight=window.innerHeight;
    bg.style.opacity=mozop;
} else if(document.documentElement && (document.documentElement.clientWidth|| document.documentElement.clientHeight)) {
    //IE 6+ in 'standards compliant mode'
    myWidth=document.documentElement.clientWidth;
    myHeight=document.documentElement.clientHeight;
    bg.filters.alpha.opacity=10;
} else if(document.body &&(document.body.clientWidth||document.body.clientHeight)) {
    //IE 4 compatible
    myWidth=document.body.clientWidth;
    myHeight=document.body.clientHeight;
}

interval=setInterval("popFadeIn()",40);


var scroll=scrollPos();
xScroll=scroll[0];
yScroll=scroll[1];

//Get dimensions of entire document
if (document.body.scrollHeight > document.body.offsetHeight)
{ // all but Explorer Mac
	fullWidth=document.body.scrollWidth;
	fullHeight=document.body.scrollHeight;
} 
else 
{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
	fullWidth=document.body.offsetWidth;
	fullHeight=document.body.offsetHeight;
}

var height=myHeight;
var width=myWidth;
var centerY=(height-high)/2+yScroll;
var centerX=(width-wide)/2;

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  ajax.innerHTML="Your browser does not support AJAX.";
  return;
  } 
var url="/windows/forms.php?action="+page+"&uid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);

bg.style.height=fullHeight+"px";
bg.style.width=fullWidth+"px";
popup.style.height=high+"px";
popup.style.width=wide+"px";
popup.style.position="absolute";
popup.style.top=centerY+"px";
popup.style.left=centerX+"px";
ajax.style.height=high-42+"px";
ajax.style.width=wide-6+"px";

bg.style.display="block";
popup.style.display="block";
ajax.focus();
}

function closePopup()
{
document.getElementById("popup").style.display="none";
document.getElementById("bg").style.display="none";
document.getElementById("ajax").innerHTML="<img src='/images/loading.gif' style='margin-top:25%;' /><br /><br /><b>Loading...</b>";
clearInterval(interval);
}

function popFadeIn()
{
if(mozop<0.60) {
mozop+=0.05;
document.getElementById("bg").style.opacity=mozop;
}
else if (document.getElementById("bg").filters&&document.getElementById("bg").filters.alpha.opacity<70) {
document.getElementById("bg").filters.alpha.opacity+=5;
}
else{clearInterval(interval)}
}


function postForm(id)
{
xmlHttp=GetXmlHttpObject();
var frm=document.getElementById(id);
var target=frm.action;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("POST",target);
xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    
queryString=""; 
var numberElements=frm.elements.length; 
	for(var i=0;i<numberElements;i++) 
	{
	var ele=frm.elements[i];
	if((ele.type=="checkbox"||ele.type=="radio")&&ele.checked!=true){continue;}
	queryString+=ele.name+"="+encodeURIComponent(ele.value);
	if(i<numberElements-1){queryString+="&";}
	}
xmlHttp.send(queryString);
}

function vote(site)
{
var str='vote&site='+site;
openPopup(str);
}

function showComments(site)
{
var str='view_comments&site='+site;
openPopup(str,500,500);
}