/*
	Autor: G. Novaro
	Date: 2007/04/29
	Purpouse: Generics JS Functions
	URL: http://www.elevacion.biz
	Version: 2.2
*/
function hide(targetDiv){
	var oVDiv = document.getElementById(targetDiv);
	oVDiv.style.display = "none";
}

function show(targetDiv){
	var oVDiv = document.getElementById(targetDiv);
	oVDiv.style.display = "block";
}
	
function showhide(targetDiv){
/*
	Porpouse: Change the orginal state visibility of div changing porperty display: block / none
*/
	var oVDiv = document.getElementById(targetDiv);
	if (oVDiv.style.display == "block")
		oVDiv.style.display = "none";
	else
		oVDiv.style.display = "block";
}//showhide

function showhide_page(targetDiv,sPage){
/*
	Porpouse: Change the orginal state visibility of div changing porperty display: block / none
*/
	var oVDiv = document.getElementById(targetDiv);
	if (oVDiv.style.display == "block")
		oVDiv.style.display = "none";
	else
		oVDiv.style.display = "block";
	if (sPage!="")
		window.location = sPage;
}//showhide

function popitup(url) {
	var newwindow = window.open(url,'name','height=350,width=500');
	if (window.focus) {newwindow.focus()}
}

function goto(url){
	window.location = url;
}
//Cambia el color de una fila por uno que le indicamos
function color(src,color_entrada){
	src.bgColor = "#" + color_entrada;
	src.style.cursor = "pointer";
} 
//Cambia el color por el del fondo cuando el mouse no esta sobre la fila
function colorOut(src,color_default) {
	src.bgColor = color_default;
	src.style.cursor = "default";
} 

function validateEmail(){
   if(
	  (document.getElementById("email").value.length <6) || 
	  (document.getElementById("email").value.indexOf("@")<1)|| 
	  (document.getElementById("email").value.indexOf(".")<1)
	 )
   {
    alert("not E-mail valid!");
    document.getElementById("email").focus();
   }
   else
   {
    document.getElementById("frmSuscribe").submit();
   } 
}//function

function isValidEmail(sEmail){
	if( (String(sEmail).length <6) || (String(sEmail).indexOf("@")<1)|| (String(sEmail).indexOf(".")<1) )
		return false;
	else
		return true;
}//validEmail

function Left(str, n){
	if (n <= 0)
		return "";
	else if (n > String(str).length)
		return str;
	else
		return String(str).substring(0,n);
}//Left 
	
function Right(str, n){
	if (n <= 0)
	   return "";
	else if (n > String(str).length)
	   return str;
	else {
	   var iLen = String(str).length;
	   return String(str).substring(iLen, iLen - n);
	}//if
}//Right
	
function popitup(url) {
	var newwindow = window.open(url,'name','height=340,width=720,resizable=yes');
	if (window.focus) {newwindow.focus()}
}//pop
	
//On load page disable submit
//document.getElementById("btSend").disabled = true;
function validateForm(sFrmID){
/*
	Function: validateForm();
	Purpouse: Generic validation function
	Author: G. Novaro
	Version: 2.3
	Change log:
	2.0 add file support
	2.1 add select support
	2.2 color white is not blank
	2.3 add id parameter for use for various forms
*/
		/*-------------- CHECKS --------------*/
		/*var chkFood = document.getElementById("chkFood");
		var chkGift = document.getElementById("chkGift");
		var chkInformation = document.getElementById("chkInformation");
		
		if ( chkFood.checked == false &&  chkGift.checked == false && chkInformation.checked == false ){
			chkFood.style.background = "#FF0033";
			chkGift.style.background = "#FF0033";
			chkInformation.style.background = "#FF0033";
			document.getElementById("Msg").innerHTML = "You may select more than one";	
			return;
		}else{
			chkFood.style.background = "#FFFFFF";
			chkGift.style.background = "#FFFFFF";
			chkInformation.style.background = "#FFFFFF";
		}*/
		/*-------------- CHECKS --------------*/
		
		/*-------------- RADIO --------------*/
		/*var swradio = false;
		for (i=0;i<document.getElementById(sFrmID).culture.length;i++) {
			if (document.getElementById(sFrmID).culture[i].checked)
				swradio = true;
		}
		
		if (swradio == false){
			document.getElementById("Msg").innerHTML = "You may select almost one option.";	
			return;
		}*/
		/*-------------- RADIO --------------*/
		var elementList = document.getElementById(sFrmID).elements;
		for (i = 0; i < elementList.length; i++){
			
			if (elementList[i].type == 'text' || elementList[i].type == 'textarea' || elementList[i].type=='password' || elementList[i].type=='file' || elementList[i].type == 'select-one' || elementList[i].type == 'checkbox' || elementList[i].type == 'radio' ){
				//alert(elementList[i].value);
				if ( Right(elementList[i].id,1) == "R" && elementList[i].value == "" ){
					document.getElementById("Msg").innerHTML = "Please, complete the required fields";
					elementList[i].style.background = "#FF0033";
					elementList[i].focus();
					return false;
				}//if R
				else
					elementList[i].style.background = "#FFFFFF";		
			
				if ( elementList[i].id == "emailR" )
					if(isValidEmail(elementList[i].value) == false){
						document.getElementById("Msg").innerHTML = "You must enter a <strong>valid</strong> email address.";
						elementList[i].style.background = "#FF0033";
						elementList[i].focus();
						return false;
					}//if
						
				
			}//if 

		}//for
		
		//if ok send
		document.getElementById("btSend").style.display = 'none';
		document.getElementById("Msg").innerHTML = "<img src='loading.gif'/>&nbsp;Sending Information..., Please Wait!";
		document.getElementById(sFrmID).submit();
}//validateForm

function searchWeb(){
		document.getElementById("frmSearch").submit();
}//searchWeb()