// JavaScript Document
var AjaxFree2=1;
var AjaxFree3=1;
var AjaxFree4=1;

function SRmakeObject()
{
var x; 
var browser = navigator.appName; 
if(browser == "Microsoft Internet Explorer")
{
x = new ActiveXObject("Microsoft.XMLHTTP");
}else{
x = new XMLHttpRequest();
}
return x;
}

var SRPhotorequest = SRmakeObject();	//Create Ajax Object 
var SRPhotorequest1 = SRmakeObject();	//Create Ajax Object 
var SRPhotorequest2 = SRmakeObject();	//Create Ajax Object 
var SRPhotorequest3 = SRmakeObject();	//Create Ajax Object 
var SRPhotorequest4 = SRmakeObject();	//Create Ajax Object 
var SRPhotorequest5 = SRmakeObject();	//Create Ajax Object 
var SRPhotorequest6 = SRmakeObject();	//Create Ajax Object 


var SRratecurid="";
var SRratenextid="";
var SRratecurno="";
var SRinitialcall=0;

//Open any div
function SROpenDiv(Odivname)
{
document.getElementById(Odivname).style.display='';
}

//Close any div
function SRCloseDiv(Cdivname)
{	
document.getElementById(Cdivname).style.display='none';
}


//Get Paging Starting Value
function SRGetStartValue()
{		
SRssvalue = SRGetEndValue();
var comboid = parseInt(document.SRfrm.HiddenCombo.selectedIndex)
return SRssvalue=comboid * SRrecperpages + 1	;
}

//Get Paging Ending Value
function SRGetEndValue()
{		
var comboid = parseInt(document.SRfrm.HiddenCombo.selectedIndex)
var ComboValue = document.SRfrm.HiddenCombo.value;
SRtemp = ComboValue.split(',');	
return SReevalue=comboid * SRrecperpages + SRtemp.length-1	;
}

function PagingControl(SRPtype)	//Control Next and Previous Records for Paging 
{

if(SRPtype == 1)	//Previous Record - Paging
{
var comboid = parseInt(document.SRfrm.HiddenCombo.selectedIndex)-1;	
document.SRfrm.HiddenCombo.selectedIndex = comboid;
var ComboValue = document.SRfrm.HiddenCombo.value;
SRFillPaging(ComboValue);
}
else			//Next Record - Paging
{	
var comboid = parseInt(document.SRfrm.HiddenCombo.selectedIndex)+1;	
document.SRfrm.HiddenCombo.selectedIndex = comboid;
var ComboValue = document.SRfrm.HiddenCombo.value;	
SRFillPaging(ComboValue);
}	 

var SRnoofpages=document.SRfrm.HiddenCombo.options.length-1;	//number of pages

var SRendvalue = SRGetEndValue();
var SRstartvalue = SRGetStartValue();

document.getElementById("SRendingValue").innerHTML=SRendvalue;		//fill ending value
document.getElementById("SRstaringValue").innerHTML=SRstartvalue;	//fill staring value

	if(comboid == 0)	//Current Paging at 1st page
	{
	SRCloseDiv('divPagingleft');
	SRCloseDiv('divPagingleft1');
	SROpenDiv('divPagingright');
	SROpenDiv('divPagingright1');	
	}
	
	if(comboid > 0 && comboid < SRnoofpages)	//Current Paging at middle
	{
	SROpenDiv('divPagingleft');
	SROpenDiv('divPagingleft1');
	SROpenDiv('divPagingright');
	SROpenDiv('divPagingright1');	
	}

	if(comboid == SRnoofpages)	//Current Paging at last
	{
	SROpenDiv('divPagingleft');
	SROpenDiv('divPagingleft1');
	SRCloseDiv('divPagingright');
	SRCloseDiv('divPagingright1');	
	}


}	//Control Next and Previous Records for Paging

function SRFillPaging(Idvals)
{	
if(AjaxFree2 == 0)
return false;

AjaxFree2=0;

	var xmlhttp=false; 
	try 
	{
	xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
	} 
	
	catch (e) 
	{
		try 
		{
		xmlhttp = new
		ActiveXObject('Microsoft.XMLHTTP'); 
		} 
		catch (E) 
		{
		xmlhttp = false;
		}
	}
	
	if (!xmlhttp && typeof XMLHttpRequest!='undefined')
	xmlhttp = new XMLHttpRequest(); 

	var page = Idvals;
	var file = '../photos/photo_left.php?Cur_array_value='; 

	xmlhttp.open('GET', file + page, true); 

document.getElementById("SROutPutLeft").innerHTML = "<br /><br /><br /><center><img src='../images/wait.gif' border='0' /></center><br /><center>Loading...</center><br /><br /><br />";
	
	xmlhttp.onreadystatechange=function() 
	{
		if (xmlhttp.readyState==4) 
		{ 
			var content = xmlhttp.responseText; 
			document.getElementById("SROutPutLeft").innerHTML =  content;
			AjaxFree2=1;	
			if(SRinitialcall == 1)
			SRFillPhoto(0, 0);	
			SRinitialcall=1;
		}
						
	}
					
	xmlhttp.send(null) 
	return;
}



function SRFillPhoto(dispid, currid)
{	

if(AjaxFree3 == 0)
return false;

AjaxFree3=0;	


if(currid == 15)
{
PagingControl(2);
dispid = 0;
currid = 0;
}

if(currid == -1)
{
PagingControl(1);
dispid = 0;
currid = 0;
}

if(currid == -2)
{
dispid = dispid;
currid = -2;
}

document.getElementById("SROutPutRight").innerHTML = "<br /><br /><br /><center><img src='../images/wait.gif' border='0' /></center><br /><center>Loading...</center><br /><br /><br />";

var SRnoofpages=document.SRfrm.HiddenCombo.options.length;	//number of pages

if(document.SRfrm.HiddenCombo.selectedIndex == -1)
document.SRfrm.HiddenCombo.selectedIndex = 0;

var comboid = parseInt(document.SRfrm.HiddenCombo.selectedIndex)
var ComboValue = document.SRfrm.HiddenCombo.value;
SRtemp = ComboValue.split(',');	

AjaxParameters='CurRec='+dispid+'&CurNo='+currid+'&TotIds='+SRtemp+'&TotalRecords='+TotalRecords+'&CurPaging='+comboid+'&elink='+SRrightpagename;		

SRPhotorequest2.open('post', '../photos/photo_right.php');
SRPhotorequest2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
SRPhotorequest2.onreadystatechange = SRBKFillPhoto; 
SRPhotorequest2.send(AjaxParameters);

}

function SRBKFillPhoto()
{
var InfoReturn2 = SRPhotorequest2.responseText;
if(SRPhotorequest2.readyState == 4)
{	
AjaxFree3=1;
document.getElementById("SROutPutRight").innerHTML = InfoReturn2;	
}

}

function SRratepic(ratvalue, picid, currno, nextpicid)
{	

if(UserLoged == 0)
{	alert('Login required!');	return false;	}


if(AjaxFree3 == 0)
return false;

AjaxFree3=0;
SRratecurid=picid;
SRratenextid=nextpicid;
SRratecurno=currno;

document.getElementById("SRratingOutput1").innerHTML = "<center><font color='green'>Successfully rated for this photo.</font></center> ";

AjaxParameters='pic_id='+picid+'&ratnum='+ratvalue;
SRPhotorequest.open('post', '../photos/Ajax_ratestar.php');
SRPhotorequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
SRPhotorequest.onreadystatechange = SRBKratepic; 
SRPhotorequest.send(AjaxParameters);

}


function SRBKratepic()
{	
var InfoReturn3 = SRPhotorequest.responseText;

if(SRPhotorequest.readyState == 4)
{	
document.getElementById("SRratingOutput1").innerHTML = "";
AjaxFree3=1;

if(SRratecurno == 15)
{
PagingControl(2);
dispid = 0;
currid = 0;
}

if(TotalRecords != parseInt(document.getElementById("SRstaringValue").innerHTML) )
SRFillPhoto(SRratenextid, (SRratecurno+1));

}

}

//Add to your photos list - Scrap book
function Addscrap(scrapid, scraptype)
{

if(UserLoged == 0)
{	alert('Login required!');	return false;	}

if(AjaxFree2 == 0)
return false;

AjaxFree2=0;

if(scraptype == 1)
document.getElementById("SRscrapOutput").innerHTML = "Saving...";
else
document.getElementById("SRscrapOutput").innerHTML = "Removing...";

AjaxParameters='pic_id='+scrapid+'&scraptype='+scraptype;
SRPhotorequest5.open('post', '../photos/Ajax_addscrap.php');
SRPhotorequest5.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
SRPhotorequest5.onreadystatechange = AddBKscrap; 
SRPhotorequest5.send(AjaxParameters);

}

function AddBKscrap()
{

var InfoReturn2 = SRPhotorequest5.responseText;

if(SRPhotorequest5.readyState == 4)
{	
AjaxFree2=1;
document.getElementById("SRscrapOutput").innerHTML = InfoReturn2;
}

}

function badcontent(SRbad)
{
if(UserLoged == 0)
{	alert('Login required!');	return false;	}	
	
if(AjaxFree2 == 0)
return false;

AjaxFree2=0;

AjaxParameters='bad_id='+SRbad;	
SRPhotorequest3.open('post', '../photos/Ajax_badcontent.php');
SRPhotorequest3.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
SRPhotorequest3.onreadystatechange = badBKcontent; 
SRPhotorequest3.send(AjaxParameters);

}

function badBKcontent()
{
	
var InfoReturn4 = SRPhotorequest3.responseText;

if(SRPhotorequest3.readyState == 4)
{	
document.getElementById("SRbadcontent").innerHTML = InfoReturn4;
AjaxFree2=1;
}
	
}

function SROpenCloseDiv(Cdivname)
{	
if(document.getElementById(Cdivname).style.display == 'none')
document.getElementById(Cdivname).style.display='';
else
document.getElementById(Cdivname).style.display='none';

}


function SRcombocall()
{	
if(AjaxFree4 == 0)
return false;

AjaxFree4=0;

AjaxParameters='r=1';
SRPhotorequest4.open('post', '../photos/Ajax_callcombo.php');
SRPhotorequest4.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
SRPhotorequest4.onreadystatechange = SRBKcombocall; 
SRPhotorequest4.send(AjaxParameters);

}

function SRBKcombocall()
{
	
var InfoReturn4 = SRPhotorequest4.responseText;

if(SRPhotorequest4.readyState == 4)
{	
document.getElementById("SRcombodisplay").innerHTML = InfoReturn4;
AjaxFree4=1;
}
	
}

function SRcombofill(lanid)
{
AjaxParameters='lid='+lanid;
SRPhotorequest4.open('post', '../photos/Ajax_fillcombo.php');
SRPhotorequest4.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
SRPhotorequest4.onreadystatechange = SRBKcombofill; 
SRPhotorequest4.send(AjaxParameters);	
	
}

function SRBKcombofill()
{
document.getElementById("SRcombodisplay2").innerHTML = 'Loading...!';
var InfoReturn4 = SRPhotorequest4.responseText;	
if(SRPhotorequest4.readyState == 4)
document.getElementById("SRcombodisplay2").innerHTML = InfoReturn4;
}

// for share orkut form submit
function shareorkut()
{
document.SRfrm.action ="../share-sn/index.php";
document.SRfrm.method="post";
document.SRfrm.submit();
}

function delphotocomment(delid, picid)
{
commdelid = "Divdelcomment"+delid;
document.getElementById(commdelid).innerHTML = 'Deleting...!';

if(confirm("Are you sure want to delete?"))
{
AjaxParameters='type=1&delid='+delid+'&pid='+picid;
SRPhotorequest6.open('post', '../photos/Ajax_photocomment.php');
SRPhotorequest6.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
SRPhotorequest6.onreadystatechange = SRBKphotocomment; 
SRPhotorequest6.send(AjaxParameters);	
}
}

function SRBKphotocomment()
{
var InfoReturn6 = SRPhotorequest6.responseText;	
if(SRPhotorequest6.readyState == 4)
document.getElementById("Divdisplaycomment").innerHTML = InfoReturn6;
}

function add_photocomment(pid)
{
if(UserLoged == 0)
{	alert('Login required!');	return false;	}		
	
var comdesc = encodeURIComponent(Trim(document.getElementById('txtPhotocomment').value)); 
if(comdesc == "")
{	alert("Message Required!");	return false;	}
	
document.getElementById("commadd_id").value = 'Adding Comment...!';
AjaxParameters='type=3&pid='+pid+'&comdesc='+comdesc;
SRPhotorequest6.open('post', '../photos/Ajax_photocomment.php');
SRPhotorequest6.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
SRPhotorequest6.onreadystatechange = SRBKadd_photocom; 
SRPhotorequest6.send(AjaxParameters);	
}

function SRBKadd_photocom()
{
var InfoReturn6 = SRPhotorequest6.responseText;	
if(SRPhotorequest6.readyState == 4)
{
document.getElementById("commadd_id").value = 'Submit';
document.getElementById('txtPhotocomment').value = "";
document.getElementById('txtPhotocomment').focus();
document.getElementById("Divdisplaycomment").innerHTML = InfoReturn6;
}
}


function editphotocomment(pid)
{
var comdesc = encodeURIComponent(Trim(document.getElementById('txtPhotocomment').value)); 
if(comdesc == "")
{	alert("Message Required!");	return false;	}
	
document.getElementById("commadd_id").value = 'Adding Comment...!';
AjaxParameters='type=3&pid='+pid+'&comdesc='+comdesc;
SRPhotorequest6.open('post', '../photos/Ajax_photocomment.php');
SRPhotorequest6.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
SRPhotorequest6.onreadystatechange = SRBKadd_photocom; 
SRPhotorequest6.send(AjaxParameters);	
}

document.write("<script type='text/javascript' src='../sharetool/sharetool.js'></script>");




