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;}		
	window_name+="_"+Math.round(Math.random()*1000);	
	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 open_converter() {
	name_w="converter";	
	source="/tpls/converter.php?ml="+lang;
	win_open(source,name_w,290,250,1);
}
 
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);
			}        
		}      
	}
}

