function frmSubscribe_onFocus(o)
{
    if (o.value == o.title)
    {
        o.style.color = '#000000';
        o.value = '';
    }
}

function frmSubscribe_onBlur(o)
{
    if ('' == o.value)
    {
        o.style.color = '#999999';
        o.value = o.title;
    }
}

function frmSubscribe_onSubmit(f)
{
    var sFocus = '';
    var sError = '';

    if (typeof(f.persone) != 'undefined' &&
        ('' == f.persone.value || f.persone.value == f.persone.title)
    )
    {
        sError = f.persone.title;
        sFocus = 'persone';
    }
    else if ('' == f.email.value || f.email.value == f.email.title)
    {
        sError = f.email.title;
        sFocus = 'email';
    }
    else if (false == validateEmail(f.email.value))
    {
        sError = 'Введен неверный Email (шаблон: имя@домен.зона)';
        sFocus = 'email';
    }
    else if (typeof(f.format) != 'undefined' && '' == f.format.value)
    {
        sError = 'Выберите формат рассылки';
        sFocus = 'format';
    }

    if ('' != sError)
    {
        alert(sError);
        f.elements[sFocus].focus();
        return false;
    }

    return true;
}

function frmLogin_onSubmit(f)
{
    var sFocus = '';
    var sError = '';

    if (typeof(f.login) != 'undefined' &&
        ('' == f.login.value || f.login.value == f.login.title)
    )
    {
        sError = 'Введите логин';
        sFocus = 'login';
    }
    else if ('' == f.pswd.value || f.pswd.value == f.pswd.title)
    {
        sError = 'Введите пароль';
        sFocus = 'pswd';
    }

    if ('' != sError)
    {
        alert(sError);
        f.elements[sFocus].focus();
        return false;
    }

    return true;
}

function frmSearch_onSubmit(f)
{
    if ('' == f.q.value)
    {
        alert(f.q.title);
        f.q.focus();
        return false;
    }
    return true;
    
}

function mailus()
{
    self.location = 'mailto:roman1331@gmail.com';
}

function validateEmail(sEmail)
{
	//alert(sEmail.match(/^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$/));
    if (null == sEmail.match(/^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$/)) {
        //alert(0);
		return false;
    } else
        return true;
}

function onChangeCity(sel)
{
	location.href=sel.value;
}

function frmOpros_onSubmit(f)
{
    var sFocus = '';
    var sError = '';
    if (typeof(f.email) != 'undefined' && 
        ('' == f.email.value || f.email.value == f.email.title)
    )
    {
        sError = f.email.title;
        sFocus = 'email';
    }
    if (typeof(f.fio) != 'undefined' &&
        ('' == f.fio.value || f.fio.value == f.fio.title)
    )
    {
        sError = f.fio.title;
        sFocus = 'fio';
    }
    if ('' != sError)
    {
        alert(sError);
        f.elements[sFocus].focus();
        return false;
    }
	if(!validateEmail(f.email.value)) {
		alert('Введите правильный e-mail!');
		f.email.focus();
		return false;
	}
    return true;
}

function frmOrder_onSubmit(f)
{
    var sFocus = '';
    var sError = '';
    if (typeof(f.address) != 'undefined' &&
        ('' == f.address.value || f.address.value == f.address.title)
    )
    {
        sError = f.address.title;
        sFocus = 'address';
    }
    if (typeof(f.phone) != 'undefined' &&
        ('' == f.phone.value || f.phone.value == f.phone.title)
    )
    {
        sError = f.phone.title;
        sFocus = 'phone';
    }
    if (typeof(f.fullName) != 'undefined' &&
        ('' == f.fullName.value || f.fullName.value == f.fullName.title)
    )
    {
        sError = f.fullName.title;
        sFocus = 'fullName';
    }
    if ('' != sError)
    {
        alert(sError);
        f.elements[sFocus].focus();
        return false;
    }
    return true;
}
function nav(url) { //v3.0
	window.open("http://"+url);
	return false;
}

function reportError() {
	location.href='mai'+'lto:te'+'ch@na'+'kor'+'mit.ru?'+'Subject=Error on page '+location.href;
}

function bookMark() {
	var tempAgent = navigator.userAgent;
	if(tempAgent.indexOf('MSIE')>=0) window.external.AddFavorite(location.href,document.title);
	return false;

}
function makeStart(o) {
	o.style.behavior='url(#default#homepage)';
	o.setHomePage('http://www.domain.ru/');
}

function unlogin() {
	var o=document.getElementById('unLogForm');
	o.submit();
}

function changePswd(o) {
	o.setAttribute('type','password');
	o.value='';
}

function changeText(o) {
	if(o.value=='') {
		o.type='text';
//		o.value='Пароль';
	}
}

function blankText(o) {
	o.value='';
}

var md=new Array();
	md['01']=31;
	md['02']=29;
	md['03']=31;
	md['04']=30;
	md['05']=31;
	md['06']=30;
	md['07']=31;
	md['08']=31;
	md['09']=30;
	md['10']=31;
	md['11']=30;
	md['12']=31;

function validDate(name) {
	var d=document.getElementById(name+'_birth_day');
	var m=document.getElementById(name+'_birth_month');
	var y=document.getElementById(name+'_birth_year');
	if(d.value>md[m.value]) d.value=md[m.value];
	if(m.value=='02') {
		if(d.value>28) {
			if(y.value%4!=0) d.value=28;
		}
	}
}

function showHelp(id) {
	document.getElementById(id).style.display='inline';
}

function hideHelp(id) {
	document.getElementById(id).style.display='none';
}


function winOpen(url, w, h, text) {
	var width,height;
	if(w==0 || h==0)
		return;
	width=w+12;
	height=h+40;
	height+=Math.ceil((text.length*10)/(w-10))*16;
	var q=window.open('/empty.htm', "", "width="+width+",height="+height+",status=no,toolbar=no,menubar=no,scrollbars=no");
	var code='';
	//var text='Пока не передаем заголовок';
	code+="<html><head><title>Просмотр увеличенного изображения</title><style>"+"\n"+"body { padding: 0px; margin: 0px 5px 0px 5px; background-color: #FFFFFF; font-family: Verdana, Arial, Helvetica, sans-serif; }"+"\n";
	code+="img { border: 1px solid #9cceff; text-align: center; } \n";
	code+="h1 { color: orange; font-size: 14px; text-align: center; margin: 5px 0px 5px 0px; } \n";
	code+="p { font-size: 11px; text-align: center; margin: 5px 0px 5px 0px;}\n";
	code+="</style></head><body>\n";
	code+="<h1>"+text+"</h1>\n";
	code+="<img src=\""+url+"\" width=\""+w+"\" height=\""+h+"\" border=\"0\" alt=\""+text+"\" title=\""+text+"\">\n";
	code+="<p><a href=\"javascript:window.close();\">закрыть окно</a></p>\n";
	code+="</body></html>";
	q.document.write(code);
}

function winOpen2(url, w, h) {
	var width,height;
	if(w==0 || h==0)
		return;
	width=w+12;
	height=h+40;
	window.open(url, "", "width="+width+",height="+height+",status=no,toolbar=no,menubar=no,scrollbars=yes");

}
