
// JavaScript Document
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}
function ayuda() {
document.getElementById('wizard').style.display='block'; 
document.getElementById('ayuda').style.display='block';	
}
function comprar(mov, nom) {
document.getElementById('wizard').style.display='block'; 
document.getElementById('wiz').style.display='block';
document.getElementById('titulotabla').innerHTML=nom;
document.getElementById('ref').value=mov;
}
function llamanos(mov, nom) {
document.getElementById('wizard').style.display='block'; 
document.getElementById('llamanos').style.display='block';
//document.getElementById('titulotabla').innerHTML=nom;
//document.getElementById('ref').value=mov;
}
function vertarifa(tarifa) {
respuesta = document.getElementById('fichatarifaframe');
switch(tarifa){
	case "blackberry":envia('tarifas/blackberry.php','');
					break;
	case "datos":envia('tarifas/datos.php','');
					break;
	case "voz":envia('tarifas/voz.php','');
					break;
	case "vozynav":envia('tarifas/vozynav.php','');
					break;
	case "winmob":envia('tarifas/winmob.php','');
					break;
}


document.getElementById('wizard').style.display='block'; 
document.getElementById('fichatarifa').style.display='block';

//document.getElementById('fichatarifaframe').innerHTML=nom;
//document.getElementById('ref').value=mov;
}

function enviarpedido() {
if((document.contacto.telefono.value == '' && document.contacto.telmovil.value == '')||((document.contacto.telefono.length<9)&&(document.contacto.telmovil.length<9)))
	resultado=megavalidacion(document.contacto.id);
	
else if((document.contacto.telefono.length<9)||(document.contacto.telmovil.length<9))
	resultado=megavalidacion(document.contacto.id);
	
else
	{
	var modal=getCheckedValue(document.contacto.modalidad)
	var client=getCheckedValue(document.contacto.cliente)
	if(document.contacto.telefono.value=="")
		document.contacto.telefono.value=document.contacto.telmovil.value;

	if(document.contacto.telmovil.value=="")
		document.contacto.telmovil.value=document.contacto.telefono.value;
		alert ('No se si llega');
		resultado=megavalidacion(document.contacto.id);
		if (resultado!=false)
		{
			respuesta = document.getElementById('respuesta');
			envia('ajax/enviapedido.php',
			'producto='+document.contacto.ref.value+
			'&cliente='+client+
			'&modalidad='+modal+
			'&nombre='+document.contacto.nombre.value+
			'&empresa='+document.contacto.empresa.value+
			'&apellido1='+document.contacto.apellido1.value+
			'&apellido2='+document.contacto.apellido2.value+
			'&numcolegiado='+document.contacto.numcolegiado.value+
			'&tipodoc='+document.contacto.tipodocumento.value+
			'&numdoc='+document.contacto.docnacional.value+
			'&telefono='+document.contacto.telefono.value+
			'&telmovil='+document.contacto.telmovil.value+
			'&email='+document.contacto.email.value);
		} 
	}
}
function recomendar()

{



	if(megavalidacion('recomendarfrm'))

	{	

		document.getElementById('recomendar').style.display='none';

		urlcod = document.location.href;

		urlcod = urlcod.replace(/&/g,"%");

		respuesta = document.getElementById('semaforo');

		envia('ajax/recomendar.php',

		'nombre='+document.getElementById('recomendarfrm').txtnombre.value+

		'&mensaje='+document.getElementById('mensaje').value+

		'&email='+document.getElementById('email').value+

  		'&url='+urlcod);

  		

  		document.forms['recomendarfrm'].reset();

	}

}
//Funciones que devuelven dimensiones y scroll del area de contenido del navegador
function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_scrollLeft() {
    return f_filterResults (
        window.pageXOffset ? window.pageXOffset : 0,
        document.documentElement ? document.documentElement.scrollLeft : 0,
        document.body ? document.body.scrollLeft : 0
    );
}

function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function comprobarEmail(formulario)
{
	if(formulario.email.value!=formulario.confirmacion.value)
	{
	alert("Los campos de e-mail no coinciden");
	formulario.email.focus();
	formulario.email.select();
	return false;
	}
	else
	{
		if(formulario.clave.value!=formulario.claveconfirm.value)
		{
		alert("Los campos de clave no coinciden");
		formulario.clave.focus();
		formulario.clave.select();
		return false;
		}
		else{
		return true; 
		}
	}
}

/* Validacion de formulario de Sergio*/

