

var cascadeWinTop = 0;
var cascadeWinLeft = 0;



function CookieHandler()
{
	this.setCookie = function(c_name,value,expiredays)
	{
		var exdate=new Date();
		exdate.setDate(exdate.getDate()+expiredays);
		document.cookie=c_name+ "=" +escape(value) + ";path=/" +
		((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
	}
	
	this.getCookie = function(c_name)
	{
		if (document.cookie.length!=0)
		  {
		  c_start=document.cookie.indexOf(c_name + "=");
		  if (c_start!=-1)
		    {
		    c_start=c_start + c_name.length+1;
		    c_end=document.cookie.indexOf(";",c_start);
		    if (c_end==-1) c_end=document.cookie.length;
		    return unescape(document.cookie.substring(c_start,c_end));
		    }
		  }
		return "";
	}

}	

var CookieHandler = new CookieHandler();

function handlebgcolor() {
	if(CookieHandler.getCookie('bgcolor') !='') {
		for (var i=0; i < document.bgcolorform.bgcolorselect.length; i++) {
			if (document.bgcolorform.bgcolorselect[i].value == CookieHandler.getCookie('bgcolor')) {
				document.bgcolorform.bgcolorselect[i].selected = true;
			}
		}							
	}
}

function setUsername(username){
    CookieHandler.setCookie('username',username,30);
}

function getUsername(){
    return CookieHandler.getCookie('username');
}




function Gallery()
{
	this.newPopupWindow = function(setId)
	{
   	    
   	    url = '?service=gallery&action=show_slideshow_page&language=en&gallery=1&set=' + setId;
   	    var slideshow_width = 850;
		var slideshow_height = 687;
		var slideshow_scroll = 1;
		var slideshow_resizeable = 1;
		var win_left = (screen.width - slideshow_width) / 2;
		var win_top = (screen.height - slideshow_height) / 2;
		var winprops = 'address=no,menubar=no,toolbar=no,height='+slideshow_height+',width='+slideshow_width+',top='+win_top+',left='+win_left+',scrollbars='+slideshow_scroll+',resizable='+slideshow_resizeable;
		
				 
   	    //commented working..
   	    browser=navigator.appName;
   		browserindex = browser.search(/Netscape/);
		if(browserindex >= '0')
		{
		
   	    	//window.open(url, 'viewSlideShow','width=550, height=480');
   	    	win = window.open(url, 'viewSlideShow',winprops);
   	    	if (parseInt(navigator.appVersion) >= 4) 
			{ 
				win.window.focus(); 
			}
   	    	
   	    }
   	    else
   	    {
   	    	window.open(url, 'viewSlideShow', winprops);
   	    	//win = window.open(url, 'viewSlideShow', winprops);
   	    	//if (parseInt(navigator.appVersion) >= 4) 
			//{ 
				//win.window.focus(); 
			//}
   	    	
   	    }
        return false;
   	   
  	}
	
	this.setNewGallery = function(setId)
	{
		gallery_id = setId.value;
		//alert('new gallery id is '+setId.value);
		url = '?service=gallery&action=show_slideshow_page&language=en&gallery=1&set=' + gallery_id;
   	    window.location = url;
	}
	
	this.share = function()
	{
		document.location.href = 'mailto:?body=' + encodeURIComponent($('gallery-share-url').value);
	}
	
	this.searchImage = function(image)
	{
		url = "?service=search&action=do_quick_search&language=en&mime_type=all&q='"+image+"'";
		window.opener.location.href = url;
		window.opener.focus();
	}

}

// *** OBJECT ***

var Gallery = new Gallery();

//

