/* Bienvenido al JavaScript de Betazeta
	-- IT Betazeta <it@betazeta.com> */
var betagato="";
function randOrd(){
    return (Math.round(Math.random())-0.7);
}
$(function() {
	$(".recortes a[rel]").overlay({
		mask: '#000',
		effect: 'apple',
		onBeforeLoad: function() {
			var wrap = this.getOverlay().find(".contentWrap");
			wrap.load(this.getTrigger().attr("href"));
			$('img[src=non]').css("display","none")
		}
	});
});
$(document).ready(function() { 
    temp1= '<div class="quote type_1"><p>No paro de leer FayerWayer desde que el primer dia que lo descubrí. Sigan así por mucho tiempo.</p><p class="author">-- <strong>agua_light Sin Vida™</strong> en <a href="http://www.fayerwayer.com/2009/03/4-anos-de-fayerwayer/" target="_blank">FayerWayer</a></p></div>';
    temp2= '<div class="quote type_2"><p>Me encanta el trato con el usuario y la forma de tomar las noticias en familia, con sus cachondeos y sus decepciones.</p><p class="author">-- <strong>Tanatos_neon</strong> en <a href="http://www.fayerwayer.com/2009/03/4-anos-de-fayerwayer/" target="_blank">FayerWayer</a></p></div>';
    temp3= '<div class="quote type_3"><p style="margin-top:3px;">Uno de los blogs más completos, entretenidos y quizas mi favorito. Se ha hecho ya una necesidad de leerlo todos los días.</p><p class="author">-- <strong>Cristian</strong> en <a href="http://www.fayerwayer.com/2009/03/4-anos-de-fayerwayer/" target="_blank">FayerWayer</a></p></div>';

    temp4= '<div class="quote type_1"><p>GRANDE CHW lejos lo mas grande. Con CHW he aprendido bastante. Para mi exsiste un antes y un despues de CHW.</p><p class="author">-- <strong>Pinguino386</strong> en <a href="http://www.chw.net/foro/noticias-breves-f55/184718-chw-aparece-en-revista-capital-p3.html" target="_blank">CHW</a></p></div>';
    temp5= '<div class="quote type_2"><p>Gran comunidad, recién llevo dos años pero todo lo que me ha entregado esta comunidad no se compra con tiempo.</p><p class="author">-- <strong>Daniel_X</strong> en <a href="http://www.chw.net/foro/articulos-f90/299229-chw-cumple-6-anos-p5.html" target="_blank">CHW</a></p></div>';
    temp6= '<div class="quote type_3"><p>Gracias a su foro he aprendido mucho mucho y con diferencia, simplemente por lo que se implican todos los usuarios.</p><p class="author">-- <strong>Kosiro</strong> en <a href="http://www.chw.net/foro/hackintosh-f179/249182-hackintosh-para-un-programa.html" target="_blank">CHW</a></p></div>';

    temp7= '<div class="quote type_1"><p style="margin-top:3px;">Se han convertido en una entretenida alternativa de lectura. Abordando temas diversos y  de gran interés para las mujeres.</p><p class="author">-- <strong>Coni</strong> en <a href="http://www.belelu.com/2010/07/celebremos-juntos-el-primer-cumpleanos-de-belelu/" target="_blank">Belelú</a></p></div>';
    temp8= '<div class="quote type_2"><p>Me gusta que algunos temas se toquen con más profundidad que en  otros blogs femeninos.</p><p class="author">-- <strong>Patilu</strong> en <a href="http://www.belelu.com/2010/07/celebremos-juntos-el-primer-cumpleanos-de-belelu/" target="_blank">Belelú</a></p></div>';
    temp9= '<div class="quote type_3"><p>De corazón les deseo una gran celebración, muy merecida por lo demás!</p><p class="author">-- <strong>María José Celedón Fort</strong> en <a href="http://www.belelu.com/2010/07/celebremos-juntos-el-primer-cumpleanos-de-belelu/" target="_blank">Belelú</a></p></div>';

    temp10= '<div class="quote type_1"><p>Es bueno tener un sitio específico donde los verdaderos hinchas y fanáticos del fútbol se reúnan.</p><p class="author">-- <strong>Jean</strong> en <a href="http://www.fayerwayer.com/2009/12/ferplei-ha-llegado-a-betazeta/" target="_blank">Ferplei</a></p></div>';
    temp11= '<div class="quote type_2"><p>Ustedes se acaban de convertir en una de mis páginas favoritas. No nos defrauden. Son excelentes.</p><p class="author">-- <strong>| Laughing Man</strong> en <a href="http://www.fayerwayer.com/2009/12/ferplei-ha-llegado-a-betazeta/" target="_blank">Ferplei</a></p></div>';
    temp12= '<div class="quote type_3"><p>Felicitaciones! Está muy buena la página! Reemplazará mis vistazos a la del CDF!</p><p class="author">-- <strong>Yanlot</strong> en <a href="http://www.fayerwayer.com/2009/12/ferplei-ha-llegado-a-betazeta/" target="_blank">Ferplei</a></p></div>';

    temp13= '<div class="quote type_1"><p>Excelente pagina, me gusto mucho el formato, simple y preciso. Esta muy bien hecho.</p><p class="author">-- <strong>Hueo</strong> en <a href="http://www.chw.net/foro/articulos-f90/310216-lupa-una-foto-vale-mas.html" target="_blank">Lupa</a></p></div>';
    temp14= '<div class="quote type_2"><p>Me encantó la interfaz simple y la gran calidad de las fotos. Se fue de inmediato a mis favoritos.</p><p class="author">-- <strong>JCronos</strong> en <a href="http://www.chw.net/foro/articulos-f90/310216-lupa-una-foto-vale-mas.html" target="_blank">Lupa</a></p></div>';
    temp15= '<div class="quote type_3"><p style="margin-top:3px;">Me encanto la simpleza de la interfaz que no opaca el contenido que conmueve. La calidad de las fotos es impresionante.</p><p class="author">-- <strong>RodrigoTKD</strong> en <a href="http://www.chw.net/foro/articulos-f90/310216-lupa-una-foto-vale-mas.html" target="_blank">Lupa</a></p></div>';

    temp16= '<div class="quote type_1"><p>Uff dieron al grano se guillaron con esta! En mis marcadores y un blog mas para visitar a diario!</p><p class="author">-- <strong>Jnmx</strong> en <a href="http://www.fayerwayer.com/2009/02/niubie-dice-hola/" target="_blank">Niubie</a></p></div>';
    temp17= '<div class="quote type_2"><p>AWESOME!!!!<br />Niubie, para variar un gran sitio.</p><p class="author">-- <strong>Zunga</strong> en <a href="http://www.niubie.com/2010/04/starcraft-ii-a-primera-vista-modo-de-un-jugador/comment-page-1/#comment-625170" target="_blank">Niubie</a></p></div>';
    temp18= '<div class="quote type_3"><p>Muchas felicidades! Yo sigo a Niubie desde que eran Boton Turbo... recuerdo aquellas fotos chistosas jajaja.</p><p class="author">-- <strong>&lt;&lt;=Aquiles=&gt;&gt;</strong> en <a href="http://www.chw.net/foro/noticias-breves-f55/307331-feliz-cumpleanos-niubie.html" target="_blank">Niubie</a></p></div>';

    temp19= '<div class="quote type_1"><p style="margin-top:3px;">Las cosas que he leído en el blog me parecen reales, creíbles, más humanas. Muestran a una mujer menos exitista y más real.</p><p class="author">-- <strong>Patilu</strong> en <a href="http://www.belelu.com/2010/07/celebremos-juntos-el-primer-cumpleanos-de-belelu/" target="_blank">Belelú</a></p></div>';

    temp20= '<div class="quote type_1"><p>Cualquier iniciativa ecológica con mi apoyo. Muy bien!</p><p class="author">-- <strong>Jay</strong> en <a href="http://www.fayerwayer.com/2008/11/¡veoverde-dice-hola/" target="_blank">VeoVerde</a></p></div>';
    temp21= '<div class="quote type_2"><p>Estudio diseño industrial y hoy es fundamental mantenerme bien informado sobre diseño y medio ambiente.<p class="author">-- <strong>Binary_Seed</strong> en <a href="http://www.fayerwayer.com/2008/11/¡veoverde-dice-hola/" target="_blank">VeoVerde</a></p></div>';
    temp22= '<div class="quote type_3"><p>Muy bienvenidas las iniciativas que se enfocan en la divulgación de temas relacionados con el ambiente!</p><p class="author">-- <strong>Carlos</strong> en <a href="http://www.fayerwayer.com/2008/11/¡veoverde-dice-hola/" target="_blank">VeoVerde</a></p></div>';

    temp23= '<div class="quote type_1"><p>Soy realmente un visitante asiduo de Wayerless (lo sigo tanto o mas que a FayerWayer y Engadget). Excelente sitio.</p><p class="author">-- <strong>Daniel</strong> en <a href="http://www.wayerless.com/2010/04/crece-nuestra-linea-editorial/" target="_blank">Wayerless</a></p></div>';
    temp24= '<div class="quote type_2"><p>Dan en el clavo compadres, las noticias de celulares siempre tienen harta importancia.</p><p class="author">-- <strong>sebastian</strong> en <a href="http://www.fayerwayer.com/2008/08/%C2%A1wayerless-dice-hola/comment-page-2/#comments" target="_blank">Wayerless</a></p></div>';
    temp25= '<div class="quote type_3"><p>Qué bien que hayan hecho un blog especial para celulares. Espero que les vaya excelente con eso!</p><p class="author">-- <strong>Dani</strong> en <a href="http://www.fayerwayer.com/2008/08/%C2%A1wayerless-dice-hola/comment-page-2/#comments" target="_blank">Wayerless</a></p></div>';
    temp26= '<div class="quote type_2"><p>Me gusta que se opine y se discuta, que no traten  de quedar bien con todos.</p><p class="author">-- <strong>Patilu</strong> en <a href="http://www.belelu.com/2010/07/celebremos-juntos-el-primer-cumpleanos-de-belelu/" target="_blank">Belelú</a></p></div>';
    temp27= '<div class="quote type_2"><p style="margin-top:20px;">Alabado sea el Zimior.</p><p class="author">-- <strong>Sebastián</strong> en <a href="http://www.zimio.com/" target="_blank">Zimio</a></p></div>';
    temp28= '<div class="quote type_2"><p style="margin-top:20px;">Sólo Zimio supera a Zimio.</p><p class="author">-- <strong>Federico</strong> en <a href="http://www.zimio.com/" target="_blank">Zimio</a></p></div>';
    temp29= '<div class="quote type_2"><p style="margin-top:20px;">Más vale Zimio, que mal acompañado.</p><p class="author">-- <strong>Pato</strong> en <a href="http://www.zimio.com/" target="_blank">Zimio</a></p></div>';

    anyArray = new Array(temp1,temp2,temp3,temp4,temp5,temp6,temp7,temp8,temp9,temp10,temp11,temp12,temp13,temp14,temp15,temp16,temp17,temp18,temp19,temp20,temp21,temp22,temp23,temp24,temp25,temp26,temp27,temp28,temp29);
    anyArray.sort( randOrd );
    $('#user_testimonials').html(anyArray[0]+anyArray[1]+anyArray[2]);
    
		anyArray = new Array('entel','falabella','lg');
    anyArray.sort( randOrd );
    $('#client_testimonials ul li.'+anyArray[1]).addClass('quoted');
    $("#client_testimonials div#"+anyArray[1]).removeClass("hidden").addClass("active");


    $("dd label").append(":");
    /* Publicidad  */
    $("#accordion").accordion({
        active: false,
        collapsible: true,
        icons:false,
        autoHeight: false
    });
    $("#accordion").tabs("#accordion div.pane", {tabs: 'h3', effect: 'slide', initialIndex: null});


    $("#tech a").click(function tech() {
        $("#betazetanet").find(".active").removeClass("active");
        $("#tech").addClass("active");
        $("#betazetanet").find(".logos").addClass("hidden");
        $("#tech").find(".logos").removeClass("hidden");
    });
    $("#vida a").click(function () {
        $("#betazetanet").find(".active").removeClass("active");
        $("#vida").addClass("active");
        $("#betazetanet").find(".logos").addClass("hidden");
        $("#vida").find(".logos").removeClass("hidden");
    });
    $("#servicios a").click(function () {
        $("#betazetanet").find(".active").removeClass("active");
        $("#servicios").addClass("active");
        $("#betazetanet").find(".logos").addClass("hidden");
        $("#servicios").find(".logos").removeClass("hidden");
    });
    $("#client_testimonials ul li a").click(function () {
        var nombre = this.name;
        if ( $('#client_testimonials ul li.'+nombre).hasClass("quoted").toString()=="false"){
           $("#client_testimonials").find(".active").addClass("hidden").removeClass("active");
           $("#client_testimonials div#"+nombre).removeClass("hidden").addClass("active");
           $("#client_testimonials ul").find(".quoted").removeClass("quoted");
           $("#client_testimonials ul li."+nombre).addClass("quoted");
        }
    });
    /* Comunidades */
    // prev next
    $('#prev a').click(function () {
        var aSite = new Array("chw", "fayerwayer", "fayerwayerbr", "niubie", "wayerless", "belelu", "bolido", "ferplei", "lupa", "saborizante", "veoverde", "betaid", "zimio");
        var temp = $("#deck").find("div.active")[0].id
        for (i=0;i<=aSite.length;i++){
            if( aSite[i]==temp){
                if(i!=0){
                    if(i>0 && i<=5){
                        $("#betazetanet").find(".active").removeClass("active");$("#tech").addClass("active");$("#betazetanet").find(".logos").addClass("hidden");$("#tech").find(".logos").removeClass("hidden");
                    }else if(i>5 &&i<=11){
                        $("#betazetanet").find(".active").removeClass("active");$("#vida").addClass("active");$("#betazetanet").find(".logos").addClass("hidden");$("#vida").find(".logos").removeClass("hidden");
                    }
                    else{
                        $("#betazetanet").find(".active").removeClass("active");$("#servicios").addClass("active");$("#betazetanet").find(".logos").addClass("hidden");$("#servicios").find(".logos").removeClass("hidden");
                    }
                    $("#deck").find(".active").removeClass("active").addClass("hidden");
                    $("#"+aSite[i-1]+"").removeClass("hidden").addClass("active");
                    $(".logos li."+aSite[i-1]).addClass("active");
                    $(".logos li."+aSite[i]).removeClass("active");
                }else{
                    $("#betazetanet").find(".active").removeClass("active");$("#servicios").addClass("active");$("#betazetanet").find(".logos").addClass("hidden");$("#servicios").find(".logos").removeClass("hidden");
                    $("#deck").find(".active").removeClass("active").addClass("hidden");
                    $("#"+aSite[aSite.length-1]+"").removeClass("hidden").addClass("active");
                    $(".logos li."+aSite[aSite.length-1]).addClass("active");
                    $(".logos li."+aSite[i]).removeClass("active");
                }
            }
        }
    });
    $('#next a').click(function () {
        var aSite = new Array("chw", "fayerwayer", "fayerwayerbr", "niubie", "wayerless", "belelu", "bolido", "ferplei", "lupa", "saborizante", "veoverde", "betaid", "zimio");
        var temp = $("#deck").find("div.active")[0].id
        for (i=0;i<=aSite.length;i++){
            if( aSite[i]==temp){
                if(i!=aSite.length-1){
                    if(i>=0 && i<4){
                        $("#betazetanet").find(".active").removeClass("active");$("#tech").addClass("active");$("#betazetanet").find(".logos").addClass("hidden");$("#tech").find(".logos").removeClass("hidden");
                    }else if(i>=4 &&i<10){
                        $("#betazetanet").find(".active").removeClass("active");$("#vida").addClass("active");$("#betazetanet").find(".logos").addClass("hidden");$("#vida").find(".logos").removeClass("hidden");
                    }
                    else{
                        $("#betazetanet").find(".active").removeClass("active");$("#servicios").addClass("active");$("#betazetanet").find(".logos").addClass("hidden");$("#servicios").find(".logos").removeClass("hidden");
                    }
                    $("#deck").find(".active").removeClass("active").addClass("hidden");
                    $("#"+aSite[i+1]+"").removeClass("hidden").addClass("active");
                    $(".logos li."+aSite[i+1]).addClass("active");
                    $(".logos li."+aSite[i]).removeClass("active");
                }else{
                    $("#betazetanet").find(".active").removeClass("active");$("#tech").addClass("active");$("#betazetanet").find(".logos").addClass("hidden");$("#tech").find(".logos").removeClass("hidden");
                    $("#deck").find(".active").removeClass("active").addClass("hidden");
                    $("#"+aSite[0]+"").removeClass("hidden").addClass("active");
                    $(".logos li."+aSite[0]).addClass("active");
                    $(".logos li."+aSite[i]).removeClass("active");
                }
            }
        }
    });
    // logos
    $(".trigger").click(function () {
        var nombre = this.name;
        if ($("#"+nombre+"_metricas").hasClass("expanded").toString()=="true" ){
            $("#"+nombre+"_metricas").removeClass("expanded").addClass("collapsed");
        }else{
            $("#"+nombre+"_metricas").removeClass("collapsed").addClass("expanded");
        }
    });
    $(".logos li a").click(function () {
        var nombre = this.name;
        $("#deck").find(".active").removeClass("active").addClass("hidden");
        $("#"+nombre+"").removeClass("hidden").addClass("active");
        $(".logos li."+nombre).addClass("active");
    });

    /* Fotos Nosotros */ 
    $('ul[name=nosotros] li a').mouseenter(function () {
        $('ul[name=nosotros] li').removeClass("active");
    });
    $('#team').mouseleave(function() {
        $('ul[name=nosotros] li').addClass("active");
        if (betagato!=""){  $('div#'+betagato).removeClass("active").addClass("hidden"); }
        $("ul[name=nosotros] li a[name="+betagato+"] img").fadeTo("fast", "1");
    });
    $('ul[name=nosotros] li a').click(function() {
        var nombre = this.name;
        if (nombre!=""){
					if($('div#'+nombre).hasClass("active").toString()=="false" ){
						if (betagato!=""){  $('div#'+betagato).removeClass("active").addClass("hidden"); }
							$("ul[name=nosotros] li a[name="+betagato+"] img").fadeTo("fast", "0.3")
							$('div#'+nombre).removeClass("hidden").addClass("active");
							$("ul[name=nosotros] li a[name="+nombre+"] img").fadeTo("slow", "1");
							betagato=nombre;
					}else{
							$('div#'+nombre).removeClass("active").addClass("hidden");
							$("ul[name=nosotros] li a[name="+nombre+"] img").fadeTo("fast", "0.3");
							betagato="";
					}
				}
    });
    $('#prev2 a').click(function () {
        var tam = $("#gallery ul li").size();
        var primero = $("#gallery").find(".recortes")[0].id ;
        var t = parseInt(primero)-1;
        if (t > 0  ){
            $('#gallery ul li[id='+(parseInt(primero)+2)+']').addClass('hidden').removeClass('recortes');
            $('#gallery ul li[id='+(parseInt(primero)-1)+']').removeClass('hidden').addClass('recortes');
        }else{
            $('#gallery ul li[id=1]').addClass('hidden').removeClass('recortes');
            $('#gallery ul li[id='+tam+']').addClass('recortes').removeClass('hidden');
        }
    });
    $('#next2 a').click(function () {
        var tam = $("#gallery ul li").size();
        var primero = $("#gallery").find(".recortes")[0].id ;
        var ult = parseInt(primero) + 3 ;
        if (tam >= ult  ){
            $('#gallery ul li[id='+primero+']').addClass('hidden').removeClass('recortes');
            $('#gallery ul li[id='+ult+']').removeClass('hidden').addClass('recortes');
        }else{
            $('#gallery ul li[id=1]').addClass('recortes').removeClass('hidden');
            $('#gallery ul li[id='+tam+']').addClass('hidden').removeClass('recortes');
        }
    });
    /* Btn trabaja con nosotros */
    $('.button-138').click(function(){
				$('#contacto').find('.active').removeClass("active").addClass("hidden");
				$('div.trabajar').removeClass("hidden").addClass("active");
				$('#opciones').find('.actived').removeClass("actived");
				$('#opciones ul li[name=trabajar]').addClass("actived");
		});
    /* Contacto */
    $('#opciones ul li a').click(function(){
        var nombre = this.name;
        $('#contacto').find('.active').removeClass("active").addClass("hidden");
        $('div.'+nombre).removeClass("hidden").addClass("active");
        $('#opciones').find('.actived').removeClass("actived");
        $('#opciones ul li[name='+nombre+']').addClass("actived");
    });
    $('.formulario input').focus(function(){
        if (this.value==this.name){ this.value=''; }else if (this.value=='Empresa (opcional)'){ this.value=''; }
    });
    $('.formulario input').blur(function(){
        if (this.value==''){ this.value=this.name; }
    });
    $('#enviar_comercial').formValidator({
        scope : '#comercial',
        errorDiv : '#errorDiv1'
    });
    $('#enviar_editorial').formValidator({
        scope : '#editorial',
        errorDiv : '#errorDiv2'
    });
    $('#enviar_trabajar').formValidator({
        scope : '#trabajar',
        errorDiv : '#errorDiv3'
    });
    $('#enviar_na').formValidator({
        scope : '#na',
        errorDiv : '#errorDiv4'
    });
}); 

