//CLEAR TEXTFIELD
function doClear(theText) {
	 if (theText.value == theText.defaultValue) {
	     theText.value = ""
	 }
}

 function loadMenu(id) { 		  
	  	if (document.getElementById(id)) document.getElementById(id).className 	= "active";  		
}
 

// Layers
var openedDiv = "0";
function doOnClick(idDiv) {				
	if(openedDiv != "0")
	document.getElementById(openedDiv).style.display='none';
				
if(openedDiv == idDiv) {
	document.getElementById(idDiv).style.display='none';
	openedDiv = "0";
} else {
	document.getElementById(idDiv).style.display='inline';
	document.getElementById(idDiv).style.position='relative';
		openedDiv = idDiv;
	}								
}

// Open layers
function mostrarSubItem (nro, cant) {
	var i;
	var abrir = document.getElementById('sub_' + nro).style.visibility != 'visible';
	for (i=1; i<=cant; i++) {
		document.getElementById('sub_' + i).style.visibility = 'hidden';
		document.getElementById('sub_' + i).style.display = 'none';
		}
	if (abrir) {
		document.getElementById('sub_' + nro).style.visibility = 'visible';
		document.getElementById('sub_' + nro).style.display = 'block';
		//var top = document.getElementById('sub_' + nro);
		//scrollbar.swapContent(top);
		//if (top.y) scrollbar.scrollTo(0, top.y);
	}
}


// Busqueda
function search(pattern) {
	window.location.href = "/busqueda/" + pattern;
}

function checkEnter(e){
	var characterCode;
	if(e && e.which){
		e = e;
		characterCode = e.which;
	} else {
		e = event;
		characterCode = e.keyCode;
	}				
	if(characterCode == 13){
		return true;
	} else{
		return false;
	}
}

function validarEmail(valor) {    
	if (/^_*[a-z0-9]+[_a-z0-9-]*(\.[_a-z0-9-]+)*@[a-z0-9]+([a-z0-9-]+[a-z0-9])*(\.[a-z0-9]+([a-z0-9-]+[a-z0-9])*)*(\.[a-z]{2,3})$/.test(valor)){
		return (true)
	} else {
		alert("La dirección de E-Mail " + valor    + " no es valida");
		return (false);
	}		
}


function abrirGaleria(show, showAll){
	if($("flash_container_video")){
		$("flash_container_video").hide();
	}

	litbox = new LITBox('/galeria.php', {
				type:'window',
				draggable:false,
				overlay:true,
				resizable:false,
				opacity:1,
				width: 689,
				height: 663
			}
	);
	
	viewer = new Viewer(SITE_LANG, show, '1', showAll);
}

function activeMenuImageButtom(){
	$("imagenes").className 	= "active";
	
	$("home_shows").className 	= "";
	$("home").className 	= "";
	$("home_videos").className 	= "";
	$("programacion").className 	= "";
	$("sobretrutv").className 	= "";
	$("suscripcion").className 	= "";
	$("contacto").className 	= "";
}

function activeFooterImageButtom(){
	$("imagenes_footer").className 	= "active";
	
	$("shows_footer").className 	= "";
	$("home_footer").className 	= "";
	$("videos_footer").className 	= "";
	$("programacion_footer").className 	= "";
	$("sobretrutv_footer").className 	= "";
	$("suscripcion_footer").className 	= "";
	$("contacto_footer").className 	= "";
}

