var ban = 0;
var banCalificacion = 0;
var cantidadCarrito =0;
// Instancia XMLHttpRequest
var xmlHttp = createXmlHttpRequestObject();
// Mostrar error (true) o comportamiento AJAX (false)
var showErrors = true;
// Muestra el estado de Place Order, falso en otro caso
var placingOrder = false;
// Link de la accion del usuario
var actionObject = '';
// Crear un XMLHttpRequest instancia
function createXmlHttpRequestObject(){
    // Objeto XMLHttpRequest
    var xmlHttp;
    // Crear el objecto XMLHttpRequest
    try {
        // Create native XMLHttpRequest object
        xmlHttp = new XMLHttpRequest();
    } catch(e) {
        // Asumir Explorer 6 o menor
        var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP");
        // Buscar la version
        for (i = 0; i < XmlHttpVersions.length && !xmlHttp; i++){
            try{
                // Intentamos crear el objeto
                xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
            }
            catch (e) {} // Ignorar el error potencial
        }
    }

    // Devuelvo el objeto XMLHttpRequest creado satisfactoriamente
    if (xmlHttp){
        return xmlHttp;
    }
    // Si un error aparece lo paso a la funcion
    else{
        handleError("Error creando el objeto XMLHttpRequest.");
    }
}

// Muestro un mensaje de error o un comportamiento non-AJAX
function handleError($message){
    // Ignoro el error si es false
    if (showErrors){
        alert("Error encontrado: \n" + $message);
        return false;
    }
    // Comportamiento non-AJAX
    else if (!actionObject.tagName){
        return true;
    }
    // Comportamiento non-AJAX
    else if (actionObject.tagName == 'A'){
        window.location = actionObject.href;
    }
    // Comportamiento non-AJAX
    else if (actionObject.tagName == 'FORM'){
        actionObject.submit();
    }
}
/******************************************************/
//FUNCIONES CARRITO DE COMPRAS VENTANA PEQUEÑA
// Agregar un producto al Shopping cart
function addProductToCart(formEntra,selSize,selColor,textCantidad){
	params = '';
	varerror = 0;
	
	// Obtener y valido los atributos a enviar

	try{
		selectColor = document.getElementById(selColor);
		if(selectColor.value==0){
			varerror =1;
			alert("Please select Color");
		}else{
			params += '&' + selectColor.name + '=' + selectColor.options[selectColor.selectedIndex].text;
		}
    }catch (e){
    }
	
	try{
		selectSize = document.getElementById(selSize);
		if(selectSize.value==0){
			varerror =1;
			alert("Please select Size");
		}else{
			params += '&' + selectSize.name + '=' + selectSize.value
		}
    }catch (e){
    }
	
	try{
		textoCantidad = document.getElementById(textCantidad);
		if(textoCantidad.value==0 || isNaN(textoCantidad.value) ){
			varerror =1;
			alert("Cantidad Incorrecta");
		}else{
			params += '&Cantidad=' + textoCantidad.value;
		}
    }catch (e){
    }

	// Si hay parametros para enviar hacemos ajax, de lok contrario no hacemos nada
	if(params!="" && varerror!=1 ){	
		form = document.getElementById(formEntra);
		// Vuelvo al form clasico si no existe el objeto XMLHttpRequest
		if (!xmlHttp){
			form.submit();
			return true;
		}
		// Crear la URL del request
		request = form.action + '&AjaxRequest';
		// alert("ENTROREQ "+request)
		// alert("ENTRO "+params)
		// Conectarse al servidor
		try{
		// Continuar si el objeto no esta ocupado
			if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0){
				// Enviar la peticion
				xmlHttp.open("POST", request, true);
				xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				xmlHttp.send(params);
				xmlHttp.onreadystatechange = addToCartStateChange;
			}
		}catch (e){
			// Muestro el error si existe
			handleError(e.toString());
		}
		// Salgo de la funcion si todo esta bien
	}
}

function addProductToWishList(producto, ruta){
	request = ruta + 'add-wish-list/';
	params = "product_id=" + producto;
	try{
	// Continuar si el objeto no esta ocupado
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0){
			// Enviar la peticion
			xmlHttp.open("post", request, true);
			xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			xmlHttp.send(params);
			xmlHttp.onreadystatechange = function(){
				if (xmlHttp.readyState==4){
					var results = xmlHttp.responseText;
					if(results=="OK"){
						alert("Your selection has been added");
						document.getElementById('aRemoveToWish').style.display = "block";
						document.getElementById('aAddToWish').style.display = "none";
					}else{
						alert(results);
					}
				}
			}
		}
	}catch (e){
		// Muestro el error si existe
		handleError(e.toString());
	}
}

// Funcion que me manda los correos al administrador
function sendEmailAdmin(ruta){
	request = ruta + 'email-admin/';
	params = "variable=variable";
	try{
	// Continuar si el objeto no esta ocupado
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0){
			// Enviar la peticion
			xmlHttp.open("post", request, true);
			xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			xmlHttp.send(params);
			xmlHttp.onreadystatechange = function(){
				if (xmlHttp.readyState==4){
					var results = xmlHttp.responseText;
					//alert(results);
					document.formAuto.submit();
				}
			}
		}
	}catch (e){
		document.formAuto.submit();
		//alert("Error");
		// Muestro el error si existe
		handleError(e.toString());
	}
}

function addToNewsLeter(ruta){
	request = ruta + 'add_news_leter/';
	email = document.getElementById('emailNewsLeter');
	params = "email=" + email.value;
	try{
	// Continuar si el objeto no esta ocupado
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0){
			// Enviar la peticion
			xmlHttp.open("post", request, true);
			xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			xmlHttp.send(params);
			xmlHttp.onreadystatechange = function(){
				if (xmlHttp.readyState==4){
					var results = xmlHttp.responseText;
					if(results=="OK"){
						alert("You were successfully added to our subscribers database");
					}else{
						alert(results);
					}
				}
			}
		}
	}catch (e){
		// Muestro el error si existe
		handleError(e.toString());
	}
}

function removeProductToWishList(producto, ruta){
	request = ruta + 'remove-wish-list/';
	params = "product_id=" + producto;
	try{
	// Continuar si el objeto no esta ocupado
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0){
			// Enviar la peticion
			xmlHttp.open("post", request, true);
			xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			xmlHttp.send(params);
			xmlHttp.onreadystatechange = function(){
				if (xmlHttp.readyState==4){
					var results = xmlHttp.responseText;
					if(results=="OK"){
						alert("Erased");
						document.getElementById('aRemoveToWish').style.display = "none";
						document.getElementById('aAddToWish').style.display = "block";
					}else{
						alert(results);
					}
				}
			}
		}
	}catch (e){
		// Muestro el error si existe
		handleError(e.toString());
	}
}

function validarSaleAlert(Email, ruta){
	var msg = "" ;
	
	textoEmail = document.getElementById(Email);
	
	if(trim(textoEmail.value)==0){msg = "Llena Email\n";}

	if(msg!=""){alert(msg);return false}
	else {
		request = ruta + 'sale-alert/';
		params = "email=" + textoEmail.value ;
		try{
		// Continuar si el objeto no esta ocupado
			if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0){
				// Enviar la peticion
				xmlHttp.open("post", request, true);
				xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				xmlHttp.send(params);
				xmlHttp.onreadystatechange = function(){
					if (xmlHttp.readyState==4){
						var results = xmlHttp.responseText;
						alert(results);
					}
				}
			}
		}catch (e){
			// Muestro el error si existe
			handleError(e.toString());
		}
	}
}

function validarLogin(textEmail,textPass,checkbox_mantener_frm, ruta, redirect){
	var msg = "" ;
	
	textoEmail = document.getElementById(textEmail);
	textoPass = document.getElementById(textPass);
	checkbox_mantener = document.getElementById(checkbox_mantener_frm);
	
	if(trim(textoEmail.value)==0){msg = "Please enter your email\n";}
	if(trim(textoPass.value)==0){msg += "Please enter your password\n";}
	if(checkbox_mantener.checked){valor_check = 1;}else{valor_check = 0;}
	
	if(msg!=""){alert(msg);return false}
	else {
		request = ruta + 'login/';
		params="ruta=" + document.formLogin.action + "&email=" + textoEmail.value + "&password=" + textoPass.value + "&mantener_logueado=" + valor_check;
		try{
		// Continuar si el objeto no esta ocupado
			if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0){
				// Enviar la peticion
				xmlHttp.open("post", request, true);
				xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				xmlHttp.send(params);
				xmlHttp.onreadystatechange = function(){
					if (xmlHttp.readyState==4){
						var results = xmlHttp.responseText;
						if(results=="reload"){
							document.location = redirect;
						}else{
							alert(results);
						}
					}
				}
			}
		}catch (e){
			// Muestro el error si existe
			handleError(e.toString());
		}
	}
}


// Funcio que me regarga la pagina del producto y me muestra la nueva imagen
function newImgPro(ruta,id){
	if(id==0){
		document.location = ruta;
	}else{
		redirect = ruta + "img-" + id + "/";
		document.location = redirect;
	}
}

// Funcio que me hace un redirect de direccion
function hacerRedirect(ruta){
	//alert(ruta);
	document.location = ruta;
}

function logout(raiz, redirect){
	request = raiz + '/logout/';
	params="logout=1";
	try{
	// Continuar si el objeto no esta ocupado
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0){
			// Enviar la peticion
			xmlHttp.open("post", request, true);
			xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			xmlHttp.send(params);
			xmlHttp.onreadystatechange = function(){
				if (xmlHttp.readyState==4){
					var results = xmlHttp.responseText;
					if(results=="OK"){
						window.location = redirect;
					}else{
						alert(results);
					}
				}
			}
		}
	}catch (e){
		// Muestro el error si existe
		handleError(e.toString());
	}

}

/******************************************************/
//FUNCIONES CARRITO DE COMPRAS VENTANA PEQUEÑA
// Funcion para recibir la respuesta
function addToCartStateChange(){
    // Leemos la respuesta cuando el estado es 4
    if (xmlHttp.readyState == 4){
        // Continuo si el HTTP status es OK
        if (xmlHttp.status == 200){
            try {
                //funcion para mostrar que se agrego
                updateCartSummary();
            }
            catch (e){
                handleError(e.toString());
            }
        }else{
            handleError(xmlHttp.statusText);
        }
    }
}

/******************************************************/
//FUNCIONES CARRITO DE COMPRAS VENTANA PEQUEÑA
// Agregar el producto al carrito
function updateCartSummary(){
    // Leo la respuest
    response = xmlHttp.responseText;
    // Si existe un error lo muestro
    if (response.indexOf("ERRNO") >= 0 || response.indexOf("error") >= 0) {
        handleError(response);
    }else{
		divCartSum = document.getElementById("cart-summary");
		divCartSum.style.display = "inline"
		mostrarDiv("cart-summary")
		cantidadCarrito +=1;
		actualizaNumeroCarrito(cantidadCarrito)
        divCartSum.innerHTML = response;
    }
}

function ocultarCartSum(){
	divCartSum = document.getElementById("cart-summary");
	divCartSum.style.display = "none";
}

function actualizaNumeroCarrito(cantidad){
	cantidadCarrito = cantidad;
	document.getElementById("numeroProductos").innerHTML = cantidadCarrito;
}

/******************************************************/
//FUNCIONES DETALLES CARRITO DE COMPRAS
// Called on shopping cart update actions
function executeCartAction(obj){
    if (placingOrder)
        return true;
	// Mostrar el mensaje "Actualizando..."
    document.getElementById('updating').style.display = 'block';
    // Volvemos al classic submit si no soporta AJAX
    if (!xmlHttp)
        return true;

    // Referencia al objeto
    actionObject = obj;
    // Inicializar variables
    response = '';
    params = '';
    // Si click el link entonces enviamos el request
    if (obj.tagName == 'A'){
        url = obj.href + '&AjaxRequest';
    }
    // oBtenemos los elementos enviados en el form
    else {
        url = obj.action + '&AjaxRequest';
        formElements = obj.getElementsByTagName('INPUT');

        if (formElements){
            for (i = 0; i < formElements.length; i++){
                if (formElements[i].name != 'place_order'){
                    params += '&' + formElements[i].name + '=';
                    params += encodeURIComponent(formElements[i].value);
                }
            }
        }
    }

    // Conectar al servidor
    try {
        // Miramos is no esta ocupado
        if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0){
            xmlHttp.open("POST", url, true);
            xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
            xmlHttp.onreadystatechange = cartActionStateChange;
            xmlHttp.send(params);
        }
    }
    catch (e){
        // Manejo de errores
        handleError(e.toString());
    }
    // Para el envio del clasico submit si ajax lo logro
    return false;
}


// Respuesta del servidro
function cartActionStateChange(){
    if (xmlHttp.readyState == 4){
        // Continuar solo si el estatus es "OK"
        if (xmlHttp.status == 200){
            try {
                // Leer la respuesta
                response = xmlHttp.responseText;
                // Si hubo error
                if (response.indexOf("ERRNO") >= 0 || response.indexOf("error") >= 0){
                    handleError(response);
                }else{
                    // Actualizo el carro
                    document.getElementById("contents").innerHTML = response;
                    // Escondo el mensaje de "Actualizando..."
                    document.getElementById('updating').style.display = 'none';
                 }
            } catch (e) {
                // Manejo de errores
                handleError(e.toString());
            }
        }else{
            // Manejo de errores
            handleError(xmlHttp.statusText);
        }
    }
}

function mostrarLogin(){
	divcon = document.getElementById("divMascara");
	divcon.style.display = "block";
	mostrarDivHasta('divMascara' , 65);
}

function mostrarSaleAlert(){
	ban=3;
	divconsale = document.getElementById("divMascara");
	divconsale.style.display = "block";
	mostrarDivHasta('divMascara' , 65);
}

function ocultarLogin(){
	document.getElementById("divMascara").style.display = "none";
	document.getElementById("bodyPrincipal").style.overflowY = "visible";
}

function ocultarDivsMascara(){
	document.getElementById("divMascara").style.display = "none";
	document.getElementById("divSaleAlert").style.display="none";
}

function ocultarSaleAlert(){
	document.getElementById("divMascara").style.display = "none";
	document.getElementById("divSaleAlert").style.display="none";
}

/*
function ocultarSizeChart(){
	document.getElementById("divMascara").style.display = "none";
	document.getElementById("bodyPrincipal").style.overflowY = "visible";
	document.getElementById("divSizeChart").style.display="none";
}

function mostrarSizeChart(ruta){
	divconlogin = document.getElementById("divMascara");
	document.getElementById("imgTitleSizeChart").innerHTML = '<img src="' + ruta + 'img/title_size_chart.jpg" border="0" align="left"/>';
	document.getElementById("imgSizeChart").innerHTML = '<img src="' + ruta + 'img/size_chart.jpg" border="0" align="left"/>';
	divconlogin.style.display = "block";
	ban = 1;
	mostrarDivHasta('divMascara' , 65);
}
*/
/************************************************
FUNCIONES DE VENTANA PEQUEÑA DE COPMPRA
************************************************/
var opacidad=0;
var hilo;

function iniciaActualizaActividades(intervalo){
	//alert("entro")
	setTimeout('revisaActividades(' + intervalo + ')',intervalo);
}
iniciaActualizaActividades(7000);

function mostrarDiv(id) {
	clearInterval(hilo);
	opacidad=1;
	document.getElementById(id).style.opacity=".0";
	document.getElementById(id).style.filter="alpha(opacity=0)";
	hilo=setInterval("hacerOpaco('"+id+"')",7);
}

function hacerOpaco( id ) {
	opacidad++;
	opacidadFireFox=opacidad/100;
	document.getElementById(id).style.opacity=opacidadFireFox;
	document.getElementById(id).style.filter="alpha(opacity="+opacidad+")";
	if (opacidad>99) {
		clearInterval(hilo);
		document.getElementById(id).style.opacity="1";
		document.getElementById(id).style.filter="alpha(opacity=100)";
		opacidad=100;
		clearInterval(hilo);
		return;
	}
}

function hacerOpacoHasta( id , hasta) {
	opacidad+=5;
	//opacidad = 100;
	opacidadFireFox=opacidad/100;
	document.getElementById(id).style.opacity=opacidadFireFox;
	document.getElementById(id).style.filter="alpha(opacity="+opacidad+")";
	if (opacidad>hasta) {
		//document.getElementById("bodyPrincipal").style.overflowY = "hidden";
		if(ban==0){
			document.getElementById("divLogin").style.display="block";
		}else if(ban==3){
			document.getElementById("divSaleAlert").style.display="block";
		}else{
			document.getElementById("divSizeChart").style.display="block";
		}
		clearInterval(hilo);
		ban=0;
		return;
	}
}

function mostrarDivHasta(id, hasta) {
	clearInterval(hilo);
	opacidad=1;
	document.getElementById(id).style.opacity=".0";
	document.getElementById(id).style.filter="alpha(opacity=0)";
	hilo=setInterval("hacerOpacoHasta('"+id+"', "+hasta+")",7);
}

/*Funcion que me devuelve el numero de caracteres - blancos de una cadena*/
function trim(cadena){
	var nuevacadena="";
	nuevacadena=cadena.replace(/\ /g,"");
	return nuevacadena.length;
}

/*****************************************************
Cambiamos las estrellas segun el mousemove
*****************************************************/
var estado_estrellas=false;
var estrellaSeleccionada =0;
function selstar(val,ruta) {
	var x=0;
	if(banCalificacion==0){
		for(x=0;x<=val;x++)	{
			document['star'+x].src=ruta+"img/estrella_llena.jpg";
		}
	}
}
function remstar(val,ruta){
	var x=0;
	if(banCalificacion==0){
		if(estado_estrellas == false){
			for(x=0;x<=val;x++){
				document['star'+x].src=ruta+"img/estrella_vacia.jpg";
			}
		}else{
			for(x=0;x<=3;x++){
				document['star'+x].src=ruta+"img/estrella_vacia.jpg";
			}
			for(x=0;x<=estrellaSeleccionada;x++){
				document['star'+x].src=ruta+"img/estrella_llena.jpg";
			}
		}
	}
}
function valorStar(val,ruta,productId){
	var x=0;
	if(banCalificacion==0){
		estado_estrellas = true;
		estrellaSeleccionada = val;
		document.getElementById('valorCalificaion').value = val + 1;
		for(x=0;x<=estrellaSeleccionada;x++){
			document['star'+x].src=ruta+"img/estrella_llena.jpg";
		}
		agregarCalificacion(ruta,productId);
	}
}

function validarComentario(){
	var msg="";
	textoComentario = document.getElementById('textRecomendacion');
	if(trim(textoComentario.value)==0){msg += "The comment field is empty\n";}
	if(msg!=""){alert(msg);return false;}
	else return true;
}

function agregarCalificacion(ruta,productId){
	if(banCalificacion==0){
		banCalificacion=1;
		calificacion = document.getElementById('valorCalificaion');
		request = ruta + 'add-calification/';
		//alert(request)
		params = "calificacion=" + calificacion.value + "&productoID=" + productId;
		try{
		// Continuar si el objeto no esta ocupado
			if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0){
				// Enviar la peticion
				xmlHttp.open("post", request, true);
				xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				xmlHttp.send(params);
				xmlHttp.onreadystatechange = function(){
					if (xmlHttp.readyState==4){
						var results = xmlHttp.responseText.split("|");
						if(results[0]=="si"){
							document.getElementById('divEstrellas').innerHTML = results[1];
							document.getElementById('divNumeroVotos').innerHTML = results[2];
							//document.forms['enviar'].submit();
						}else{
							alert(results);
						}
					}
				}
			}
		}catch (e){
			alert("Error");
			// Muestro el error si existe
			handleError(e.toString());
		}
	}else{alert("Ya hizo su comentario");}
}


/* devolver fedex */
function fedexChecout(ruta, direccion, ciudad, region, codigo_postal, pais){
	request = ruta + 'traer-fedex/';
	alert(request)
	params = "tipofedex=&direccion=" + direccion + "&ciudad=" + ciudad + "&region=" + region + "&codigo_postal=" + codigo_postal + "&pais=" + pais;
	try{
	// Continuar si el objeto no esta ocupado
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0){
			// Enviar la peticion
			xmlHttp.open("post", request, true);
			xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			xmlHttp.send(params);
			xmlHttp.onreadystatechange = function(){
				if (xmlHttp.readyState==4){
					var results = xmlHttp.responseText.split("|");
					if(results[0]=="si"){
						alert("traigo fedex: " + results[1]);
						//document.forms['enviar'].submit();
					}else{
						alert(results);
					}
				}
			}
		}
	}catch (e){
		alert("Error");
		// Muestro el error si existe
		handleError(e.toString());
	}
}
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
function ver_zoom(valor){
	
	if(valor == 0){
	  document.getElementById("ima_producto_zoom").style.display = "block";
	  
	}else if(valor == 1){
	  document.getElementById("ima_producto_zoom1").style.display = "block";
      document.getElementById("ima_producto_detalle_1").style.display = "none";
	}else if(valor == 2){
	  document.getElementById("ima_producto_zoom2").style.display = "block";
	   document.getElementById("ima_producto_detalle_2").style.display = "none";
	}else if(valor == 3){
	  document.getElementById("ima_producto_zoom3").style.display = "block";
	  document.getElementById("ima_producto_detalle_3").style.display = "none";
	}else if(valor == 4){
	  document.getElementById("ima_producto_zoom4").style.display = "block";
	  document.getElementById("ima_producto_detalle_4").style.display = "none";
	}else if(valor == 5){
	  document.getElementById("ima_producto_zoom5").style.display = "block";
	  document.getElementById("ima_producto_detalle_5").style.display = "none";
	}
	
	document.getElementById("ima_producto_normal").style.display = "none";
	document.getElementById("ima_size_chart").style.display = "none";
}

function ver_det_imagen(valor){
	
	if(valor == 0){
	  document.getElementById("ima_producto_normal").style.display = "block";
	}else if(valor == 1){
	  document.getElementById("ima_producto_detalle_1").style.display = "block";
	}else if(valor == 2){
	  document.getElementById("ima_producto_detalle_2").style.display = "block";
	}else if(valor == 3){
	  document.getElementById("ima_producto_detalle_3").style.display = "block";
	}else if(valor == 4){
	  document.getElementById("ima_producto_detalle_4").style.display = "block";
	}else if(valor == 5){
	  document.getElementById("ima_producto_detalle_5").style.display = "block";
	}
	
	document.getElementById("ima_producto_normal").style.display = "none";
	document.getElementById("ima_size_chart").style.display = "none";
}



function no_detalle(){
	document.getElementById("ima_producto_normal").style.display = "block";
	document.getElementById("ima_size_chart").style.display = "none";
	document.getElementById("ima_producto_zoom").style.display = "none";
	document.getElementById("ima_producto_zoom1").style.display = "none";
	document.getElementById("ima_producto_detalle_1").style.display = "none";
	document.getElementById("ima_producto_zoom2").style.display = "none";
	document.getElementById("ima_producto_detalle_2").style.display = "none";
	document.getElementById("ima_producto_zoom3").style.display = "none";
	document.getElementById("ima_producto_detalle_3").style.display = "none";
	document.getElementById("ima_producto_zoom4").style.display = "none";
	document.getElementById("ima_producto_detalle_4").style.display = "none";
	document.getElementById("ima_producto_zoom5").style.display = "none";
	document.getElementById("ima_producto_detalle_5").style.display = "none";
	
}


function no_zoom(){
	document.getElementById("ima_producto_normal").style.display = "block";
	document.getElementById("ima_size_chart").style.display = "none";
	document.getElementById("ima_producto_zoom").style.display = "none";
	document.getElementById("ima_producto_zoom1").style.display = "none";
	document.getElementById("ima_producto_zoom2").style.display = "none";
	document.getElementById("ima_producto_zoom3").style.display = "none";
	document.getElementById("ima_producto_zoom4").style.display = "none";
	document.getElementById("ima_producto_zoom5").style.display = "none";
	
}

function ver_size_chart(){
	document.getElementById("ima_producto_normal").style.display = "none";
	document.getElementById("ima_producto_zoom").style.display = "none";
	document.getElementById("ima_size_chart").style.display = "block";
	document.getElementById("ima_producto_zoom").style.display = "none";
	document.getElementById("ima_producto_zoom1").style.display = "none";
	document.getElementById("ima_producto_zoom2").style.display = "none";
	document.getElementById("ima_producto_zoom3").style.display = "none";
	document.getElementById("ima_producto_zoom4").style.display = "none";
	document.getElementById("ima_producto_zoom5").style.display = "none";
}

function ocultarSizeChart(){
	document.getElementById("ima_producto_normal").style.display = "block";
	document.getElementById("ima_producto_zoom").style.display = "none";
	document.getElementById("ima_size_chart").style.display = "none";
	document.getElementById("ima_producto_zoom").style.display = "none";
	document.getElementById("ima_producto_zoom1").style.display = "none";
	document.getElementById("ima_producto_zoom2").style.display = "none";
	document.getElementById("ima_producto_zoom3").style.display = "none";
	document.getElementById("ima_producto_zoom4").style.display = "none";
	document.getElementById("ima_producto_zoom5").style.display = "none";
}



//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
function add_fields(){
	div = document.getElementById("fields");
	document.getElementById("addfields").style.display = "none";
	
	codigo='<table border="0" cellpadding="0" cellspacing="0" width="100%">'
	codigo+='<tr>'
	  codigo+='<td height="2"></td>'
	codigo+='</tr>'
	codigo+='<tr>'
      codigo+='<td width="70%" ><input type="text" name="nombre1" id="nombr1" /></td>'
      codigo+='<td><input type="text" name="email1" id="email1" /></td>'
    codigo+='</tr>'
	codigo+='<tr>'
	  codigo+='<td height="10"></td>'
	codigo+='</tr>'
	codigo+='<tr>'
      codigo+='<td width="70%" ><input type="text" name="nombre2" id="nombr2" /></td>'
      codigo+='<td><input type="text" name="email2" id="email2" /></td>'
    codigo+='</tr>'
	
	
	codigo+='</table>'
	
	div.innerHTML = codigo;
}


function removeProductToWishList2(producto, ruta){
	request = ruta + 'remove-wish-list/';
	params = "product_id=" + producto;
	try{
	// Continuar si el objeto no esta ocupado
		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0){
			// Enviar la peticion
			xmlHttp.open("post", request, true);
			xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			xmlHttp.send(params);
			xmlHttp.onreadystatechange = function(){
				if (xmlHttp.readyState==4){
					var results = xmlHttp.responseText;
					if(results=="OK"){
						alert("Erased");
						window.location.reload(true);
					}else{
						alert(results);
					}
				}
			}
		}
	}catch (e){
		// Muestro el error si existe
		handleError(e.toString());
	}
}


function add_kids(tipo){
	
	div_gril = document.getElementById('divkids_girl');
	div_boys = document.getElementById('divkids_boys');
	if(tipo==1){
		option='<select name="girls" id="girls" class="selectSearch" style="width:186px;">'
		//option+='<option value="0"  >CHOOSE</option>'
		option+='<option value="0" >I DONT HAVE</option>'
		option+='<option value="1" >FROM 0 TO 12</option>'
		option+='<option value="2" >FROM 13 TO 18</option>'
		option+='<option value="3" >OLDER</option>'
		option+='</select>'
		div_gril.innerHTML = option;
		
		
		option='<select name="boys" id="boys" class="selectSearch" style="width:186px;">'
		//option+='<option value="0"  >CHOOSE</option>'
		option+='<option value="0" >I DONT HAVE</option>'
		option+='<option value="1" >FROM 0 TO 12</option>'
		option+='<option value="2" >FROM 13 TO 18</option>'
		option+='<option value="3" >OLDER</option>'
		option+='</select>'
		div_boys.innerHTML = option;
		
	}else{
		option='<select name="girls" id="girls" class="selectSearch" style="width:186px;">'
		option+='<option >CHOOSE</option>'
		option+='</select>'
		div_gril.innerHTML = option;
		
		
		option='<select name="boys" id="boys" class="selectSearch" style="width:186px;">'
		option+='<option >CHOOSE</option>'
		option+='</select>'
		div_boys.innerHTML = option;
	}
		
		
		
	
	
}
		

function valoreskids(tipo,girl,boy,ruta){
	
		div_girl = document.getElementById('divkids_girl');
		div_boys = document.getElementById('divkids_boys');
		request = ruta + 'add-kids/';
		params = "tipo=" + tipo+ "&girl=" + girl+ "&boy=" + boy;
		try{
		// Continuar si el objeto no esta ocupado
			if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0){
				// Enviar la peticion
				xmlHttp.open("post", request, true);
				xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				xmlHttp.send(params);
				xmlHttp.onreadystatechange = function(){
					
					if (xmlHttp.readyState==4){
						var results = xmlHttp.responseText.split("|");
						
						if(results[0]=="si"){
							
							div_girl.innerHTML = results[1];
							div_boys.innerHTML = results[2];
							//document.forms['enviar'].submit();
						}else{
							alert(results);
						}
					}
				}
			}
		}catch (e){
			alert("Error");
			// Muestro el error si existe
			handleError(e.toString());
		}
	
}

function iniciaCarga(tipo,ruta,intervalo){
	
    img=setTimeout('img_my_account(' + tipo + ',"'+ruta+'",'+ intervalo +')',intervalo);
	
}
function img_my_account(tipo,ruta,intervalo){
	
		div = document.getElementById('img_account');
		request = ruta + 'imgaccount/';
		params = "tipo=" + tipo;
		try{
		// Continuar si el objeto no esta ocupado
			if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0){
				// Enviar la peticion
				xmlHttp.open("post", request, true);
				xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				xmlHttp.send(params);
				xmlHttp.onreadystatechange = function(){
					
					if (xmlHttp.readyState==4){
						var results = xmlHttp.responseText.split("||");
						
						if(results[0]=="si"){
							
							
							div.innerHTML = results[1];
							if(tipo<4){
								tipo=tipo+1;
								iniciaCarga(tipo,ruta,intervalo)
							}else{
								tipo=1;
								iniciaCarga(tipo,ruta,intervalo)
							}
						}else{
							//alert(results);
						}
					}
				}
			}
		}catch (e){
			alert("Error");
			// Muestro el error si existe
			handleError(e.toString());
		}
	
}