function changeDisplay( elementId, setTo ) {
    if( document.getElementById ) {
        //Mozilla
        var theElement = document.getElementById( elementId );
    } else {
        if( document.all ) {
            //IE
            var theElement = document.all[ elementId ];
        } else {
            // neco jineho
            var theElement = new Object();
        }
    }
    if( !theElement ) {
        return;
    }
    if( theElement.style ) { theElement = theElement.style; }
    if( typeof( theElement.display ) == 'undefined' &&
    !( window.ScriptEngine && ScriptEngine().indexOf('InScript') + 1 ) ) {
      window.alert( 'Tenhle browser to neumi' );
      return;
    }
    theElement.display = setTo;
}

function echeck(str) {

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   alert("Selected please your email");
		   return false;
		}
		
		//pokud se ma uzivatel upozornovat primo na konretni chybu v mailu, musi se zmenit nasledujici stringy
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Selected please your email");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Selected please your email");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Selected please your email");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Selected please your email");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Selected please your email");
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Selected please your email");
		    return false;
		 }

 		 return true;				
	}

function ValidateForm(formid) {
    if(document.getElementById) {
        //Mozilla
        var myform = document.getElementById(formid);
    } else {
        if(document.all) {
            //IE
            var myform = document.all[formid];
        } else {
        	// neznamy browser, kontrola neprobehne a formular se odesle
        	return true;
	}
    }
    // alert(myform.email);

	if ((myform.jmeno.value==null)||(myform.jmeno.value=="")){
		alert("Please selected your name");
		myform.jmeno.focus();
		return false;
	}
	if ((myform.firma.value==null)||(myform.firma.value=="")){
		alert("Please selected name company");
		myform.firma.focus();
		return false;
	}
// Adresa se nekontroluje
/*	if ((myform.adresa.value==null)||(myform.adresa.value=="")){
		alert("Vyplòte prosím adresu");
		myform.adresa.focus();
		return false;
	}
*/
	if ((myform.telefon.value==null)||(myform.telefon.value=="")){
		alert("Please selected your telephone number");
		myform.telefon.focus();
		return false;
	}			
	
	if ((myform.email.value==null)||(myform.email.value=="")){
		alert("Please selected your email");
		myform.email.focus();
		return false;
	}
	if (echeck(myform.email.value)==false){
		// myform.email.value="";	//pokud se ma spatne vyplneny email smazat, tak tohle odkomentujte
		myform.email.focus();
		return false;
	}
	
	return true
 }
