//
// Get the HTTP Object
//
var	PageLength=15;
var GlobalCount=0;

function getHTTPObject(){
	if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest) return new XMLHttpRequest();
	else {
		alert("Your browser does not support AJAX.");
		return null;
	}
}

//
//
//
function hideline(temp)
{
	document.getElementById(temp).style.display="none";
	return true;
}

//
//
//
function getOutput(RUNURL,output,line,src)
{
	var httpObject=getHTTPObject();
	if (httpObject != null)
	{
		httpObject.open("GET",RUNURL,true);
		httpObject.send(null);
		httpObject.onreadystatechange = function()
		{
			if (httpObject.readyState == 4 && httpObject.status == 200)
			{
				var temp="line_"+line;
				document.getElementById(output).innerHTML=httpObject.responseText;

				if(output != 'popupContact')
				{
					//
					//	Refresh every PageLength submits because this is a paginated report with page length set to PageLength
					//
					if(GlobalCount<(PageLength-1))
					{
						GlobalCount++;
						timer=setTimeout("hideline('"+temp+"')",2000);
					}
					else
					{
						GlobalCount=0;
						timer=setTimeout("window.location.reload()",2000);
					}
				}
				else if(output == 'popupContact')
				{
					document.getElementById('popupimg').src=src;
				}
			}
			else
			{
				//document.getElementById(output).innerHTML='';
			}
		}
	}
}

//
//
//
function flickrUpload(img,output,line)
{
	//
	var runProg="/cgi-bin/ealing/fupload.pl?ID=ealing&img="+img;
	if(img!='' && img != null)
	{
		document.getElementById(output).innerHTML='Please wait...';
		getOutput(runProg,output,line,'');
	}
	else
	{
		document.getElementById(output).innerHTML='';
	}
}

//
//
//
function flickrReject(img,output,line)
{
	//
	var runProg="/cgi-bin/ealing/reject.pl?ID=ealing&img="+img;
	if(img!='' && img != null)
	{
		document.getElementById(output).innerHTML='Please wait...';
		getOutput(runProg,output,line,'');
	}
	else
	{
		document.getElementById(output).innerHTML='';
	}
}

//
//
//
function GetCookie(cook)
{
	var allcookies=document.cookie;
	var cooklen=cook.length;
	// alert('cook '+cook+' len '+cooklen);
	var pos=allcookies.indexOf(cook+'=');
	cookval='';
	//alert('cook '+pos+' allcookies '+allcookies);
	if (pos != -1)
	{
		var start=pos+cooklen+1;
		var end=allcookies.indexOf(';',start);
		end+1;
		if (end==-1) {end=allcookies.length;}
		cookval=unescape(allcookies.substring(start,end));
		// alert(' cook '+start+' end '+end+' cookval '+cookval);
	}
	return cookval;
}
