// JavaScript Document
var xmlHttp=createXmlHttpRequestObject();

function createXmlHttpRequestObject()
{
	var xmlHttp;
	
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch(e)
	{
		var XmlHttpVersions=new Array("MSXML2.XMLHTTP.6.0",
									  "MSXML2.XMLHTTP.5.0",
									  "MSXML2.XMLHTTP.4.0",
									  "MSXML2.XMLHTTP.3.0",
									  "MSXML2.XMLHTTP",
									  "Microsoft.XMLHTTP");
		for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)
		{
			try
			{
				xmlHttp= new ActiveXObject(XmlHttpVersions[i]);
			}
			catch(e) {}
		}
	}
	if (!xmlHttp)
		alert("error of creating XMLHttpRequest");
	else
		return xmlHttp;
}





var div=0;
function GlobalVar(var_name) {
div=var_name;
}


function result(array_values,request_file,result_div,method)
{
GlobalVar(result_div);	


// [[0],[1],[2]]
//
	if(xmlHttp)
	{
		try
		{
	var send_post=array_values[0] + "=" + document.getElementById(array_values[0]).value;		
     for(i=1;i<array_values.length;i++)
       {
       	send_post += "&" + array_values[i] + "=" + document.getElementById(array_values[i]).value;
       }
   
			xmlHttp.open(method,request_file,true);
			xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			xmlHttp.onreadystatechange=handleRequestStateChange;
			
			xmlHttp.send(send_post);
		}
		catch(e)
		{
			alert("could not connect"+e.toString());
		}
	}
		
}



function helpful(yesno,rev_id,request_file,result_div,method)
{
GlobalVar(result_div);	


// [[0],[1],[2]]
//
	if(xmlHttp)
	{
		try
		{
		wh=screen.width+'x'+screen.height;
       	send_post = "yesno="+yesno+"&rev_id="+rev_id+"&wh="+wh;

   
			xmlHttp.open(method,request_file,true);
			xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			xmlHttp.onreadystatechange=handleRequestStateChange;
			
			xmlHttp.send(send_post);
		}
		catch(e)
		{
			alert("could not connect"+e.toString());
		}
	}
		
}

function auto_chk(request_file,result_div)
{
GlobalVar(result_div);	


// [[0],[1],[2]]
//
	if(xmlHttp)
	{
		try
		{
	num = (Math.round((Math.random()*9)+1));
       	send_post = "auto_get_data=" + num;

   
			xmlHttp.open('POST',request_file,true);
			xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			xmlHttp.onreadystatechange=handleRequestStateChange;
			
			xmlHttp.send(send_post);
		}
		catch(e)
		{
			alert("could not connect"+e.toString());
		}
	}
		
}

function handleRequestStateChange()
{
	myDiv = document.getElementById(div);
	myDiv.innerHTML = "";
		 if(xmlHttp.readyState==4)
	{
		if(xmlHttp.status==200)
		{
			try
			{
				
			
			
				response=xmlHttp.responseText;
			if(response.charAt(0)=="#")
				window.location =response.replace(/#/, "");
				else
				myDiv.innerHTML +=response;
			}
			catch(e)
			{
				alert("error of reading"+ e.toString());
			}
		}
		else
		{
			alert("problems fith connecting"+xmlHttp.statusText);
		}
		
	}
	
}




