$(document).ready(function() {
	
	$('#suchen').change(function() {
		document.location.href = '/?id=escorts&name='+document.getElementById('suchen').options[document.getElementById('suchen').selectedIndex].text;
	});
	/*
	if($(document).height() > $('#container').height()) {
		$('#container').height($(document).height() - $('#container_footer').height());
	}
	*/
	if($('#map').length > 0) {
		try {
			loadg();
		} catch (e) {
			alert(e);
		}
		$(document).unload(function() { GUnload(); });
	}
	
	$('#gal01').show('fast', function() {
		$('#container').height($(document).height()-20);
	});
	
	$('.gal_number a').each(function() {
		$(this).click(function() {
			$('.gallery_container').hide();
			$('#gal'+$(this).text()).show('fast');
		});
	});
	/*
	$('.menu ul').each(function() {
		$(this).parent().hover(
			function() {
				$('.menu ul').hide();
				$(this).find('ul').show('fast');
			},
			function() {
				$(this).find('ul').hide();
			}
		);
	});
	*/
	startList = function() {
	if (document.all&&document.getElementById) {
	navRoot = document.getElementById("menu_container");
	for (i=0; i<navRoot.childNodes.length; i++) {
	node = navRoot.childNodes[i];
	if (node.nodeName=="LI") {
	node.onmouseover=function() {
	this.className+=" over";
	  }
	  node.onmouseout=function() {
	  this.className=this.className.replace(" over", "");
	   }
	   }
	  }
	 }
	}
	window.onload=startList;
});

function validar_mail(t) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(t)) {
		return (true);
	} else {
		return (false);
	}
}
function validate_send(type) {
	cleanErrors();
	var nombre = document.getElementById('nombre').value;
	var email = document.getElementById('email').value;
	var mensaje = '';
	var errormsg = new Array();
	var username = document.getElementById('usr').value;
	var password = document.getElementById('pwd').value;
	var password2 = document.getElementById('pwd2').value;
	if (type == 1) {
		var mensaje = document.getElementById('mensaje').value;
	}
	if (nombre == '') {
		errormsg.push("Por favor completa tu nombre");
	}
	if (email == '') {
		errormsg.push("Por favor completa tu E-Mail");
	} else if (!validar_mail(email)) {
		errormsg.push("El E-Mail es incorrecto");
	}
	if (/^([a-zA-Z0-9_-]{4,12})$/.test(username) == false) {
		errormsg
				.push("El nombre de usuario solo puede contener letras, numeros y guiones bajos, y debe tener entre 4 y 12 caracteres");
	}
	if (password == '' || password2 == '') {
		errormsg.push("Por favor completa tu contraseña");
	} else if (password != password2) {
		errormsg.push("Verifica las contraseas, no son iguales");
	}
	if (errormsg.length > 0) {
		showErrors(errormsg);
		return false;
	}
	document.getElementById('fsubscribe').submit();
}
function showErrors(ar) {
	var container = document.getElementById('errormsgs');
	container.style.display = 'block';
	for (c = 0; c < ar.length; c++) {
		var div = document.createElement('div');
		var li = document.createElement('li');
		div.className = 'txt_09';
		div.style.textAlign = 'left';
		div.innerHTML = ar[c];
		li.appendChild(div);
		container.appendChild(li);
	}
}
function cleanErrors() {
	var container = document.getElementById('errormsgs');
	container.style.display = 'none';
	var childs = container.childNodes.length;
	for (var c = 0; c < childs; c++) {
		container.removeChild(container.firstChild);
	}
}