function formSubmit(formName) {
	document.forms[formName].submit();
}

function addFavorite(name) {
	window.external.addFavorite(document.getElementsByTagName("base")[0].href , name);
}

function imgView(href,w,h)
{
   	var maxwidth = screen.width;
	var maxheight = screen.height;
	var top = Math.max(Math.floor((screen.height - h) / 2), 10);
	var left = Math.max(Math.floor((screen.width - w) / 2), 10);
	var param = 'toolbar=0,top=' + top + ',left=' + left + ',Toolbar=0,Location=0,Directories=0,Status=0,Menubar=0, Resizable=0';
	if (w <= maxwidth && h <= maxheight) param += ',scrollbars=0';
	else { param += ',scrollbars=1'; w += 20; h += 20; }
	if(w > maxwidth) w = maxwidth; else w += 17;
	param  = param + ',width=' + w;
	if(h > maxheight) h = maxheight; else h += 40;
	param = param + ',height=' + h;

	imgWin = window.open('', '_blank', param);
	imgWin.opener = window;
	imgWin.resizeTo(w,h);
    imgWin.document.open("text/html");
    imgWin.document.writeln("<html>");
    imgWin.document.writeln("<head><title>Supervelik</title></head>");
    imgWin.document.writeln("<body leftMargin='0' topMargin='0'>");
    imgWin.document.writeln('<img src='+document.getElementsByTagName("base")[0].href + href+
    	' onclick="parent.close()" style=cursor:hand;>');
    imgWin.document.writeln("<br>");
    imgWin.document.write("</body></html>");
	imgWin.focus();
}

function search(form) {
	var errStr='Введите критерий для поиска';
	if(form.query.value == '') {
		alert(errStr);
		return false;
	} else {
		return true;
	}
}

function subscribe(form) {
	var errStr='Укажите e-mail';
	var errEmail='Некорректный e-mail';
	if(form.email.value == '') {
		alert(errStr);
		return false;
	} else if (isEmailValid(form.email.value) == false) {
		alert(errEmail);
		return false;
	} else {
		return true;
	}
}

function isEmailValid(email) {
	var s = "[\\w\\-]+(\\.[\\w\\-]+)*@((([a-zA-Z0-9]+)|([a-zA-Z0-9]+[\\w\\-]*))(\\.([\\w^_]+\\.\\2))?\\.)?[\\w\\-]{2,}\\.[a-zA-Z]{2,}";
	var re = new RegExp(s);
	return re.test(email);
}
