///
var cambiarTimeoutId;
var nuevaImagen;
function chageimage2(img1 , img2 ){		
	var  imagen = new Image();
	var nombre;
	imagen = document.getElementById("transformacion").src.split("/");
	if (imagen[4] == ("Con1.jpg")){
			document.getElementById("transformacion").src = "images/Con2.jpg";
			$('fotoprincipal').fade({duration: 1.0});			
			nuevaImagen = img1;
			window.setTimeout(mostrarFotoPrincipal, 1500);
	}
	if (imagen[4] == ("Con2.jpg")){
			document.getElementById("transformacion").src = "images/Con1.jpg";	
			$('fotoprincipal').fade({duration: 1.0});
			nuevaImagen = img2;
			window.setTimeout(mostrarFotoPrincipal, 1500);			
	}
}
function mostrarFotoPrincipal(imagen)
{
	window.clearTimeout(cambiarTimeoutId);
	document.getElementById("foto").src = 'image.php/real_'+nuevaImagen+'?width=325&height=242&image=/fotos/'+nuevaImagen;// 'fotos/'+nuevaImagen;
	$('linkfotoprincipal').href = 'fotos/'+nuevaImagen;
	$('fotoprincipal').appear({duration: 1.0});
}



// JavaScript Document
function nuevoAjax(){
var xmlhttp=false;
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }

if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function add_item(id , tabla){
var t1, t2,
caja = document.getElementById(id);
ajax=nuevoAjax();
ajax.open("GET", "ajax.php?id="+id,true);
ajax.onreadystatechange=function() {
if (ajax.readyState==4) {
//caja.innerHTML = ajax.responseText
}
}
ajax.send(null)
}

function update_item(obj,obj2){
	var id, valor;
	valor = document.getElementById(obj).value;
	id = document.getElementById(obj2).value;
	ajax=nuevoAjax();
	ajax.open("GET", "ajax.php?modo=2&id="+id+"&valor="+valor,true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
		}
	 }
 ajax.send(null)
}

////////////// VIDEOS

function cambiarFoto(srcNueva){
	document.getElementById("foto").src=srcNueva;
}
function ampliar_imagen(){
	var foto;
	foto = document.getElementById("foto").src ;
	nombre = foto.split("/");
	open("fotos/"+nombre[4],"Enviar","toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=460")
}

function mapa(srcNueva){
	document.getElementById("mapa").src=srcNueva;
}
function mapaf(srcNueva){
	document.getElementById("mapa").src="img/inactivo.jpg";
}

function chageimage(img1 , img2 ){
	var  imagen = new Image();
	var nombre 
	imagen = document.getElementById("transformacion").src.split("/");
	if (imagen[4] == ("Con1.jpg")){
			document.getElementById("transformacion").src = "images/Con2.jpg";
			document.getElementById("foto").src = "fotos/"+img1;			
	}
	if (imagen[4] == ("Con2.jpg")){
			document.getElementById("transformacion").src = "images/Con1.jpg";	
			document.getElementById("foto").src = "fotos/"+img2;
	}
}

function imprimir(){
	window.print();
}
function confirmar(msj){
		return confirm('Deseas eliminar '+ msj+' ?');
}
function link_list(){
	if (document.f11.categorialink.value =="0"){
		alert ("Seleciona una categoria para agregar el link ")	
		return false
	}
	if (document.f11.titulo.value ==""){
		alert ("Debes especificar el Titulo del Link.")	
		return false
	}
	if (document.f11.link2.value ==""){
		alert ("El link no puede estar vacio.")	
		return false
	}
	return true
}

function imprimir(){
	window.print();
}
function abrir(){
 	open("lista_nado.php","Enviar","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=700")
}

function validar(){
	
	if ( this.document.f.checkbox.checked == true){
		return true;
	}else{
		alert("Cal que hi accepti les condicions");
		return false;
	}
}

function validar_ca(){
	
	if ( this.document.f.checkbox.checked == true){
		return true;
	}else{
		alert("Cal que hi accepti les condicions");
		return false;
	}
}
function validar_es(){
	
	if ( this.document.f.checkbox.checked == true){
		return true;
	}else{
		alert("Debe aceptar las condiciones");
		return false;
	}
}


function validar_envio(){
	var error = "error";
	var infook = "cuadro_texto";
	var enviar = true;

	if (document.enviar_cesta.nombre.value!=""){	
			document.enviar_cesta.nombre.className = infook;
		}else{
			document.enviar_cesta.nombre.className = error;
			enviar = false;
		}
	// EMPRESA
	if (document.enviar_cesta.correo.value==""){
		document.enviar_cesta.correo.className = error;
		enviar=false;
	}else{
			if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.enviar_cesta.correo.value)){
				document.enviar_cesta.correo.className = error;
				alert("E-mail incorrecte")
				enviar=false;
			}else
				document.enviar_cesta.correo.className = infook;
	}

	if (document.enviar_cesta.telefono.value!=""){	
				document.enviar_cesta.telefono.className = infook;
			}else{
				document.enviar_cesta.telefono.className = error;
				enviar = false;
			}
			// END MAIL	
		//	alert(enviar);
			return enviar;
	// END FUNCION
}

