// JavaScript Document
function stimeout(){
	document.location.href = 'index.php?rt=login/loginAction&Errorid=2';
}


function showResult(divs,args){
	//This div to open div in complete report
    document.getElementById(divs).style.display = 'block';
	document.getElementById(divs).innerHTML = args;
}


function callTimer(divs,limit){
	setTimeout("showResult('"+divs+"','')",limit);
}

function postZoneData(url,params,resCont){
	params = params+"&cajax=1";
	var http = GetXmlHttpObject();
	http.open("POST", url, true);
	
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	
	http.onreadystatechange = function() {//Call a function when the state changes.
		document.getElementById(resCont).innerHTML = "";
		if(http.readyState == 4 && http.status == 200) {
			if(http.responseText == "stimedout") stimeout();
			$("#zoneCont").html(http.responseText);
	
			$(".zoneStyle").mouseover(function () {
				$("div[id*='"+this.id+"']").addClass("zonehStyle");
			});
			
			$(".zoneStyle").mouseout(function () {
				$("div[id*='"+this.id+"']").removeClass("zonehStyle");
			});
			
			$('#zoneCont div').tooltip({
				track: true,
				delay: 0,
				showURL: false,
				showBody: " - ",
				fade: 250
			});
			
		}
	}
	http.send(params);
}


function postData1(url,params,resCont){
	params = params+"&cajax=1";
	var http = GetXmlHttpObject();
	http.open("POST", url, true);
	
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	http.onreadystatechange = function() {//Call a function when the state changes.
		document.getElementById(resCont).innerHTML = "";
		if(http.readyState == 4 && http.status == 200) {
		if(http.responseText == "stimedout") stimeout();
		   	showResult(resCont,http.responseText)
		}
	}
	http.send(params);
}

function postData(url,params,resCont){
	$('#mainContainer').hide(); 
	$('#ajaxLoader').html('Loading...');
	params = params+"&cajax=1";
	var http = GetXmlHttpObject();
	http.open("POST", url, true);
	
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	
	http.onreadystatechange = function() {//Call a function when the state changes.
		document.getElementById(resCont).innerHTML = "";
		$("#zoneCont").hide();
		if(http.readyState == 4 && http.status == 200) {
			if(http.responseText == "stimedout") stimeout();
			$('#ajaxLoader').html('');
			
			//showResult(resCont,http.responseText)
			         
			if(http.responseText == "singlephoto")
  		{ 
  		  document.getElementById('photosHolder').style.display="none";
  		  showResult("userHints","Photo Successfully Clipped!");
      }
      else if(http.responseText == "NoPhotos")
      {
		  document.getElementById('photosHolder').style.display="none";
  		  showResult("userHints","No Photos to clip!");
      }
      else
      {
      	showResult(resCont,http.responseText)
      }
			
			//callTimer(resCont,'15000')
			$("#closeRtag").click(function () {
				$("body").css("overflow", "auto");
				$("#rConatiner").fadeOut("fast");
				$("#zoneCont").fadeIn("slow");
				$('#mainContainer').fadeIn("slow");
			});
			
			
			//alert($(window).height());
			//alert($("#iContainer").height());
			$("#iContainer").height($(window).height()-115);
			//$("#iContainer").attr("height",$("#iContainer").height());
			//alert($("#iContainer").height());
			
		}
	}
	http.send(params);
}




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;
}

