window.onload = function() {
	addTB();
}

// CSS (if JavaScript is enabled)
function writeJSstyle(){
	document.write('<link rel="stylesheet" type="text/css" media="screen" href="css/leto-js.css" />');
}

function isMail(mail){
  var mailre=/^[_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$/;
  return mailre.test(mail);  
}

function isDate(num){
	var numre=/^[0-9]{2}\.[0-9]{2}\.[0-9]{4}$/;
	return numre.test(num);
}

function reVal(el){
  if(trim(el.value)!="")el.style.backgroundColor="#ffffff";
}

function checkFrm(f){

	var emptys=new Array();
	var invalids=new Array();

	if(f.id=="form_search_tour") {
//		neco=new Date("12 31,2006 00:00:00");
//		
//		if (f.f_tour_price.value=='' && trim(f.f_tour_term_from.value)=="" && f.f_tour_destination.value==0)
//		{
//			emptys[emptys.length]=new Array(f.f_tour_term_from,"Termín od (DD.MM.RRRR)");
//			emptys[emptys.length]=new Array(f.f_tour_destination,"Destinace");
//			emptys[emptys.length]=new Array(f.f_tour_term_from,"Cena");
//		}
		
//		if(trim(f.f_tour_term_from.value)=="") {
//			emptys[emptys.length]=new Array(f.f_tour_term_from,"Termín od (DD.MM.RRRR)");
//		} else {
//			//alert(neco.getTime());
//			if(!isDate(trim(f.f_tour_term_from.value)))invalids[invalids.length]=new Array(f.f_tour_term_from,"Termín od (DD.MM.RRRR)  "+neco.getTime());
//		}
//		if(trim(f.f_tour_term_to.value)=="") {
//			emptys[emptys.length]=new Array(f.f_tour_term_to,"Termín do (DD.MM.RRRR)");
//		} else {
//			if(!isDate(trim(f.f_tour_term_to.value)))invalids[invalids.length]=new Array(f.f_tour_term_to,"Termín do (DD.MM.RRRR)");
//		}
//		if(f.f_tour_destination.value==0)emptys[emptys.length]=new Array(f.f_tour_destination,"Destinace");
		//if(f.f_tour_transport.value==0)emptys[emptys.length]=new Array(f.f_tour_transport,"Doprava");
	}

	if(f.id=="form_newsletter") {
		if(trim(f.f_news_email.value)=="") {
			emptys[emptys.length]=new Array(f.f_news_email,"Váš email");
		} else {
			if(!isMail(trim(f.f_news_email.value)))invalids[invalids.length]=new Array(f.f_news_email,"Vá1 email");
		}
	}

	if(f.id=="form_extranet") {
		if(trim(f.f_login_name.value)=="") emptys[emptys.length]=new Array(f.f_login_name,"Jméno");
		if(trim(f.f_login_password.value)=="") emptys[emptys.length]=new Array(f.f_login_password,"Heslo");
	}

	if(f.id=="form_order") {
		if(trim(f.f_name.value)=="") emptys[emptys.length]=new Array(f.f_name,"Jméno");
		if(trim(f.f_surname.value)=="") emptys[emptys.length]=new Array(f.f_surname,"Příjmení");
		if(trim(f.f_street.value)=="") emptys[emptys.length]=new Array(f.f_street,"Ulice");
		if(trim(f.f_city.value)=="") emptys[emptys.length]=new Array(f.f_city,"Místo");
		if(trim(f.f_zipcode.value)=="") emptys[emptys.length]=new Array(f.f_zipcode,"PSČ");
		if(trim(f.f_phone.value)=="") emptys[emptys.length]=new Array(f.f_phone,"Telefon");
		if(trim(f.f_email.value)=="") {
			emptys[emptys.length]=new Array(f.f_email,"Email");
		} else {
			if(!isMail(trim(f.f_email.value)))invalids[invalids.length]=new Array(f.f_email,"Email");
		}
	}

	if(emptys.length>0 || invalids.length>0){
		var alrt="";
		if(emptys.length>0){
			alrt+="Následující položky nebyly vyplněny:\n\n";
			for(var i=0;i<emptys.length;i++){
				alrt+=emptys[i][1]+"\n";
				emptys[0][0].focus();
				emptys[i][0].style.backgroundColor="#f7ed98";
			}
		}

		if(invalids.length>0){
			alrt+=(emptys.length>0?"\n\n":"")+"Nasledujici položky nebyly správně vyplněny:\n\n";
			for(var i=0;i<invalids.length;i++){
				alrt+=invalids[i][1]+"\n";
				invalids[0][0].focus();
				invalids[i][0].style.backgroundColor="#f7ed98";
				//invalids[i][0].style.backgroundImage="url('images/layout/crumbs/exclamation-mark.gif')";
			}
		}

		alert(alrt);
		return false;
	} else {
		return true;
	}
}

function rowOver(row){
  var tds=row.getElementsByTagName("td");
  for(var i=0;i<tds.length;i++){
    //tds[i].style.color="#fff";	/zmena textu
    tds[i].style.backgroundColor="#CFDFE3";
	//tds[0].getElementsByTagName("a")[0].style.color="#"; /zmena acek
  }
}


function rowOut(row){
  var tds=row.getElementsByTagName("td");
  for(var i=0;i<tds.length;i++){
   // tds[i].style.color="#000";
    tds[i].style.backgroundColor=row.className.indexOf("tr1")<0?"#fff":"#f0f0f0";
	//tds[0].getElementsByTagName("a")[0].style.color="#000";
  }
}

