var intTimeoutID;


function changeQuickNavigation() {
  var strLinkText;
  
  strLinkText = document.getElementById("quick_nav").options[document.getElementById("quick_nav").selectedIndex].value;
  if(strLinkText.length > 0)
    document.location = strLinkText;
  else
    document.getElementById("quick_nav").selectedIndex = 0;
}



function changeAd(intI) {
  var i, currentAd;
  
  clearTimeout(intTimeoutID);

  //select a random text to show
  currentAd = Math.floor((Math.random()*intI) + 1);

  if(currentAd > intI)
    currentAd = intI;

  for(i = 1; i <= intI; i++)
    if(i == currentAd)
      document.getElementById('ad_chevy_' + i).style.display = 'block';
    else
      document.getElementById('ad_chevy_' + i).style.display = 'none';

  //set future timeout here
  intTimeoutID = setTimeout('changeAd(' + intI + ')', 15000);

  return 0;
}


function changeCarItem(intCur) {
  intCur = parseInt(intCur);

  for(intI = 1; intI <= 8; intI++)
    if(document.all['row_0' + intI])
      if(intI == intCur)
        document.all['row_0' + intI].className = 'hyu_cell_active';
      else
        document.all['row_0' + intI].className = 'hyu_cell';
}

function validateForumSearchForm() {
  if((document.forum_search_item.searchword) && (document.forum_search_item.searchword.value.length < 3)) {
    alert('Zadejte prosím hledané slovo (alespoň tři znaky).');
	return false;
  }
    
  return true;
}

function validateLeasingForm() {
  if((document.leasing_input.car_price) &&
		   ((document.leasing_input.car_price.value.length == 0) ||
		    (parseInt(document.leasing_input.car_price.value).toString() != document.leasing_input.car_price.value) ||
		    (parseInt(document.leasing_input.car_price.value).toString() <= 0))
		   ) {
          alert('Zadejte prosím cenu automobilu jako kladné celé číslo.');
      	  return false;
        } 
    
  return true;
}

function validatePreplatekForm() {
  if((document.leasing_input.car_price) &&
		   ((document.leasing_input.car_price.value.length == 0) ||
		    (parseInt(document.leasing_input.car_price.value).toString() != document.leasing_input.car_price.value) ||
		    (parseInt(document.leasing_input.car_price.value).toString() <= 0))
		   ) {
          alert('Zadejte prosím cenu automobilu jako kladné celé číslo.');
      	  return false;
        } 

  if((document.leasing_input.car_splatka) &&
		   ((document.leasing_input.car_splatka.value.length == 0) ||
		    (parseInt(document.leasing_input.car_splatka.value).toString() != document.leasing_input.car_splatka.value) ||
		    (parseInt(document.leasing_input.car_splatka.value).toString() <= 0))
		   ) {
          alert('Zadejte prosím měsíční splátku jako kladné celé číslo.');
      	  return false;
        } 

  if((document.leasing_input.car_pojistne) &&
		   ((document.leasing_input.car_pojistne.value.length == 0) ||
		    (parseInt(document.leasing_input.car_pojistne.value).toString() != document.leasing_input.car_pojistne.value) ||
		    (parseInt(document.leasing_input.car_pojistne.value).toString() <= 0))
		   ) {
          alert('Zadejte prosím výši pojistného jako kladné celé číslo.');
      	  return false;
        } 
    
  return true;
}

function validateSubmitForm() {
  var emailPat = /^(.+)@(.+)$/;
  
  if((document.mail_it.jmeno) && (document.mail_it.jmeno.value.length == 0)) {
    alert('Zadejte prosím své jméno.');
	return false;
  }

  if((document.mail_it.mailfrom) && (document.mail_it.mailfrom.value.length == 0) || (document.mail_it.mailfrom.value.match(emailPat) == null)) {
    alert('Zadejte prosím svou platnou e-mailovou adresu.');
	return false;
  }

  if((document.mail_it.mesto) && (document.mail_it.mesto.value.length == 0)) {
    alert('Zadejte prosím město.');
	return false;
  }
  
  if((document.mail_it.phone) && (document.mail_it.phone.value.length == 0)) {
    alert('Zadejte prosím své telefonní číslo.');
	return false;
  }
    
  YY_checkform('mail_it','textfield','#textfield2','6','Prosím opište správný ověřovací kód');
    
  return document.MM_returnValue;
}

function validateHotelSubmitForm() {
  var emailPat = /^(.+)@(.+)$/;
  
  if((document.mail_it.jmeno) && (document.mail_it.jmeno.value.length == 0)) {
    alert('Zadejte prosím své jméno.');
	return false;
  }

  if((document.mail_it.mailfrom) && (document.mail_it.mailfrom.value.length == 0) || (document.mail_it.mailfrom.value.match(emailPat) == null)) {
    alert('Zadejte prosím svou platnou e-mailovou adresu.');
	return false;
  }
  
  if((document.mail_it.phone) && (document.mail_it.phone.value.length == 0)) {
    alert('Zadejte prosím své telefonní číslo.');
	return false;
  }

  if((document.mail_it.datum) && (document.mail_it.datum.value.length == 0)) {
    alert('Zadejte prosím předpokládaný datum příjezdu.');
	return false;
  }
    
  return true;
}

function validateHotelSlevaSubmitForm() {
  var emailPat = /^(.+)@(.+)$/;
  
  if((document.mail_it.nazev) && (document.mail_it.nazev.value.length == 0)) {
    alert('Zadejte prosím název firmy.');
	return false;
  }
  
  if((document.mail_it.jmeno) && (document.mail_it.jmeno.value.length == 0)) {
    alert('Zadejte prosím své jméno.');
	return false;
  }

  if((document.mail_it.mailfrom) && (document.mail_it.mailfrom.value.length == 0) || (document.mail_it.mailfrom.value.match(emailPat) == null)) {
    alert('Zadejte prosím svou platnou e-mailovou adresu.');
	return false;
  }
  
  if((document.mail_it.phone) && (document.mail_it.phone.value.length == 0)) {
    alert('Zadejte prosím své telefonní číslo.');
	return false;
  }

  if((document.mail_it.termin) && (document.mail_it.termin.value.length == 0)) {
    alert('Zadejte prosím předpokládaný datum příjezdu.');
	return false;
  }
  
  YY_checkform('mail_it','textfield','#textfield2','6','Prosím opište správný ověřovací kód');
    
  return document.MM_returnValue;
}


function validateSubmitFormENG() {
  var emailPat = /^(.+)@(.+)$/;
  
  if((document.mail_it.jmeno) && (document.mail_it.jmeno.value.length == 0)) {
    alert('Please enter your name.');
	return false;
  }

  if((document.mail_it.mailfrom) && (document.mail_it.mailfrom.value.length == 0) || (document.mail_it.mailfrom.value.match(emailPat) == null)) {
    alert('Please enter your valid e-mail address.');
	return false;
  }

  if((document.mail_it.mesto) && (document.mail_it.mesto.value.length == 0)) {
    alert('Please enter your city (country).');
	return false;
  }
  
  if((document.mail_it.phone) && (document.mail_it.phone.value.length == 0)) {
    alert('Please enter your phone number.');
	return false;
  }
    
  return true;
}

function validateRegisterForm() {
  var emailPat = /^(.+)@(.+)$/;
  
  if((document.mail_it.reg_email) && (document.mail_it.reg_email.value.length == 0) || (document.mail_it.reg_email.value.match(emailPat) == null)) {
    alert('Zadejte prosím svou platnou e-mailovou adresu.');
	return false;
  }


  if((document.mail_it.reg_name) && (document.mail_it.reg_name.value.length == 0)) {
    alert('Zadejte prosím své jméno.');
	return false;
  }


  if((document.mail_it.reg_pwd) && (document.mail_it.reg_pwd.value.length == 0)) {
    alert('Zadejte prosím heslo pro případné změny v registraci.');
	return false;
  }
    
  return true;
}

function validateForumForm() {
  var emailPat = /^(.+)@(.+)$/;
  
  if((document.forum_new_item.jmeno) && (document.forum_new_item.jmeno.value.length == 0)) {
    alert('Zadejte prosím své jméno.');
	return false;
  }

  if((document.forum_new_item.cely_text) && (document.forum_new_item.cely_text.value.length == 0)) {
    alert('Zadejte prosím text příspěvku.');
	return false;
  }
  
  //Jestli zadal i email, zvalidovat
  if((document.forum_new_item.email) && (document.forum_new_item.email.value.length != 0) &&
     (document.forum_new_item.email.value.match(emailPat) == null)) {
    alert('Zadejte prosím svou platnou e-mailovou adresu.');
	return false;
  }
    
  return true;
}

function changeImage(strPath, strDescription) {
  var img = document.getElementById('car_colorpicker');
  var imgDesc = document.getElementById('car_colorpicker_description');

  if((img != null) && (strPath != ''))
    img.src = strPath;
	
  if((imgDesc != null) && (strDescription != ''))
    imgDesc.innerHTML = strDescription;
}
