// JavaScript Document

	function centrarLogo()
	{
		var x = (screen.width - 155)/2;
		document.getElementById('logo').style.left = x + "px";
	}

	var tempor = null;
	
	function getParameter(parameter)
	{
		// Obtiene la cadena completa de URL
		var url = location.href;
		/* Obtiene la posicion donde se encuentra el signo ?, ahi es donde empiezan los parametros */
		var index = url.indexOf("?");
		/* Obtiene la posicion donde termina el nombre del parametro e inicia el signo = */
		index = url.indexOf(parameter,index);
		if (index > -1)
		{
			index = index + parameter.length;
			/* Verifica que efectivamente el valor en la posicion actual es el signo = */
			if (url.charAt(index) == "=")
			{
				// Obtiene el valor del parametro
				var result = url.indexOf("&",index);
				if (result == -1){result=url.length;};
				// Despliega el valor del parametro
//					alert(url.substring(index + 1,result));
			}
			var len = url.substring(index + 1,result);
		}
		else {
			var len = '1';
		}
		return len;
	}
	
	function cambiaImg(img, pos) {
		var idioma = getParameter("le");
		var imagen = "images/flores/"+img;
		/*obtenemos las coordenadas*/
		var y = pos.indexOf("_");
		var x = pos.substring(0, y);
			x = x - 100 + 175;
			y = pos.substring(y+1, pos.length);
			y = y - 100;
		document.getElementById('div_img').style.left = x + "px";
		document.getElementById('div_img').style.top = y + "px";
		document.getElementById('div_img').style.visibility = "visible";
		document.getElementById('img_prod').src = imagen;
	}

	// en base a la cantidad de productos del arreglo hacemos el random
	function random()
	{
		var num_prod = prod.length;
		var ranNum = Math.floor(Math.random()*num_prod);
		if(ranNum < num_prod) {		return ranNum;	}
		else {	random();	}
	}

	// Rotador de banner's . Carlitos. carlosbernad@teleline.es
	var indice = 0;
	function rota()
	{
		indice = random();
		var idioma = getParameter("le");
		var imagen = "images/flores/"+prod[indice];

		if (document.images)
			document.images.rand_prod.src = imagen;
		else
			document.getElementById('rand_prod').src = imagen;
			
		document.getElementById('aproducto').href = "http://www.coxflor.com/index.php?id="+(prodid[indice])+"&le="+idioma;
		/*document.getElementById('nombre').innerHTML = "" + ;*/

		tempor = setTimeout('rota()',5000);
	}
	function parar()
	{
		clearTimeout(tempor);
	}
	
	function oculta() {
		document.getElementById('div_img').style.visibility = "hidden";
	}

	//Display Mouse coordinates- By Kous (kous@ihateclowns.com) //Visit http://javascriptkit.com for this script and more
	var where = ""; // which link
	function checkwhere(e) {
		if (document.layers){
			xCoord = e.x;
			yCoord = e.y;
		}
		else if (document.all){
			xCoord = event.clientX;
			yCoord = event.clientY;
		}
		else if (document.getElementById){
			xCoord = e.clientX;
			yCoord = e.clientY;
		}

/*		self.status = "X= "+ xCoord + " Y= " + yCoord;
			alert("X= "+ xCoord + " Y= " + yCoord);*/
		return xCoord + "_" + yCoord;
	}
/*		document.onmousemove = checkwhere;
	if(document.captureEvents) {document.captureEvents(Event.MOUSEMOVE);}*/

								/* METODO PARA VALIDAR LA FORMA */
		//Script original de KarlanKas para forosdelweb.com
		//Adaptado a firefox gracias a JavierB ;-)

		colorMal="#FFC71C";
		colorBien="#FFFFFF";
		colorFondo="#FFFF99";
    
	    regla=new Array()

	    regla[0]="valor.length<3";
	    regla[1]="valor.length<3";
	    regla[2]="valor.length<3";
	    regla[3]="valor.lastIndexOf('@')!=valor.indexOf('@') || valor.indexOf('@')<2 || valor.lastIndexOf('.')<valor.length-4 || valor.lastIndexOf('.')>valor.length-3";

	    mensaje=new Array()

		mensaje[0]="El nombre no es válido (longitud mayor a 3)";
		mensaje[1]="El apellido no es válido (longitud mayor a 3)";
		mensaje[2]="El nombre de la empresa no es válido (longitud mayor a 2)";
		mensaje[3]="El correo no es válido (usuario@dominio.com)";
		mensaje[4]="Debes ingresar la cantidad del producto";
    
		function comprobar(){ 
			errores=""; 
			mensaje2="";
			respe = "Seleciona al menos una casilla y completa la información";
			for(a=0; a<regla.length; a++){ 
				valor=document.formato.elements[a].value;
				if(eval(regla[a])) {
					mensaje2=(mensaje[a])?mensaje[a]:"Por favor, rellene el campo "+document.formato.elements[a].name;
					errores+=mensaje2+"<br>"; 
					document.formato.elements[a].style.background=colorMal;
				} 
				else{document.formato.elements[a].style.background=colorBien;} 
			}
			
			if(!check_values())
				errores+=mensaje[4]+"<br>";
			
			pepe = document.getElementById("herror");
			pepe.style.background=(errores!="")?colorMal:colorFondo; 
			pepe.style.border=(errores!="")?"solid 1px black":"none"; 
			pepe.innerHTML=errores;
			
			return (errores=="")
		}
		
		function check_values()
		{
			i=0;
			while(i < document.formato.elements.length - 6)
			{
				val = document.getElementById("cantidad"+i);
				if(isNum(val.value) && val.value > 0) {		}
				else	break;

				i++;
			}
			return( i+6 == document.formato.elements.length )
		}
			/* FIN */
	
function isNum(x) {
	var RegExp = /^(\d*)$/;
	var result = x.match(RegExp);
	if(result == null){
		alert("ingresa la cantidad")
		return false;
	}
	return true;
}

