function objGet(id) 
{
   if (Boolean(document.getElementById))
      return document.getElementById(id);
   else if (Boolean(document.all))
      return eval('document.all.'+id);
   else
      return eval('document.'+id);
}

function openImage(id, eshop, root){
  url = root+'photo.php?id='+id+'&eshop='+eshop;
  win = window.open(url, id,'resizable=1,top=20,left=20,menubar=0,scrollbars=1,width=' + 840 + ',height=' + 640);
  win.focus()
}

function wrong_mail_address(adresa){
  var error=false;
  var pozice_zavinace = adresa.indexOf("@");
    if (pozice_zavinace < 0)
        error=true;
    var cast_pred_zavinacem = adresa.substring(0,pozice_zavinace);
    var cast_po_zavinaci = adresa.substring(pozice_zavinace+1,adresa.length);
    if (cast_po_zavinaci.indexOf("@") >= 0)
        error=true;
    if (cast_pred_zavinacem.length <= 0)
        error=true;
    if (cast_po_zavinaci.length <= 0)
        error=true;

    return error;
}

function validate_company(){
  if(objGet('company_name').value=="" || objGet('country').value=="" 
  || objGet('adress').value=="" || objGet('city').value==""
  || objGet('post_code').value=="" || objGet('company_phone').value==""
  || wrong_mail_address(objGet('company_email').value) || (objGet('country').value=='48' && objGet('ico').value=="")
  || (objGet('country').value!='48' && objGet('vat').value=="") || objGet('contact_name').value==""
  || objGet('contact_surname').value=="" || objGet('contact_phone').value==""
  || wrong_mail_address(objGet('contact_email').value) || objGet('reg_login').value==""
  || objGet('reg_password').value==""){
    objGet('submit').disabled=true;
  }
  else objGet('submit').disabled=false;
}

function update_form_company(){
  if(objGet('country').value != '48'){
    objGet('CZ').style.display='none';
    objGet('NOCZ').style.display='block';
  }
  else{
    objGet('CZ').style.display='block';
    objGet('NOCZ').style.display='none';
  }
}

function clearField(){
  if(objGet('login_field').value == 'login'){
    objGet('login_field').value = '';
  }
}

