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 GetCenterImage(divId,centerId,linkId)
{		
	xmlHttp=GetXmlHttpObject();
	if(xmlHttp==null)
	{
		alert("Your browser does not support AJAX..")
		return;
	}
	var url="index_ajax.php"
	url=url+"?divId="+divId;
	url=url+"&centerId="+centerId;
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=function()
	{
		
			if (xmlHttp.readyState==4)
			{				
				document.getElementById("DivCenterImg").innerHTML = xmlHttp.responseText;
				if(xmlHttp.responseText!="")
				{
					for(i=1;i<=15;i++)
					{
						if(document.getElementById("RightLink"+i))
						{
							document.getElementById("RightLink"+i).className="art_right";
						}
					}					
					document.getElementById("RightLink"+linkId).className="art_right_active";
				}
				if(xmlHttp.responseText=="")
				{
					document.getElementById("DivCenterImg").innerHTML="Sorry data not available"
					document.getElementById("DivCenterImg").style.display="block";
					document.getElementById("DivLoadImg").style.display="none";
				}
			}
			else
			{
				document.getElementById("DivCenterImg").style.display="none";
				document.getElementById("DivLoadImg").style.display="block";				
			}
			
	}
	xmlHttp.open("get",url,true)
	xmlHttp.send(null)
}
function OnLoadOfDiv()
{
	document.getElementById("DivCenterImg").style.display="block";
	document.getElementById("DivLoadImg").style.display="none";
}
function GetLeftLink(divId,centerId,rightLinkId)
{
	for(i=1;i<=12;i++)
	{
		document.getElementById("Link"+i).className="artwork";
	}
	document.getElementById("Link"+divId).className="artwork_active";
	xmlHttp=GetXmlHttpObject();
	if(xmlHttp==null)
	{
		alert("Your browser does not support AJAX..")
		return;
	}
	var url="index_left_ajax.php"
	url=url+"?divId="+divId		
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=function()
	{
		
			if (xmlHttp.readyState==4)
			{
				document.getElementById("DivLeftLinks").innerHTML = xmlHttp.responseText;
				GetCenterImage(divId,centerId,rightLinkId);
			}
			
	}
	xmlHttp.open("get",url,true)
	xmlHttp.send(null)	
}
function GetCenter(divId)
{
	totalLeftLinks=document.getElementById("HFTotalLeftLink").value;
	for(i=1;i<=totalLeftLinks;i++)
	{						
		document.getElementById("RightLink"+i).className="art_right";
	}
	document.getElementById("RightLink"+divId).className="art_right_active";
	document.getElementById("DivCenterImg").innerHTML=document.getElementById("DivCenter"+divId).innerHTML
}
function OpenImage(imgName)
{
	window.open("popimage.html?"+imgName,"RaghavaGallery","scrollbars=no,left=60%,top=50%,width=200,height=200,resizable=no,status=no,location=no").focus();	
}
function OpenText(textHtml)
{
	window.open(textHtml,"RaghavaGalleryText","left=60%,top=50%,width=600,height=500,resizable=yes,status=no,location=no,scrollbars=yes").focus();	
}


var scHeight=0;
var scrollFun;
function scrollUp(divcontent,divcontainer,scrollUP,scrollDOWN)
{	
	divcontentObj=document.getElementById(divcontent);
	divcontainerObj=document.getElementById(divcontainer);	
	contantH=divcontentObj.offsetHeight;
	containerH=divcontainerObj.offsetHeight;	
	if(contantH>containerH)
	{	
		diffH=contantH-containerH;			
		if(diffH > scHeight *-1)
		{
			scHeight=scHeight+3*-2;
			divcontentObj.style.top=scHeight+"px";	
			scrollFun=setTimeout("scrollUp('"+divcontent+"','"+divcontainer+"','"+scrollUP+"','"+scrollDOWN+"')",100);		
		}
		else
		{
			document.getElementById(scrollUP).style.visibility="hidden";
			clearTimeout(scrollFun);
		}
	}	
	if(scHeight<0)
	{
		document.getElementById(scrollDOWN).style.visibility="visible";
	}
}
function clearScroll()
{
	clearTimeout(scrollFun);
}
function scrollDown(divcontent,divcontainer,scrollUP,scrollDOWN)
{	
	divcontentObj=document.getElementById(divcontent);
	divcontainerObj=document.getElementById(divcontainer);
	contantH=divcontentObj.offsetHeight;
	containerH=divcontainerObj.offsetHeight;	
	if(scHeight<0)
	{		
		scHeight=scHeight+3*2;
		divcontentObj.style.top=scHeight+"px";	
		scrollFun=setTimeout("scrollDown('"+divcontent+"','"+divcontainer+"','"+scrollUP+"','"+scrollDOWN+"')",100);		
	}
	else
	{
		document.getElementById(scrollDOWN).style.visibility="hidden";
		clearTimeout(scrollFun);
	}
	diffH=contantH-containerH;				
	if(contantH>containerH && scHeight*-1 < diffH)
	{
		document.getElementById(scrollUP).style.visibility="visible";
	}
		
}