// JavaScript Document

/***********************************************
* Switch Content script II- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use. Last updated April 2nd, 2005.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/


var enablepersist="on" //Enable saving state of content structure using session cookies? (on/off)
var memoryduration="7" //persistence in # of days

var contractsymbol='img/minus.gif' //Path to image to represent contract state.
var expandsymbol='img/plus.gif' //Path to image to represent expand state.

/////No need to edit beyond here //////////////////////////

function getElementbyClass(rootobj, classname){
var temparray=new Array()
var inc=0
var rootlength=rootobj.length
for (i=0; i<rootlength; i++){
if (rootobj[i].className==classname)
temparray[inc++]=rootobj[i]
}
return temparray
}

function sweeptoggle(ec){
var inc=0
while (ccollect[inc]){
ccollect[inc].style.display=(ec=="contract")? "none" : ""
inc++
}
revivestatus()
}


function expandcontent(curobj, cid){
if (ccollect.length>0){
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="none")? "none" : ""
curobj.src=(document.getElementById(cid).style.display=="none")? expandsymbol : contractsymbol
}
}

function revivecontent(){
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="none"
}

function revivestatus(){
var inc=0
while (statecollect[inc]){
if (ccollect[inc].style.display=="none")
statecollect[inc].src=expandsymbol
else
statecollect[inc].src=contractsymbol
inc++
}
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="none")
selectedItem+=ccollect[inc].id+"|"
inc++
}
if (get_cookie(window.location.pathname)!=selectedItem){ //only update cookie if current states differ from cookie's
var expireDate = new Date()
expireDate.setDate(expireDate.getDate()+parseInt(memoryduration))
document.cookie = window.location.pathname+"="+selectedItem+";path=/;expires=" + expireDate.toGMTString()
}
}

function do_onload(){
uniqueidn=window.location.pathname+"firsttimeload"
var alltags=document.all? document.all : document.getElementsByTagName("*")
ccollect=getElementbyClass(alltags, "switchcontent")
statecollect=getElementbyClass(alltags, "showstate")
if (enablepersist=="on" && get_cookie(window.location.pathname)!="" && ccollect.length>0)
revivecontent()
if (ccollect.length>0 && statecollect.length>0)
revivestatus()
}

if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate



//////////////////////////////////////////////////////////////

/* ===================================================================== */

// JavaScript Document



var pong;
function makeArray(n){
  this.length = n;
  for (i=1;i<=n;i++){
    this[i]=0;
  }
  return this;
}

// standard date display function with y2k compatibility
function displayDate() {
  var this_month = new makeArray(12);
  this_month[0]  = "Enero";
  this_month[1]  = "Febrero";
  this_month[2]  = "Marzo";
  this_month[3]  = "Abril";
  this_month[4]  = "Mayo";
  this_month[5]  = "Junio";
  this_month[6]  = "Julio";
  this_month[7]  = "Agosto";
  this_month[8]  = "Septiembre";
  this_month[9]  = "Octubre";
  this_month[10] = "Noviembre";
  this_month[11] = "Deciembre";

  var this_day_e = new makeArray(7);
  this_day_e[0]  = "Domingo";
  this_day_e[1]  = "Lunes";
  this_day_e[2]  = "Martes";
  this_day_e[3]  = "Miércoles";
  this_day_e[4]  = "Jueves";
  this_day_e[5]  = "Viernes";
  this_day_e[6]  = "Sábado";

  var today = new Date();
  var day   = today.getDate();
  var month = today.getMonth();
  var year  = today.getYear();
  var dia = today.getDay();
    if (year < 1000) {
       year += 1900; }
  return( " " + this_day_e[dia] + ", " + day + " de " + this_month[month] + " " + year);
}


var lowercaseLetters = "abcdefghijklmnopqrstuvwxyzáéíóúñü_-";
var uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZÁÉÍÓÚÑ_-";

function isDigit (c) //devuelve si un caracter es numero o no
{   return ((c >= "0") && (c <= "9"))
}

function implode( o, delimiter )
	{
		var val; var str="";
		for(i=0; i<o.length; i++)
		{
			if (str.length>0) { str=str+delimiter; }
			str=str+o.options[i].value;
		}
		return str;
	}

function isLetter (c) //busca en un arreglo de todas las letras si es una letra o no
{
    return( ( uppercaseLetters.indexOf( c ) != -1 ) ||
            ( lowercaseLetters.indexOf( c ) != -1 ) )
}

function isemail( v ) 
{
	var reg  = /(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i;
	return reg.test( v );
}

function isEmpty(s) //verifica si un string es nulo o vacio
{   return ((s == null) || (s.length == 0) || (s == ""))
}

function isAlphanumeric (s) //verifica que un string sea alfanumerico estricto y sin espacios en blanco
{   var i;

    if (isEmpty(s)) return false;
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (! (isLetter(c) || isDigit(c) ) )
        return false;
    }

    return true;
}

/* ===================================================================== */

function isblank(val)
{
	if(val==null) return true;
	for(var i=0;i<val.length;i++)
	{
		if
		(	
				(val.charAt(i) != ' ') 
			&& 	(val.charAt(i) != "\t") 
			&& 	(val.charAt(i) != "\n") 
			&& 	(val.charAt(i) != "\r")
		) return false;
	}
	return true;
}

/* ===================================================================== */
// Este solo funciona en IE

function numeros ()  { //verifica que solo ingresen al campo de texto numeros en el evento onKeypress

if ((event.keyCode < 48) ||(event.keyCode > 57)) event.returnValue = false;

}


/* ===================================================================== */


function CheckNumericKeyInfo($char, $mozChar) {
if($mozChar != null) { // Look for a Mozilla-compatible browser
if(($mozChar >= 48 && $mozChar <= 57) || $mozChar == 0 || $char == 8 || $mozChar == 13) $RetVal = true;
else {
$RetVal = false;
//alert('Please enter a numeric value.');
}
}
else { // Must be an IE-compatible Browser
if(($char >= 48 && $char <= 57) || $char == 13) $RetVal = true;
else {
$RetVal = false;
//alert('Please enter a numeric value.');
}
}
return $RetVal;
}


/* ===================================================================== */



function iswrote( field )
{
	var v = field.value;
	if( isblank(v) )
	{
		try
		{
			field.value = "";
		}catch(e){}
		field.focus();
		return false;
	}

	return true;
}

/* ===================================================================== */

function isselected( field )
{
	if( field.selectedIndex == 0 )
	{
		field.focus();
		return false;
	}

	return true;
}

function numeros ()  { //verifica que solo ingresen al campo de texto numeros en el evento onKeypress

if ((event.keyCode < 48) ||(event.keyCode > 57)) event.returnValue = false;

}

function chequeaRequeridos(frm, CamposRequeridos, Descripcion) {
	var alertMsg = "_______________________________________________________________\n\n";
 		 alertMsg += "El formulario no ha sido enviado debido a que se presentaron problemas.\n";
	 	 alertMsg += "Por favor corrija los problemas y vueva a enviar el formulario.\n";
		 alertMsg += "_______________________________________________________________\n\n";
		 alertMsg += "Los siguientes campos deben rellenarse: \n\n";

	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < CamposRequeridos.length; i++){
		var obj = frm.elements[CamposRequeridos[i]];
		if (obj) {
			switch(obj.type) {
			case "select-one":
				if (obj.selectedIndex == 0 || obj.options[obj.selectedIndex].text == "" || obj.value == ""){
					alertMsg += " - " + Descripcion[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + Descripcion[i] + "\n";
				}
				break;
						
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + Descripcion[i] + "\n";
				}
				break;
				
			case "text":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + Descripcion[i] + "\n";				
					
				}
				break;
				
			case "password":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + Descripcion[i] + "\n";				
					
				}						
				break;
				
			default:
			}
			
			if (obj.type == undefined) {
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++)
					if (obj[j].checked) blnchecked = true;
				
				if (!blnchecked)
					alertMsg += " - " + Descripcion[i] + "\n";
			}
		}
	}

	if (alertMsg.length == l_Msg) {
		return true;
	} else {
		alert(alertMsg);
		return false;
	}
}

function longitud_login_password(frm) {
	
	var errorMsg = "";
	var errorMsgLong = "";

	var pass;
	pass = frm.password.value; 
	
	var confirmacion;
	confirmacion = frm.confirmacion.value;
	
	var login;
	login = frm.login.value;

	if (login.length < 6) {
		
		errorMsg += "\n Nombre de usuario \t- El nombre de usuario debe tener al menos 6 caracteres";
		frm.login.value =  "";
	
	} else {
		
		if (isAlphanumeric(login) == false){
			
			errorMsg += "\n Nombre de usuario \t- El nombre de usuario solo puede tener numeros y letras";
			frm.login.value =  "";
		}
	}
	
	if (pass.length < 6 ){
			
		errorMsg += "\n Contraseña \t- La contraseña debe tener al menos 6 caracteres";
 
 		} else {
			
			if (isAlphanumeric(pass) == false){
			
			errorMsg += "\n Contraseña \t\t- La contraseña solo puede tener numeros y letras";
			
			} else {
			
				if (confirmacion != pass) {
	
				errorMsg += "\n Confirmación \t- No coinciden la contraseña y la confirmación";
				frm.password.value = "";
				frm.confirmacion.value =  "";
				
				}
			}
			
		
	 }	
		
	if ((errorMsg != "") || (errorMsgLong != "")){
		msg = "_______________________________________________________________\n\n";
		msg += "El formulario no ha sido enviado debido a que se presentaron problemas.\n";
		msg += "Por favor corrija los problemas y vueva a enviar el formulario.\n";
		msg += "_______________________________________________________________\n\n";
		msg += "Los siguientes campos necesitan ser corregidos: \n";
		
		errorMsg += alert(msg + errorMsg + "\n" + errorMsgLong);
		return false;
	}

	return true;
	
}


function longitud_password(frm) {
	
	var errorMsg = "";
	var errorMsgLong = "";

	var pass;
	pass = frm.password.value; 
	
	var confirmacion;
	confirmacion = frm.confirmacion.value;
	
	if (pass.length < 6 ){
			
		errorMsg += "\n Contraseña \t- La contraseña debe tener al menos 6 caracteres";
 
 	} else {
			
			if (isAlphanumeric(pass) == false){
			
			errorMsg += "\n Contraseña \t\t- La contraseña solo puede tener numeros y letras";
			
			} else {
			
				if (confirmacion != pass) {
	
				errorMsg += "\n Confirmación \t- No coinciden la contraseña y la confirmación";
				frm.password.value = "";
				frm.confirmacion.value =  "";
				
				}
			}
			
		
	 }	
		
	if ((errorMsg != "") || (errorMsgLong != "")){
		msg = "_______________________________________________________________\n\n";
		msg += "El formulario no ha sido enviado debido a que se presentaron problemas.\n";
		msg += "Por favor corrija los problemas y vueva a enviar el formulario.\n";
		msg += "_______________________________________________________________\n\n";
		msg += "Los siguientes campos necesitan ser corregidos: \n";
		
		errorMsg += alert(msg + errorMsg + "\n" + errorMsgLong);
		return false;
	}

	return true;
	
}


function validaEmail(frm) {
	
	var errorMsg = "";
	var errorMsgLong = "";
	
	
	//Verifica el email
			
	if (frm.email.value != '') {
	var checkEmail = "@.";
	var checkStr = frm.email.value;
	var EmailValid = false;
	var EmailAt = false;
	var EmailPeriod = false;
	for (i = 0;  i < checkStr.length;  i++)
	{
	ch = checkStr.charAt(i);
	for (j = 0;  j < checkEmail.length;  j++)
	{
		if (ch == checkEmail.charAt(j) && ch == "@")
		EmailAt = true;
		if (ch == checkEmail.charAt(j) && ch == ".")
		EmailPeriod = true;
		if (EmailAt && EmailPeriod)
		break;
		if (j == checkEmail.length)
		break;
	}
	// if both the @ and . were in the string
		if (EmailAt && EmailPeriod)
		{
			EmailValid = true
			break;
		}
	}
	if (!EmailValid) {
	  errorMsg += "\n Correo electrónico \t- Debe ingresar un correo electrónico válido";
	}
	}
	
	if ((errorMsg != "") || (errorMsgLong != "")){
		msg = "_______________________________________________________________\n\n";
		msg += "El formulario no ha sido enviado debido a que se presentaron problemas.\n";
		msg += "Por favor corrija los problemas y vueva a enviar el formulario.\n";
		msg += "_______________________________________________________________\n\n";
		msg += "Los siguientes campos necesitan ser corregidos: \n";
		
		errorMsg += alert(msg + errorMsg + "\n" + errorMsgLong);
		return false;
	}

	return true;
}

function Validar (frm, fecha, deshabilitar) 
{
 
 if (chequeaRequeridos(frm, cmpReq, desc))
  {
    if (deshabilitar == null) frm.Submit.disabled = true;
    return true;
  }
  else
    return false;
}   

function ValidarEmail (frm, fecha, deshabilitar) 
{
	
  if (chequeaRequeridos(frm, cmpReq, desc) && validaEmail(frm))
  {
    if (deshabilitar == null) frm.Submit.disabled = true;
    return true;
  }
  else
    return false;
}   

/*
function verifica_numero_preguntas () {

			
		if (document.forma.num_preguntas.value == 0) {
		
			alert ("El número de preguntas debe ser mayor a 0");
			return false;
			
		} else {
			
			return true;
		}
	
}
*/

function verifica_numero_preguntas () {

		
		if (document.forma.banco_items.value == 0) {
		
			alert ("El número de preguntas del banco de items debe ser mayor a 0");
			return false;
		
	    } else if ( parseInt(document.forma.num_preguntas.value) > parseInt(document.forma.banco_items.value) ) {
					
			alert ("El número de preguntas del Quiz no puede ser mayor al número de preguntas del banco items");
			return false;
			
		} else {
			
			return true;
		}
	
}

function verifica_numero_preguntas_edit () {

		
		if (document.forma.banco_items.value == 0) {
		
			alert ("El número de preguntas del banco de items debe ser mayor a 0");
			return false;
		
	    } else if ( (document.forma.num_preguntas.value) > (document.forma.banco_items.value) ) {
			
			alert ("El número de preguntas del Quiz no puede ser mayor al número de preguntas del banco items");
			return false;
			 		
			
		} else if ( (document.forma.banco_items.value) < (document.forma.num_preguntas_ingresadas.value) ) {
		
			alert ("El número de preguntas del banco de items no puede ser menor a la cantidad de preguntas ya existentes para este Quiz.\nSi desea un menor número de preguntas debe eliminarlas una por una");
			return false;	
			
			
		} else {
			
			return true;
		}
	
}

function verifica_opciones () {
	
		if (( (document.forma.id_tipo_preguntas[2].checked) && ((document.forma.opciones_seleccion_simple.value=="") || (document.forma.opciones_seleccion_simple.value<3)  || (document.forma.opciones_seleccion_simple.value>5)) ) || ( (document.forma.id_tipo_preguntas[3].checked) && ((document.forma.opciones_seleccion_multiple.value=="") || (document.forma.opciones_seleccion_multiple.value<3)  || (document.forma.opciones_seleccion_multiple.value>5)) ) ) {
		
			alert ("Debe ingresar una cantidad de opciones entre 3 y 5 para las preguntas de selección");
			return false;
			
		} else {
			
			return true;
		}
	
}

function verifica_opciones_tipo_pregunta () {
	
		if (( (document.forma.id_tipo_pregunta[2].checked) && ((document.forma.opciones_seleccion_simple.value=="") || (document.forma.opciones_seleccion_simple.value<3)  || (document.forma.opciones_seleccion_simple.value>5)) ) || ( (document.forma.id_tipo_pregunta[3].checked) && ((document.forma.opciones_seleccion_multiple.value=="") || (document.forma.opciones_seleccion_multiple.value<3)  || (document.forma.opciones_seleccion_multiple.value>5)) ) ) {
		
			alert ("Debe ingresar una cantidad de opciones entre 3 y 5 para las preguntas de selección");
			return false;
			
		} else {
			
			return true;
		}
	
}

function verifica_cantidad () {
	
		if ((document.forma.opciones_seleccion_simple.value < 3) || (document.forma.opciones_seleccion_simple.value > 5)) {
		
			alert ("Debe ingresar una cantidad de opciones entre 3 y 5 para las preguntas de selección");
			return false;
			
		} else {
			
			return true;
		}
	
}
	
	
function verifica_cantidad_multiple () {
	
		if ((document.forma.opciones_seleccion_multiple.value < 3) || (document.forma.opciones_seleccion_multiple.value > 5)) {
		
			alert ("Debe ingresar una cantidad de opciones entre 3 y 5 para las preguntas de selección");
			return false;
			
		} else {
			
			return true;
		}
	
}
	
	
function verifica_calificacion_cualitativa () {
	
		if ( (document.forma.tipo_calificacion[0].checked) && ((document.forma.cualitativa_1.value=="") || (document.forma.cualitativa_2.value=="") || (document.forma.cualitativa_3.value=="") || (document.forma.cualitativa_4.value=="") || (document.forma.cualitativa_5.value==""))  ) {
		
			alert ("Debe ingresar los valores para la calificación Cualitativa");
			return false;
			
		} else {
			
			return true;
		}
	
}

function verifica_calificacion_cuantitativa () {
	
		if ( (document.forma.tipo_calificacion[1].checked) && ((document.forma.cuantitativa_min.value=="") || (document.forma.cuantitativa_max.value==""))  ) {
		
			alert ("Debe ingresar los valores para la calificación Cuantitativa");
			return false;
		
		} else if ( parseInt(document.forma.cuantitativa_min.value) >= parseInt(document.forma.cuantitativa_max.value) ) {
		
			alert ("Calificación cuantitativa: El valor mínimo debe ser menor al valor máximo");
			return false;
			
		} else {
			
			return true;
		}
	
}

function destinatarios()
	{
	
		var f = document.forms["forma"];
				
		f.destinatario_bd.value = implode(f.destinatarios,",");
		
		
	}

function ValidarQuiz (frm, fecha, deshabilitar) 
{
	
  if (chequeaRequeridos(frm, cmpReq, desc) && verifica_numero_preguntas() && verifica_opciones() && verifica_calificacion_cualitativa () && verifica_calificacion_cuantitativa ())
  {
	 
	 
    if (deshabilitar == null) frm.Submit.disabled = true;
    return true;
  }
  else
    return false;
}   

function ValidarQuizEdit (frm, fecha, deshabilitar) 
{

	destinatarios();

  if (chequeaRequeridos(frm, cmpReq, desc) && verifica_numero_preguntas() && verifica_opciones() && verifica_calificacion_cualitativa () && verifica_calificacion_cuantitativa ())
  {
	
	
    if (deshabilitar == null) frm.Submit.disabled = true;
    return true;
  }
  else
    return false;
} 

////////////////////////////////////////////////////////////////////////////////

function submit_tipo()  {
	
	

		for (var i=0; i < document.forma.id_tipo_pregunta.length; i++)
			{
				 if (document.forma.id_tipo_pregunta[i].checked)
				  {
				  var tipo_preg = document.forma.id_tipo_pregunta[i].value;
				  }
		   }		
		   
		 
		
		switch (tipo_preg) { 
			case '1': 
			   document.forma.action = 'pregunta_completa_crx.php';
			   var a = 'pregunta_completa_crx.php'
			   break 
			case '2': 
			   document.forma.action = 'pregunta_vf_crx.php';
			   var a = 'pregunta_vf_crx.php'
			   break 
			case '3': 
			   document.forma.action = 'pregunta_simple_crx.php';
			   var a = 'pregunta_simple_crx.php'
			   break 
			case '4': 
			   document.forma.action = 'pregunta_multiple_crx.php';
			   var a = 'pregunta_multiple_crx.php'
			   break
		}  
		
		document.forma.submit();

	}

function ValidarTipoPregunta (frm, fecha, deshabilitar) 
{
	
  if (chequeaRequeridos(frm, cmpReq, desc) && verifica_opciones_tipo_pregunta())
  {
    if (deshabilitar == null) frm.Submit.disabled = true;
	submit_tipo();
    return true;
  }
  else
    return false;
} 

///////////////////////////////

function submit_tipo_nueva(id)  {
	
	

		for (var i=0; i < document.forma.id_tipo_pregunta.length; i++)
			{
				 if (document.forma.id_tipo_pregunta[i].checked)
				  {
				  var tipo_preg = document.forma.id_tipo_pregunta[i].value;
				  }
		   }		
		   
		 
		
		switch (tipo_preg) { 
			case '1': 
			   document.forma.action = 'pregunta_completa_new_crx.php?ID='+id;
			   var a = 'pregunta_completa_new_crx.php?ID='+id;
			   break 
			case '2': 
			   document.forma.action = 'pregunta_vf_new_crx.php?ID='+id;
			   var a = 'pregunta_vf_new_crx.php?ID='+id;
			   break 
			case '3': 
			   document.forma.action = 'pregunta_simple_new_crx.php?ID='+id;
			   var a = 'pregunta_simple_new_crx.php?ID='+id;
			   break 
			case '4': 
			   document.forma.action = 'pregunta_multiple_new_crx.php?ID='+id;
			   var a = 'pregunta_multiple_new_crx.php?ID='+id;
			   break
		}  
		
		document.forma.submit();

	}

function ValidarTipoPreguntaNueva (frm, id, fecha, deshabilitar) 
{
	
  if (chequeaRequeridos(frm, cmpReq, desc) && verifica_opciones_tipo_pregunta())
  {
    if (deshabilitar == null) frm.Submit.disabled = true;
	submit_tipo_nueva(id);
    return true;
  }
  else
    return false;
} 

function ValidarTipoPreguntaSelSimple (frm, fecha, deshabilitar) 
{
	
  if (chequeaRequeridos(frm, cmpReq, desc) && verifica_cantidad())
  {
    if (deshabilitar == null) frm.Submit.disabled = true;
	submit_tipo();
    return true;
  }
  else
    return false;
}

function ValidarTipoPreguntaSelSimple (frm, fecha, deshabilitar) 
{
	
  if (chequeaRequeridos(frm, cmpReq, desc) && verifica_cantidad())
  {
    if (deshabilitar == null) frm.Submit.disabled = true;
	submit_tipo();
    return true;
  }
  else
    return false;
}

function ValidarTipoPreguntaSelMultiple (frm, fecha, deshabilitar) 
{
	
  if (chequeaRequeridos(frm, cmpReq, desc) && verifica_cantidad_multiple())
  {
    if (deshabilitar == null) frm.Submit.disabled = true;
	submit_tipo();
    return true;
  }
  else
    return false;
}


///////////////////////////////////////////////////////////////////////////////////////

function ValidarEmail_Login_Password (frm, fecha, deshabilitar) 
{
  if (chequeaRequeridos(frm, cmpReq, desc) && validaEmail(frm) && longitud_login_password(frm))
  {
    if (deshabilitar == null) frm.Submit.disabled = true;
    return true;
  }
  else
    return false;
} 

function ValidarEmail_Password (frm, fecha, deshabilitar) 
{
  if (chequeaRequeridos(frm, cmpReq, desc) && validaEmail(frm) && longitud_password(frm))
  {
    if (deshabilitar == null) frm.Submit.disabled = true;
    return true;
  }
  else
    return false;
}



function abrir_forgot(name){
	var winleft = (screen.width - 300) / 2;
	var winUp = (screen.height - 130) / 2;
	var winProp;
	winProp = 'width=300'+',height=130'+',left='+winleft+',top='+winUp+',scrollbars=no,resizable=no'
	ventana = window.open(name, "forgot", winProp); 
	if (ventana.opener == null) ventana.opener = self;
}

function abrir_producto(name){
	var winleft = (screen.width - 500) / 2;
	var winUp = (screen.height - 300) / 2;
	var winProp;
	winProp = 'width=500'+',height=300'+',left='+winleft+',top='+winUp+',scrollbars=no,resizable=no'
	ventana = window.open(name, "prod", winProp); 
	if (ventana.opener == null) ventana.opener = self;
}

function ExpandSection(idVariable){

	if (idVariable.style.display=="none") {

			idVariable.style.display="" ;

	} else {

		idVariable.style.display="none" ;
		
	}

}


function ContractSection(idVariable){

	if (idVariable.style.display=="") {

		idVariable.style.display="none"

	}

}

function PopupFoto(url) {
	ventana = window.open(url, "ventana", "width=5,height=5,dependent=yes,screenX=0,screenY=0,titlebar=no,directories=no,menubars=no,status=no,scrollbars=no,resizable=no"); 
	if (ventana.opener == null) ventana.opener = self;
}

function iniciosesion() {
	
	if ((document.forma.login.value == "") || (document.forma.password.value == "")) {
		alert("Debe ingresar su nombre de usuario y contraseña");
		return (false);
	} else {

	   document.forma.action ='check_login.php';
	   document.forma.submit();
	}

 return true;
}



