/* JavaScript file */

function wfloat () {
	openwnd ('','wfloat','width=547,height=584,status=no,toolbar=no,menubar=yes,resizable=no');
}


function additionalStyles() {
	if ( screen.width>1000 ) {
		document.write('<LINK href="/styles/common.css" rel="stylesheet"  type="text/css">');
	}
	else {
		document.write('<LINK href="/styles/800.css" rel="stylesheet"  type="text/css">');
	}
}


function OpenWindowImage (url,target,width,height) {
/*	wnd = null;
	var width = width || 535;
	var height = height-19 || 600;
	var url = url || '';
	var size = 'width='+width+',height='+height;
	var target = target || 'wfloat';
	wnd = window.openwnd (url,target,size+'toolbar=no,menubar=yes,scrollbars=no,status=no');
	wnd.document.open();
	wnd.document.write("<html><head><script>function resize(){");
	wnd.document.write("self.resizeTo (100,100); } onload=resize;");
	wnd.document.write("</script><title>Business Car</title></head><body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0><img src='"+url+"'  border='0' vspace='0' hspace='0' id='photo'/><body></html>");
  wnd.document.close();*/
	
	var isOpera = navigator.userAgent.indexOf('Opera')!=-1 ? true: false;
	
	var image = new Image();
	image.src = url;

	if (isOpera){
		var wnd = null;
		var url = image.src || '';
		var size = 'width='+width+',height='+height;
		var target = document.target || 'wfloat';
		var imageHtml = '';
		imageHtml = "<html><head><title>Business Car</title></head><body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0><img src='"+url+"'  border='0' vspace='0' hspace='0'/><body></html>";
		wnd = window.open (url,target,size+'toolbar=no,menubar=yes,scrollbars=no,status=no');
		wnd.document.open();
		wnd.document.write(imageHtml);
		wnd.document.close();
	} else {
		image.onload = function(){
			var wnd = null;
			var width = image.width;
			var height = image.height;
			var url = image.src || '';
			var size = 'width='+width+',height='+height;
			var target = document.target || 'wfloat';
			var imageHtml = '';
			imageHtml = "<html><head><title>Business Car</title></head><body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0><img src='"+url+"'  border='0' vspace='0' hspace='0'/><body></html>";
			wnd = window.open (url,target,size+'toolbar=no,menubar=yes,scrollbars=no,status=no');
			wnd.document.open();
			wnd.document.write(imageHtml);
			wnd.document.close();
		}
	}

}

// проверка корректного e-mail

function check_email(s)

{ 
flag=true;
	if (window.RegExp) {
		st="a";ex=new RegExp(st);
		if (st.match(ex)) {
			r1=new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
			r2=new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
			b=(!r1.test(s)&&r2.test(s));
		} else { flag=false; }
	} else { flag=false; }
	if(!flag) b=(s.indexOf("@")>0&&s.indexOf(".")>0&&s!=""&&s!="Введите e-mail");
	return (b);
}
function f(param) { param.focus();param.select(); }
function check(email)
{	if(val(email)) return true;
		else return false;
}
function val(param)
{	s=param.value;
	if(check_email(s)) { return true;
	} else {
		alert("Пожалуйста, введите корректный e-mail адрес.");
		f(param);return false; }
}



