	var maxSize=3;
	
	function trimString (str) 
	{
	  str = this != window? this : str;
	  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
	}
// JavaScript Document
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 next_previous(flag,id)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	
	if(!id)
		id=document.getElementById("cur_post").value;
	
	var str = id;
	var url="/html/cat_photo.php";
	//alert (url);
	url=url+"?id="+str;
	url=url+"&flag="+flag;
	url=url+"&sid="+Math.random();
//	alert (url);
	xmlHttp.onreadystatechange=next_previous1next;	
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	
}

function next_previous1next() 
{
	if (xmlHttp.readyState==4)
	{ 
		result=trimString(xmlHttp.responseText).split('**');
		//alert (result);
		if(result)
		{
			 if (result[0]!="")
			 {
				 
				document.big_img.src="admin/user_photos/120_120_thumb_"+result[0];
				document.getElementById('big_light').href="admin/user_photos/"+result[0];
				document.getElementById('big_light').title=result[1];
				document.getElementById("imgTitle").innerHTML=result[1].truncate(21, '...');
				document.getElementById("cur_post").value=result[2];
				document.getElementById("outof").innerHTML=result[2];

//				alert (result[2]%maxSize);
				
				if(result[3])
				{
					document.getElementById("thumb_nail_imgs").innerHTML=result[3];
					document.getElementById("outof3").innerHTML=result[4];				
				}
				
				var modRs=(result[2]%maxSize)
				
				if(modRs<=0)
					modRs=result[2];
					
				document.getElementById("img"+result[2]).className='transparent_class'

				//increment value
				 var lp=(parseInt(result[2])-modRs)+1;
				for (cp=lp; cp<result[2]; cp++)
				{
					if(cp>0 && cp<(parseInt(result[2])))
					{
						if(document.getElementById("img"+cp)!=null);
							document.getElementById("img"+cp).className="transparent_class1";
					}
				}
				//decrement value				 
				 var lp=cp+(parseInt(maxSize-modRs));
				for (cp=cp; cp<=lp; cp++)
				{
					if(cp>0 && cp>(parseInt(result[2])))
					{
						if(document.getElementById("img"+cp)!=null);
							document.getElementById("img"+cp).className="transparent_class1";
					}
				}
			 }
		}
	}
}


function changeCat(str)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var url="/html/cat_photo.php";
	url=url+"?id="+str;
	url=url+"&flag=cat";
	url=url+"&sid="+Math.random();

	xmlHttp.onreadystatechange=changeCat1;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function changeCat1() 
{ 

	if (xmlHttp.readyState==4)
	{ 
		result=trimString(xmlHttp.responseText);

		if(result)
		{
			document.getElementById("photoGall").innerHTML=result;
		}
	}
}
