var objAlbum;
var rowNo,url;  
    function albumReq()
    {
       
        var serUrl ='/servlet/PhotoGallary?rowNo='+rowNo+'&stateName='+stateName+'&destinationName='+destinationName+'&randomNum='+Math.random()*5;
       //alert("serUrl value :->"+serUrl);   
        
        if(window.ActiveXObject)
        {
            objAlbum = new ActiveXObject('Microsoft.XMLHTTP');
            
        }
        else
        {
            objAlbum = new XMLHttpRequest();
        }
        if(objAlbum)
        {
            //alert("objAddRequest 1");
            objAlbum.onreadystatechange = sendAlbumInfo;
            //alert("objAddRequest 2");
            objAlbum.open('Get',serUrl,true);
            //alert("objAddRequest 3");
            objAlbum.send('');
            
        }
    }
    function sendAlbumInfo()
    {   
        
        //alert('object state :-> '+objAddRequest.readyState)
        if(objAlbum.readyState==4)
        {
            //alert('object status :-> '+objAddRequest.status)
            if(objAlbum.status==200)
            {
               //alert('200');
			   
			   try
				{
					var resAlbum = objAlbum.responseText;
			   	   //alert('Res :->'+resAlbum);
				   					
				   	 	var filterAlbumRes = resAlbum.split("^");
			   			/*alert(filterAlbumRes[0]);
						alert(filterAlbumRes[1]);
						alert(filterAlbumRes[2]);
						*/
						if(!(filterAlbumRes[1]==null))
						{
			   				var albImageTDObj = document.getElementById('albumImageTD');
							var albImageObj = document.getElementById('albumImage');
							
							albImageObj.src = filterAlbumRes[1];						
							//albImageObj.alt = filterAlbumRes[2];
							//albImageTDObj.title  = filterAlbumRes[2];
							rowNo = filterAlbumRes[0];
							//url = filterAlbumRes[6];
							//alert('Url:->'+url);
						}
						else
						{
							alert('Error ! Try After Some time');
							rowNo=1;
							document.getElementById('photoGallary').style.display='none';
						}
			   	   		//alert(pGCss.style.backgroundImage);
				   		//alert('rowNo :->'+rowNo);
						if(filterAlbumRes[3]=='true')
						{
							var nextClickObj = document.getElementById('nextClick');
							nextClickObj.innerHTML = '<a href="javascript:void(0)" onClick="nextPhoto()"><img src="/image/Home/Album/next_but.gif" width="16" height="12"  alt="Next" border="0"/></a>';
					
						}
						else
						{
							var nextClickObj = document.getElementById('nextClick');
							nextClickObj.innerHTML = '<img src="/image/Home/Album/next_but.gif" width="16" height="12"  alt="Next" border="0"/>';
					
						}
						if(filterAlbumRes[4]=='true')
						{
							var preClickObj = document.getElementById('preClick');
							preClickObj.innerHTML = '<a href="javascript:void(0)" onClick="previousPhoto()"><img src="/image/Home/Album/prvi_but.gif" width="16" height="12" alt="Previous" border="0" /></a>';
					
						}
						else
						{
							var preClickObj = document.getElementById('preClick');
							preClickObj.innerHTML = '<img src="/image/Home/Album/prvi_but.gif" width="16" height="12" alt="Previous" border="0" />';
					
						}
				}
				catch(e)
				{
					alert('exception in sendAlbumInfo():->'+e);
				}
				 
			  }
        }
    }
    
    
 	function closePhotoGallary()
	{
		rowNo=1;
		document.getElementById('photoGallary').style.display='none';
	}
	function openPhotoGallary()
	{
		rowNo=1;
		albumReq();
		document.getElementById('photoGallary').style.display='block';
		//alert(document.getElementById('photoGallary').style.display);
				
		/*if (true) 
		{
			var photoGallaryObj = document.getElementById('photoGallary')
		
        	if (photoGallaryObj.addEventListener)
		 	{
            	// firefox, etc.
            	photoGallaryObj.addEventListener("mousedown", function(e) { return contentMouseDown(e) }, true);
        	}
        	else
			{
            	// IE
            	photoGallaryObj.attachEvent("onmousedown", function(e) { return contentMouseDown(e) });
        	}
    	}*/
	}
    
	function previousPhoto()
	{
		rowNo--;
		albumReq();
	}
	
	function nextPhoto()
	{
		rowNo++;
		albumReq();
	}
	
	/*function detailPG()
	{
		//alert('detailPG()');
		window.open(url,'','screenX=0,screenY=0,scrollbars=yes,resizable=yes');
	}*/
