// JavaScript Document

function cambiarIdioma(){
	
	/*var indice = document.getElementById('selectIdioma').selectedIndex ; //obtengo indice seleccionado
	var valor = document.getElementById('selectIdioma').options[indice].value ; // obtengo el id seleccionado
	*/
	valor =  document.getElementById('selectIdioma').href;
	
	window.location = valor
	/*
	if (valor)
	{
		if(url[valor])
			window.location = url[valor];
		else
			window.location = "http://nuriaruiz.localhost.com"
	}*/
}
function cambiarPais(pais){
	/*var indice = document.getElementById('selectIdioma').selectedIndex ; //obtengo indice seleccionado
	var valor = document.getElementById('selectIdioma').options[indice].value // obtengo el id seleccionado
	*/
	valor =  document.getElementById('selectIdioma').href;

	/* Cambio de pais por ajax*/
	changePais(pais,valor);
	//window.location = url[valor]+"&selectPaises="+pais ;

	
	}


function centrarVentana(objvent, width, height)
{

	objvent.moveTo((screen.width-width)/2,(screen.height-height)/2);
}
	
function enviarForm(nombre_form){

	document.getElementById(nombre_form).submit();
}

function onclickEnter(e,funcion){

	var evento_key = (document.all) ? e.keyCode : e.which; 

	if(evento_key==13)//si la tecla apretada es enter
		 eval(funcion);
		


}	

function cambiar_cesta(total, html_cesta){

	document.getElementById('cesta_home').innerHTML = html_cesta;
	document.getElementById('cantidad_total_home').innerHTML = total;	
	mostrarCesta();
}


function comprarJoyaColeccion(id_producto, precio,cant, nombre, talla )
{
	
	if( document.getElementById('form_'+id_producto))
	{
		if( document.getElementById('form_'+id_producto).talla)
		{
			var talla = document.getElementById('form_'+id_producto).talla.value;
	
		}			
		else{
			var talla =0;
		}
	}	
	url = "/modulos/cesta/include/ajax.php?action=cesta_comprarCestaAjax&id_producto="+id_producto+"&cant="+cant+"&precio="+precio+"&nombre="+nombre+"&talla="+talla;
		
	ajax=objetoAjax();
	ajax.open("POST",url);
	
	ajax.onreadystatechange=function() {
	  if (ajax.readyState==4) 
	  {
		   rta = ajax.responseText;
		   arreglo = rta.split("#");
		
		   if(arreglo[0] == "0")
		   {
		   		mostrarStockInsuficiente(arreglo[1]);
		   }
		   else{
		   	cambiar_cesta(arreglo[0], arreglo[1]);
		   }
		   
	  	}
	  	
	  	
	 }
	ajax.send(null);
}

function mostrarEsperar(id_pensando, id_ocultar){
	document.getElementById(id_pensando).className="pensando";
	document.getElementById(id_ocultar).className="none";
	
}

function enviarConfirmacion(form,id_pensando, id_ocultar ){

	mostrarEsperar(id_pensando, id_ocultar)
	enviarForm(form);
}
	
function mostrarStockInsuficiente(html){
	if(document.getElementById('stock_insuficiente'))
	{
		ocultarSelects(); 
		ocultarVideos();
		document.getElementById('fade').style.display='block';
		document.getElementById('contenido_stock').innerHTML = html;
		document.getElementById('stock_insuficiente').style.display='block';
	}
}	

function llamaralancla(name){
document.location.href = "#"+name;
}