var main,container,header,boxTop,footer,windowSize,Scroll,api,iscroll,loader,videoInitialized=false,curLink="",oldLink="",limitF=50,autoFeature=false,pageCoordsLeft=0,pageCoordsOld,clientCoords,direction="",actualDirection="",start=false,startInterval=0,positionLeft=0;var mobile=function(){return{detect:function(){var a=navigator.userAgent.toLowerCase();var c=this.mobiles;var b=false;for(var e=0;e<c.length;e+=1){if(a.indexOf(c[e])!=-1){b=true}}return b},mobiles:["midp","240x320","blackberry","netfront","nokia","panasonic","portalmmm","sharp","sie-","sonyericsson","symbian","windows ce","benq","mda","mot-","opera mini","philips","pocket pc","sagem","samsung","sda","sgh-","vodafone","xda","palm","iphone","ipod","android"]}}();var html5=true;var isMobile=mobile.detect();var isiPad=(navigator.userAgent.toLowerCase().match(/iPad/i)!==null)||(navigator.userAgent.toLowerCase().match(/iPhone/i)!==null)||(navigator.userAgent.toLowerCase().match(/iPod/i)!==null)||(navigator.userAgent.toLowerCase().match(/android/i)!==null);function is_mobile(){var a=$(window).width();return(a<=480)?true:false}function initScroll(){Scroll=$("#scroll");if(!isiPad&&Scroll.size()){Scroll.jScrollPane();api=Scroll.data("jsp")}}function refreshScroll(){if(typeof Scroll=="undefined"||Scroll.size()===0){return}if(!isiPad&&api){api.reinitialise()}}function scrollUp(){if(!isiPad){api.scrollToY(0,true)}else{$("body").animate({scrollTop:0},500)}}function initVimeoApiControl(){if(window.addEventListener){window.addEventListener("message",onMessageReceived,false)}else{window.attachEvent("onmessage",onMessageReceived,false)}}function postMessage(e,d,c){if(!c.contentWindow.postMessage){return false}var a=c.getAttribute("src").split("?")[0],b=JSON.stringify({method:e,value:d});c.contentWindow.postMessage(b,a)}function onMessageReceived(a){}function vimeo_player_loaded(){}$.fn.activeBox=function(){$(this).addClass("active");return this};function heightCenter(){var c=boxTop.height();var b=footer.outerHeight();var a=parseInt(windowSize[1]-(c+b),10);return a}$.fn.keepProjectActive=function(){this.addClass("active").find(".info-project").css("left","0px");return this};function removeProjectsHover(){var a;$(".navigation.active .info-project").each(function(){a=$(this);a.stop(true).animate({left:"-"+a.width()+"px"},500).parents(".navigation").removeClass("active")})}function get(a){return $("#"+a).val()}function px(a){var b=a.split("px");return parseInt(b[0],10)}function getSize(a){return Array($(a).width(),$(a).height())}function rand(a,b){var d=a-b;var c=Math.random()*d;c=Math.round(c);return parseInt(b,10)+c}function idiomas(a){var b=$("#qtranslate-chooser a");b.each(function(){var c=$(this).attr("rel");if(a){$(this).attr("href",c+"#/"+a)}})}$.fn.randomSize=function(){var b=$(this);var a=b.find("img");if(is_mobile()){a.css("height","60px")}else{a.css("height","180px")}var c=a.innerWidth();b.css({width:c+"px"})};function getHeightProject(){var c=boxTop.height();var b=footer.outerHeight();var a=parseInt(windowSize[1]-(c+b),10);return a}function ajustarLoader(){if(!loader.length){return}var a=getHeightProject()+"px";main.css("min-height",a);loader.css("height",a)}function ajustarBoxTop(){if(!boxTop.length){return}boxTop.css("height",header.outerHeight()+"px")}function ajustarAbout(a){if(typeof a!="undefined"&&a){removeLoader()}$("a[href^='http://'], a[href^='mailto:']",$("#about")).addClass("jump");refreshScroll()}function ajustarContenido(g){if(typeof g!="undefined"&&g){removeLoader()}windowSize=getSize($(window));if((!isiPad&&!isMobile)||typeof Scroll=="undefined"){Scroll.css({height:(windowSize[1])+"px"})}var b=windowSize[0]-80;var a=$("#contact",container);if(a.length){$("a[href^='http://'], a[href^='mailto:']",a).addClass("jump");var e=280,c=335,f;var d=b-260;$("#mapa").css("width",d)}main.css({width:b+"px"});refreshScroll()}$.fn.endProjectGalleryLoad=function(a){if(a){a.fadeOut(500)}};function ajustarBoxProject(r){var d=$("#boxProject");if(!d.length){return}r=(typeof r=="undefined")?false:r;var a=$("#gallery",d);var q=$("ul",a);var p=$("li",q);var o=$("#project-content",d);var b=$("#project-details-content",o);var c=container.width();var l=getHeightProject();d.css({height:l});if(a.length&&p.length){var h=c-230;var u=l-20;var n=(h-125);a.css({width:h+"px",height:u+"px"});p.css({width:(n)+"px",height:u+"px"});$("#galleryControl",d).css("width",a.width()-n-p.css("margin-right"));var f=p.size();var w=n+parseInt(p.css("margin-right"),10);q.css({width:(w*f)+"px"});var i=p.filter(".video").children("iframe");if(i.length){if(!r){var t,k,v,j;i.each(function(){t=$(this);k=t.attr("width");if(k!="100%"){v=t.attr("height");j=k/v;t.data("initWidth",k).data("initHeight",v).data("ratio",j);t.attr("height",u).attr("width",(u*j))}})}else{var t;i.each(function(){t=$(this);if(t.data("ratio")){t.attr("height",u).attr("width",(u*t.data("ratio")))}})}}var e,g,s;if(!r){}else{var m=p.getCurrentItemIndex();var x=(m>=1)?("-"+(w*m)):0;q.css("left",x+"px")}}}function insertLoader(){container.after(loader);loader.fadeIn(100);ajustarLoader()}function removeLoader(){if(loader.length){loader.fadeOut(200,function(){$(this).remove()})}}function loadPage(b){videoInitialized=false;var a="option="+b;$.ajax({beforeSend:function(){var c=container.children();if(c.length){c.stop().fadeOut("fast",function(){insertLoader()})}else{insertLoader()}},type:"POST",url:"templates.php",data:a,success:function(c){container.html(c)}})}jQuery.expr[":"].parents=function(c,d,b){return jQuery(c).parents(b[3]).length<1};function initAddress(){$.address.init(function(a){$('a:not(".jump")').address(function(){return $(this).attr("href")})}).change(function(a){curLink=a.value;var c=$.address.value();var b=$('a[href="'+c+'/"]');b=(b.size())?b:$('a[href="'+c+'"]');oldLink=curLink;startInterval=setInterval(function(){if(start){clearInterval(startInterval);if(b.is(".menuPage")){$("#nav a").removeClass("active");footer.fadeIn(1000);scrollUp();removeScrollFooterInteraction();b.addClass("active");loadPage(curLink.slice(1));idiomas(curLink.slice(1));return false}if(!$("#project").length){if(curLink!="/"&&curLink!==""){$("#nav a").removeClass("active")}loadPage(curLink.slice(1));idiomas(curLink.slice(1))}else{var e=$.address.value();var d=$('.nav[href="'+e+'"]').eq(0);if(d.size()){$("#nav a").removeClass("active");d.addClass("active")}}}},100)})}function destacadosCycle(){var a=$("#destacados").cycle({timeout:5000,speed:600,fx:"custom",cssFirst:{zIndex:1},cssBefore:{zIndex:1,opacity:0},cssAfter:{zIndex:0},animOut:{opacity:0},animIn:{opacity:1}});var b=$("li",a);b.fadeIn();$("img",b).fadeIn();refreshScroll()}function ajustarDestacados(g,d){var c=$("#destacados");if(!c.length){return}d=(typeof d=="undefined")?false:d;var e=heightCenter();c.css({height:e+"px"});var b=$("li img",c);var h=b.size();var f=0;if(g=="false"){b.removeAttr("height");return false}var a;b.each(function(){a=$(this);a.removeAttr("height").verticalCrop(e,a.parents("li"));if(d){if(a[0].complete){f++;if(f>=h&&d){removeLoader();destacadosCycle()}}else{a.load(function(){f++;if(f>=h&&d){removeLoader();destacadosCycle()}})}}})}function ajustarVideo(){var b=$("#video-container #video");if(!b.length){return}var c=container.width();var a=heightCenter();$("#contentVideo").css({width:c+"px",height:a+"px"})}function checkVideo(g,b,d,h){var a=$("#video-container");if(isiPad||isMobile){a.append('<img id="video" src="'+h+'" width="100%"/>')}else{a.append('<div id="video"></div>');html5=false;var f={allowfullscreen:"true",allowscriptaccess:"always",wmode:"opaque"};var c={id:"video",name:"video"};var e={};e.file=d;swfobject.embedSWF("swf/videoloop.swf","video","100%","100%","9.0.0","expressInstall.swf",e,f,c)}ajustarVideo();a.css({opacity:"0",display:"block"}).animate({opacity:"1"},{queue:true,duration:600,complete:function(){removeLoader()}})}function videoEnded(b){var a=$(b.target);if(a){a[0].currentTime=0;a[0].play()}}function goToFeatured(){if(!autoFeature){var c=heightCenter();var b=$("#destacados");var a=$("#contentVideo");$("li:eq(0), li:eq(0) img",b).show();$("#precargaDestacados").css("display","block");var d;$("li img",b).each(function(){d=$(this);d.verticalCrop(c,d.parents("li"))});a.fadeOut(500,function(){$('a[href="una-marca-marca-si-se-desmarca"]').removeClass("active");$('a[href="destacados"]').addClass("active");a.remove();destacadosCycle()});autoFeature=true}}function videoCanPlay(){if(videoInitialized){return}var a=document.getElementById("video");if(a){a.addEventListener("ended",videoEnded,false);a.play()}videoInitialized=true;if(!autoFeature){setTimeout(function(){videoInitialized=false;a.removeEventListener("ended",videoEnded,false);goToFeatured()},3000)}}function initVideo(){var a=document.getElementById("video");a.addEventListener("canplay",videoCanPlay,false)}function noAuto(){autoFeature=true}$(document).ready(function(){main=$("#main");container=$("#container");loader=$('<div id="loader"></div>');header=$("#header");boxTop=$("#boxTop");footer=$("#footer");initScroll();ajustarContenido();$(".slogan",header).fadeIn(1000);$("#nav",header).css("border-bottom","1px solid #333");var c=0,b=0;var a=$(".fadeMenu").size();$(".fadeMenu").each(function(){$(this).stop(true).delay((c*50)).fadeIn("fast",function(){b++;$(this).css("display","inline-block");if(b>=a){if(boxTop.size()){ajustarBoxTop()}start=true}});c++});initMenuNavigation();$("body").mousemove(function(d){if(pageCoordsLeft<=d.clientX){direction="right"}else{direction="left"}pageCoordsLeft=d.clientX});if(!isMobile&&!isiPad){$(".nav, .menuPage").typewriter()}initAddress()});function resizeContent(){ajustarBoxTop();ajustarContenido();ajustarBoxProject(true);ajustarDestacados();ajustarVideo();refreshScroll();ajustarLoader()}if(!isiPad&&!isMobile){$(window).resize(function(){resizeContent()})}else{window.addEventListener("onorientationchange" in window?"orientationchange":"resize",resizeContent,false)}function getCurrentGalleryImage(){return $("#gallery ul li.active").index()}$.fn.getCurrentItem=function(){return this.filter(".active")};$.fn.getCurrentItemIndex=function(){return this.getCurrentItem().index()};$.fn.getNextItem=function(){return this.getCurrentItem().next()};function centerImageProject(c){var d=$(c).offset();var b=0.5*($(c).width());if(d&&windowSize[0]>1024){var a=(0.5*((0.5*windowSize[0])-parseInt(d.left,10)-b))-25;if(a<0){$(c).css({position:"relative"});$(c).animate({left:a+"px"},{queue:true,duration:500})}}}function showProjectInWorks(c){var a,b;$(".navigation").each(function(){a=$(this);b=a.find("."+c).size();if(!b){a.removeClass("show");a.addClass("hide")}else{a.removeClass("hide");a.addClass("show")}})}function openProject(b){var a=$('.navigation[rel="post-'+b+'"]');a.click().activeBox()}function closeBoxProject(b){b=(typeof b=="undefined")?true:b;var a=$("#boxProject");if(b){showProjectInWorks("imagen-product")}a.stop().animate({opacity:"0"},{queue:false,duration:500}).slideUp(500,function(){a.remove();footer.fadeIn(1000);var c=$("#project");if(c.length){c.addClass("works")}removeProjectsHover();refreshScroll();if(b){addScrollFooterInteraction()}});scrollUp()}function controlProjectGallery(){initVimeoApiControl();var u;$(".toggleProject").click(function(){$(".toggleWorks").toggle()});var e=$("#paginador .back");e.click(closeBoxProject);var j=false;var c=$("#boxProject");var a=$("#gallery",c);$("#project-details a[href^='http://']",c).addClass("jump").attr("target","_blank");if(a.size()){var p=$("ul",a);var o=$("li",p);var q=$("img",o);var t=o.size();if(!t||t===0){return}var m=$("#galleryControl",c);var r=$(".next",m);var h=$(".prev",m).addClass("noarrow");var n=$(".capa",m);var d=$("#paginador .paginator_number");var s=0,g="",x="";for(s;s<t;s++){x=(s===0)?" active":"";g=(s<t)?" / ":"";d.append('<a href="'+curLink.slice(1)+'" class="paginator'+x+'">'+(s+1)+g+"</a>")}if(t<=1){return}var l=$(".paginator",d);var k=null,f,v,b,w;l.click(function(z){w=$(this);if(w.hasClass("active")){return false}j=true;if(!isMobile&&!isiPad){n.hide()}l.removeClass("active");w.addClass("active");b=w.index();if(b===0){h.addClass("noarrow")}else{if(h.hasClass("noarrow")){h.removeClass("noarrow")}}if(b===(t-1)){r.addClass("noarrow")}else{if(r.hasClass("noarrow")){r.removeClass("noarrow")}}v=o.filter(".active").removeClass("active");if(v.hasClass("video")){postMessage("pause","undefined",$("iframe",v)[0]);if(isiPad||isMobile){var y=$("iframe",v);y.attr({src:y.attr("src")})}}f=o.eq(b);var i=0;if(b>=1){i="-"+((f.outerWidth(true))*b)}f.css({"text-align":"center",overflow:"hidden"}).filter(".video").children("iframe").css("margin","auto");k=f.next();if(k.length){k.css({"text-align":"left",overflow:"visible"}).filter(".video").children("iframe").css("margin","0px")}p.stop().animate({left:i+"px"},{queue:true,duration:500,complete:function(){f.addClass("active");j=false;if((!isiPad&&!isMobile)&&k.length){n.fadeIn(700)}if(positionLeft<i&&i>0){q.css({position:"relative"})}positionLeft=i}});z.preventDefault()});o.eq(0).addClass("active").next().css({"text-align":"left",overflow:"visible"}).filter(".video").children("iframe").css("margin","0px");m.show();r.click(function(y){y.preventDefault();if(!j){var i=o.getCurrentItemIndex();l.eq(i+1).click()}});h.click(function(y){y.preventDefault();if(!j){var i=o.getCurrentItemIndex();if(i>0){l.eq(i-1).click()}}});n.click(function(){q.css({"margin-left":"0px"});r.click()});if(!isMobile&&!isiPad){n.hover(function(){if(!k){k=o.getNextItem()}var i=$("img, iframe",k);i.stop().animate({marginLeft:"-10px"},{queue:true,duration:100});$(this).stop().animate({left:"-10px"},{queue:true,duration:100})},function(){if(!k){k=o.getNextItem()}var i=$("img, iframe",k);i.stop().animate({marginLeft:"0px"},{queue:true,duration:100});$(this).stop().animate({left:"0px"},{queue:true,duration:100})})}}}function loadProject(e,a,d){var b,c;b="option=proyect&id="+a+"&mobil=0";$('a[rel="post-'+a+'"]').activeBox();$.ajax({beforeSend:function(){c=$("#galleryLoading",e);if(!c.size()){c=$('<div id="galleryLoading"></div>');e.prepend(c);c.hide().fadeIn(100)}else{c.fadeIn(100)}var f=e.children().not(c);if(f.length>0){f.fadeOut(100,function(){f.remove()})}},type:"POST",url:"templates.php",data:b,success:function(f){e.append(f);controlProjectGallery();ajustarBoxProject();c.fadeOut();showProjectInWorks(d);projectCont=$("#project");if(projectCont.size()){projectCont.removeClass("works")}footer.fadeOut();refreshScroll()}})}function initLoadProjectEvents(){var c,f,e,a,b,d;$(".navigation").unbind("click").click(function(g){c=$(this);if(c.hasClass("active")){return false}removeProjectsHover();c.keepProjectActive();scrollUp();e=c.find("div").attr("class").split(" ");a=c.attr("rel").split("-");b=getHeightProject();f=$("#boxProject");if(!f.length){removeScrollFooterInteraction();f=$('<div id="boxProject" />');container.prepend(f);f.css({height:b+"px",display:"none"}).slideDown(700,function(){loadProject(f,a[1],e[1])})}else{loadProject(f,a[1],e[1])}g.preventDefault()})}function initMenuNavigation(){$(".nav").unbind("click").click(function(d){var f=$(this);var h=$("#boxProject");if(f.is(".active")){if(h.size()){closeBoxProject()}return false}if(h.size()){closeBoxProject(false)}else{scrollUp()}f.addClass("active");var a=$(".imagen-product").filter(":visible");var c=a.size();var g=$(".nav").find(".info-project");g.addClass("nohover");$(".navigation .info-project").css("display","none");var b=1;a.each(function(){var i=$(this).children("img");var e=i.width();i.stop(true).delay(rand(1,500)).animate({left:"-"+e+"px"},{duration:300,complete:function(){if(b==c-1){a.fadeOut(500)}else{if(b==c){removeScrollFooterInteraction();loadPage(curLink.slice(1))}}b++}})});d.preventDefault()})}function animateProjectPreviews(e,b){removeLoader();var c,a,h,g,i,f=0,d,k;c=$(".navigation").data("complete",false);a=$(".imagen-product",c);i=a.size()-1;a.each(function(){h=$(this);h.randomSize();g=h.children("img");d=parseInt(g.width(),10);k=h.children(".info-project");g.css("left","-"+d+"px");k.css({left:"-"+d+"px",display:"block"});h.children("img").stop().delay(rand(1,500)).show().animate({left:"0"},{queue:true,duration:700,complete:function(){k=$(this).parent().find(".info-project");k.removeClass("nohover");if(i==f){c.data("complete",true);if(b){openProject(b);return false}refreshScroll();addScrollFooterInteraction()}f++}})})}function addScrollFooterInteraction(){if(Scroll.length&&!isiPad&&api){var a;Scroll.unbind("jsp-scroll-y").bind("jsp-scroll-y",function(d,c,e,b){if(footer.is(":visible")&&!e&&!b){footer.stop(true,true).fadeOut(300)}if(a){clearTimeout(a)}a=setTimeout(function(){footer.stop(true,true).fadeIn(600)},800)})}}function removeScrollFooterInteraction(){if(Scroll.length&&!isiPad&&api){Scroll.unbind("jsp-scroll-y")}}function initAnimation(f,c){var i=0,j=$(".imagen-product"),h=j.size()-1;f=(f=="all")?"imagen-product":f;if(f){$('.nav[rel="'+f+'"]').addClass("active")}var d=$("img",j),e=d.size();d.each(function(){var k=$(this);if(k[0].complete){if(i==(e-1)){animateProjectPreviews(f,c)}i++}else{k.load(function(){if(i==(e-1)){animateProjectPreviews(f,c)}i++})}});if(!isMobile&&!isiPad){var b,a,g;$(".navigation").hover(function(k){a=$(this);if(a.data("complete")&&!(a.is(".active"))){b=$(".info-project",this);g=b.width();actualDirection=direction;if(direction=="left"){b.css("left",g+"px").stop(true).animate({left:"0px"},200)}else{b.stop(true).animate({left:"0px"},200)}}},function(){a=$(this);if(a.data("complete")&&!(a.is(".active"))){b=$(".info-project",this);g=b.width();if(direction=="left"){b.stop(true).animate({left:"-"+g+"px"},200)}else{b.stop(true).animate({left:g+"px"},200)}}})}}(function(a){a.fn.outerHeightHidden=function(c){this.css({visibility:"hidden",display:"block"});var b=this.outerHeight(c);this.css({visibility:"visible",display:"none"});return b};a.fn.outerWidthParentHidden=function(d,b){d.css({visibility:"hidden",display:"block"});var c=this.outerWidth(b);d.css({visibility:"visible",display:"none"});return c};a.fn.outerHeightParentHidden=function(d,c){d.css({visibility:"hidden",display:"block"});var b=this.outerHeight(c);d.css({visibility:"visible",display:"none"});return b};a.fn.verticalCrop=function(e,b){var f=a(this);if(e===null){e=getHeightProject()}var d;if(b&&b.is(":hidden")){d=f.outerHeightParentHidden(b)}else{d=f.outerHeight()}var c=(d<=e)?0:(0.5*(e-d));f.css({top:c+"px"})}}(jQuery));(function(a){var b={speed:300,text:""};a.fn.typewriter=function(c){var d=a.extend({},b,c);a(this).each(function(){var g=a(this).css({position:"relative"}),f=g.outerWidth(true),h=a("<div />"),e=a("<span>"+g.html()+"</span>").css("width",f);h.css({position:"absolute",top:0,left:0,width:0,display:"block",height:"100%",overflow:"hidden",background:"#FFFFFF"}).append(e).appendTo(g);g.hover(function(){h.show().stop().animate({width:f+"px"},{queue:true,duration:d.speed})},function(){h.stop().css("width","0")})})}}(jQuery));
