var ie6 = false;
if ($.browser.msie)
{
    if ($.browser.version <= 6)
    {
        ie6 = true;
    }
}

$(document).ready(init);

function init() {
	if (ie6) {
		$("div.tendencias div.listado div.item:first").addClass("first-child");
	}

	$("div.desplegables div.item p.titulo").click(function () {
		$(this).closest("div.item").find("div.contenido").slideToggle();
		if ($(this).hasClass("on")) $(this).removeClass("on");
		else $(this).addClass("on");
	});

	if (typeof($("[zoom=1]").lightBox) != "undefined") {
		$("[zoom=1]").lightBox();
	}

	if ($("#home").is("div")) {
		if ($("#home div.selector span").size() > 0) {
			var INT = null;
			$("#home div.selector span").click(function () {
				var rel = $(this).attr("data-des");
				var index = $("#home div.scroll div.destacado[data-id="+rel+"]").prevAll().size();
				$("#home div.scroll").animate({
					left: "-"+(index*150)+"px"
				});
				$(this).siblings().removeClass("active").end().addClass("active");
				clearInterval(INT);
			});
			$("#home div.selector span").focus(function () {
				var rel = $(this).attr("data-des");
				var index = $("#home div.scroll div.destacado[data-id="+rel+"]").prevAll().size();
				$("#home div.scroll").animate({
					left: "-"+(index*150)+"px"
				});
				$(this).siblings().removeClass("active").end().addClass("active");
			});
			$("#home div.selector span:first").click();
			INT = setInterval(function () {
				var span = $("#home div.selector span.active");
				var next = span.next();
				if (!next.is("span")) {
					next = $("#home div.selector span:first");
				}
				next.focus();
			},5000);
		}
	}
}

function is_mail(texto) {
	var mailres = true;
	var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890@._-";

	var arroba = texto.indexOf("@",0);
	if ((texto.lastIndexOf("@")) != arroba) arroba = -1;

	var punto = texto.lastIndexOf(".");

	for (var contador = 0 ; contador < texto.length ; contador++){
		if (cadena.indexOf(texto.substr(contador, 1),0) == -1){
			mailres = false;
			break;
		}
	}

	if ((arroba > 1) && (arroba + 1 < punto) && (punto + 1 < (texto.length)) && (mailres == true) && (texto.indexOf("..",0) == -1))
		mailres = true;
	else
		mailres = false;

	return mailres;
}
