String.prototype.trim = function() {
	return this.replace(/(^\s*)|(\s*$)/g, "");
}

function check_email(str) {
	var re = /^[a-zA-Z0-9\-\_\.]{1,}@[A-Za-z0-9\_\-\.]{2,}\.[A-Za-z]{2,4}$/  
	if (str.match(re) == null)  {
		return false;
	} 	
	else {
		return true;
	}
}



function win_open(source,window_name,w,ht,sc){
	ws=screen.availWidth;
	hs=screen.availHeight;
	kl=(ws-w)/2;
	if (kl<0){kl=0;}
	kt=(hs-ht)/2;
	if (kt<0){kt=0;}
	var window_params = 'status=no,toolbar=no,scrollbars='+sc+',titlebar=yes,menubar=no,resizable=no,width='+w+',height='+ht+',left='+kl+',top='+kt+',directories=no,location=no';
	window.open(source, window_name, window_params);	
 }
 
			
function big_img(){
	if (document.all){
		//IE Opera
		im = event.srcElement;
		im_src=im.getAttribute("src");
		im_alt=im.getAttribute("alt");
		name_im=im_src.slice(im_src.lastIndexOf("/")+1,-4);
		name_im=name_im.replace("-","");
		big_im_src=im_src.replace("/s_","/b_");			
		win_open("/tpls/big_img.php?ml="+lang+"&im="+big_im_src+"&alt="+im_alt,"big_im"+name_im,500,400,1);
	}
	else {
		//Mozilla
		window.captureEvents(Event.CLICK);
		window.onclick= handle; 
	}   
}


function handle(e) {
	var retval = routeEvent(e);
	if (retval == true){
		return true;
	}
	else {
		obj=e.target;
		tag_name=obj.tagName;
		if (tag_name!='IMG'){
			return true;
		}
		else {
			im_src=obj.src;		
			link_im=obj.parentNode;
			link_im_function=link_im.getAttribute("onclick");
			if (link_im_function!="big_img();"){
				return true;
			}
			else {
				im_alt=obj.getAttribute("alt");
				name_im=im_src.slice(im_src.lastIndexOf("/")+1,-4);
				big_im_src=im_src.replace("/s_","/b_");
				win_open("/tpls/big_img.php?ml="+lang+"&im="+big_im_src+"&alt="+im_alt,"big_im"+name_im,500,400,0,0,1,0);
			}        
		}      
	}
}


function submit_form(link,commen){
		var forma=document.f_selection;
		var city=forma.city_id.value;

		if(commen!=undefined){
			//alert(link);
			//forma.action=link+city+"/"+commen+"/";
			forma.action=link;
		}else{
			
			forma.action=link+city+"/";			
		}		
		forma.submit();
}


function rBasket(){	
	$.post("/ajax.reserv.php", {active: "count"},  function(data){
		document.getElementById('oBasket').innerHTML=data;
	});
}




