/****************************************************************
/ Nombre: getHTTPObject
/ Implentacion: 
/ Revision: 301106
/ Descripcion: Manejo del AJAX
'***************************************************************/
function getHTTPObject() {
	var xmlhttp;      
  
  /*@cc_on
  @if (@_jscript_version >= 5)
	try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	  try {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
		xmlhttp = false;
	  }
	}
  @else
  xmlhttp = false;
  @end @*/
  
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {  
		try {
		  xmlhttp = new XMLHttpRequest();
		} catch (e) {
		  xmlhttp = false;
		}
	}
	return xmlhttp;
}
    
//--
var http = getHTTPObject(); 


/****************************************************************
/ Nombre: Paginacion
/ Implentacion: 
/ Revision: 301106
/ Descripcion: funcion para realizar la paginacion de los productos
'***************************************************************/
function paginacion(pagina){
	document.getElementById("formularioPaginacion").numPagina.value=pagina
	document.getElementById("formularioPaginacion").submit();
}


function paginacINDEX(pagina){
	document.getElementById("formularioPaginacion").numPagina.value=pagina
	document.getElementById("formularioPaginacion").submit();
}

function volverCatalogo(pagina){
	document.getElementById("formularioVolver").numPagina.value=pagina
	document.getElementById("formularioVolver").submit();
}

function buscarChicas(){			
	document.getElementById("buscadorChicas").submit()
}	





/****************************************************************
/ Nombre: cambiaFondo
/ Implentacion: JBernalte
/ Revision: 301106
/ Descripcion: Cambia el fondo del obj como ID
'***************************************************************/
function cambiaFondo(pagina, obj){
		var fondo;
		fondo="";
		switch(pagina){
			
			case 1: 
				fondo= "url(images/top-background-grupo.jpg)";
				break;
			default:
				fondo= "url(images/top-background.jpg)";
		}
		document.getElementById(obj).style.backgroundImage =fondo;
	}






function validarEmail(valor){
//funcion para validar el formato del email
	return (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor));
	
}

/****************************************************************
/ Nombre: validar
/ Implentacion
/ Revision: 301106
/ Descripcion: Valida los campos del formulario
'***************************************************************/
function validar(tipo){
//Funcion para la validar los datos enviados desde el formulario de contacto
	var texto;
	texto = "";

	var cadenaEnvio;
	cadenaEnvio = "";
	
	//Aqui validamos que los campos obligatorios tengan valor y se añaden a la cadena de envio
	
	if ( document.getElementById("formularioContacto").nombre.value == "" ) {
		texto+=" * Debe indicar su nombre.\n";
	}else{
		cadenaEnvio="nombre=" + document.getElementById("formularioContacto").nombre.value;
	}
	
	if ( document.getElementById("formularioContacto").email.value == "" ) {
		texto+=" * Debe indicar su e-mail.\n";
	}
	
	if(document.getElementById("formularioContacto").email.value!=""){
		if(!validarEmail(document.getElementById("formularioContacto").email.value)){
				texto+=" * Formato de E-mail incorrecto.\n";
		}else{
			cadenaEnvio+="&email=" + document.getElementById("formularioContacto").email.value;
		}
	}
	if (( document.getElementById("formularioContacto").telefono.value != "" ) && ( isNaN(document.getElementById("formularioContacto").telefono.value)) ){
		document.getElementById("formularioContacto").telefono.value = ""
		document.getElementById("formularioContacto").telefono.focus();
		texto+=" * El número de teléfono debe ser numérico.\n";
	}
	if (( document.getElementById("formularioContacto").movil.value != "" ) && ( isNaN(document.getElementById("formularioContacto").movil.value)) ){
		document.getElementById("formularioContacto").movil.value = ""
		document.getElementById("formularioContacto").movil.focus();
		texto+=" * El número de móvil debe ser numérico.\n";
	}
	if ( isNaN(document.getElementById("formularioContacto").cpostal.value) ){
		document.getElementById("formularioContacto").cpostal.value = ""
		document.getElementById("formularioContacto").cpostal.focus();
		texto+=" * El código postal debe ser numérico.\n";
	}

	if ( document.getElementById("formularioContacto").nick.value == "" ) {
		texto+=" * Debe indicar su nick.\n";
	}else if ( document.getElementById("formularioContacto").nick.value.length < 4 ) {
				texto+=" * El nick debe ser de al menos 4 carácteres.\n";
	}
	if ( document.getElementById("formularioContacto").pass.value == "" ) {
		texto+=" * Debe indicar su clave de acceso.\n";
	}else if ( document.getElementById("formularioContacto").pass.value.length < 4 ) {
				texto+=" * La clave debe ser de al menos 4 carácteres.\n";
	}
	
	//para controlar que las fechas sean correctas
	var dia, mes, anyo;
	
	dia = document.getElementById('formularioContacto').dia.value;
	mes = document.getElementById('formularioContacto').mes.value;
	anyo = document.getElementById('formularioContacto').anyo.value;
	
	if (!compruebaFecha(dia, mes, anyo)){
		texto+=" * La fecha intorducida es incorrecta.\n";
	}

//	if ( document.getElementById("formularioContacto").comentarios.value == "" ){
//		texto+=" * Debe incluir el motivo de su consulta.<br>";
//	}else{
		cadenaEnvio+="&=" + document.getElementById("formularioContacto").preferencias.value;
//	}	
	
	
	if ( texto != "" ){
			alert(texto);
//	/	document.getElementById("mensajeError").innerHTML=texto;
//		document.getElementById("capaError").style.display='block';
		
	}else{
		//alert(cadenaEnvio);
			document.getElementById("formularioContacto").op.value = 1;
			document.formularioContacto.submit();
/*		document.getElementById("mensaje-respuesta").innerHTML="";
		document.getElementById("mensajeError").innerHTML="";
		document.getElementById("capaError").style.display='none';
		http.open("POST", "registro/registro.asp?" + extension, true);
    	 http.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		http.send(cadenaEnvio);
		http.onreadystatechange = handleHttpResponseContacto;*/
	}
	
}

/****************************************************************
/ Nombre: validar
/ Implentacion
/ Revision: 301106
/ Descripcion: Valida los campos del formulario
'***************************************************************/
function validarIns(tipo){
//Funcion para la validar los datos enviados desde el formulario de contacto
	var texto;
	texto = "";

	var cadenaEnvio;
	cadenaEnvio = "";
	
	//Aqui validamos que los campos obligatorios tengan valor y se añaden a la cadena de envio
	
/*	if ( document.getElementById("formRegistro").nombre.value == "" ) {
		texto+=" * Debe indicar su nombre.\n";
	}else{
		cadenaEnvio="nombre=" + document.getElementById("formRegistro").nombre.value;
	}*/
	
	if ( document.getElementById("formRegistro").email.value == "" ) {
		texto+=" * Debe indicar su e-mail.\n";
	}
	
	if(document.getElementById("formRegistro").email.value!=""){
		if(!validarEmail(document.getElementById("formRegistro").email.value)){
				texto+=" * Formato de E-mail incorrecto.\n";
		}else{
			cadenaEnvio+="&email=" + document.getElementById("formRegistro").email.value;
		}
	}
	if (( document.getElementById("formRegistro").telefono.value != "" ) && ( isNaN(document.getElementById("formRegistro").telefono.value)) ){
		document.getElementById("formRegistro").telefono.value = ""
		document.getElementById("formRegistro").telefono.focus();
		texto+=" * El número de teléfono debe ser numérico.\n";
	}
	if (( document.getElementById("formRegistro").movil.value != "" ) && ( isNaN(document.getElementById("formRegistro").movil.value)) ){
		document.getElementById("formRegistro").movil.value = ""
		document.getElementById("formRegistro").movil.focus();
		texto+=" * El número de móvil debe ser numérico.\n";
	}
	if ( isNaN(document.getElementById("formRegistro").cpostal.value) ){
		document.getElementById("formRegistro").cpostal.value = ""
		document.getElementById("formRegistro").cpostal.focus();
		texto+=" * El código postal debe ser numérico.\n";
	}

	if ( document.getElementById("formRegistro").nick.value == "" ) {
		texto+=" * Debe indicar su nick.\n";
	}else if ( document.getElementById("formRegistro").nick.value.length < 4 ) {
				texto+=" * El nick debe ser de al menos 4 carácteres.\n";
	}
	if ( document.getElementById("formRegistro").dia.value == "0" ) {
		texto+=" * Debe seleccionar el día de su fecha de nacimiento.\n";
	}
	if ( document.getElementById("formRegistro").mes.value == "0" ) {
		texto+=" * Debe seleccionar el mes de su fecha de nacimiento.\n";
	}
	if ( document.getElementById("formRegistro").anyo.value == "0" ) {
		texto+=" * Debe seleccionar el año de su fecha de nacimiento.\n";
	}
	
	//para controlar que las fechas sean correctas
	var dia, mes, anyo;
	
	dia = document.getElementById('formRegistro').dia.value;
	mes = document.getElementById('formRegistro').mes.value;
	anyo = document.getElementById('formRegistro').anyo.value;
	
	if (!compruebaFecha(dia, mes, anyo)){
		texto+=" * La fecha intorducida es incorrecta.\n";
	}

		cadenaEnvio+="&=" + document.getElementById("formRegistro").preferencias.value;

	if ( document.getElementById("formRegistro").condiciones.checked == false ) {
		texto+=" * Debe aceptar las condiciones legales para registrarse.\n";
	}
	
	var email = document.getElementById("formRegistro").email.value;
	var nick = document.getElementById("formRegistro").nick.value;
	
		if ( texto != "" ){
				alert(texto);
		}else{
			http.open("GET", "registro/compruebaEmail.asp?email=" + email +"&nick=" + nick, true);
			http.onreadystatechange = handleHttpResponseComprobar;
			http.send(null);
		}
	
	
}

function handleHttpResponseComprobar() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
			var t =  http.responseText;	
		if ( t != "" ){
				alert(t);
		}else{
				document.getElementById("formRegistro").op.value = 0;
				document.formRegistro.submit();
		}
	}    
}


/****************************************************************
/ Nombre: compruebaFecha()
/ Implentacion: Fperez

/ Revision:
/ Descripcion: Comprueba que las fechas sean correctas
'***************************************************************/
function compruebaFecha(dia, mes, anyo){
	var error;
	if ((dia > 30) && ((mes == 2) || (mes == 4) || (mes == 6) || (mes == 9) || (mes == 11))){
		return false;
	}
	if ((dia > 29) && (mes == 2)){
		return false;
	}
	var resto = parseInt(anyo)%4;
	if (resto != 0){
		if ((dia > 28) && (mes == 2)){
			return false;
		}
	}
	
	return true;
}


/****************************************************************
/ Nombre: cerrarAviso
/ Implentacion: 

/ Revision:
/ Descripcion: Cierra la capa del aviso del formulario
'***************************************************************/
function cerrarAviso(){
	document.getElementById("mensajeError").innerHTML="";
	document.getElementById("capaError").style.display='none';
}

function handleHttpResponseContacto() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
			alert(http.responseText);
//		document.getElementById("mensaje-respuesta").innerHTML = http.responseText;	
		document.getElementById("formularioContacto").reset();
	}    
}



function handleHttpResponseReferencia() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
		document.getElementById("referencia").innerHTML = "-&nbsp;" + http.responseText + "<br><br>";	
		document.getElementById("referencia").style.display = "block";	
	}    
}

/****************************************************************
/ Nombre: openWindow
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Abre un popup
'***************************************************************/
	function openWindow(theURL,winName,features){
 		window.open(theURL,winName,features);
		return
	}


/****************************************************************
/ Nombre: muestraTema
/ Implentacion:
/ Revision:
/ Descripcion: Muestra los temas
'***************************************************************/
/*
/ Nombre: capaPosition
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Posiciona una capa en el centro de la pantalla +- los pixeles deseados
'***************************************************************/
function capaPosition(layer, position){
		element = document.getElementById(layer);
		screenCenterX = document.body.clientWidth / 2;
		element.style.left = screenCenterX + position;
		element.style.display = 'inline';
	}


/****************************************************************************************
/ Nombre: ampliaImagen
/ Implentacion: PACO
/ Revision:
/ Descripcion: Muestra el PopUp de ampliacion de las imagenes y lo redimensiona
'***************************************************************************************/
function ampliaImagen(url){
	document.getElementById('imagenAmpliada').src = "images/" + url;
	}

function redimensionarImagen(img){
	var anchoImagen,altoImagen,anchoPantalla,altoPantalla;
	img1 = new Image(); 
	img1.src = img.src;
	anchoImagen = img1.width;
	altoImagen = img1.height;
//	anchoPantalla = window.screen.width;
	anchoPantalla = 930
	altoPantalla = window.screen.height - 240;
	posicionx = (anchoPantalla/2) - (anchoImagen/2);
	posiciony = (altoPantalla/2) - (altoImagen/2);
	
	// coloca la capa de la imagen y la redimensiona
	document.getElementById('capaImagenAmpliada').style.top = posiciony + 'px';
	document.getElementById('capaImagenAmpliada').style.left = posicionx + 'px';
	document.getElementById('capaImagenAmpliada').style.width = anchoImagen + 'px';
	document.getElementById('capaImagenAmpliada').style.height = altoImagen + 'px';
	// coloca un poco más arriba la capa del enlace para cerrar
	posicionCerrar = posiciony - 19;
	document.getElementById('cerrarImagenAmpliada').style.top = posicionCerrar + 'px';
	document.getElementById('cerrarImagenAmpliada').style.left = posicionx + 'px';

	document.getElementById('capaImagenAmpliada').style.display = 'block';
	document.getElementById('cerrarImagenAmpliada').style.display = 'block';
	// en caso del formulario de contacto, ocultamos el combo
	document.getElementById('pais').style.visibility = 'hidden';
}

function cerrarImagenAmpliada(){
	document.getElementById('imagenAmpliada').src = "";
	document.getElementById('capaImagenAmpliada').style.display = 'none';
	document.getElementById('cerrarImagenAmpliada').style.display = 'none';
	document.getElementById('pais').style.visibility = 'visible';
}

/****************************************************************************************
/ Nombre: edit, handleHttpResponseReload
/ Implentacion: JBERNALTE
/ Revision:13/06/2007
/ Descripcion: Recarga la pagina despues de ejecutar AJAX
'***************************************************************************************/
function handleHttpResponseReload() {
	if (http.readyState == 4) {
		//window.location.reload();
		var respuesta=http.responseText;
		if (respuesta=="no"){
			document.getElementById("mensaje-alerta").style.display='block';
		}
		if (respuesta=="si"){
			var pagina=document.getElementById("login").pagina.value;
			var subpagina=document.getElementById("login").subpagina.value;
			var c=document.getElementById("login").c.value;
			document.location="index.asp?pagina=" + pagina + "&subpagina=" + subpagina + "&c=" + c;
		}
	}    
}

/****************************************************************************************
/ Nombre: edit, handleHttpResponseEdit
/ Implentacion: JBERNALTE
/Parametros: [Type] (off) previsualiza (otra cosa) edita
/ Revision:
/ Descripcion: Cambia a modo edicion en la zona privada
'***************************************************************************************/
function edit2(type){
	var strEnvio = '';
	

		strEnvio += "edicionMode=" + type;


		url = "includes/loginEngine.asp?" + strEnvio;
		http.open("GET", url , true);
		http.onreadystatechange = handleHttpResponseReload2;
		http.send(null);		
}


/****************************************************************************************
/ Nombre: edit, handleHttpResponseReload
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Recarga la pagina despues de ejecutar AJAX
'***************************************************************************************/
function handleHttpResponseReload2() {
	if (http.readyState == 4) {
		window.location.href= "index.asp?pagina=ficha-de-usuario";
	}    
}



/****************************************************************************************
/ Nombre: changeAccountData, handleHttpResponseAccount
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Actualiza los datos del usuario
'***************************************************************************************/
function changeAccount(type){
	
	alert("GUAU! ( o )( o )");
	
	
	strEnvio='';
	
	//FALTA MONTAR EL ENVIO
	
	if(type == 'new'){
		strEnvio += "account=new"
	}else{
		strEnvio += "account=update"
	}
	
	url = "includes/AccountEngine.asp?" + strEnvio;
	http.open("GET", url , true);
	http.onreadystatechange = handleHttpResponseAccount;
	http.send(null);
}


function handleHttpResponseAccount() {
	if (http.readyState == 4) {    	
		document.getElementById("resultado").innerHTML = http.responseText;
	}    
}

/****************************************************************************************
/ Nombre: changePicture
/ Implentacion: JBERNALTE
/ Revision:
/ Descripcion: Cambia una imagen
'***************************************************************************************/
function changePicture(id, picture){
		
		document.getElementById(id).src = picture;
}

function muestraCapa(){
	document.getElementById('recordarPassword').style.display = 'block';
}
/****************************************************************************************
/ Nombre: enviarEmail
/ Implentacion: Fperez
/ Revision:
/ Descripcion: Envia el recordatorio de la contraseña por email
'***************************************************************************************/
function enviarEmail(email){
//	alert(document.formrecuerdo.email.value);
		cadenaEnvio = 'email='+document.formrecuerdo.email.value;
		http.open("GET", "actualizer/formcorreosMultiple/envioEmail.asp?" + cadenaEnvio, true);
		http.onreadystatechange = handleHttpResponseEmail;
		http.send(null);
}

function handleHttpResponseEmail() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
		document.getElementById("recordarPassword").style.display = 'none';	
		document.getElementById("respuestaRecuerdo").style.display = 'block';	
		document.getElementById("respuestaRecuerdo").innerHTML = http.responseText;	
		document.getElementById("formrecuerdo").reset();
	}    
}


function openCenteredWindow(URL, WIDTH, HEIGHT) {
	day = new Date();
	id = day.getTime();
	var width = WIDTH;
	var height = HEIGHT;
	var left = parseInt((screen.availWidth/2) - (width/2));
	var top = parseInt((screen.availHeight/2) - (height/2));
	var windowFeatures = "width=" + width + ",height=" + height + 
		",status='no',resizable='no',scrollbars='no',left=" + left + ",top=" + top + 
		",screenX=" + left + ",screenY=" + top;
	eval("page" + id + "  = window.open(URL, '" + id + "', windowFeatures);");
}


 

function handleHttpResponse() {
	if (http.readyState == 4) {    	
		capaModelos.innerHTML = http.responseText;        		 
	}    
}

function actualizaModelos() {
var url="includes/getModelos.asp?m=";   
  capaModelos.innerHTML = "Cargando...";        		 
 // alert(document.getElementById("fk_marcas").value);
  var pk_marcas = document.getElementById("fk_marcas").value;    
  
  http.open("GET", url + escape(pk_marcas), true);  
  http.onreadystatechange = handleHttpResponse;
  http.send(null);  
}




function openCenteredWindowM(URL, WIDTH, HEIGHT) {
	day = new Date();
	id = day.getTime();
	var width = WIDTH;
	var height = HEIGHT;
	var left = parseInt((screen.availWidth/2) - (width/2));
	var top = parseInt((screen.availHeight/2) - (height/2));
	var windowFeatures = "width=" + width + ",height=" + height + 
		",status='no',resizable='no',scrollbars='no',left=" + left + ",top=" + top + 
		",screenX=" + left + ",screenY=" + top;
	eval("page" + id + "  = window.open(URL, '" + id + "', windowFeatures);");
}

 

function handleHttpResponseM() {
	if (http.readyState == 4) {    	
		capaModelos.innerHTML = http.responseText;        		 
	}    
}

function actualizaModelosM() { 
  var url="includes/getModelosMotos.asp?m=";   
  capaModelos.innerHTML = "Cargando...";        		 
  var pk_marcas = document.getElementById("fk_marcas").value;    
  http.open("GET", url + escape(pk_marcas), true);  
  http.onreadystatechange = handleHttpResponseM;
  http.send(null);  
}



function btnVolver_click(){
	window.history.go(-1);
}



function validarUsuariosCU(){
	var strTexto="";
	if (document.getElementById("us_login").value.length<1){
		strTexto+="\n - User."	
	}
	if (document.getElementById("us_password").value.length<1){
		strTexto+="\n - Password."	
	}
	if (strTexto==""){
		document.getElementById("iOp").value=1;
		//alert(document.getElementById("formularioValidacion").document.getElementById("iOp").value);
		document.formularioValidacion.submit();
	}
	else{
		alert("Fill in the following fields to continue:\n"+strTexto)
	}
	
}

function borrarCoche(pk_coche){

	if (confirm("¿ Esta seguro que desea dar de baja este coche ?")){
		//alert(document.getElementById("form1"));
		document.getElementById("borrarCoche").pk_cochesusados.value=pk_coche;
		document.getElementById("borrarCoche").iOp.value=1
		document.getElementById("borrarCoche").submit();
	}
}

function paginacionCU(pagina){
	document.getElementById("formularioPaginacionCU").numPagina.value=pagina
	document.getElementById("formularioPaginacionCU").submit();
}


function handleHttpResponse2() {
	if (http.readyState == 4) {    	
		capaModelosCU.innerHTML = http.responseText;        		 
	}    
}


function buscarMotorpoint(){			
	if (document.getElementById("busqueda").textobusqueda.value.length<1){
		alert("Introduzca el texto de búsqueda");
	}
	else{
		document.getElementById("busqueda").submit()
	}				
}	


function validarRecordar()
{	var strTexto="";
	
	if (document.getElementById("recordarPass").us_email.value.length<1)
	{	strTexto+="\n * Refill the following fields E-mail.";
	}
	else
	{	if(!validarEmail(document.getElementById("recordarPass").us_email.value))
		{	strTexto+="\n * Format of incorrect E-mail.";
		}
	}
	if (strTexto=="")
	{	document.getElementById("recordarPass").iOp.value=1;
		document.getElementById("recordarPass").submit();
	}
	else
	{	alert("Opposing mistakes:\n"+strTexto);
	}
}

function handleHttpResponseMU() {
	if (http.readyState == 4) {    	
		capaModelosMU.innerHTML = http.responseText;        		 
	}    
}


/*********** BUSCADOR MOTORPOINT **************/
function buscar()
{	if (document.getElementById("buscador").textobusqueda.value.length<1 || document.getElementById("buscador").textobusqueda.value=="search...")
	{	alert("Enter the text search");
	}
	else
	{	document.getElementById("buscador").submit();
	}
}	

function handleHttpResponseBusc() {
	if (http.readyState == 4) {	
		window.open(http.responseText);
		
	}    
}


function openCenteredWindowBusc(URL, WIDTH, HEIGHT) {
	day = new Date();
	id = day.getTime();
	var width = WIDTH;
	var height = HEIGHT;
	var left = parseInt((screen.availWidth/2) - (width/2));
	var top = parseInt((screen.availHeight/2) - (height/2));
	var windowFeatures = "width=" + width + ",height=" + height + 
		",status='no',resizable='no',scrollbars='no',left=" + left + ",top=" + top + 
		",screenX=" + left + ",screenY=" + top;
	eval("page" + id + "  = window.open(URL, '" + id + "', windowFeatures);");
}


/************* AGENDA *********/
function MesAnterior(mesAux,anyoAux){	
	mesAux=parseInt(mesAux);
	anyoAux=parseInt(anyoAux);	
	if (mesAux==1){
		anyoAux=anyoAux-1
		document.getElementById("miform").action='index.asp?pagina=agenda&mes=12&anyo=' + anyoAux;
	}else{
		mesAux=mesAux-1;		
		document.getElementById("miform").action='index.asp?pagina=agenda&mes=' + mesAux + '&anyo=' + anyoAux;
	}	
	document.getElementById("miform").submit();
}

function MesSiguiente(mesAux,anyoAux){	
	mesAux=parseInt(mesAux);
	anyoAux=parseInt(anyoAux);	
	if (mesAux==12){
		anyoAux=anyoAux+1;
		document.getElementById("miform").action='index.asp?pagina=agenda&mes=1&anyo=' + anyoAux;
	}else{
		mesAux=mesAux+1;
		document.getElementById("miform").action='index.asp?pagina=agenda&mes=' + mesAux + '&anyo=' + anyoAux;
	}	
	document.getElementById("miform").submit();
}

function handleHttpResponseVideos() {
	if (http.readyState == 4) {    	
		capaModelos.innerHTML = http.responseText; 
	}    
}

function actualizaModelosVideos() {    

  capaModelos.innerHTML = "<span style='font-family:arial;font-size:11px;'><b>Cargando...</b></span>";
  var pk_marcas = document.getElementById("fk_marcas").value;
  http.open("GET","includes/getModelosVideos.asp?marcas=" + pk_marcas, true); 
  http.onreadystatechange = handleHttpResponseVideos;
  http.send(null);  
}

function cargaVideo(){

	var strVideo = document.getElementById("fk_modelos").value;
	if (strVideo!=0){
		document.getElementById("MPlay1").Stop();
		document.getElementById("MPlay1").filename="mms://stream.hooping.net/MotorPoint/Coches/"+strVideo
		document.getElementById("MPlay1").src="mms://stream.hooping.net/MotorPoint/Coches/"+strVideo
		Play();
	}
}

function cargaVideoExterno(strArchivo){

	document.getElementById("MPlay1").Stop();
	document.getElementById("MPlay1").filename="mms://stream.hooping.net/MotorPoint/"+strArchivo
	document.getElementById("MPlay1").src="mms://stream.hooping.net/MotorPoint/"+strArchivo
	Play();
	
}

function Play() {
	
	document.getElementById("MPlay1").Play();
	
}

function Pausar() {

	document.getElementById("MPlay1").Pause();

}

function Parar() {

	document.getElementById("MPlay1").currentPosition=0;
	document.getElementById("MPlay1").Stop();

}

function Avanzar(tiempo){

	document.getElementById("MPlay1").currentPosition=MPlay1.currentPosition+tiempo;
	Play();
	
}

function Retroceder(tiempo){

	document.getElementById("MPlay1").currentPosition=MPlay1.currentPosition-tiempo;
	Play();
	
}

/************ SUSCRIPCION DEPORTES ******/
function validarSusDeportes(){

	var y=""; 
	if (document.getElementById("formularioSusDeportes").nombre.value==""){
		y=y+"- Nombre.\n";
	} 
	if (document.getElementById("formularioSusDeportes").email.value==""){
		y=y+"- Email.\n";
	}
	else{
		if(!validarEmail(document.getElementById("formularioSusDeportes").email.value)){
			 y+="- Formato de E-mail incorrecto.\n";
		}
	}
	if (y!=""){
		alert("Debe rellenar los siguientes campos:\n\n"+y);
	}
	else{
		document.getElementById("formularioSusDeportes").submit();
	}
}

function validarBLOG(){

	var y=""; 
	if (document.getElementById("formularioBLOG").nombre.value==""){
		y=y+"- Nombre.\n";
	} 
	if (document.getElementById("formularioBLOG").opinion.value==""){
		y=y+"- Su opinión.\n";
	} 

	if (y!=""){
		alert("Debe rellenar los siguientes campos:\n\n"+y);
	}
	else{
		document.getElementById("formularioBLOG").submit();
	}
}


/****************************************************************
/ Nombre: validarContacto
/ Implentacion
/ Revision: 301106
/ Descripcion: Valida los campos del formulario
'***************************************************************/
function validarContacto(){
//Funcion para la validar los datos enviados desde el formulario de contacto
	var texto;
	texto = "";

	var cadenaEnvio;
	cadenaEnvio = "";
	
	//Aqui validamos que los campos obligatorios tengan valor y se añaden a la cadena de envio
	
	if ( document.getElementById("formularioContacto").nombre.value == "" ) {
		texto+=" * Debe indicar su nombre.<br>";
	}else{
		cadenaEnvio="nombre=" + document.getElementById("formularioContacto").nombre.value;
	}
	
	if ( document.getElementById("formularioContacto").email.value == "" ) {
		texto+=" * Debe indicar su e-mail.<br>";
	}
	
	if(document.getElementById("formularioContacto").email.value!=""){
		if(!validarEmail(document.getElementById("formularioContacto").email.value)){
				texto+=" * Formato de E-mail incorrecto.<br>";
		}else{
			cadenaEnvio+="&email=" + document.getElementById("formularioContacto").email.value;
		}
	}
	if ( document.getElementById("formularioContacto").comentarios.value == "" ){
		texto+=" * Debe incluir el motivo de su consulta.<br>";
	}else{
		cadenaEnvio+="&comentarios=" + document.getElementById("formularioContacto").comentarios.value;
	}	
	
	//Aqui vamos añadiendo los demas campos sino estan vacion
	
	if ( document.getElementById("formularioContacto").direccion.value != "" ){
		cadenaEnvio+="&direccion=" + document.getElementById("formularioContacto").direccion.value;
	}
	
	if ( document.getElementById("formularioContacto").poblacion.value != "" ){
		cadenaEnvio+="&poblacion=" + document.getElementById("formularioContacto").poblacion.value;
	}
	
	if ( document.getElementById("formularioContacto").provincia.value != "" ){
		cadenaEnvio+="&provincia=" + document.getElementById("formularioContacto").provincia.value;
	}
	
	if ( document.getElementById("formularioContacto").telefono.value != "" ){
		cadenaEnvio+="&telefono=" + document.getElementById("formularioContacto").telefono.value;
	}
	
	if ( document.getElementById("formularioContacto").movil.value != "" ){
		cadenaEnvio+="&movil=" + document.getElementById("formularioContacto").movil.value;
	}
	
	if ( document.getElementById("formularioContacto").cpostal.value != "" ){
		cadenaEnvio+="&cpostal=" + document.getElementById("formularioContacto").cpostal.value;
	}

	if ( document.getElementById("formularioContacto").fax.value != "" ){
		cadenaEnvio+="&fax=" + document.getElementById("formularioContacto").fax.value;
	}
	//if ( document.getElementById("formularioContacto").pais2.value != "" ){
		cadenaEnvio+="&pais=" + document.getElementById("formularioContacto").pais.options[document.getElementById("formularioContacto").pais.selectedIndex].text
		
	//}
	
	//Si falta algun campo obligatorio o el email no tiene un formato correcto
	//mostramos un mensaje de avios
	
	if ( texto != "" ){
		document.getElementById("mensajeError").innerHTML=texto;
		document.getElementById("capaError").style.display='block';
		
	}else{
		//alert(cadenaEnvio);
		document.getElementById("mensaje-respuesta").innerHTML="";
		document.getElementById("mensajeError").innerHTML="";
		document.getElementById("capaError").style.display='none';
		http.open("GET", "actualizer/formcorreosMultiple/envioSinBd.asp?" + cadenaEnvio, true);
		http.onreadystatechange = handleHttpResponseContacto2;
		http.send(null);
	}
	
}

function handleHttpResponseContacto2() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
		document.getElementById("mensaje-respuesta").innerHTML = http.responseText;	
		document.getElementById("formularioContacto").reset();
	}    
}


/****************************************************************
/ Nombre: validarenviar
/ Implentacion
/ Revision: 301106
/ Descripcion: Valida los campos del formulario
'***************************************************************/
function validarenviar(){
//Funcion para la validar los datos enviados desde el formulario de contacto
	var texto;
	texto = "";
	var cadenaEnvio;
	cadenaEnvio = "";
	
	//Aqui validamos que los campos obligatorios tengan valor y se añaden a la cadena de envio
	if ( document.getElementById("formularioContacto").email_yo.value == "" ) {
		texto+=" * Debe indicar su e-mail.<br>";
	}
	if ( document.getElementById("formularioContacto").email_el.value == "" ) {
		texto+=" * Debe indicar el e-mail destino.<br>";
	}

	if(document.getElementById("formularioContacto").email_yo.value!=""){
		if(!validarEmail(document.getElementById("formularioContacto").email_yo.value)){
				texto+=" * Formato de E-mail de usted es incorrecto.<br>";
		}else{
			cadenaEnvio+="&email_yo=" + document.getElementById("formularioContacto").email_yo.value;
		}
	}	
	if(document.getElementById("formularioContacto").email_el.value!=""){
		if(!validarEmail(document.getElementById("formularioContacto").email_el.value)){
				texto+=" * Formato de E-mail destino es incorrecto.<br>";
		}else{
			cadenaEnvio+="&email_el=" + document.getElementById("formularioContacto").email_el.value;
		}
	}
	//Si falta algun campo obligatorio o el email no tiene un formato correcto
	//mostramos un mensaje de avios
	
	if ( texto != "" ){
		document.getElementById("mensajeError").innerHTML=texto;
		document.getElementById("capaError").style.display='block';
		
	}else{
		//alert(cadenaEnvio);
		cadenaEnvio=cadenaEnvio+"&idnoticias=" + document.getElementById("formularioContacto").idnoticias.value;
		cadenaEnvio=cadenaEnvio+"&origens=" + document.getElementById("formularioContacto").origens.value;
		cadenaEnvio=cadenaEnvio+"&tt=" + document.getElementById("formularioContacto").tt.value;
		document.getElementById("mensaje-respuesta").innerHTML="";
		document.getElementById("mensajeError").innerHTML="";
		document.getElementById("capaError").style.display='none';
		http.open("GET", "/includes/envionoticorreo.asp?" + cadenaEnvio, true);
		http.onreadystatechange = handleHttpResponseEnvio2;
		http.send(null);
	}	
}

function handleHttpResponseEnvio2() {
	if (http.readyState == 4) {    	
		//Aqui va el nombre de la capa donde queramos cargar el contenido
		document.getElementById("mensaje-respuesta").innerHTML = http.responseText;	
		document.getElementById("formularioContacto").reset();
	}    
}






function handleHttpResponseContador() {
			if (http.readyState == 4) {	
				window.open(http.responseText);
			}    
		}

		function actualizaContador(numeroBanner) {  		  
			http.open("GET","includes/actualizaContador.asp?numeroBanner=" + numeroBanner, true);  
			http.onreadystatechange = handleHttpResponseContador;
			http.send(null);  
		}
		function actualizaContadorFlash(numeroBanner,tipo) {        		  
			http.open("GET","includes/actualizaContador.asp?numeroBanner=" + numeroBanner + "&tipo=" + tipo, true);    
			http.send(null);  
		}

