function basename(str)
{
	if(!str) return '';
	var basename_reg = /[^\/]+$/;
	var name = basename_reg.exec(str);
	if(name) str = name[0];
	return str;
}

function check_mail(str)
{
	if(str == '') return true;
	var reg = /\s/g;
	str = str.replace(reg,'');
	var mails = str.split(",");
	var reg2 = /^[a-zA-Z0-9][a-zA-Z0-9\._-]+@[a-zA-Z0-9_\.-]+\.[a-zA-Z]{2,4}$/;
	for(i = 0;i < mails.length;i++) if(!reg2.test(mails[i])) return false;
	return true;
} 

function open_image(imgID,imgWidth,imgHeight,lang)
{
   if(!lang) lang = 'ru'
   winTop=(screen.height-imgHeight)/2;
   winLeft=(screen.width-imgWidth)/2;
   if(imgHeight > screen.height) imgHeight = screen.height;
   if(imgWidth > screen.width) imgWidth = screen.width;
   window.open("/open_image.php?lang="+lang+"&file="+imgID,"new_image","toolbar=0,menubar=0,location=0,status=0,statusbar=0,scrollbars=auto,directories=0,resizable=auto,copyhistory=0,top="+winTop+",left="+winLeft+",width="+imgWidth+",height="+imgHeight);
}

function ajax(div,url,pars,meth,func)
{
	var reg = new RegExp("^/");
	var reg2 = new RegExp("^http");
	url = url.replace(reg,"");
	if(!reg2.test(url)) url = '/' + url;
	if(!meth) meth = "get";

	if(meth == 'get')
	{
		if(!func) $.get(url,pars,function(data){ $('#'+div).attr('innerHTML',data) });
		else $.get(url,pars,function(data){ $('#'+div).attr('innerHTML',data);eval(func);});
	}
	else
	{
		if(!func) $.post(url,pars,function(data){ $('#'+div).attr('innerHTML',data) });
		else $.post(url,pars,function(data){ $('#'+div).attr('innerHTML',data);eval(func);});
	}
}

function insert_smile(str)
{
	void(0);
}	
