function ShowHideElement(a)
	{
if (document.getElementById(a).style.display=="none")
{document.getElementById(a).style.display="";}
else
{document.getElementById(a).style.display="none";}
	}

function ShowHideElementMenu(a, b)
{
    if (document.getElementById(a).style.display=="none")
    {
        document.getElementById(a).style.display="";
        document.getElementById(b).src="/images/minus.gif";
    }
    else
    {
        document.getElementById(a).style.display="none";
        document.getElementById(b).src="/images/plus.gif";
    }
}

function SubmitMyForm(a){
document.getElementById(a).submit();
}

function open_frame(a, u)
{
myWindow=window.open(u,'','width=500,height=400');
myWindow.focus();
window.location.reload();
}

function closeIt(a, b) {
window.opener.location.reload();
  close();
}

function close_backet(b)
{
    window.opener.set_value('div_quan', b);
    close();
}

function close_backet2(b)
{
    window.opener.set_value('div_quan', b);
    window.opener.location = "/registraciya";
    close();
    //window.location= '/registraciya';
}

function check(id)
{
    if(document.getElementById(id).value=="") {
        alert ("Поле не может быть пустым!");
    }
 }
 
 function mail_check()
 {
    var a=0; var crash=0;
    for(var i=0; i<document.getElementById(id).value.length; i++)
        if(document.getElementById('mail').value[i]=='@') a++;
    if(a==0) { crash=1;
        alert("Неверный e-mail адрес");
        return false;
    }
    if(document.getElementById('login').value=="") { crash=1;
        alert ("Поле Логин не может быть пустым!");
        return false;
    }
    if(document.getElementById('pass').value=="") { crash=1;
        alert ("Поле Пароль не может быть пустым!");
        return false;
    }
    if(document.getElementById('address').value=="") { crash=1;
        alert ("Поле Адрес не может быть пустым!");
        return false;
    }
    if(document.getElementById('name').value=="") { crash=1;
        alert ("Поле Имя не может быть пустым!");
        return false;
    }
    for(var i = 0; i<document.getElementById('name').value.length; i++)
		if((document.getElementById('name').value[i]=='0')||(document.getElementById('name').value[i]=='1')||(document.getElementById('name').value[i]=='2')||(document.getElementById('name').value[i]=='3')||(document.getElementById('name').value[i]=='4')||
		(document.getElementById('name').value[i]=='5')||(document.getElementById('name').value[i]=='6')||(document.getElementById('name').value[i]=='7')||(document.getElementById('name').value[i]=='8')||(document.getElementById('name').value[i]=='9')
        ||(document.getElementById('name').value[i]=='\"')||(document.getElementById('name').value[i]=='\'')||(document.getElementById('name').value[i]=='!')||(document.getElementById('name').value[i]=='?')||(document.getElementById('name').value[i]=='_'))
		{  crash=1;
		alert("Неверное имя"); return false;
		}
    if(document.getElementById('surname').value=="") { crash=1;
        alert ("Поле Фамилия не может быть пустым!");
        return false;
    }
    if(crash==0) document.getElementById('reg').submit();    
 }
 
 function FormRegistrationSubmit(a){
 var str="";
 var res=0;
 if(a!='account') { if(document.getElementById('clients_login').value=="") str = str + "* поле Логин не заполнено <br />"; }
 if(document.getElementById('clients_passwd').value=="") str = str + "* поле Пароль не заполнено <br />";
 if(a!='account') { if(document.getElementById('clients_repassword').value=="") str = str + "* поле Повтор пароля не заполнено <br />"; }
 if(document.getElementById('clients_name').value=="") str = str + "* поле Имя не заполнено <br />";
 if(document.getElementById('clients_surname').value=="") str = str + "* поле Фамилия не заполнено <br />";
 if(document.getElementById('clients_mail').value=="") str = str + "* поле E-mail не заполнено <br />";
 if(a!='account') { if(document.getElementById('captcha_submit').value=="") str = str + "* поле подтверждение регистрации не заполнено <br />"; }

 if(a=='account') {
    for(var s=0; s<document.getElementById('clients_mail').value.length; s++)
    if(document.getElementById('clients_mail').value[s]=='@') res='1';
    if(res!='1') str = str + "* Неверный e-mail адрес <br />";
 }
 if(a!='account') { if(document.getElementById('clients_passwd').value!=document.getElementById('clients_repassword').value) str = str + "* Поля Пароль и Повтор пароля не совпадают <br />"; }
 if(str=="") document.getElementById('reg').submit(); 
 else {
  document.getElementById('mess').innerHTML=str;
  document.getElementById('warn').style.display=""; 
  return false;
 }
}

function getframe(){
    if(document.getElementById('clients_login').value!=""){
        var a='/check_login.php?login=' + document.getElementById('clients_login').value;
        document.getElementById('ifr').src=a;
    }
}

function SetSearch()
{
    var a='';
    var i=0;
    for(i=0; i<document.getElementById('searchX').value.length; i++) {
        if(document.getElementById('searchX').value[i]==' ') 
            a=a+'+'; 
        else 
            a=a+document.getElementById('searchX').value[i];
    }
    os=document.getElementById('action_search');
    os.action='/'+a;
    os.submit();
}

function change_type()
{
    if(document.getElementById('clients_passwd').type=='text')
    document.getElementById('clients_passwd').type='password';
    else
    document.getElementById('clients_passwd').type='text';
}

function openWin(a, b)
{
myWindow=window.open('/basket2.php?id='+a+'&price='+b,'','width=450,height=120, status=no, titlebar=no, scrollbar=no, menubar=no, toolbar=no');
myWindow.focus();
}

function check_quantity(a)
{
    
    for(var i=0; i<document.getElementById(a).value.length; i++)
    if((document.getElementById(a).value[i]==',')||(document.getElementById(a).value[i]=='.')||(document.getElementById(a).value[i]=='/')||(document.getElementById(a).value[i]=='+'))   
    {
        alert("Неверное количество"); return false;
    }
}

function set_value(a, b)
{
    document.getElementById(a).innerHTML=b;
}

function show_edit_func(id, site_id)
{
    myWindow=window.open('/edit_window.php?id='+id+'&site_id='+site_id,'','width=450,height=300, status=no, titlebar=no, scrollbar=no, menubar=no, toolbar=no');
    myWindow.focus();
}

function show_wide_edit_func(id, site_id, cat)
{
    myWindow=window.open('/wide_edit_window.php?id='+id+'&site_id='+site_id+'&categories_id='+cat,'','width=650,height=700, status=no, titlebar=no, scrollbar=no, menubar=no, toolbar=no');
    myWindow.focus();
}

function show_editcat_func(id, site_id)
{
    myWindow=window.open('/editcat_window.php?id='+id+'&site_id='+site_id,'','width=450,height=300, status=no, titlebar=no, scrollbar=no, menubar=no, toolbar=no');
    myWindow.focus();
}

function show_delete_func(id, site_id, category)
{
    myWindow=window.open('/delete_window.php?id='+id+'&site_id='+site_id+'&categories_id='+category,'','width=450,height=300, status=no, titlebar=no, scrollbar=no, menubar=no, toolbar=no');
    myWindow.focus();
}

function show_add_func(id, site_id, category)
{
    myWindow=window.open('/prod_to_cat.php?prodid='+id,'','width=450,height=300, status=no, titlebar=no, scrollbar=no, menubar=no, toolbar=no');
    myWindow.focus();
}

