Learn how to use jQuery at the Blog

AyerViernes « visit

  • Added 9 months ago
  • 825 Lines of Code shown
  • 1 Links of Interest
http://ayerviernes.com
This is my Source Code and I don't want to show it here
View Source Code only (as overlay)
// That code snippet belongs to AyerViernes - http://ayerviernes.com

/** AyerViernes S.A.
*
*   Interacciones Javascript desarrolladas por AyerViernes
*   para el sitio http://www.ayerviernes.com
*   usando el Framework JQuery version 1.1.4
*
*   Empresa: Ayerviernes S.A
*   Url empresa: http://www.ayerviernes.com
*   twitter @ayerviernes
*
*   Autor: Basilio Caceres Luke
*   Url autor: http://www.isotipo.net
*   Email: bcaceres@ayerviernes.com
*   tiwtter @basilio
*
*   ta bonito!
*/

uri = "http://"+location.host+location.pathname+location.hash;
if(!uri.match(/#/) && location.pathname!="/") uri = "http://"+location.host+"/#"+location.pathname;

var data = {}

var porid = {
	idname: function(e) {
		if(e.target.id){
			if(eval("this."+e.target.id)!=undefined){
				eval("this."+e.target.id)(e.target);
			}
		}
	},
	link_tools : function(e){
		$("#box_tools").toggle("slow", function(){ $("#"+e.id).toggleClass("toHide"); });
	},
	link_infoProy : function(e){
		if($(".subCont object")){
			estilo_box = $("#box_infoProy").attr("style");
			if(estilo_box.match(/block/)){
				$("#box_infoProy").slideToggle("slow", function(){ $("#link_infoProy").toggleClass("toHide"); $(".subCont object").css("visibility","visible"); });
			}
			else{
				$(".subCont object").css("visibility","hidden");
				$("#box_infoProy").slideToggle("slow", function(){ $("#link_infoProy").toggleClass("toHide"); });
			}
		}
		else{
			$("#box_infoProy").slideToggle("slow", function(){ $("#link_infoProy").toggleClass("toHide"); });
		}
	},
	close_infoProy : function(e){
		estilo_box = $("#box_infoProy").attr("style");
		if(estilo_box.match(/block/)){
			$("#box_infoProy").slideToggle("slow", function(){ $("#link_infoProy").toggleClass("toHide"); $(".subCont object").css("visibility","visible"); });
		}
		else{
			$(".subCont object").css("visibility","hidden");
			$("#box_infoProy").slideToggle("slow", function(){ $("#link_infoProy").toggleClass("toHide"); });
		}
	},
	enviar : function(e){
		data = '';
		comp = $("#form").serialize();
		comp = comp+"&contactar=true";
		$.getJSON("index.php", comp, function(data){
			if(typeof(data.respuesta_email)=="undefined"){
				for(i = 0 ; i < data.length ; i++){
					tipo_alerta = data[i].alerta;
					if(!$.id("#"+data[i].tipo+"_alert")){
						$("#"+data[i].tipo).after('<samp id="'+data[i].tipo+'_alert" class="'+tipo_alerta+'">'+data[i].mensaje+'</samp>');
						if(tipo_alerta == "alert") $("#"+data[i].tipo).addClass(tipo_alerta);
						else $("#"+data[i].tipo).removeClass("alert");
					}
					else{
						$("#"+data[i].tipo+"_alert").html(data[i].mensaje);
						$("#"+data[i].tipo+"_alert").attr("class",tipo_alerta);
						if(tipo_alerta == "alert") $("#"+data[i].tipo).addClass(tipo_alerta);
						else $("#"+data[i].tipo).removeClass("alert");
					}
				}
			}
			else{
				$("#form").remove();
				$("#cont h2").after(data.respuesta_email);
			}
		});
	}
}

var porclass = {
	mvc : function(position_section){
		uri = "http://"+location.host+location.pathname+location.hash;
		if(!uri.match(/#/) && location.pathname!="/") uri = "http://"+location.host+"/#"+location.pathname;
		section = uri.split("#");
		section = section[1].split("/");
		if(position_section=="last"){
			section = section.reverse();
			section = section[1];
		}
		else{
 			section = section[position_section];
		}
		return section;
	},
	mvc_in_uri : function(position_section, uri){
		if(uri.match(/#/)){
			section = uri.split("#");
			section = section[1].split("/");
			if(position_section=="last"){
				section = section.reverse();
				section = section[1];
			}
			else{
				section = section[position_section];
			}
		}
		else{
			section = "";
		}
		return section;
	},
	pos_mvc : function(var_section){
		uri = "http://"+location.host+location.pathname+location.hash;
		section = uri.split("#");
		section = section[1].split("/");
		for (i = 0; i < section.length; i++){
			if(section[i]==var_section) position_section = i;
		}
		return position_section;
	},
	init : function(){
		width = navigator.userAgent.match(/WebKit/) ? window.innerWidth : $(document).width() ;
		height = navigator.userAgent.match(/WebKit/) ? window.innerHeight : $(document).height() ;
	
		elements = $("#imagenes").children();
		element_random =  Math.floor ( Math.random () * ( elements.length ) );
	
		width_box = 0;
		for (var i = 0; i < elements.length; i++) {
			width_box += elements[i].width;
		};
		$("#imagenes").css('width',width_box+'px');

		porclass.vars(width,height,element_random);
	},
	vars : function(width, height, element_random){
		for(i = 0; i < elements.length; i++){
			height_element = elements[i].height;
			top_element = parseInt(height - height_element)/2;
			$(elements[i]).animate({ marginTop : top_element+'px' }, 500);
		}
		width_element = elements[element_random].width;
		top_element = parseInt(height - height_element)/2;
		left_element = parseInt((width - width_element)/2) < 0 ? 0 : parseInt((width - width_element)/2) ;
		top_subMenu = parseInt((height/4)-20) < 125 ? 125 : parseInt((height/4)-20) ;
		top_cont = parseInt((height/3)-100) < 125 ? 130 : parseInt((height/3)-120);

		left_subCenter = $("#subFoot .center")[0].offsetLeft;
		left_centerToSubCenter = parseInt(left_subCenter - left_element);

		position_left = 0;
		for (var i = 0; i < element_random; i++) {
			position_left += elements[i].width;
		}
		left_box = width_element > width ? (position_left + parseInt((width_element - width)/2)) * -1 : (position_left - left_element) * -1 ;
	},
	loads : function(){
		$("#message").animate({ left : left_subCenter+"px"}, 500);
		porclass.imagesmove();
		if($.id("#subMenu")) $("#subMenu").animate({ left : left_element+"px", top : top_subMenu+"px", paddingLeft : left_centerToSubCenter+"px"}, 500);
		if($.id("#menuCont")){
			$("#menuCont").animate({ left : parseInt(left_element+left_centerToSubCenter+140)+"px", top : parseInt(top_cont-20)+"px", opacity : '100'}, 500);
			$("#cont").animate({ left : parseInt(left_element+left_centerToSubCenter+360)+"px", top : top_cont+"px", opacity : '100'}, 500);
		}
		else{
			if($.id("#cont")) $("#cont").animate({ left : eval(left_element+left_centerToSubCenter+140)+"px", top : top_cont+"px", opacity : '100'}, 1000);
		}
	},
	resize_window : function(){
		width = navigator.userAgent.match(/WebKit/) ? window.innerWidth : $(document).width() ;
		height = navigator.userAgent.match(/WebKit/) ? window.innerHeight : $(document).height() ;
		porclass.vars(width,height,element_random);
		$("#message").animate({ left : left_subCenter+"px"}, 500);
		$("#imagenes").animate({ marginLeft : left_box+'px' }, 500);
		$("#subMenu").animate({ left : left_element+"px", top : top_subMenu+"px", paddingLeft : left_centerToSubCenter+"px"}, 500);
		if($.id("#menuCont")){
			$("#menuCont").animate({ left : parseInt(left_element+left_centerToSubCenter+140)+"px", top : parseInt(top_cont-20)+"px", opacity : '100'}, 500);
			$("#cont").animate({ left : parseInt(left_element+left_centerToSubCenter+360)+"px", top : top_cont+"px", opacity : '100'}, 500);
		}
		else{
			if($.id("#cont")) $("#cont").animate({ left : eval(left_element+left_centerToSubCenter+140)+"px", top : top_cont+"px", opacity : '100'}, 1000);
		}
	},
	imagesmove : function(){
		$("#imagenes img").animate({ opacity: '.4'}, 500);
		$(elements[element_random]).animate({ opacity: '100'}, 500);
		$("#imagenes").animate({ marginLeft: left_box+'px'}, 1000);
	},
	url_av : function(){
		elements_menu = $(".link_av");
		for(i=0; i < elements_menu.length; i++){
			url = elements_menu[i].href;
			server = location.hostname;
			if (url.match(server+'/en/'))
				elements_menu[i].href = url.replace(server+'/en/',server+'/en/#/');
			else
				elements_menu[i].href = url.replace(server,server+'/#');
		}
	},
	url_av_uri : function(url){
		server = location.hostname;
		if (url.match('/en/'))
			url = url.replace(server+'/en/',server+'/en/#/');
		else
			url = url.replace(server,server+'/#');
		return url;
	},
	force_language : function(url){
		server = location.hostname;
		if (url.match('/en/'))
			url = url.replace(server+'/en/#/',server+'/#/');
		else
			url = url.replace(server+'/#/',server+'/en/#/');
		$("#force_language").attr("href",url);
	},
	remove_init_element : function(){
		if($.id("#tagline")) $("#tagline").hide();
		if($.id("#message")) $("#message").remove();
	},
	// para crear tooltips dinamicos onmousemove
	tooltip : function(e){
		var fuente = e.target.title;
		var link = e.target.href;
		alt = 'Fuente: <strong dir="'+link+'" title="'+fuente+'">'+fuente+'</strong>';
		$("#"+e.target.id).attr("title","");
		mouseX = e.pageX;
		mouseY = e.pageY;
		if(!document.getElementById("toolTip")){
			var toolTip = document.createElement("div");
			toolTip.style.display = 'none';
			toolTip.id = "toolTip";
			toolTip.innerHTML = "<p>"+alt+"</p><span></span>";
			document.getElementsByTagName('body')[0].appendChild(toolTip);
		}
		else{
			var toolTip = document.getElementById("toolTip");
		}
		if(parseInt(document.documentElement.clientWidth) < parseInt(toolTip.offsetWidth + mouseX)){
			if(navigator.userAgent.match(/MSIE/))
				toolTip.style.top = (mouseY-42)+'px';
			else
				toolTip.style.top = (mouseY-60)+'px';
			toolTip.style.left = (mouseX-(toolTip.offsetWidth+15))+'px';
		}
		else{
			toolTip.style.top = (mouseY)+'px';
			toolTip.style.left = (mouseX+12)+'px';
		}
		toolTip.style.position = 'absolute';
		toolTip.style.zIndex = 100;
		$(toolTip).show('fast');
	},
	tooltip_out : function(e){
		title = $("#toolTip strong").attr("title")
		$("#"+e.target.id).attr("title", title).html(title);
		$("#toolTip").hide('fast', function(){ $("#toolTip").remove(); });
	},

	screenshots : function(e){
		height_subcont = $(".subCont").height();
		$(".subCont").prepend('<p class="dynamic" id="loading_rss" style="margin-top:'+parseInt((height_subcont-20)/2)+'px;">Loading...</p>');
		var link_imag = e.target.href;
		elements_imags = $(".imagProy");
		new_image = new Image();
		new_image.onload = function(){
			$("#loading_rss").remove();
			$(".imagProy.acti").fadeOut(1, function(){
				$(".imagProy.acti").removeClass("acti");
				$(".link_screenshot").parent().removeClass("acti");
				for( i = 0 ; i < elements_imags.length ; i++ ){
					if(elements_imags[i].src == link_imag){
						$("#screenshot_"+i).fadeIn("fast");
						$("#screenshot_"+i).addClass("acti");
						$(".link_screenshot[href='"+link_imag+"']").parent().addClass("acti");
					}
				}
			});
		}
		new_image.src = link_imag;
	},

	// Contenidos
	content_html : function(data,where){
		// Defaults
		submenu_list_item = "";
		menucont_list_item = "";
		imagenes_list_item = "";
		imagenes_screenshots = "";
		social_list_item = "";
		messages = "";
		titulo_content = typeof(data["contenido"])!="undefined" ? "<h1>"+data["contenido"][0].post_title+"</h1>" : ""; // titulo principal
		titulo_content_final = "";      // titulo principal final
		contenido_content = typeof(data["contenido"])!="undefined" ? data["contenido"][0].post_content : ""; // contenido general
		frase_fuente = "";              // fuente de frase titulo
		url_proyecto = "";              // link a sitio proyecto
		embed = "";                     // embed de slideshare
		social_list_icons = "";         // lista de iconos comunidades de staff
		email = "";                     // email staff
		clase_content = " content";     // clase 'content' de subCont
		titulo_subcont = "";            // titulo h2 de subCont

		// Title principal dinamico
		var titulo_html = document.title;
		if(typeof(data["contenido"])!="undefined"){
			document.title = data["contenido"][0].post_title+" « AyerViernes";
		} else {
			document.title = "AyerViernes | Estrategia y diseño para tu vida digital";
		}

		// Lista de items subMenu, menu de segundo nivel
		if(typeof(data["submenu"])!="undefined"){
			if(typeof(data["submenu"][0].guid)!="undefined"){
				submenu_list_item = "<ul>";
				for(i = 0 ; i < data["submenu"].length ; i++){
					clase = data["submenu"][i].guid.match(data["submenu_acti_nicename"]) ?' class="acti"':'';
					submenu_list_item += '<li'+clase+'><a href="'+data["submenu"][i].guid+'" title="'+data["submenu"][i].post_title+'">'+data["submenu"][i].post_title+'</a></li>';
				}
				submenu_list_item += "</ul>";
			}
			else{
				submenu_list_item = "<p style='color: #666; font-size: 1em; line-height: 110%; font-weight: bold;'>"+data["submenu"]+"</p>";
			}
		}
		// Lista de items menuCont, menu de tercer nivel
		if(typeof(data["menucont"])!="undefined"){
			menucont_list_item = "<ul>";
			for(i = 0 ; i < data["menucont"].length ; i++){
				clase = data["menucont"][i].guid.match(data["menucont_acti_nicename"]) ?' class="acti"':'';
				menucont_list_item += '<li'+clase+'><a href="'+data["menucont"][i].guid+'" title="'+data["menucont"][i].post_title+'">'+data["menucont"][i].post_title+'</a><span></span></li>';
			}
			menucont_list_item += "</ul>";
		}
		// Lista Thumbs imagenes screenshots | Imagenes screenshots
		if(typeof(data["info"])!="undefined" && typeof(data["info"].imagen)!="undefined"){
			// Lista de thumbs
			imagenes_list_item = '<ul class="listThumbs cf">';
			for(i = 0 ; i < data["info"].imagen.length ; i++){
				clase = i == 0 ?' class="acti"':'';
				imagenes_list_item += '<li'+clase+'><a href="'+data["info"].imagen[i].url_imagen+'" title="'+data["info"].imagen[i].title_imagen+'" class="link_screenshot"><span>'+data["info"].imagen[i].title_imagen+'</span></a></li>';
			}
			imagenes_list_item += "</ul>";
			// Lista de screenshots
			imagenes_screenshots = '<p id="loading_rss">Loading...</p>';
			for(i = 0 ; i < data["info"].imagen.length ; i++){
				imagenes_screenshots += '<img src="'+data["info"].imagen[i].url_imagen+'" alt="'+data["info"].imagen[i].title_imagen+'" id="screenshot_'+i+'" class="imagProy" style="display: none;" />';
			}
		}
		// Lista de items sociales
		if(typeof(data["social"])!="undefined"){
			social_list_item = '<ul id="social_list">';
			for( i = 0 ; i < data["social"].length ; i++){
				social_list_item += '<li><a href="'+data["social"][i].url_social+'" title="'+data["social"][i].item_social+'" class="'+data["social"][i].item_social+'">'+data["social"][i].item_social+'</a></li>';
			}
			social_list_item += '<li id="desc_social">Conóceme un poco más:</li>';
			social_list_item += "</ul>";
		}
		// Lista de Resultados
		if(typeof(data["resultados"])!="undefined"){
			resultados_list_item = '<ol id="resuBusc">';
			for( i = 0 ; i < data["resultados"].length ; i++){
				resultados_list_item += '<li><span>'+eval(i+1)+'.</span><p><a href="'+data["resultados"][i].link+'" title="'+data["resultados"][i].post_title+'">'+data["resultados"][i].post_title+'</a><br />'+data["resultados"][i].post_content+'</p></li>';
			}
			resultados_list_item += '</ol>';
		}
		// Icono mensajes home
		if(typeof(data["mensajes"])!="undefined")
			messages = '<img src="'+data["mensajes"].url_icono+'" alt="'+data["mensajes"].post_title+'" />'+data["mensajes"].post_content;

		if(typeof(data["frase"])!="undefined" && typeof(data["frase"].texto)!="undefined")
			titulo_content = "<h1>"+data["frase"].texto+"</h1>" ;
		if(typeof(data["frase"])!="undefined" && typeof(data["frase"].fuente)!="undefined")
			frase_fuente = '<a href="'+data["frase"].url_frase+'" title="'+data["frase"].fuente+'" rel="External" id="linkFuen">'+data["frase"].fuente+'</a>';
		if(typeof(data["info"])!="undefined" && (typeof(data["info"].url_proyecto)!="undefined" && data["info"].url_proyecto!=null))
			url_proyecto = '<a href="'+data["info"].url_proyecto+'" title="'+data["info"].visita_sitio+'" class="visitProy out">'+data["info"].visita_sitio+'</a>';
		if(typeof(data["info"])!="undefined" && (typeof(data["info"].embed)!="undefined" && data["info"].embed!=null))
			embed = data["info"].embed;
		if(typeof(data["social"])!="undefined")
			social_list_icons = social_list_item;
		if(typeof(data["email"])!="undefined")
			email = '<p class="tRight" id="email_staff"><a href="mailto:'+data["email"]+'" title="Email" rel="Alternate">'+data["email"]+'</a></p>';
		if(id_list_element == "menu_8" || typeof(data["info"])=="object" || embed!='')
			clase_content = '';
		if(id_list_element != "menu_8" && typeof(data["contenido"])!="undefined")
			titulo_subcont = '<h2>'+data["contenido"][0].post_title+'</h2>';
		if(typeof(data["info"])=="undefined" && embed=="")
			titulo_content_final = titulo_content;
		if(typeof(data["info"])=="object" || embed!=''){
			contenido_content = '<div class="infoProy">'+
				'<a href="#" title="'+data["info"].title_acerca+'" id="link_infoProy" class="js">'+data["info"].acerca+'</a>'+
				url_proyecto +
				'</div>'+
				'<div id="box_infoProy" class="content" style="display: none"><a href="#" title="'+data["info"].cerrar+'" id="close_infoProy" class="js">'+data["info"].cerrar+'</a>'+data["contenido"][0].post_content+'</div>';
		}
		if(typeof(data["resultados"])!="undefined"){
			contenido_content = '<h2 style="color: #FFF !important;">'+data["titulo_contenido"]+' <span style="color: #F00">'+data["query"]+'</span></h2>' + resultados_list_item;
		}

		// message
		if(typeof(data["mensajes"])!="undefined")
			$("#main").append('<div id="message" style="opacity: 0">'+messages+'</div>');
		// submenu
		if(!$.id("#subMenu") && typeof(data["submenu"])!="undefined")
			$("#main").append('<div id="subMenu" style="top:'+top_subMenu+'px; left:'+parseInt(left_element+10)+'px; opacity: 0;">'+submenu_list_item+'</div>');
		// menucont
		if(!$.id("#submenu") && !$.id("#menuCont") && typeof(data["menucont"])!="undefined")
			$("#main").append('<div id="menuCont" style="top:'+top_menuCont+'px; left:'+parseInt(left_menuCont+5)+'px; opacity: 0">'+menucont_list_item+'</div>');
		if($.id("#menuCont") && typeof(data["menucont"])!="undefined" && where=="submenu")
			$("#menuCont").html(menucont_list_item);
		if(!$.id("#menuCont") && typeof(data["menucont"])!="undefined")
			$("#subMenu").after('<div id="menuCont" style="top:'+top_menuCont+'px; left:'+parseInt(left_menuCont+5)+'px; opacity: 0">'+menucont_list_item+'</div>');
		// contenido
		if(!$.id("#cont") && typeof(data["mensajes"])=="undefined")
			$("#main").append('<div id="cont" style="top:'+top_cont+'px; left:'+parseInt(left_cont+5)+'px; opacity: 0"></div>');

		if(typeof(data["mensajes"])=="undefined"){
			$("#cont").html(
				titulo_content_final +
				frase_fuente +
				'<div class="subCont'+clase_content+' cf">'+
				//titulo_subcont +
				embed +
				imagenes_screenshots +
				imagenes_list_item +
				contenido_content +
				social_list_icons +
				'</div>'
			);
			if(typeof(data["info"])=="object" && embed==""){
				new_image = new Image();
				new_images_cont = $(".imagProy");
				new_image.onload = function(){
					new_images_cont[0].setAttribute("class","imagProy acti");
					if(!navigator.userAgent.match(/MSIE/)){
						$("#loading_rss").animate({ "visibility" : "hidden"}, 100, function(){
							$("#"+new_images_cont[0].id).fadeIn();
							$("#loading_rss").remove();
						});
					} else {
						$("#loading_rss").remove();
						$("#"+new_images_cont[0].id).fadeIn();
					}
				}
				new_image.src = new_images_cont[0].src;
			}
		}
	},

	// Navegacion
	nav_init : function(url_busc){
		if(!url_busc.match(/s_ajax=true/)){
			element_menu = porclass.mvc_in_uri(1,url_busc);
			element_submenu = porclass.mvc_in_uri(2,url_busc);
			element_menucont = porclass.mvc_in_uri(3,url_busc);
		}

		menu_elements = $("#menu").children();
		menu_element = 0;
		for( i = 1 ; i < (menu_elements.length) ; i++ ){
			url = menu_elements[i].childNodes[0].href;
			url = url.match(/#\/./) ? url : porclass.url_av_uri(url) ;
			nombre = "";
			nombre = porclass.mvc_in_uri("last",url);
			if(nombre == element_menu){ id_list_element = menu_elements[i].id; element_random = eval(i-1); }
		};

		if(element_random == 0)
			element_random = element_random + 1;
		else if(element_random == (elements.length-1))
			element_random = element_random - elements.length;
		else
			element_random = element_random + 1;

		if( url_busc == "http://"+location.host+"/#/" || url_busc == "http://"+location.host+"/en/#/" ){
			element_random = 0;
			id_list_element = "menu_1";
		}
		if( url_busc.match(/\/contacto\//) ){
			element_random = 6;
			id_list_element = "menu_7";
		}
		if( url_busc.match(/\/oficinas\//) ){
			element_random = 7;
			id_list_element = "menu_8";
		}
		if( url_busc.match(/s_ajax=true/) ){
			element_random = 8;
			id_list_element = "menu_9";
		}

		porclass.vars(width,height,element_random);

		left_cont = parseInt(left_element+left_centerToSubCenter+140) ;
		top_menuCont = parseInt(top_cont-20);
		left_menuCont = parseInt(left_element+left_centerToSubCenter+140);

		/* ejecucion */
		$("#tagline").slideUp("fast");
		$("#message").fadeOut("fast");
		$("#subMenu").fadeOut("fast");
		$("#menuCont").fadeOut("fast");
		$("#cont").fadeOut("fast");
		if($.id("#spotlight")) $("#spotlight").fadeOut("fast").remove();

		porclass.imagesmove();
		porclass.force_language(url_busc);
		
		str = "";
		if(!url_busc.match(/s_ajax=true/)){
			if( url_busc == "http://"+location.host+"/#/" || url_busc == "http://"+location.host+"/en/#/" ) str += "post_name_1=mensajes";
			if(element_menu!="" && typeof(element_menu)!="undefined") str += "post_name_1="+element_menu;
			if(element_submenu!="" && typeof(element_submenu)!="undefined") str += "&post_name_2="+element_submenu;
			if(element_menucont!="" && typeof(element_menucont)!="undefined") str += "&post_name_3="+element_menucont;
		}
		else{
			str += "s="+value+"&s_ajax=true";
		}

		data = '';
		$.getJSON("index.php", str, function(data){
			$(".acti").removeClass("acti");
			$("#"+id_list_element).addClass("acti");
			$("#main").html('');
			if(typeof(data["menucont"])!="undefined")
				left_cont = parseInt(left_element+left_centerToSubCenter+360);
			var n = setTimeout(function(){
				porclass.content_html(data,"menu");

				if(typeof(data["menucont"])!="undefined"){
					$("#subMenu").animate({ left : left_element+"px", top : top_subMenu+"px", paddingLeft : left_centerToSubCenter+"px", opacity : '100'}, 500, function(){
						$("#menuCont").animate({ left : left_menuCont+"px", top : top_menuCont+"px", opacity : '100'}, 500, function(){
							$("#cont").animate({ left : left_cont+"px", top : top_cont+"px", opacity : '100'}, 500);
							$(".link_screenshot").bind("click", function(e){ porclass.screenshots(e); return false; });
						});
					});
				}
				else if(typeof(data["mensajes"])!="undefined"){
					$("#tagline").slideDown("slow");
					$("#message").animate({ opacity : '100'}, 2500);
				}
				else{
					$("#main").fadeIn(1000);
					$("#subMenu").animate({ left : left_element+"px", top : top_subMenu+"px", paddingLeft : left_centerToSubCenter+"px", opacity : '100'}, 500, function(){
						$("#cont").animate({ left : left_cont+"px", top : top_cont+"px", opacity : '100'}, 500);
						$(".link_screenshot").bind("click", function(e){ porclass.screenshots(e); return false; });
					});
				}
				porclass.detecciones(data,"menu");
			}, 2000);
		});
	},
	subMenu : function(e){
		if( e.href.match(/\/contacto\//) ){
			element_random = 6;
			id_list_element = "menu_7";
		}
		if( e.href.match(/\/oficinas\//) ){
			element_random = 7;
			id_list_element = "menu_8";
		}
		porclass.vars(width,height,element_random);

		left_cont = parseInt(left_element+left_centerToSubCenter+140) ;
		top_menuCont = parseInt(top_cont-20);
		left_menuCont = parseInt(left_element+left_centerToSubCenter+140);

		porclass.force_language(e.href);

		id_element = porclass.mvc_in_uri(2,e.href);
		id_element = id_element.replace(/-/g,"_");
		var str = "post_name_1="+porclass.mvc(1)+"&post_name_2="+id_element;
		data = '';
		$.getJSON("index.php", str, function(data){
			if(typeof(data["menucont"])!="undefined"){
				left_cont = parseInt(left_element+left_centerToSubCenter+360);
				if($.id("#menuCont")){
					$("#menuCont").animate({ left : parseInt(left_menuCont+5)+"px", top : top_menuCont+"px", opacity : '0'}, 500);
					$("#cont").animate({ left : parseInt(left_cont+5)+"px", top : top_cont+"px", opacity : '0'}, 500, function(){
						porclass.content_html(data,"submenu");
						$("#subMenu li.acti").removeClass('acti');
						$(e.parentNode).addClass('acti');

						$("#menuCont").animate({ left : left_menuCont+"px", top : top_menuCont+"px", opacity : '100'}, 500, function(){
							$("#cont").animate({ left : left_cont+"px", top : top_cont+"px", opacity : '100'}, 500, function(){
								porclass.detecciones(data,"submenu");
							});
						});
					});
				}
				else{
					$("#cont").animate({ left : parseInt(left_cont+5)+"px", top : top_cont+"px", opacity : '0'}, 500, function(){
						porclass.content_html(data,"submenu");
						$("#subMenu li.acti").removeClass('acti');
						$(e.parentNode).addClass('acti');

						$("#menuCont").animate({ left : left_menuCont+"px", top : top_menuCont+"px", opacity : '100'}, 500, function(){
							$("#cont").animate({ left : left_cont+"px", top : top_cont+"px", opacity : '100'}, 500, function(){
								porclass.detecciones(data,"submenu");
							});
						});
					});
				}
			}
			else{
				if($.id("#menuCont")){
					left_cont = parseInt(left_element+left_centerToSubCenter+360);
					$("#menuCont").animate({ left : parseInt(left_menuCont+5)+"px", top : top_menuCont+"px", opacity : '0'}, 500 );
					var n = setTimeout(function(){
						$("#cont").animate({ left : parseInt(left_cont+5)+"px", top : top_cont+"px", opacity : '0'}, 500, function(){
							$("#menuCont").remove();
							porclass.content_html(data,"submenu");
							$("#subMenu li.acti").removeClass('acti');
							$(e.parentNode).addClass('acti');

							left_cont = parseInt(left_element+left_centerToSubCenter+140);
							$("#cont").animate({ left : left_cont+"px", top : top_cont+"px", opacity : '100'}, 500, function(){
								porclass.detecciones(data,"submenu");
							});
						});
					}, 200);
				}
				else{
					$("#cont").animate({ left : parseInt(left_cont+5)+"px", top : top_cont+"px", opacity : '0'}, 500, function(){
						porclass.content_html(data,"submenu");
						$("#subMenu li.acti").removeClass('acti');
						$(e.parentNode).addClass('acti');

						$("#cont").animate({ left : left_cont+"px", top : top_cont+"px", opacity : '100'}, 500, function(){
							porclass.detecciones(data,"submenu");
						});
					});
				}
			}
		});
	},
	menuCont : function(e){
		porclass.vars(width,height,element_random);
		porclass.force_language(e.href);
		id_element = porclass.mvc_in_uri(3,e.href);
		id_element = id_element.replace(/-/g,"_");
		var str = "post_name_1="+porclass.mvc(1)+"&post_name_2="+porclass.mvc(2)+"&post_name_3="+id_element;
		data = '';
		$.getJSON("index.php", str, function(data){
			left_cont = parseInt(left_element+left_centerToSubCenter+360);
			$("#cont").animate({ left : parseInt(left_cont+5)+"px", top : top_cont+"px", opacity : '0'}, 500, function(){
				porclass.content_html(data,"menucont");
				$("#menuCont li.acti").removeClass('acti');
				$(e.parentNode).addClass('acti');

				$("#cont").animate({ left : left_cont+"px", top : top_cont+"px", opacity : '100'}, 500, function(){
					porclass.detecciones(data,"menucont");
				});
			});
		});
	},
	posts_rss : function(url_rss){
		$("#social_list").before('<p class="tCent" id="loading_rss">Loading...</p>');
		$.getJSON("index.php", "url_rss="+url_rss, function(data){
			$("#loading_rss").fadeOut("fast",function(){ 
				post_items = '<ul class="listPost" style="display: none">';
				for( i = 0 ; i < data.length ; i++){
					post_items += '<li><span class="date">'+data[i]["date"]+'</span> <a href="'+data[i]["link"]+'" title="'+data[i]["title"]+'" rel="External Follow">'+data[i]["title"]+'</a></li>';
				}
				post_items += '</ul>';
				$("#loading_rss").remove();
				$("#social_list").before(post_items);
				$(".listPost").fadeIn();
			});
		});
	},

	// Buscador Spotlight
	buscar_spot : function(e){
		$("form").submit;
		value = $("#busc").attr("value");
		str = "s="+value+"&s_spot=true";
		$.getJSON("index.php", str, function(data){
			// Lista de Resultados
			if(typeof(data["resultados"])!="undefined"){
				resultados_list_item = '<ul id="resuBusc">';
				for( i = 0 ; i < data["resultados"].length ; i++){
					var imagen = data["resultados"][i].imagen!="" ?'<span class="masc" '+data["resultados"][i].style+'><img src="'+data["resultados"][i].imagen+'" alt="'+data["resultados"][i].post_title+'" '+data["resultados"][i].style+' /></span>':'';
					resultados_list_item += '<li class="cf">'+ 
									'<a href="'+data["resultados"][i].link+'" title="'+data["resultados"][i].post_title+'" class="link_spot cf">'+
										imagen +
										'<strong>'+data["resultados"][i].post_title+'</strong>'+
										'<span>'+data["resultados"][i].post_content+'</span>'+
									'</a>'+
								'</li>';
				}
				resultados_list_item += '</ul>';
			} else {
				resultados_list_item = data;
			}
			if(!$.id("#spotlight")) { $("#buscador").after('<div id="spotlight">'+resultados_list_item+'</div>'); }
			else { $("#spotlight").html(resultados_list_item); }
			$("ul#resuBusc li a").bind("click", function(e){
				tag = e.target.tagName;
				if(tag=="STRONG" || tag=="SPAN" || tag=="IMG"){
					url_busc = e.target.parentNode.href;
				} else {
					url_busc = e.target.href;
				}
				porclass.nav_init(url_busc);
				$("#spotlight").remove();
				$("#busc").attr("value","");
				return true;
			});
		});
	},
	buscar_close : function(e){
		iden = e.target.id;
		if((iden!="busc" && iden!="resuBusc") && $.id("#spotlight")) { $("#spotlight").remove(); }
	},
	detecciones : function(data,where){
		if(typeof(data["blog_rss"])!="undefined") porclass.posts_rss(data["blog_rss"]);
		if($.id("#subMenu") && where=="menu") $("#subMenu li a").bind("click", function(e){ porclass.subMenu(e.target);return true; });
		if($.id("#menuCont") && (where=="menu" || where =="submenu")) $("#menuCont li a").bind("click", function(e){ porclass.menuCont(e.target);return true; });
		if(where=="submenu" || where=="menucont") $(".link_screenshot").bind("click", function(e){ porclass.screenshots(e); return false; });
		if(typeof(data["contenido"])!="undefined" && (data["contenido"][0].post_content.match(/[location.host]\/#/) || data["contenido"][0].post_content.match(/..\/#/))){
			elements_anchor_av = $(".subCont a[href*='"+location.host+"/#']");
			for(i = 0 ; i < elements_anchor_av.length ; i++){
				url_anchor = elements_anchor_av[i].href;
				elements_anchor_av[i].setAttribute("id","anchor"+i);
				$("#anchor"+i).bind("click", function(){ porclass.nav_init(url_anchor); });
			}
			elements_anchor_av2 = $(".subCont a[href*='../#']");
			for(i = 0 ; i < elements_anchor_av2.length ; i++){
				url_anchor2 = elements_anchor_av2[i].href;
				elements_anchor_av2[i].setAttribute("id","anchor2"+i);
				$("#anchor2"+i).bind("click", function(){ porclass.nav_init(url_anchor2); });
			}
		}
		if(typeof(data["mensajes"])!="undefined"){
			$("#message a").bind("click", function(e){ porclass.nav_init(e.target.href); });
		}
		if(typeof(data["resultados"])!="undefined"){
			$("ol#resuBusc li a").bind("click", function(e){
				url_busc = e.target.href;
				porclass.nav_init(url_busc);
				$("#busc").attr("value","");
				return true;
			});
		}
		$("#linkFuen").mousemove(function(e){porclass.tooltip(e); return false;});
		$("#linkFuen").mouseout(function(e){porclass.tooltip_out(e); return false;});
		$("#main .js").bind("click", function(e){ porid.idname(e); return false;});
	},
	gup : function(name){
		name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
		var regexS = "[\\?&]"+name+"=([^&#]*)";
		var regex = new RegExp( regexS );
		var results = regex.exec( window.location.href );
		if( results == null )
			return "";
		else
			return results[1];
	}
}

if(uri.match(/#\/./)){
	if(porclass.mvc(1)!=""){
		$(document).ready( function() {
			porclass.remove_init_element();
			porclass.init();
			if(!porclass.mvc(1).match(/s_ajax=true/)) {
				porclass.nav_init(uri);
			} else {
				url_buscar = "http://"+location.host+location.pathname+location.hash;
				porclass.nav_init(url_buscar);
				$("#busc").attr("value","");
				return true;
			}
		});
	}
	
}

$(document).ready( function() {
	porclass.url_av();
	$('.hide').hide();
	$('.show').show();
	porclass.init();
	porclass.loads();
	$(window).resize(function(e){ porclass.resize_window(); return false; });
	$("#toolBox .link_av").bind("click", function(e){ porclass.nav_init(e.target.href); });
	$("#titu a").bind("click", function(e){ porclass.nav_init(e.target.parentNode.href); });
	$("#message a").bind("click", function(e){ porclass.nav_init(e.target.href); });
	$("#link_contacto").bind("click", function(e){ porclass.nav_init(e.target.href); return true; });
	$("#link_oficina").bind("click", function(e){ porclass.nav_init(e.target.href); return true; });
	$("#menu li a").bind("click", function(e){ porclass.nav_init(e.target.href); return true; });
	$("#subMenu li a").bind("click", function(e){ porclass.subMenu(e.target);return true; });
	$("#menuCont li a").bind("click", function(e){ porclass.menuCont(e.target);return true; });
	$("form#buscador").bind("submit", function(){
		value = $("#busc").attr("value");
		location.hash = "/?s="+value+"&s_ajax=true";
		url_busc = "http://"+location.host+location.pathname+location.hash;
		porclass.nav_init(url_busc);
		$("#busc").attr("value","");
		return false;
	});
	$(".link_screenshot").bind("click", function(e){ porclass.screenshots(e); return false; });
	$("form#buscador").keyup(function(e){ porclass.buscar_spot(e); return false; } )
	$("#botoBusc").onsubmit = function() { return false; }
	$().bind("click", function(e){ porclass.buscar_close(e); });
	if($.id("#busc")) $("#busc").attr("autocomplete","off");
	$(".js").bind("click", function(e){ porid.idname(e); return false; });
	$("#linkFuen").mousemove(function(e){porclass.tooltip(e); return false;});
	$("#linkFuen").mouseout(function(e){porclass.tooltip_out(e); return false;});
});

jQuery.extend({ //extension de metodo $
	id : function(id) {
		var id = id.split("#");
		return document.getElementById(id[1])?true:false;
	}
});