// JavaScript Document



function validatorObject_core(ObjectName,ObjectType,ObjectDescription,ObjectPass,Objectlength,ObjectEqual,ObjectEqualMessage)



{



	var ObjectStr = document.getElementById(ObjectName).value;



	if(ObjectType=="V")



	{



		var allValid = false; 



  		if (ObjectStr.length>0){allValid = true;}   



  		if (!allValid){alert("Error en el "+ObjectPass+" : El campo "+ObjectDescription+" esta vacío");return false;}



		else{return true;}



	}



	if(ObjectType=="L")



	{



		var allValid = false; 



		var checkStr = ObjectStr;



  		if (!(checkStr.length==Objectlength)){alert("El campo "+ObjectDescription+" solo debe contener "+Objectlength+" digitos");return false;}   



		else{return true;}



	}



	if(ObjectType=="I")



	{



		var allValid = false; 



  		if (!(ObjectStr==ObjectEqual)){allValid = true;}   



  		if (!allValid){



		if(ObjectEqualMessage=="1"){alert("Error en el "+ObjectPass+" : El campo "+ObjectDescription+" no ha sido seleccionado");return false;}



		if(ObjectEqualMessage=="2"){alert("Error en el "+ObjectPass+" : El campo "+ObjectDescription+" no ha sido ingresado");return false;}



		if(ObjectEqualMessage=="3"){alert("Error en el "+ObjectPass+" : El campo "+ObjectDescription+" debe ser mayor a 0");return false;}



		}



		else{return true;}



	}



	if(ObjectType=="S")



	{



		var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ'" + "abcdefghijklmnñopqrstuvwxyzáéíóú ";



		var checkStr = ObjectStr;



		var allValid = true; 



			for (i = 0; i < checkStr.length; i++)



			{



			    ch = checkStr.charAt(i); 



				    for (j = 0; j < checkOK.length; j++)



						if (ch == checkOK.charAt(j))break;



					if (j == checkOK.length){allValid = false;break; }



			}



  		if (!allValid){alert("Error en el "+ObjectPass+" : Escriba sólo letras en el campo "+ObjectDescription);return false;}



		else{return true;}



	}







	if(ObjectType=="N")



	{	



	



	  var checkOK = "0123456789"; 



  	  var checkStr = ObjectStr;



      var allValid = true; 



	  	for (i = 0; i < checkStr.length; i++)



			{



			    ch = checkStr.charAt(i); 



				    for (j = 0; j < checkOK.length; j++)



						if (ch == checkOK.charAt(j))break;



					if (j == checkOK.length){allValid = false;break; }



			} 



	  	if (!allValid){alert("Escriba sólo numeros en el campo "+ObjectDescription);return false;}



		else{return true;}



	}	







}







function getSelectedRadio(buttonGroup) {



   // returns the array number of the selected radio button or -1 if no button is selected



   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)



      for (var i=0; i<buttonGroup.length; i++) {



         if (buttonGroup[i].checked) {



            return i



         }



      }



   } else {



      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero



   }



   // if we get to this point, no radio button is selected



   return -1;



} // Ends the "getSelectedRadio" function







function getSelectedRadioValue(buttonGroup) {



   // returns the value of the selected radio button or "" if no button is selected



   var i = getSelectedRadio(buttonGroup);



   if (i == -1) {



      return "";



   } else {



      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)



         return buttonGroup[i].value;



      } else { // The button group is just the one button, and it is checked



         return buttonGroup.value;



      }



   }



} // Ends the "getSelectedRadioValue" function







function getSelectedCheckbox(buttonGroup) {



   // Go through all the check boxes. return an array of all the ones



   // that are selected (their position numbers). if no boxes were checked,



   // returned array will be empty (length will be zero)



   var retArr = new Array();



   var lastElement = 0;



   if (buttonGroup[0]) { // if the button group is an array (one check box is not an array)



      for (var i=0; i<buttonGroup.length; i++) {



         if (buttonGroup[i].checked) {



            retArr.length = lastElement;



            retArr[lastElement] = i;



            lastElement++;



         }



      }



   } else { // There is only one check box (it's not an array)



      if (buttonGroup.checked) { // if the one check box is checked



         retArr.length = lastElement;



         retArr[lastElement] = 0; // return zero as the only array value



      }



   }



   return retArr;



} // Ends the "getSelectedCheckbox" function







function getSelectedCheckboxValue(buttonGroup) {



   // return an array of values selected in the check box group. if no boxes



   // were checked, returned array will be empty (length will be zero)



   var retArr = new Array(); // set up empty array for the return values



   var selectedItems = getSelectedCheckbox(buttonGroup);



   if (selectedItems.length != 0) { // if there was something selected



      retArr.length = selectedItems.length;



      for (var i=0; i<selectedItems.length; i++) {



         if (buttonGroup[selectedItems[i]]) { // Make sure it's an array



            retArr[i] = buttonGroup[selectedItems[i]].value;



         } else { // It's not an array (there's just one check box and it's selected)



            retArr[i] = buttonGroup.value;// return that value



         }



      }



   }



   return retArr;



} // Ends the "getSelectedCheckBoxValue" function







function validateEmail(email)



{



    if(email.length <= 0)



	{



	  return true;



	}



    var splitted = email.match("^(.+)@(.+)$");



    if(splitted == null) return false;



    if(splitted[1] != null )



    {



      var regexp_user=/^\"?[\w-_\.]*\"?$/;



      if(splitted[1].match(regexp_user) == null) return false;



    }



    if(splitted[2] != null)



    {



      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;



      if(splitted[2].match(regexp_domain) == null) 



      {



	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;



	    if(splitted[2].match(regexp_ip) == null) return false;



      }// if



      return true;



    }



return false;



}







function getNewSwf(sCorrelative,sName,sDiv,sWith,sHeight,sColor)



{



	var trailer = new FlashObject("swf/"+sName, "swf"+sCorrelative ,sWith,sHeight, "6.0.65",sColor);



   	trailer.addParam("quality", "high");



   	trailer.addParam("wmode", "transparent"); //

	trailer.addParam("salign", "t"); //



   	trailer.write(sDiv);



}

function enviarDataLogin() // envia datos para verificar 
{
	document.getElementById("textMessage").innerHTML ='<img src="../images/ajax-loader.gif" width="16" height="16" /> <span class="ver10bold">Verificando datos</span>';
	
	$usuario=document.getElementById("txt_tarjeta").value;
	$password=document.getElementById("txt_password").value;
	$page=document.getElementById("namePage").value;
	
	//alert($page);

	if($page=="concurso")
	{	document.getElementById("client").value=document.getElementById("txt_tarjeta").value;
		xajax_validaLoginAid($usuario,$password);}
	
	if($page=="login")
	{

		document.getElementById("client").value=document.getElementById("txt_tarjeta").value;
		document.getElementById("rClienteId").value=document.getElementById("txt_tarjeta").value;
		xajax_validaLogin($usuario,$password);
	}
}

function getNameMonth()

{

var d=new Date()

var month=new Array(12)

month[0]="Enero";

month[1]="Febrero";

month[2]="Marzo";

month[3]="Abril";

month[4]="Mayo";

month[5]="Junio";

month[6]="Julio";

month[7]="Agosto";

month[8]="Setiembre";

month[9]="Octubre";

month[10]="Noviembre";

month[11]="Diciembre";

document.write(month[d.getMonth()])

}

function getNameDay()

{

var d=new Date()

var day=new Array(7)

day[0]="Lunes";

day[1]="Martes";

day[2]="Miercoles";

day[3]="Jueves";

day[4]="Viernes";

day[5]="Sabado";

day[6]="Domingo";


document.write(day[d.getDay()]+' '+d.getDay()+' de ')

}

function fix(cantidad, decimales) {
var cantidad = parseFloat(cantidad);
var decimales = parseFloat(decimales);
decimales = (!decimales ? 2 : decimales);
return Math.round(cantidad * Math.pow(10, decimales)) / Math.pow(10, decimales);
}
