/*
	Autor: G. Novaro
	Date: 2007/04/29
	Purpouse: Generics JS Functions
	URL: http://www.elevacion.biz
*/
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 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');
	if (window.focus) {newwindow.focus()}
}//pop
	
//On load page disable submit
//document.getElementById("btSend").disabled = true;
function validateForm(sFrmID){
		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 == 'select-one' || elementList[i].type == 'password' || elementList[i].type == 'file'){
				//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;
				}//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;
					}//if
								
			}//if 

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