//funcion contra el spam
function antispamempresa(cuenta,dominio,clase)
{
	if ((cuenta!="") && (dominio!="")){
		document.write("<a class='"+ clase +"' href=\"mailto:" + cuenta + "@" + dominio + "\">" + cuenta + "@" + dominio + "</a>");
	}
}


function googlekeyempresas(keyabajo,kayarriba,domabajo){
	
	cadena = new String (document.location.href);
	if (cadena.indexOf(domabajo)>0)
	{
		document.write("<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key="+ keyabajo +"' type='text/javascript'></script>");
	}
	else
	{
			document.write("<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key="+ kayarriba +"' type='text/javascript'></script>");
	}
}




//funcion para google maps
var map;
function onLoad() {
	//document.getElementById("mycarousel").style.visibility="";
	
	if (GBrowserIsCompatible()){
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		if ((x=="0") || (y=="0") || (x=="") || (y=="")) 
		{
			map.setCenter(new GLatLng(36.77202135586331, -2.810976505279541), 12);
		}
		else
		{
			map.setCenter(new GLatLng(y,x), 16);
		}
		
		var icon = new GIcon();
		icon.image = "../empresas/imagenes/flecha.png";
		
		icon.iconSize = new GSize(40, 40);
		icon.shadowSize = new GSize(40, 40);
		
		icon.iconAnchor = new GPoint(15, 35);
		icon.infoWindowAnchor = new GPoint(20, 25);
		
		
		function createMarker(point,html,icono) {
			html = "<div >" + html + "<\/div>";
			var marker = new GMarker(point,icono);
		
			GEvent.addListener(marker, "click", function() {
				if (map.getZoom()<17){
				map.setCenter(point, 17);
				}
			});
		
			GEvent.addListener(marker, "mouseover", function() {
				marker.openInfoWindow(html);
			});
		
			GEvent.addListener(marker, "dblclick", function() {
				if (map.getZoom()<17){
					map.setCenter(point, 17);
				}
			});
		
			return marker;
		}
		
		var punto = new GLatLng(y,x);
		var marca = createMarker(punto,datosempresa,icon);
		map.addOverlay(marca);
	}
}


//funcion para validar enviar noticias
function validar_enviar(formulario){
	if ((formulario.Codigo.value == "" ) || (formulario.Nombre.value == "" ) || (formulario.Email.value == "" )){
		alert("Los campos Nombre, Email y Codigo son obligatorios.");
		return(false);
	}
	else{
		if (((validarEmail(formulario.Email.value)) || (formulario.Email.value == ""))){
			return(true);
		}
		else{
			alert("El e-mail introducido no es valido.");
			return(false);
		}
	}
}

function validarEmail(TMP){
var posicion;
var mensaje;
	posicion=TMP.indexOf("@");
	switch (posicion)
	{
		case -1:
		return false;
		case 0:
		return false;
		case TMP.length-1:
		return false;
		default:
		TMP=TMP.substr(posicion+1);
		posicion=TMP.indexOf("@");
	if (posicion>-1)
	{
		return false;
	}
		posicion=TMP.indexOf(".");
	if (posicion==-1)
	{
		return false;
	}
	if (posicion==0)
	{
		return false;
	}
		while (posicion>-1)
	{
	if (posicion==TMP.length-1)
	{
		return false;
	}
	TMP=TMP.substr(posicion+1);
	posicion=TMP.indexOf(".");
	}
}
return true;
}




