var aSelId = {
		SelFore : '',
		SelBack: ''
	}

var aSelectedItem = {
		Listado : '',
		Listado1 : '',
		Listado2 : '',
		check : '',
		suma : '',
		multiple : ''
	}
var _f, _b;
	_f = _b = '';


function CheckCboEmpty(cParams) {

		aItems = cParams.split(',');

		lValid = true;
		for(i = 0; i < aItems.length; i++) {

			cadena = document.getElementById(aItems[i]).id;
			oTitulo = "tit"+cadena.substr(3,cadena.length);

			oVal2 = document.getElementById(oTitulo);
			oVal2.style.color = "000000";
			oVal3 = document.getElementById(oTitulo).innerHTML;
 
			if (document.getElementById(aItems[i]).value == 0) {
				document.getElementById(aItems[i]).focus();
				oVal2.style.color = "ff0000";
				alert('El campo "' + oVal3 + '" es obligatorio, debe proporcionar su información.');
				lValid = false;
				break;
			}

		}
		return (lValid);
}

function CheckEmpty(cParams) {
		//cParams = document.getElementById('hidden').value;
		//alert(document.getElementById('hidden').value);
		aItems = cParams.split(',');
		lValid = true;
		for(i = 0; i < aItems.length-1; i++) {
		//alert("chk_"+aItems[i]);
			cadena = document.getElementById("chk_"+aItems[i]).id;
			oTitulo = "tit_"+cadena.substr(4,cadena.length);
			oTitulo2 = "txt_"+cadena.substr(4,cadena.length);
			//alert(oTitulo);
			//alert(oTitulo2);
			oVal2 = document.getElementById(oTitulo);
			oVal2.style.color = "213A85";
			oVal3 = document.getElementById(oTitulo).innerHTML;
			if (document.getElementById(oTitulo2).value == 0.00 || document.getElementById(oTitulo2).value == "") {
				//alert(oTitulo2);
				document.getElementById(oTitulo2).focus();
				oVal2.style.color = "ff0000";
				alert('El campo "' + oVal3 + '" es obligatorio, debe proporcionar su información.');
				lValid = false;
				break;
			}
		}
		return (lValid);
}

function CheckEmptyPlus(cParams) {
	//alert(cParams);
		//cParams = document.getElementById('hidden').value;
		//alert(document.getElementById('hidden').value);
		aItems = cParams.split(',');
		lValid = true;
		for(i = 0; i < aItems.length; i++) {
		//alert(aItems[i]);
			cadena = aItems[i];
			//alert(cadena);
			oTitulo = "tit_"+cadena;
			//oTitulo2 = "txt_"+cadena;
			//alert(oTitulo);
			//alert(oTitulo2);
			oVal2 = document.getElementById(oTitulo);
			oVal2.style.color = "213A85";
			oVal3 = document.getElementById(oTitulo).innerHTML;
			if (document.getElementById(aItems[i]).value == "") {
				document.getElementById(aItems[i]).focus();
				oVal2.style.color = "ff0000";
				alert('El campo "' + oVal3 + '" es obligatorio, debe proporcionar su información.');
				lValid = false;
				break;
			}

		}
		return (lValid);
}

function PwrdConfirm(cPwrd, cConf)
	{
		p = document.getElementById(cPwrd);
		c = document.getElementById(cConf);

		if (p.value != c.value) {
			p.focus();
			alert("La contraseña y su confirmación no coinciden, vuelva a escribirlas.");
		}

		return (p.value == c.value);
	}

function SaveRGB(oItem)
	{
		aSelId['SelFore'] = oItem.style.color;
		aSelId['SelBack'] = oItem.style.backgroundColor;
	}

	function btnOver(oItem, cForeRGB, cBackRGB, lRGBSave)
	{
		aSelId['SelFore'] = oItem.style.color;
		aSelId['SelBack'] = oItem.style.backgroundColor;

		if (cForeRGB != '') oItem.style.color = "#" + cForeRGB.replace("#","");
		if (cBackRGB != '') oItem.style.backgroundColor = "#" + cBackRGB.replace("#","");
		oItem.style.cursor = 'pointer';

		if (lRGBSave == true) SaveRGB(oItem);
	}


	function rowOver(oItem, cStr)
	{
		btnOver(oItem, aSelectedRGB[cStr].OverFg, aSelectedRGB[cStr].OverBg)
	}


	function btnOut(oItem)
	{
		oItem.style.color = aSelId['SelFore'];
		oItem.style.backgroundColor = aSelId['SelBack'];
	}


	function SelectCheck(oItem, cStr)
	{
		if (aSelectedItem[cStr] != '') {
			oAnt = aSelectedItem[cStr];
			oAnt.checked = false;
		}
		aSelectedItem[cStr] = oItem;
	}
	
	
	function SelectMultiplechk(oItem, cStr, hidden)
	{		
		if (aSelectedItem[cStr].indexOf(oItem.value + ',') == -1) {
			aSelectedItem[cStr] += oItem.value + ',';
			//alert(aSelectedItem[cStr]);
		}else{
			aSelectedItem[cStr] = aSelectedItem[cStr].replace(oItem.value + ',', '');
			//alert(aSelectedItem[cStr]);
		}
		
		eval("document.getElementById(hidden).value='"+aSelectedItem[cStr]+"'");		
	}
	//+document.getElementById(hidden).value+","

	function SelectMultiple(oItem, cStr)
	{
		if (aSelectedItem[cStr].indexOf(oItem.id + ',') == -1) {
			aSelectedItem[cStr] += oItem.id + ',';
			oItem.style.color = aSelectedRGB[cStr].SelFg;
			oItem.style.backgroundColor = aSelectedRGB[cStr].SelBg;
			SaveRGB(oItem);
		}
		else {
			aSelectedItem[cStr] = aSelectedItem[cStr].replace(oItem.id + ',', '');
			oItem.style.color = aSelectedRGB[cStr].OutFg;
			oItem.style.backgroundColor = aSelectedRGB[cStr].OutBg;
			SaveRGB(oItem);
			rowOver(oItem, cStr);
		}
		//alert(aSelectedItem[cStr]);
	}
	
	
	function SelectSingle(oItem, cStr)
	{
		if (aSelectedItem[cStr] != '') {
			oAnt = aSelectedItem[cStr];
			//oAnt.style.color = aSelectedRGB[cStr].OutFg;
			//oAnt.style.backgroundColor = aSelectedRGB[cStr].OutBg;
		}

		///  agregado, valida si ya esta seleccionado y lo deselecciona
		if (aSelectedItem[cStr] == oItem) {
			aSelectedItem[cStr] = '';
			//oItem.style.color = aSelectedRGB[cStr].OutFg;
			//oItem.style.backgroundColor = aSelectedRGB[cStr].OutBg;
		}else{
			aSelectedItem[cStr] = oItem;
			//oItem.style.color = aSelectedRGB[cStr].SelFg;
			//oItem.style.backgroundColor = aSelectedRGB[cStr].SelBg;
		}

		//SaveRGB(oItem);
		alert(aSelectedItem[cStr].id);
	}
	
	function SelectSingle2(oItem, cStr)
	{
		if (aSelectedItem[cStr] != '') {
			oAnt = aSelectedItem[cStr];
			oAnt.style.color = aSelectedRGB[cStr].OutFg;
			oAnt.style.backgroundColor = aSelectedRGB[cStr].OutBg;
		}

		aSelectedItem[cStr] = oItem;
		oItem.style.color = aSelectedRGB[cStr].SelFg;
		oItem.style.backgroundColor = aSelectedRGB[cStr].SelBg;

		SaveRGB(oItem);
	}

function popupcenter(mypage,myname,w,h,scroll,resize)
{
	if(!resize) resize = "yes"
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =
	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable='+resize+',status=yes';
	win = window.open(mypage,myname,settings)
}

function Reload_admin()
{

   if (window.opener && !window.opener.closed) {

      window.opener.location.reload();

      self.close();

   }

}


function b_over(celda)
	{
		celda.style.color='#FF861D';
		celda.style.cursor='pointer';
	}

	function b_click(celda)
	{
		_target = document.getElementById("titulo");
		_target.innerHTML=celda.innerHTML;
	}

	function b_out(celda)
	{
		celda.style.color='#7C7C7C';
	}

/* Funcion eliminar */
/* Parametros:  (ID , Texto del mensaje)*/
function eliminar(idnum,texto)
{ 
	var txtimprimir = texto;
	var filaid = idnum;
	filaid = filaid.replace('ln_', '');

	if(confirm("Seguro deseas eliminar "+ txtimprimir + " #" + filaid + "?")){
		window.location = window.location+"&elim="+ filaid;
	}
}
/* termina funcion eliminar */


/* Parametros:  (ID , Texto del mensaje)*/
function eliminar2(idnum,texto,prepoliza,inciso)
{ 
	var txtimprimir = texto;
	var filaid = idnum;
	var prepoliza=prepoliza;
	var id=inciso;
	//alert(filaid);
	//alert(prepoliza);
	//alert(id);
	
	//filaid = filaid.replace('ln_', '');
	if(id==""){
		if(confirm("Seguro deseas eliminar "+ txtimprimir + " #" + filaid + "?")){
		window.location = window.location+"&elim="+ filaid +"&pre_poliza="+ prepoliza;
		}
	}else{
		if(confirm("Seguro deseas eliminar "+ txtimprimir + " #" + filaid + "?")){
			window.location = window.location+"&elim="+ filaid +"&pre_poliza="+ prepoliza +"&inciso_elim="+ id;
		}
	}
}
/*-----------------------------------------------*/
/*funcion baja de incisos*/

function baja(idnum,texto){ 
	var txtimprimir = texto;
	var filaid = idnum;

	if(confirm("Seguro desea dar de baja "+ txtimprimir + "?")){
		window.location = window.location+"&elim="+ filaid;
	}
}

/* funcion para agregar incisos*/
function agregar(idnum,texto)
{ 
	var txtimprimir = texto;
	var filaid = idnum;
	//alert(filaid);
	//filaid = filaid.replace('ln_', '');
	if(filaid==undefined){
//		popupcenter('pre_poliza_subir_archivo.php?imp=1','NuevoArchivo','520','350','yes','yes');
 		popupcenter('cliente_emision.php?imp=1','Emision','600','600','yes','yes');
	}else{
		if(confirm("Para agregar mas incisos"+ txtimprimir + " #" + filaid + " de click en Aceptar.\n Si desea agregar una Pre-poliza nueva de click en Cancelar")){
//			window.location = window.location='pre_poliza_subir_archivo.php&pre_poliza='+ filaid;
			popupcenter('pre_poliza_subir_archivo.php?imp=1&agregar='+ filaid,'NuevoArchivo','540','350','yes','yes');
		}else{
			//popupcenter('pre_poliza_subir_archivo.php?imp=1','NuevoArchivo','520','350','yes','yes');
			popupcenter('cliente_emision.php?imp=1','Emision','600','600','yes','yes');
		}
	}
}
/*--------------------------------------------------------------------------------------------------------------------------------------*/


/* funcion para agregar incisos a poliza*/
function agregar_inc_pol(idnum,id_cliente,texto){
	var txtimprimir = texto;
	var filaid = idnum;
	
	poliza = filaid.split("_",1);

	if(confirm("Si desea agregar incisos"+ txtimprimir + " #" + poliza + " de click en Aceptar.\n Si no oprima el boton Cancelar")){
		if(confirm("Para importar un archivo con los incisos de click en Aceptar.\nSi desea capturar la informacion en pantalla oprima el boton Cancelar")){
			popupcenter('poliza_subir_archivo.php?imp=1&agregar='+ filaid+'&id_cliente='+id_cliente,'NuevoArchivo','540','350','yes','yes');
		}else{
			popupcenter('pol_agregar_incisos.php?imp=1&agregar='+ filaid,'NuevoInciso','800','700','yes','yes');
		}
	}
}
/*--------------------------------------------------------------------------------------------------------------------------------------*/


function activar(idnum,texto)
{
	var txtimprimir = texto;
	var filaid = idnum;
	filaid = filaid.replace('ln_', '');

	if(confirm("Seguro deseas activar "+ txtimprimir + " #" + filaid + "?")){
		window.location = window.location+"&activar="+ filaid;
	}
}


/**********Cambiar estatus***********************/

function estatus(idnum,texto)
{
	var txtimprimir = texto;
	var filaid = idnum;
	
	if(confirm("Seguro que desea "+ txtimprimir + "?")){
		window.location = window.location+"&reproceso="+ filaid;
	}
}

/*********************************/

/**********Reexpedicion***********************/

function reexpedicion(idnum,texto)
{
	var txtimprimir = texto;
	var filaid = idnum;
	
	if(confirm("Seguro que desea "+ txtimprimir + "?")){
		popupcenter('cancelar.php?reexpedir='+ filaid,'reexpedicion','530','460','yes','yes');
		//popupcenter('pre_poliza_subir_archivo.php?imp=1&agregar='+ filaid,'NuevoArchivo','520','350','yes','yes');
//		window.location = window.location+"&reexpedir="+ filaid;
	}
}

/*********************************/

/* Valida forma */
/* Parametros:  (submited(1),Texto del mensaje,Valor seleccionado)*/
function validaforma(texto,val)
{ 
	var filaid = val
	var txtimprimir = texto;
	if(confirm("¿Seguro desea "+ txtimprimir +" \"" + filaid + "\"?"))
	this.submit();
}
/* termina valida forma */

function numbersonly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

// numbers
else if ((("0123456789").indexOf(keychar) > -1))
   return true;

// decimal point jump
else if (dec && (keychar == "."))
   {
   myfield.form.elements[dec].focus();
   return false;
   }
else
   return false;
}

function isNumberKey(evt) {
     var charCode = (evt.which) ? evt.which : event.keyCode
     if (charCode > 31 && (charCode < 48 || charCode > 57))
         return false;
         return true;
 }
 
 
 function MostrarOcultar(ide){ 

		if (document.getElementById(ide).style.display == 'block'){
			//alert(document.getElementById('cobertura').value);
			if( document.getElementById('cobertura').value == 0){
				document.getElementById(ide).style.display ='none';			
			}
			//if(document.getElementById('cobertura').value == 'none'){
				
		}else{
			document.getElementById(ide).style.display ='block';
		}

	}
	
function resize(x,y){
	window.moveTo(10,10);
	window.resizeTo(x,y);
}


<!----------------------Funcion para cambiar la imagen---------------------->

function imagen(img_name, img_src){
	
   document[img_name].src = img_src; //cambia la imagen -> document.[name de la imagen].src=ruta de la nueva imagen
   document.getElementById('swf').style.display="none";
   document.getElementById('imagenes').style.display="block";
}
// <IMG id="imagenes" style="display:none;" SRC="imagenes/fot_retiro.jpg" WIDTH="387" HEIGHT="267" NAME="seccion" BORDER="0">
<!--------------------------------------------------------------------------->

function MostrarDiv(ide,posx,posy){ 

//		if (document.getElementById(ide).style.display == 'block'){
//			document.getElementById(ide).style.display ='none';
//		}else{
//			document.getElementById(ide).style.display ='block';
//		}
		document.getElementById(ide).style.display ='block';

		document.getElementById(ide).style.left = posx + 1;
		document.getElementById(ide).style.top = posy + 8;
	}

function ocultar(){
	if(document.getElementById('cargadiv').style.display=='none'){
		for(n=1;n<=6;n++){
			document.getElementById('tipo_'+n).style.display='block';
		}
	}else{
		for(n=1;n<=6;n++){
			document.getElementById('tipo_'+n).style.display='none';
		}
	}

}
function outinfo(){
	document.getElementById('cargadiv').style.display='none';
}

function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }
  
  
  
function colors(accion,sec){

	if(accion == "over"){
		document.getElementById(sec).style.color="213A85";
	}else if(accion == "out"){
		document.getElementById(sec).style.color="FFFFFF";
	}

}