$valid = true;
url = document.location.hostname;
function $(id) { return document.getElementById(id) }

function isIE()
{
	return document.all?true:false;
}

function SetActiveCommand($value, $color)
{	
	$('ActiveCommand').value = $value;
	eval($value + '()');
	
	/*Cancela el submit*/
	if (isIE())
	{
		event.cancelBubble = true;
		event.returnValue = false;
		event.cancel = true;
	}
	return false;
	
}
function ValidateSubmit($val)
{
	if (!document.getElementsByName('cbo_tipooperacion')[$val].value)
	{
		if (isIE())
		{
			event.cancelBubble = true;
			event.returnValue = false;
			event.cancel = true;
		}
		return false;
	}
}

function ValidateTelefonoAlternativo($control)
{
	
	$num = $($control).value;
	ResetState($control);
	var $num = (($num.replace('-', '')).replace('.', '')).replace('/', '');
	if($num.length>0)
	{
		
		if ($num.length < 9 || $num.length > 10)
		{
			$valid = false;
				SetErrorState($control);
		}
	
		if (!isInteger($num))
		{
	   		$valid = false;
			SetErrorState($control);
		}
	}
}
function ValidateTelefono($control)
{
	$num = $($control).value;
	ResetState($control);
	var $num = (($num.replace('-', '')).replace('.', '')).replace('/', '');
	
	if ($num.length < 9 || $num.length > 10)
	{
		$valid = false;
		SetErrorState($control);
	}

	if (!isInteger($num))
	{
   		$valid = false;
		SetErrorState($control);
	}
	
}

function ValidateText($control)
{
	$text = $($control).value;
	
	var $text = (($text.replace('-', '')).replace('.', '')).replace('/', '');

	ValidateNotEmpty($control)
	
	
	for (i = 0; i < $text.length; i++)
	{
		$s = $text.charAt(i);
		if (isInteger($s))
		{
   			$valid = false;
			SetErrorState($control);
		}
	}
	
}

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function ValidateRadioNotEmpty($control)
{
	ResetRadioState($control);
	if (document.getElementsByName($control)[0].checked == false && document.getElementsByName($control)[1].checked == false)
	{
		$valid = false;
		SetRadioErrorState($control);
	}
}

function ValidateRadioListNotEmpty($control)
{
	ResetRadioState($control);
	if (document.getElementById($control).childNodes[1].childNodes[1].checked == false && document.getElementById($control).childNodes[3].childNodes[1].checked == false)
	{
		$valid = false;
		SetRadioErrorState($control);
	}
}
function ValidateCheckList($control)
{
	if ( $($control) )
	{
		ResetState('ChkMunis');
		$arr = $($control).value.split('-');
		$e = false;
		for (i = 0; i < ($arr.length - 1); i++)
		{
			if ($('chk_munis_' + $arr[i]).checked)
			{
				$e = true;
				break;
			}
		}
		if (!$e)
		{
			$valid = false;
			SetErrorState('ChkMunis');
		}
	}
}
function ValidateCheckListDistritos($control)
{
	if ( $($control) )
	{
		
		if( document.getElementById )
			elem = document.getElementById( 'tr_distritos' );
		vis = elem.style;

		if(vis.display != 'none')
		{		
			
			ResetState('ChkDist');
			$arr = $($control).value.split('-');
			$e = false;
			for (i = 0; i < ($arr.length - 1); i++)
			{
				if ($('cdk_dists_' + $arr[i]).checked)
				{
					$e = true;
					break;
				}
			}
			if (!$e)
			{
				$valid = false;
				SetErrorState('ChkDist');
			}

		}
	}
}
function ValidateNotEmpty($control)
{
	if ($($control))
	{
		ResetState($control);
		
		if ($($control).value == '')
		{
			$valid = false;
			SetErrorState($control);
			
		}
	}
}
function ValidateNotEmptyTasa($control)
{
	if ($($control))
	{
		ResetState($control);
		if ($($control).value == -1)
		{
			$valid = false;
			SetErrorState($control);
		}
	}
}
function ValidateNotChecked($control)
{
	ResetCheckState($control);
	if ($($control).checked == false)
	{
		$valid = false;
		SetCheckErrorState($control);
	}
}
function ValidateIsEmail($control)
{
	ResetState($control);
	if (!isEmail( $($control).value ) )
	{
		$valid = false;
		SetErrorState($control);
	}
}

function isEmail(s)
{
	if(s.match(/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/))
	{
		return true;
	}
	return false;
}
function ResetState($control)
{
	if ($('lbl_' + $control))
		$('lbl_' + $control).className = 'label';
		
	if ($('err_' + $control))
		$('err_' + $control).className = 'errmsg hidden';
		
	if ($('ast_' + $control))
		$('ast_' + $control).className = '';
	
	if ($('arr_' + $control))
		$('arr_' + $control).style.display = 'none';
	
	
	if($($control))
	{
		$($control).className = 'textbox';
	}
}
function ResetRadioState($control)
{
	$('lbl_' + $control).className = 'label';
	$('err_' + $control).className = 'errmsg hidden';
	if ($('ast_' + $control))
		$('ast_' + $control).className = '';
	
	if ($('arr_' + $control))
		$('arr_' + $control).style.display = 'none';
}
function ResetCheckState($control)
{
	$('lbl_' + $control).className = 'label spanned';
	$('err_' + $control).className = 'spanned errmsg hidden';
	if ($('ast_' + $control))
		$('ast_' + $control).className = '';
	
	if ($('arr_' + $control))
		$('arr_' + $control).style.display = 'none';
	
}

function SetErrorState($control)
{
	if ($('lbl_' + $control))
		$('lbl_' + $control).className = 'label error';
	
	if ($('ast_' + $control))
		$('ast_' + $control).className = 'tpl2_ast_error';
	
	if ($('arr_' + $control))
		$('arr_' + $control).style.display = 'inline';
	
	if ($('err_' + $control))
		$('err_' + $control).className = 'errmsg';
	
	if ($($control))
	{
		$($control).className = 'error textbox';
	}
}
function SetRadioErrorState($control)
{
	
	$('lbl_' + $control).className = 'label error';
	$('err_' + $control).className = 'errmsg';
	if ($('arr_' + $control))
		$('arr_' + $control).style.display = 'inline';
	if ($('err_' + $control))
		$('err_' + $control).className = 'errmsg';
	if ($('ast_' + $control))
		$('ast_' + $control).className = 'tpl2_ast_error';
}
function SetCheckErrorState($control)
{
	$('lbl_' + $control).className = 'label spanned';
	
	$('err_' + $control).className = 'errmsg';
	$('err_' + $control).style.color = 'red';
	if ($('arr_' + $control))
		$('arr_' + $control).style.display = 'inline';
	if ($('err_' + $control))
		$('err_' + $control).className = 'errmsg';
	if ($('ast_' + $control))
		$('ast_' + $control).className = 'tpl2_ast_error';
}





/*
*
* FORMULARIOS
*
*/

function Contacto()
{
	$valid = true;
	$('errorBox').className = 'errorBox hidden';
	
	$('confirmar').disabled = true;
	
	ValidateText('txt_nombre');
	ValidateText('txt_apellido');
	ValidateNotEmpty('txt_direccion');
	ValidateNotEmpty('cbo_provincia2');
	ValidateNotEmpty('txt_codigopostal');
	ValidateNotEmpty('txt_municipio');
	ValidateTelefono('txt_telefono');
	ValidateTelefonoAlternativo('txt_telefonoalternativo');
	ValidateIsEmail('txt_email');
	ValidateNotEmpty('cbo_horariocontacto');
	ValidateNotChecked('chk_terminos');
	
	if ($valid)
	{
		$('confirmar').disabled = false;
		document.Formu.submit();
	}
	else
	{
		$('confirmar').disabled = false;
		$('ActiveCommand').value = '';
		$('errorBox').className = 'errorBox';
	}
}


function Hipoteca()
{
	$valid = true;
	$('errorBox').className = 'errorBox hidden';
	
	ValidateNotEmpty('cbo_provincia');
	ValidateNotEmpty('cbo_ingresoanualbruto');
	ValidateNotEmpty('cbo_historialcrediticia');
	ValidateNotEmpty('cbo_pagomensual');
	ValidateNotEmpty('cbo_tipoempleo');
	ValidateNotEmpty('cbo_importe');
	ValidateNotEmpty('cbo_rangoprecios');
	ValidateNotEmpty('cbo_tipointeres');
	ValidateNotEmpty('cbo_antiguedadempresa');
	ValidateRadioListNotEmpty('rdb_contrato');
	ValidateRadioListNotEmpty('rdb_problemasfinancieros');

	if ($valid)
	{
		document.Formu.submit();
	}
	else
	{
		$('ActiveCommand').value = '';
		$('errorBox').className = 'errorBox';
	}
}

function Refinanciacion()
{
	$valid = true;
	$('errorBox').className = 'errorBox hidden';

	ValidateNotEmpty('cbo_provincia');
	ValidateNotEmpty('cbo_rangoprecios');
	ValidateNotEmpty('cbo_balanceagregado');
	ValidateNotEmpty('cbo_pagomensualagregado');
//	ValidateNotEmpty('cbo_tasainteres');
	ValidateNotEmpty('cbo_importe');
	ValidateNotEmpty('cbo_ingresoanualbruto');
	ValidateNotEmpty('cbo_pagomensual');
	ValidateNotEmpty('cbo_tipoempleo');
	ValidateNotEmpty('cbo_antiguedadempresa');
	ValidateRadioListNotEmpty('rdb_problemasfinancieros');
	
	if ($valid) {
		document.Formu.submit();
	} else {
		$('ActiveCommand').value = '';
		$('errorBox').className = 'errorBox';
	}
}
	

function OtraHipoteca()
{
	$valid = true;
	$('errorBox').className = 'errorBox hidden';
	ValidateNotEmpty('cbo_provincia');
	ValidateNotEmpty('cbo_valorpropiedad');
	ValidateNotEmpty('cbo_balanceagregado');
	ValidateNotEmpty('cbo_pagomensualagregado');
	ValidateNotEmpty('cbo_importe');
	ValidateNotEmpty('cbo_historialcrediticia');
	ValidateNotEmpty('cbo_ingresoanualbruto');
	ValidateNotEmpty('cbo_pagomensual');
	ValidateNotEmpty('cbo_tipoempleo');
	ValidateNotEmpty('cbo_antiguedadempresa');
	ValidateRadioListNotEmpty('rdb_problemasfinancieros');
	
	if ($valid)
	{
		document.Formu.submit();
	}
	else
	{
		$('ActiveCommand').value = '';
		$('errorBox').className = 'errorBox';
	}
}


function ShowIcon($id,$arr)
{
	/*for ($i = 0; $i < ($arr.length); $i++)
	{
		document.getElementById('ic_' + $arr[$i]).style.display="none";
	}
	document.getElementById('ic_'+$id).style.display="block";
	
	setTimeout("OcultarElemento("+$id+")",2200);*/
	element = document.getElementById('LayerDiv');
	element.style.display="block";
	$('LayerDiv').style.height = document.body.clientHeight + 'px';
	$('LayerDiv').style.width = document.body.clientWidth + 'px';
	element = document.getElementById('ic_' + $id);
	element.style.display="";
	
	var x = parseInt((window.screen.width / 2) - (element.offsetWidth / 2), 10);
	var y = parseInt((window.screen.height / 2) - (element.offsetHeight), 10);
	
	if (y < 0)
	{
		y = 10;
		
	}
	element.style.top = y + 'px';
	element.style.left = x + 'px';
	element.style.position = 'fixed';
	if (navigator.userAgent.indexOf('MSIE 6') >= 0)
	{
		element.style.position = 'absolute';
	}
	
}
function OcultarElemento($id)
{
	/*document.getElementById('ic_'+$id).style.display="none";*/
	/*Dom.setStyle(Dom.get('LayerDiv'), 'display', '');
	Dom.setStyle(Dom.get(id), 'display', 'none');*/
	element = document.getElementById('LayerDiv');
	element.style.display="none";
	element = document.getElementById('ic_'+$id);
	element.style.display="none";
}

function Testimonio()
{
	$valid = true;

	ValidateIsEmail('txt_email');
	ValidateNotEmpty('txt_nombre');
	ValidateNotEmpty('txt_apellido');
	ValidateNotEmpty('txt_testimonio');
	ValidateNotEmpty('txt_ciudad');
	if (!$valid)
	{
		return false;
	}
}

function MostrarAyuda(id)
{
	Dom.setStyle(Dom.get('boxed'), 'display', 'none');
	Dom.setStyle(Dom.get('LayerDiv'), 'display', 'none');
	Dom.setStyle(Dom.get(id), 'display', '');
}

function LimpiarChecks()
{
	elements = document.getElementsByTagName('input');
	
	for (i=0; i< elements.length;i++)
	{
		
		if (elements[i].type == 'checkbox')
		{
			elements[i].checked = false;
		}
	}
}


var WRP_ID;
var WRP_SECTION;
var WRP_SUBSECTION;
var WRP_CONTENT;
var WRP_CHANNEL;
var wreport_ok;
var WRP_ACC = 1;

function wreportCaptalis(id, seccion, subseccion, contenido, canal)
{
	WRP_ID = id;
	WRP_SECTION = seccion;
	WRP_SUBSECTION = subseccion;
	WRP_CONTENT = contenido;
	WRP_CHANNEL = canal;
	wreport_ok = 0;
		
	wreportOk();
	
	if (wreport_ok == 1)
	{
		var w_counter = new wreport_counter(WRP_SECTION, WRP_SUBSECTION, WRP_ID, WRP_ACC, WRP_CHANNEL);
		w_counter.add_content(WRP_CONTENT);
		w_counter.count();
	}
}

function redirectForm()
{
	
	combo = document.getElementsByTagName('select');
	combo = combo[0];
	for (i = 0; i < combo.length; i++)
	{
		if (combo.options[i].selected)
		{
			idTipoOperacion = combo.options[i].id;
		}
	}
	
	switch (idTipoOperacion)
	{
		case 'HIP':
				location.href='https://www.captalis.com/hipoteca/paso1/';
			break;
		case 'HI2':
			location.href='https://www.captalis.com/segunda-hipoteca/paso1/';
			break;
		case 'REF':
				location.href='https://www.captalis.com/refinanciacion/paso1/';
			break;
		case 'COM':
				location.href='https://www.captalis.com/compra-inmueble/paso1/';
			break;
		case 'VEN':
				location.href='https://www.captalis.com/venta-inmueble/paso1/';
			break;
		case 'C-V':
				location.href='https://www.captalis.com/compra-venta-inmueble/paso1/';
			break;
		case 'PPE':
				location.href='https://www.captalis.com/prestamo-personal/paso1/';
			break;
		case 'CPR':
				location.href='https://www.captalis.com/capital-privado/paso1/';
			break;
	}
	return false;
}


function getElementBySemiId(control,valor,mostrarIndex)
{
	elementos = document.getElementsByTagName('input');
	for(i=0;i<elementos.length;i++)
	{
		a = elementos[i].name.search(control);
		if( parseInt(a) != (-1))
		{
			if (elementos[i].type == 'radio')
			{
				if (parseInt(elementos[i].value.search(valor)) != -1)
				{
					elementos[i].checked = true;
				}
				
			}
			else
			{
				elementos[i].value = valor;
			}
		}
	}
	
	elementos = document.getElementsByTagName('select');
	
	for(i=0;i<elementos.length;i++)
	{
		a = elementos[i].id.search(control);
		if( parseInt(a) != (-1))
		{
			if (mostrarIndex)
			{
				elementos[i].selectedIndex = valor;
			}
			else
			{
				elementos[i].value = valor;
			}
		}
	}
}

function validarMail()
{
	
	$valid = true;
	ValidateIsEmail('txt_email');
	
	if ($valid)
	{
		document.Formu.submit();
	}
	else
	{
		return false;
	}
	/*Cancela el submit*/
	if (isIE())
	{
		event.cancelBubble = true;
		event.returnValue = false;
		event.cancel = true;
	}
	return false;
}


function HipotecaLanding()
{
	$valid = true;
	$('errorBox').className = 'errorBox hidden';
	
	ValidateNotEmpty('cbo_provincia');
	ValidateNotEmpty('cbo_ingresoanualbruto');
	ValidateNotEmpty('cbo_historialcrediticia');
	ValidateNotEmpty('cbo_pagomensual');
	ValidateNotEmpty('cbo_tipoempleo');
	ValidateNotEmpty('cbo_importe');
	ValidateNotEmpty('cbo_rangoprecios');
	ValidateNotEmpty('cbo_tipointeres');
	ValidateNotEmpty('cbo_antiguedadempresa');
	ValidateRadioListNotEmpty('rdb_contrato');
	ValidateRadioListNotEmpty('rdb_problemasfinancieros');

	if ($valid)
	{
		document.Formu.submit();
	}
	else
	{
		return false;
	}
	
	/*Cancela el submit*/
	if (isIE())
	{
		event.cancelBubble = true;
		event.returnValue = false;
		event.cancel = true;
	}
	return false;
}

function MostrarItem(campo)
{
	$('btn_comparar').style.background = "#002060";
	$('btn_especificacion').style.background = "#002060";
	/*$('btn_valoracion').style.background = "#002060";*/
	$('btn_'+ campo).style.background = "#00A0C6";
	
	$('ficha_comparar').style.display = "none";
	$('ficha_especificacion').style.display = "none";
	/*$('ficha_valoracion').style.display = "none";*/
	
	$('ficha_'+ campo).style.display = "";
}
function BuscarProducto(nombre)
{
	document.formBusqueda.txt_search.value = nombre;
	document.formBusqueda.submit();
}

function MostrarDescripcion(control)
{
	boton = $(control);
	if(boton.style.display=='none')
	{
		boton.style.display= '';
	}
	else
	{
		boton.style.display= 'none';
	}
}

function updateCombo(idCombo, value)
{
	$(idCombo).value = value;
	$('formBusquedafiltro').submit();
}

function MostrarSubcategorias(idDiv)
{
	id = 'subcategoria' + idDiv;
	element = document.getElementById(id);
	element.style.display="block";	
}

function OcultarSubcategorias(idDiv)
{
	id = 'subcategoria' + idDiv;
	element = document.getElementById(id);
	element.style.display="none";	
}


function DeseleccionarTodo(id)
{
	objetos = document.FormBusqueda.getElementsByTagName('input');
	
	for (i = 0; i < objetos.length; i++)
	{
		if ((objetos[i].id != id) && (objetos[i].type == 'radio'))
		{
			objetos[i].checked = false;
		}
	}
	
	objetos = document.getElementsByTagName('select');
	for (i = 0; i < objetos.length; i++)
	{
		if (objetos[i].id != id)
		{
			objetos[i].value = '';
		}
	}
}


function mostrarTooltip(id)
{
	$(id).style.display='';
}

function mostrarTooltipCorrido(id)
{
	$(id).style.display='';
	$(id+'2').style.display='';
}

function ocultarTooltip(id)
{
	$(id).style.display='none';
}

function ocultarTooltipCorrido(id)
{
	$(id).style.display='none';
	$(id+'2').style.display='none';
}

function equalDivs(text) {
	t_arr = document.getElementsByTagName('div');
	var arr = new Array();
	for (i = 0; i < t_arr.length; i++) {
		if (t_arr[i].name == text) {
			arr.push(t_arr[i]);
		}
		if (t_arr[i].id == 'descp') {
			arr.push(t_arr[i]);
		}
	}
	max = 0;
	for (i = 0; i < arr.length; i++) {
		max = arr[i].clientHeight > max ? arr[i].clientHeight : max;
	}
	for (i = 0; i < arr.length; i++) {
		arr[i].style.height = max + 'px';
	}
}


function DeseleccionarTodoADSL(id,idpaso)
{
	objetos = document.FormBusqueda.getElementsByTagName('input');
	
	for (i = 0; i < objetos.length; i++)
	{
		if ((objetos[i].id != id) && (objetos[i].id != idpaso)&& (objetos[i].type == 'radio'))
		{
			objetos[i].checked = false;
		}
	}
	
	objetos = document.getElementsByTagName('select');
	for (i = 0; i < objetos.length; i++)
	{
		if (objetos[i].id != id  && (objetos[i].id != idpaso))
		{
			objetos[i].value = '';
		}
	}
}
function CalculadoraDeposito()
{
	$valid = true;
	$('errorBox').className = 'errorBox hidden';
	

	ValidateNotEmpty('txt_cantidad');
	ValidateNotEmpty('cboPeriodoDistribuye');
	ValidateNotEmpty('txtPlazoMantiene');
	ValidateNotEmpty('txtTipoInteres');
	
	if ($valid)
	{
		document.Formu.submit();
	}
	else
	{
		$('ActiveCommand').value = '';
		$('errorBox').className = 'errorBox';
	}
}
function ToogleDisplay(id, force) {
	obj = $(id);
	if (obj) {
		if (force == '') {
			if (obj.style.display == 'none') {
				obj.style.display = 'block';
			}
			else {
				obj.style.display = 'none';
			}
		}
		if (force == 'on') {
			obj.style.display = 'block';
		}
		if (force == 'off') {
			obj.style.display = 'none';
		}
	}
}
function Depositos()
{
	valid = false;
	
	objetos = document.getElementsByTagName('input');
	cantidad = 0;
	for (i = 0; i < objetos.length; i++)
	{
		if(objetos[i].type == 'checkbox')
		{
			if(objetos[i].checked)
			{
				cantidad++;
			}
			
		}
	}
	
	if (cantidad == 2)
	{
		valid=true;
	}
	if (valid == true)
	{
		document.FormCompara.submit();
	}
	else
	{
		alert('Para realizar una comparación de depósitos es necesario seleccionar dos productos. ');
		return false;
	}
	
	/*Cancela el submit*/
	if (isIE())
	{
		event.cancelBubble = true;
		event.returnValue = false;
		event.cancel = true;
	}
	return false;
}

function makeDate($idCalendar,$dateTimeName)
{
	var dia,mes,ano;
	var value = document.getElementById($idCalendar).value;
	dia=value.substr(0,2);
	mes=value.substr(3,2);
	ano=value.substr(6,4);
	document.getElementById($dateTimeName + '_day').value=dia;
	document.getElementById($dateTimeName + '_month').value=mes;
	document.getElementById($dateTimeName + '_year').value=ano;
}



function ValidateDate(control)
{   
	validaFecha=true;
	var Ano = $(control+'_year').value;
	var Mes = $(control+'_month').value;
	var Dia = $(control+'_day').value;
	ResetState(control);
	ResetState(control+'_month');
	ResetState(control+'_year');
	ResetState(control+'_day');
	if ($('ast_'))
		$('ast_').className = '';
	
	if ($('arr_'))
		$('arr_').style.display = 'none';
	if ($('lbl_'))
		$('lbl_').className = 'label';
    // Valido el año
    if (Ano == '' || isNaN(Ano) || Ano.length < 4 || parseFloat(Ano) < 1900)
    {
        $valid = false;
        validaFecha = false;
        
    }
    // Valido el Mes   
    if (Mes == '' || isNaN(Mes) || parseFloat(Mes) < 1 || parseFloat(Mes) > 12)
    {
        $valid = false;
        validaFecha = false;
        
    }
    // Valido el Dia
    if (Dia == '' || isNaN(Dia) || parseInt(Dia, 10) < 1 || parseInt(Dia, 10) > 31)
    {   
        $valid = false;
        validaFecha = false;
        
    }
    
    if ((Mes == 4) || (Mes == 6) || (Mes == 9) || (Mes == 11) || (Mes == 2))
    {
        if ((Mes == 2 && Dia > 28 && !esBisiesto(Ano)) || (Dia > 30) || (Mes == 2 && Dia > 29 && esBisiesto(Ano)))
        {
            $valid = false;
            validaFecha = false;
        }
    }
    
    if (validaFecha == false)
    {
    	$valid = false;
    	SetErrorState(control);
        SetErrorState(control+'_month');
        SetErrorState(control+'_year');
        SetErrorState(control+'_day');
        if ($('ast_'))
		$('ast_').className = 'tpl2_ast_error';

		if ($('arr_'))
		$('arr_').style.display = 'inline';
		if ($('lbl_'))
		$('lbl_').className = 'label error';
    }
}
function esBisiesto(year) 
{
    return (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) ? true : false;
}

function openPopUp(id)
{
	hasScrollBars = false;
	var theWidth = "";
	var theHeight = "";
	var scrollBars = "scrollbars";
	if (hasScrollBars == false) scrollBars = "scrollbars=0";
	if ((theWidth == "")||(theWidth == null)) theWidth =300;
	if ((theHeight == "")||(theHeight == null)) theHeight =368;
	var theLeft = (screen.availWidth - theWidth)/2;
	var theTop = (screen.availHeight - theHeight)/2;
	
	url = document.location.hostname;
	var lsURL = "/popup.php?id=" + id;
	var popupWin = window.open(lsURL, '_' + Math.round(Math.random() * 1000000),'top='+theTop+',left='+theLeft+',menubar=0,toolbar=0,location=0,directories=0,status=0,'+scrollBars+',width='+theWidth+', height='+theHeight);
}


function Productos()
{
	valid = false;
	
	objetos = document.getElementsByTagName('input');
	cantidad = 0;
	for (i = 0; i < objetos.length; i++)
	{
		if(objetos[i].type == 'checkbox')
		{
			if (objetos[i].id.substr(0,4) == 'Fchk')
			{
				if(objetos[i].checked)
				{
					cantidad++;
				}
			}
		}
	}
	
	if (cantidad == 2)
	{
		valid=true;
	}
	if (valid == true)
	{
		document.FormCompara.submit();
	}
	else
	{
		alert('Para realizar una comparación de Productos es necesario seleccionar dos productos. ');
		return false;
	}
	
	/*Cancela el submit*/
	if (isIE())
	{
		event.cancelBubble = true;
		event.returnValue = false;
		event.cancel = true;
	}
	return false;
}


/*function isDudoso($nombre, $apellido, $direccion, $telefono)
{
	$dudoso = false;
	$numbers = '0123456789876543210';
	$chars = 'qwertyuiopasdfghjklñzxcvbnmnbvcxzñlkjhgfdsapoiuytrewq0123456789876543210';
	if (regexp(sprintf('%1$s{%2$s}',substr($telefono,0,1),strlen($telefono)), $telefono) != false) 		$dudoso = true;
	if (strstr($numbers, $telefono) != false) 				$dudoso = true;
	if (strstr($chars, strtolower($nombre)) != false) 		$dudoso = true;
	if (strstr($chars, strtolower($apellido)) != false)		$dudoso = true;

	return $dudoso;
}*/
