﻿
var count=0;
function showallPhotogallary(CategoryID,TypeID,Keyword)
{
	var photoid= '#photogallery' + CategoryID;
    $('span').removeClass('gallery-selected')
    $(photoid).addClass('gallery-selected');
    $.ajax({
    type: "POST",
    url: "http://"+ document.domain +"/cms/displayphotogallerylist.ashx?CategoryID="+CategoryID+"&TypeID="+TypeID+"&Keyword="+Keyword+"",
    data:"{}",
    success: function(msg)
    {
        $("#thumbs").css('left','0px');
        $("#thumbs").html(msg); 
    },
    error:function(msg)
    {
           alert("Sorry, error in message sending.");
    }
    });
}
function showPhotogallary(CategoryID,TypeID,Keyword)
{
    var imgcount=0;
    document.getElementById("divphotoloading").style.display="block";
	var photoid= '#photogallery' + CategoryID;
    $('span').removeClass('gallery-selected')
    $(photoid).addClass('gallery-selected');
    $.ajax({
    type: "POST",
    url: "http://"+ document.domain +"/cms/photogallerylist.ashx?CategoryID="+CategoryID+"&TypeID="+TypeID+"&Keyword="+Keyword+"",
    data:"{}",
    success: function(msg)
    {
         $("#photos").html(msg);
         $('#photos > ul > li').each(function() {
                 var imgname=$(this).html();
                 var imgtitle = $(imgname).attr("src");
                 var imgarray = imgtitle.split('/');
                 
                 var path= "http://"+ document.domain + "/photogallery/large/" + imgarray[imgarray.length-1];  
                 var path1= "http://"+ document.domain + "/photogallery/hotelthumb/" + imgarray[imgarray.length-1];  
                 if(imgcount<5)
                  {
                     setImage(path);
                     setImage(path1);
                  }
                  imgcount++;
            });
        loadphoto();
        document.getElementById("divphotoloading").style.display="none";	        
    },
    error:function(msg)
    {
           alert("Sorry, error in message sending.");
    }
    });
}
function setImage ( imgSrc ) 
{
    imageobject = new Image;
    imageobject.src = imgSrc ;
    setTimeout( 'doWhileLoading()', 100 ) ;
}

function doWhileLoading() 
{
    if (imageobject.complete )
    {
        return true;
    }
    else
    {  
         setTimeout( 'doWhileLoading()', 100 ) ;
    }
}
function PreloadImage(imgSrc)
{
  var objImagePreloader = new Image();
  objImagePreloader.src = imgSrc;
  
  if(objImagePreloader.complete)
  {
        alert("true");
        return true;
  }  
  else
  {
    setTimeout(PreloadImage(imgSrc), '30000');
    
  }
}
function loadphoto()
{   
        $('#photos').galleryView({
			panel_width: 660,
			panel_height: 478,
			frame_width: 113,
			frame_height: 83,
			overlay_position: 'top',
			overlay_height : 40,
			transition_interval : 6000,
			background_color : '#FAF5D9'		
			
		});			
		if(count!=0)
		{
		    $('.nav-prev').click();
		    $('.nav-next').click();		    
		}
		else
		{
		    count=1;
		}
}	
