var time;
var timeOut;
function do_right(){
	stop();
	var div=$("gallery-scroll");
	div.scrollLeft=div.scrollLeft+2;
	time=setTimeout("do_right()",1);
	return false;
}
function stop(){
	clearTimeout(time);
	return false;
}
function do_left(){
	stop();
	var div=$("gallery-scroll");
	div.scrollLeft=div.scrollLeft-2;
	time=setTimeout("do_left()",1);
	return false;
}
//big-351982.gif
function select_image(image){
	var p_image=$("present-image");
	var search="/big-"+image+"";
	if(p_image.src.search(search) ==-1){
/*		var load=$("loading");
		//load.style.display="block";
		do_image=new Image();
		do_image.src='files/gallery/big-'+image;
		do_image.onload=function (){
			load.style.display="none";
			p_image.src=do_image.src;
			do_image.onload=function (){};
		};
*/
		p_image.src='files/gallery/big-'+image;
	}
}
function open_win(url){
	window.open(url);
	return false;
}
function go_to(ele){
	if(ele.getElementsByTagName("a")[0])
		window.location=ele.getElementsByTagName("a")[0].href;
	return false;
}
function pre_load(what){
	var array=what.split(",");
	var images=new Array();
	for(i=0;i<array.length;i++){
		images[i]=new Image();
		images[i].src='images/menu/'+array[i];
	}
	return false;
}

function change_it(ele,picname){
	ele.className='menu_hover';
	ele.style.background='url(images/menu/'+picname+'.jpg)';
	return false;
}
function change_back(ele,ltr){
	ele.className='menu';
	if(ltr)
		ele.style.background='url(images/menu/button_ltr.jpg)';
	else
		ele.style.background='url(images/menu/button.jpg)';
	return false;
}
function $(id){
	return document.getElementById(id);
}
function update_days(id,month,year){
	var sel=$(id);
	var month=$(month).value;
	var year=$(year).value;
	var days=month_days(month,parseInt(year));
	while (sel.options.length) {
		sel.remove(0);
	}
	for(i=0;i<days;i++){
			sel.options[i]=new Option(i+1,i+1);
	}
}	
function month_days(month,year){
	switch(month){
		case '1':
		case '3':
		case '5':
		case '7':
		case '8':
		case '10':
		case '12':
			return 31;
		case '4'://,6,9,11:
		case '6':
		case '9':
		case '11':
			return 30;
		case '2':
			if(year%4 == 0){
				if(year%100==0 && year%400!=0)
					return 28;
				else
					return 29;
			}else
				return 28;
		default:
			return 0;
	}	
}
function getCookie(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 "";
}
function setCookie(c_name,value,expiredays){
	var exdate=new Date()
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate.toGMTString());
}
function open_float_div(divId,cookie_name){
	var cookie=getCookie(cookie_name);
	if(cookie==""){
		//setCookie(cookie_name,"true",80);

		$(divId).style.display="block";
		var des_t = Math.round(document.documentElement.clientHeight/2 + document.documentElement.scrollTop-($(divId).offsetHeight/2));
		var des_l = Math.round(document.documentElement.clientWidth/2 + document.documentElement.scrollLeft-($(divId).offsetWidth/2));
		$(divId).style.top=des_t+"px";
		$(divId).style.left=0+"px";//des_l+"px";
		update_float_div(divId);
	}	
}
function close_float_div(divId){
	$(divId).style.display="none";
	clearTimeout(timeOut);
	return false;
}
function update_float_div(divId){
	var dev=16;//cennot be zero
	var des_t = Math.round(document.documentElement.clientHeight/2 + document.documentElement.scrollTop-($(divId).offsetHeight/2));
	var des_l = Math.round(document.documentElement.clientWidth/2 +388 + document.documentElement.scrollLeft-($(divId).offsetWidth));
	var now_t=parseInt($(divId).style.top);
	var now_l=parseInt($(divId).style.left);
	var speed_t=Math.round((des_t>now_t)?(des_t-now_t)/dev:(now_t-des_t)/dev);
	var speed_l=Math.round((des_l>now_l)?(des_l-now_l)/dev:(now_l-des_l)/dev);
	if(des_t != now_t){
		if(des_t > now_t)
			$(divId).style.top=now_t+speed_t+"px";
		else
			$(divId).style.top=now_t-speed_t+"px";
	}
	if(des_l != now_l){
		if(des_l > now_l)
			$(divId).style.left=now_l+speed_l+"px";
		else
			$(divId).style.left=now_l-speed_l+"px";
	}
	timeOut=setTimeout("update_float_div('"+divId+"');",10);
}