function mostrarVideo(){
	var video = document.getElementById("video");
	var imagen = document.getElementById("imagen");
 	if (video.style.display=="none"){
		video.style.display="block";
		imagen.style.display="none";
	}else
	{
		video.style.display="none";
		imagen.style.display="block";
	}
}
function validateFields(){
		var  nombre= document.getElementById("name");
		var  company= document.getElementById("company");
		var  mail= document.getElementById("mail");
		var comments = document.getElementById("comments");
		var combo = document.getElementById("cliente");
		var exito=true;
		if (combo.value==-1){
			if (nombre.value==''){
				alert ('Ingresar nombre de cliente');
				nombre.focus();
				return false;
			}
			if (company.value==''){
				alert ('Ingresar nombre de la empresa');
				company.focus();
				return false;
			}
			if (mail.value==''){
				alert ('Ingresar un mail de contacto');
				mail.focus();
				return false;
			}
		}
}
function DisableInputs(){
		var  nombre= document.getElementById("name");
		var  company= document.getElementById("company");
		var  mail= document.getElementById("mail");
		var comments = document.getElementById("comments");
		var combo = document.getElementById("cliente");
		var exito=true;
		
		var send = document.getElementById("send");
		var cantSelected=0;
		
		for (a=0;a<combo.length;a++)
		{ 	if (combo[a].selected) 	cantSelected+=1;
		}
	
		for (a=0;a<combo.length;a++)
		{
			if (combo[a].selected && combo[a].value=="-1" && cantSelected>1)
				exito=false;
				send.disabled=true;
		}
		
		nombre.value="";
		company.value="";		
		mail.value="";		
		if (exito==false){
			alert ('Debes seleccionar para uno nuevo u otros clientes, no las 2 cosas juntas. Por favor, selecciona correctamente para habilitar el Enviar.');
			return false;
		}else{
			send.disabled=false;
		}
		if (combo.value!="-1") {
			nombre.disabled=true;		
			company.disabled=true;		
			mail.disabled=true;		
			send.disabled=false;
			comments.focus();			
		}else{
			nombre.disabled=false;		
			company.disabled=false;		
			mail.disabled=false;		
			send.disabled=false;
			nombre.focus();				
		}

}
//here you place the ids of every element you want.
function HideServerValidationPanel(panelID)
    {    
        if (document.getElementById(panelID) != null)
        {
            document.getElementById(panelID).style.display = "none";
        }        
    }
    function DisplayErrors(errorMessages,lang)
    {        
        if (errorMessages != null && errorMessages.length > 0)
        {
             LoadValidationErrorPanel(errorMessages,lang); 
             
             return false; 
        }
        else
        {
            return true;
        }
       
    }
    function LoadValidationErrorPanel(arrMessage,lang)
    {
        
        var myMain =  document.getElementById ("MainErrorTag");
        
        if (myMain.firstChild != null)
        {
            myMain.removeChild(myMain.firstChild);
        }        
       
        var myDiv = document.createElement("div");
        var myUL = document.createElement("ul");
        var myPara =  document.createElement("p");
        var myImg = document.createElement("img");
        var myDesc = document.createElement("strong");
        
        myDiv.className = "errorSection";
        //myImg.className = "xxx";
        //myDesc.className ="yyy"

        //myImg.setAttribute ("src","Cross.JPG");        
        if (lang=="en"){
			myDesc.innerText = "Please correct the following details before proceeding ..." ;
		}else{
			myDesc.innerText = "Por Favor, corrija los errores antes de proceder." ;
		}
       
        //myPara.appendChild(myImg);
        
        myPara.appendChild(myDesc);
        myDiv.appendChild(myPara);
        var myLi;
        for(var j= 0; j < arrMessage.length;j++)
        {
            myLi = document.createElement("li");
            myLi.className="errorsectionli"
            myLi.innerText = arrMessage[j];
           // myLi.className = "abc";
            myUL.appendChild(myLi);
            
        }
        myDiv.appendChild(myUL);
        myMain.appendChild(myDiv);
    }
    function SetFocus(ControlField, isFocusSet)
    {
        if (isFocusSet == false)
        {
            controlField.focus();
            return true;
        }
        else
            return false;
    }
    
    function ValidateMyScreen()
    {
        var Errors = new Array();
        var ErrorCounter = 0;
        var lang="es";
        if (document.getElementById('Nombre_00').value == '')
        {
            Errors[ErrorCounter++] = "Please enter a Full Name";   

        }
          
        if (document.getElementById('Company_00').value== '')
        {
            Errors[ErrorCounter++] = "Please enter a Company";   
        }    
        if (document.getElementById('JobSiteAddress_00').value== '')
        {
            Errors[ErrorCounter++] = "Please enter a Job Site Address";   
        }    
         if (document.getElementById('Email_00').value== '')
        {
            Errors[ErrorCounter++] = "Please enter an Email";   
        }    
         if (document.getElementById('PhoneNumber_00').value== '')
        {
            Errors[ErrorCounter++] = "Please enter a Phone Number";   
        }    
         if (document.getElementById('ServiceNeeded_00').value== '0')
        {
            Errors[ErrorCounter++] = "Please enter a Service Needed";   
        }    
     //    if (isNaN(document.getElementById('comments_07').value)  && document.getElementById('section7').style.display == 'block' )
     //   {
     //       Errors[ErrorCounter++] = "Please enter the bird problem";   
      //  }    
        
        
    //HideServerValidationPanel('MainErrorTag');
    return DisplayErrors(Errors,lang);
    }
    function ValidateMyScreen2(lang)
    {
        var Errors = new Array();
        var ErrorCounter = 0;
        if (document.getElementById('user').value == '')
        {
            if (lang=="en"){
				Errors[ErrorCounter++] = "Please enter a valid Email.";   
			}else{
				Errors[ErrorCounter++] = "Por Favor, ingresa un Mail válido.";   
			}
        }/*else{
		 alert ('asd');
			var at="@";
			var dot=".";
			var lat=str.indexOf(at);
			var lstr=str.length;
			var ldot=str.indexOf(dot);
			if (str.indexOf(at)==-1){
			   Errors[ErrorCounter++] = "Invalid E-mail";   
			}
			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
				Errors[ErrorCounter++] = "Invalid E-mail";   
			}

			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
				Errors[ErrorCounter++] = "Invalid E-mail";   
			}

			 if (str.indexOf(at,(lat+1))!=-1){
				Errors[ErrorCounter++] = "Invalid E-mail";   
			 }

			 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
				Errors[ErrorCounter++] = "Invalid E-mail";   
			 }

			 if (str.indexOf(dot,(lat+2))==-1){
				Errors[ErrorCounter++] = "Invalid E-mail";   			 
			}
			
			 if (str.indexOf(" ")!=-1){
				Errors[ErrorCounter++] = "Invalid E-mail";   
			 }
			
		}*/
          
        if (document.getElementById('pass').value== '')
        {
            if (lang=="en"){
				Errors[ErrorCounter++] = "Please enter a Password";   
			}else{
				Errors[ErrorCounter++] = "Por Favor, ingresa una contraseña.";   
			}
        }    
        if (document.getElementById('pass2').value== '')
        {
			if (lang=="en"){
				Errors[ErrorCounter++] = "Please enter a second Password";   
			}else{
				Errors[ErrorCounter++] = "Por Favor, ingresa una segunda contraseña.";   
			}
        }    
		
		if ((document.getElementById('pass2').value!='' && document.getElementById('pass').value!=''  ) && (document.getElementById('pass').value != document.getElementById('pass2').value))
		{
            if (lang=="en"){
				Errors[ErrorCounter++] = "Please enter both passwords exactly the same.";   
			}else{
				Errors[ErrorCounter++] = "Por Favor, ingresa ambas contraseñas iguales.";   
			}
        }            
		if (document.getElementById('name').value== '')
        {
            if (lang=="en"){
				Errors[ErrorCounter++] = "Please enter a Name.";   
			}else{
				Errors[ErrorCounter++] = "Por Favor, ingresa tu Nombre.";   	
			}
        }    
		
         if (document.getElementById('phone').value== '')
        {
			if (lang=="en"){
				Errors[ErrorCounter++] = "Please enter a contact ohone.";   
			}else{
				Errors[ErrorCounter++] = "Por Favor, ingresa un teléfono de contacto.";   	
			}
        }    
    /*     if (document.getElementById('company').value== '')
        {
			if (lang=="en"){
				Errors[ErrorCounter++] = "Please enter a company.";   
			}else{
				Errors[ErrorCounter++] = "Por Favor, ingresa tu Compañia.";   
			}
        }    */
    return DisplayErrors(Errors,lang);
    }


function conditshow(rad,txt)
{
  if (document.getElementById(rad).checked)
     document.getElementById(txt).style.display = 'block';
  else
  {
       document.getElementById(txt).style.display = 'none';
       document.getElementById(txt).value='';
       }

}

function switchid(id){	

	hideallids();
	showdiv('section' + id);
}

function change(foto,tipo,modid){	
location.href="./admin.php?tipo=" + tipo + "&modid=" + modid + "&foto=" + foto;
}
function switchselect(id){	

	hideallids();
//	window.location="./admin.php?tipo=" + id;
	location.href="./admin.php?tipo=" + id;
}
function loadModel (id,tipo){
	location.href="./admin.php?tipo=" + tipo + "&modid=" + id;
}
function hideallids(){
	//loop through the array and hide each element by id
	for (var i=1;i<11;i++){
  
		hidediv('section' + i);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		 ;
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

