var FrizzeUtils={};FrizzeUtils.extend=function(b,a){b.prototype.base=a;for(method in a.prototype){if(b.prototype[method]==undefined){b.prototype[method]=a.prototype[method]}}};FrizzeUtils.isMobile=function(){if(navigator.userAgent.match(/Android/i)||navigator.userAgent.match(/webOS/i)||navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/iPad/i)){return true}return false};FrizzeUtils.supportVideo=function(){return !!document.createElement("video").canPlayType};var ApplicationLoader=function(){};ApplicationLoader.show=function(){var a="<div id='"+ApplicationLoader.ID+"' class='"+ApplicationLoader.ID+"'><img alt='' src='"+base_url+"resources/images/app-loader.gif' /></div>";$(a).appendTo("body").fadeIn("fast")};ApplicationLoader.hide=function(){$("#"+ApplicationLoader.ID).fadeOut("fast",function(){$(this).remove()})};ApplicationLoader.ID="app-loader";var Menu=function(a){this.application=a;this.sectionsInitialPosition=$("#"+Menu.ID).outerWidth();this.actualSectionIndex=0;this.firstOpening=true};Menu.prototype={initialize:function(){this.bindResize();this.bindButtons();this.show();this.showSections();this.bindHistory()},bindResize:function(){var a=this;$("#"+this.getId()).height($(window).height());$(window).resize(function(){$("#"+a.getId()).height($(this).height())})},bindButtons:function(){var a=this;$("#"+this.getId()+" #"+this.getButtonsId()+" a").click(function(){$.history.load($(this).attr("href").replace("#",""));return false});$("#"+this.getId()+" #logo").click(function(){$.history.load($(this).attr("href").replace("#",""));return false});$("#"+this.getId()+" #sonido").click(function(){a.application.changeVideoVolume();return false})},changeSoundState:function(){var a=$("#"+this.getId()+" #sonido");if(a.css("background-position")=="96px 0%"){a.css("background-position","96px 100%")}else{a.css("background-position","96px 0%")}},bindHistory:function(){var a=this;$.history.init(a.goToHash,a)},goToHash:function(a){if(a!=""){if(this.firstOpening){this.firstOpening=false;this.showSections(a)}else{this.goToSection(a)}}else{this.firstOpening=false;this.showSections();this.setSelected(this.application.sections[0].id)}},goToSection:function(f){var b=this;this.setSelected(f);var h=this.application.getSectionIndex(f);var d=this.sectionsInitialPosition;var c=h-this.actualSectionIndex;if(c<0){c*=-1}var g=500+(500*c);var a=this.application.sections.length;for(var e=0;e<a;e++){if(e<h&&this.application.sections[e].showed){d-=this.application.sections[e].width}else{if(this.application.sections[e].id==f){this.showSection(f)}}}$("#"+Section.SECTIONS_SLIDER_ID).animate({left:d},g,"easeOutExpo",function(){b.application.bindArrows()});this.actualSectionIndex=h},goToNextSection:function(){var a=this.actualSectionIndex;if(this.application.sections[a+1]!=null){$.history.load(this.application.sections[a+1].id)}},goToPrevSection:function(){var a=this.actualSectionIndex;if(this.application.sections[a-1]!=null){$.history.load(this.application.sections[a-1].id)}},showSection:function(b){var a=this.application.getSectionIndex(b);this.application.sections[a].show()},showSections:function(b){var a=this;$("#"+Section.SECTIONS_SLIDER_ID).delay(1500).animate({left:this.sectionsInitialPosition},3000,"easeOutExpo",function(){if(b!=null){a.goToSection(b)}})},setSelected:function(a){var b=this.application.getSectionIndex(a);this.application.sections[b].setSelected();$("#"+Menu.ID+" li").removeClass("selected");$("#"+Menu.ID+" li a[href=#"+a+"]").parent().addClass("selected")},deselect:function(a){var b=this.application.getSectionIndex(a);this.application.sections[b].deselect();$("#"+Menu.ID+" li").removeClass("selected")},show:function(){$("#"+Menu.ID).delay(1000).animate({left:0},500,"easeOutExpo")},hide:function(){$("#"+Menu.ID).animate({left:-this.sectionsInitialPosition},500,"easeOutExpo")},getId:function(){return Menu.ID},getButtonsId:function(){return Menu.BUTTONS_ID}};Menu.ID="menu";Menu.BUTTONS_ID="buttons";var Section=function(a,b){this.application=a;this.id=b;this.width=$("#"+this.id).outerWidth();this.padding=$("#"+this.id).css("padding");this.showed=true;this.selected=false};Section.prototype={initialize:function(){var a=this;this.adjustSection();$(window).resize(function(){a.adjustSection()});$("body").bind("orientationchange",function(){a.adjustSection()})},bindButtons:function(){var a=this;$("#"+this.id+" ."+Section.CLOSE_BUTTON_CLASS).click(function(){a.hide();return false});$("#"+this.id+" .vscrollerbar").hover(function(){$(this).addClass("vscrollerbar-clicked")},function(){$(this).removeClass("vscrollerbar-clicked")});$("#"+this.id+" .textarea-container").hover(function(){$(".textarea-over",this).show()},function(){$(".textarea-over",this).hide()});fleXenv.fleXcrollMain(this.id+"-slider");this.width=$("#"+this.id).outerWidth()},adjustSection:function(){var b=parseInt($("#"+this.id).css("paddingTop"),10)+parseInt($("#"+this.id).css("paddingBottom"),10);var a=$(window).height()-b;$("#"+this.id).css("height",a);$("#"+this.id+"-slider").css("height",a)},setSelected:function(){for(var a=0;a<this.application.sections.length;a++){this.application.sections[a].deselect()}$("#"+this.id+"-slider").focus();this.selected=true},deselect:function(){this.selected=false},show:function(){$("#"+this.id).animate({width:"show",padding:"show",opacity:"show"},700,"easeOutExpo",function(){fleXenv.updateScrollBars()});this.showed=true},hide:function(){$("#"+this.id).animate({width:"hide",padding:"hide",opacity:"hide"},700,"easeOutExpo");this.showed=false;this.application.components.menu.deselect(this.id)},showLoader:function(){var a="<div class='app-loader'><img alt='' src='"+base_url+"resources/images/app-loader.gif' /></div>";$(a).appendTo("#"+this.id).fadeIn("fast")},hideLoader:function(){$("#"+this.id+" .app-loader").fadeOut("fast",function(){$(this).remove()})},getId:function(){return this.id},getClass:function(){return Section.CLASS}};Section.SECTIONS_SLIDER_ID="sections-slider";Section.SECTIONS_CONTAINER_ID="sections";Section.CLASS="section";Section.LOGO_CLASS="section-logo";Section.CLOSE_BUTTON_CLASS="close";var Contacto=function(a,b){this.base.apply(this,[a,b]);this.formulario=$("#"+this.id+" #formulario").html()};Contacto.prototype={initialize:function(){this.base.prototype.initialize.apply(this);this.bindButtons()},bindButtons:function(){var a=this;this.base.prototype.bindButtons.apply(this);$("#"+this.id+" #contactoForm").submit(function(){var b=$(this);var c=b.serialize();a.showMessage("Enviando mensaje...");$.ajax({type:"POST",url:b.attr("action"),data:c,success:function(d){if(d.success){a.showMessage("El formulario ha sido enviado correctamente.<br /> Muchas gracias por contactarnos, en breve le responderemos.")}else{a.showMessage("Hubo un error al procesar su solicitud, por favor intente nuevamente.<br /><a class='volver'>&lt; volver</a>")}},error:function(){a.showMessage("Hubo un error al procesar su solicitud, por favor intente nuevamente.<br /><a class='volver'>&lt; volver</a>")}});return false})},adjustSection:function(){this.base.prototype.adjustSection.apply(this);var a=$("#"+this.id+" .content");var b=parseInt(a.css("paddingTop"),10);b+=parseInt(a.css("paddingBottom"),10);a.css("height",$(window).height()-b)},showMessage:function(b){$("#"+this.id+" .content #formulario").html("<p class='message'>"+b+"</p>");var a=this;$("#"+this.id+" .content .volver").click(function(){$("#"+a.id+" .content #formulario").html(a.formulario);a.bindButtons()})}};FrizzeUtils.extend(Contacto,Section);var Facebook=function(a,b){this.base.apply(this,[a,b]);this.template=null;this.statuses=null;this.logged=false};Facebook.prototype={initialize:function(){this.base.prototype.initialize.apply(this);this.showLoader();this.loadTemplate()},bindButtons:function(){this.base.prototype.bindButtons.apply(this);var a=this;$("#"+this.id+" .textarea-container").click(function(){window.open(base_url+"index.php/facebookauth/login","facebookLogin","resize=0")});$("#"+this.id+" .megusta").click(function(){var b=$(this).closest(".status").find(".post").attr("id").replace("post","");return false})},loadTemplate:function(){var a=this;$.ajax({type:"GET",dataType:"html",url:base_url+"resources/templates/statuses.html",success:function(b){a.template=$.template("statusesTemplate",b);a.loadStatuses()}})},loadStatuses:function(){var a=this;$.ajax({type:"GET",url:base_url+"index.php/api/facebookservice/statuses/format/json",success:function(c){a.statuses=c.statuses;var b=$.tmpl(a.template,c);$("#"+a.id+" #statuses").prepend(b);$("#"+a.id+" .content").fadeIn("slow");a.bindButtons();a.hideLoader()}})},post:function(b){var a=this;$("#"+this.id+" .sending-over").show("fast");$.ajax({type:"POST",url:base_url+"index.php/api/facebookservice/status/format/json",data:"status="+b,success:function(d){a.statuses.splice(0,0,d.statuses);var c=$.tmpl(a.template,d);$("#"+a.id+" #statuses").prepend(c);$("#"+a.id+" .sending-over").hide("fast")}})},loggedIn:function(){var a=this;this.logged=true;$("#"+this.id+" .textarea-container .textarea-over").remove();$("#"+this.id+" .textarea-container").unbind();$("#"+this.id+" #post-button").click(function(b){a.post($("#"+a.id+" #status_textarea").val());$("#"+a.id+" #status_textarea").val("");return false})}};FrizzeUtils.extend(Facebook,Section);var Frizze=function(a,b){this.base.apply(this,[a,b])};Frizze.prototype={initialize:function(){this.base.prototype.initialize.apply(this);this.bindButtons()},bindButtons:function(){this.base.prototype.bindButtons.apply(this);var a=this;$("#"+this.id+" .share").click(function(){var b="http://www.facebook.com/sharer.php?s=100";b+="&p[url]=http://www.frizze.com.ar";b+="&p[title]="+a.urlencode($(this).parent().find(".title").attr("title"));b+="&p[summary]="+a.urlencode($(this).parent().find(".description").text());b+="&p[images][0]="+$(this).parent().find(".image").attr("src");window.open(b,"frizze");return false})},urlencode:function(g){var c="";var a=0;g=g.toString();var f=/(^[a-zA-Z0-9_.]*)/;while(a<g.length){var d=f.exec(g.substr(a));if(d!=null&&d.length>1&&d[1]!=""){c+=d[1];a+=d[1].length}else{if(g[a]==" "){c+="+"}else{var b=g.charCodeAt(a);var e=b.toString(16);c+="%"+(e.length<2?"0":"")+e.toUpperCase()}a++}}return c}};FrizzeUtils.extend(Frizze,Section);var Twitter=function(a,b){this.base.apply(this,[a,b]);this.template=null;this.tweets=null;this.logged=false};Twitter.prototype={initialize:function(){this.base.prototype.initialize.apply(this);this.showLoader();this.loadTemplate()},bindButtons:function(){this.base.prototype.bindButtons.apply(this);var a=this;$("#"+this.id+" .textarea-container").click(function(){window.open(base_url+"index.php/twitterauth/login","twitterLogin","resize=0")})},loadTemplate:function(){var a=this;$.ajax({type:"POST",dataType:"html",url:base_url+"resources/templates/tweets.html",success:function(b){a.template=$.template("tweetsTemplate",b);a.loadTweets()}})},loadTweets:function(){var a=this;$.ajax({type:"GET",url:base_url+"index.php/api/twitterservice/tweets/format/json",success:function(c){a.tweets=c.tweets;var b=$.tmpl(a.template,c);$("#"+a.id+" #tweets").prepend(b);$("#"+a.id+" .content").fadeIn("slow");a.bindButtons();a.hideLoader()}})},loggedIn:function(){var a=this;this.logged=true;$("#"+this.id+" .textarea-container").unbind();$("#"+this.id+" .textarea-container .textarea-over").remove();$("#"+this.id+" #tweet-button").click(function(b){a.tweet($("#"+a.id+" #tweet_textarea").val());$("#"+a.id+" #tweet_textarea").val("");return false})},tweet:function(b){var a=this;$("#"+this.id+" .sending-over").show("fast");$.ajax({type:"POST",url:base_url+"index.php/api/twitterservice/tweet/format/json",data:"status="+b,success:function(d){a.tweets.splice(0,0,d.tweets);var c=$.tmpl(a.template,d);$("#"+a.id+" #tweets").prepend(c);$("#"+a.id+" .sending-over").hide("fast")}})}};FrizzeUtils.extend(Twitter,Section);var Youtube=function(a,b){this.base.apply(this,[a,b]);this.template=null;this.videos=null};Youtube.prototype={initialize:function(){this.base.prototype.initialize.apply(this);this.showLoader();this.loadTemplate()},loadTemplate:function(){var a=this;$.ajax({type:"GET",dataType:"html",url:base_url+"resources/templates/videos.html",success:function(b){a.template=$.template("videosTemplate",b);a.loadVideos()}})},loadVideos:function(){var a=this;$.ajax({type:"GET",url:base_url+"index.php/api/youtubeservice/videos/format/json",success:function(c){a.videos=c.videos;var b=$.tmpl(a.template,c);$("#"+a.id+" #videos").prepend(b);a.initializePlayer();$("#"+a.id+" .content").fadeIn("slow");a.bindButtons();a.hideLoader()}})},initializePlayer:function(){var a=this.getFirstVideoId();if(FrizzeUtils.isMobile()){$("#videoPlayer").html(this.getPlayerHtml(a))}else{var b={allowScriptAccess:"always",wmode:"transparent",allowFullScreen:"true"};var c={id:"videoPlayer"};swfobject.embedSWF("http://www.youtube.com/v/"+a+"?version=3&amp;hl=es_ES&enablejsapi=1&playerapiid=ytplayer","videoPlayer","465","290","8",null,null,b,c)}this.loadVideoData(a)},bindButtons:function(){this.base.prototype.bindButtons.apply(this);var a=this;$(".video .preview").click(function(){var b=a.getVideoId($(this).parent(".video"));a.changeVideo(b)});$(".video .title").click(function(){var b=a.getVideoId($(this).parent(".video"));a.changeVideo(b)})},changeVideo:function(c){if(FrizzeUtils.isMobile()){$("#videoPlayer").html(this.getPlayerHtml(c))}else{var a=document.getElementById("videoPlayer");a.loadVideoById(c)}this.loadVideoData(c);var b=document.getElementById(this.id+"-slider");b.fleXcroll.setScrollPos(false,0)},loadVideoData:function(b){var a=this.getVideoById(b);$("#"+this.id+" .content .section-subtitle").html(a.title);$("#"+this.id+" .content .meta .user").html(a.author.name);$("#"+this.id+" .content .meta .date").html(a.date);$("#"+this.id+" .content .meta .views").html(a.viewsCount+" views")},getPlayerHtml:function(b){var a='<iframe id="player" type="text/html" width="465" height="290" src="http://www.youtube.com/embed/'+b+'?version=3&amp;hl=es_ES&enablejsapi=1&playerapiid=ytplayer" frameborder="0" allowFullScreen></iframe>';return a},getFirstVideoId:function(){return this.videos[0].id},getVideoById:function(b){for(var a=0;a<this.videos.length;a++){if(this.videos[a].id==b){return this.videos[a]}}},getVideoId:function(a){return a.attr("id").replace("video","")}};FrizzeUtils.extend(Youtube,Section);var Application=function(){this.sections=new Array();this.components=new Object();this.sectionFactory=new SectionFactory(this);this.touchStartPageX=0;this.touchMovePageX=0;this.video=null};Application.prototype={initialize:function(){this.bindLayer()},startApplication:function(){this.initializeSections();this.components.menu=new Menu(this);this.initializeComponents();this.bindBackgroundResize();this.resizeBackgroundVideo();this.bindActions();ApplicationLoader.hide()},initializeSections:function(){var a=this;$("."+Section.CLASS).each(function(){a.sections.push(a.sectionFactory.createSection($(this).attr("id")))});for(var b=0;b<this.sections.length;b++){this.sections[b].initialize()}},initializeComponents:function(){for(componentId in this.components){this.components[componentId].initialize()}},bindActions:function(){var a=this;$(document).keydown(function(c){var b=parseInt((c.keyCode||c.which),10);if((b>=37||b>=37)&&(b<=40||b<=40)){switch(b){case 37:a.components.menu.goToPrevSection();break;case 39:a.components.menu.goToNextSection();break}return false}});$("#"+Section.SECTIONS_CONTAINER_ID).bind("touchstart",function(b){var c=b.originalEvent;a.touchStartPageX=c.targetTouches[0].pageX;return false});$("#"+Section.SECTIONS_CONTAINER_ID).bind("touchmove",function(b){var c=b.originalEvent;a.touchMovePageX=c.targetTouches[0].pageX;return false});$("#"+Section.SECTIONS_CONTAINER_ID).bind("touchend",function(b){var c=(a.touchStartPageX-a.touchMovePageX);if(c<0){c*=-1}if(c>100){if(a.touchStartPageX>a.touchMovePageX){a.components.menu.goToNextSection()}else{if(a.touchStartPageX<a.touchMovePageX){a.components.menu.goToPrevSection()}}}return false});$("body").bind("scroll touchmove",function(){return false});if(navigator.userAgent.match(/Android/i)&&navigator.userAgent.match(/webOS/i)&&navigator.userAgent.match(/(iPhone|iPod|iPad)/i)&&navigator.userAgent.match(/Blackberry/i)){$("#"+Application.CONTAINER+" .flecha-container").remove()}else{$("#"+Application.CONTAINER+" .flecha-container").hover(function(){$(this).find(".flecha").fadeIn("fast")},function(){$(this).find(".flecha").fadeOut("fast")});this.bindArrows()}},bindArrows:function(){var a=this;$("#"+Application.CONTAINER+" #flechaLeft .flecha").unbind().click(function(){a.unbindArrows();a.components.menu.goToPrevSection()});$("#"+Application.CONTAINER+" #flechaRight .flecha").unbind().click(function(){a.unbindArrows();a.components.menu.goToNextSection()})},unbindArrows:function(){$("#"+Application.CONTAINER+" .flecha").unbind()},bindLayer:function(){var a=this;$("#layer").css({width:$(window).width(),height:$(window).height()});$(window).resize(function(){$("#layer").css({width:$(this).width(),height:$(this).height()})});$("body").bind("orientationchange",function(){$("#layer").css({width:$(this).width(),height:$(this).height()})});$("#layerSi").click(function(){ApplicationLoader.show();if(FrizzeUtils.supportVideo()){a.video=document.getElementById("mainVideo");a.video.addEventListener("ended",function(){a.video.currentTime=0.1;a.video.play()},false);a.video.play()}else{setTimeout(function(){a.video=document.getElementById("defaultVideo");a.video.playVideo()},1000)}$("#layer").fadeOut("fast",function(){$(this).remove()});$("#background").fadeIn("slow",function(){a.startApplication()});return false});$("#layerNo").click(function(){return false});this.resizeLayer();$(window).resize(function(){a.resizeLayer()})},bindBackgroundResize:function(){var a=this;$(window).resize(function(){a.resizeBackgroundVideo()});$("body").bind("orientationchange",function(){a.resizeBackgroundVideo()})},changeVideoVolume:function(){if(this.video.canPlayType){if(this.video.volume==1){this.video.volume=0}else{this.video.volume=1}}else{this.video.changeVolume()}this.components.menu.changeSoundState()},resizeLayer:function(){var j=$(window).width();var c=$(window).height();var e=j/c;var b=1920;var d=1200;var g=b/d;if(e>g){var a=(j/b)*d;var f=j}else{var a=c;var f=(c/d)*b}var h=0-((a-c)/2);var i=0-((f-j)/2);$("#layer #layerBack").css({width:f,height:a,top:h,left:i});$("#layer").css({width:j,height:c})},resizeBackgroundVideo:function(){var d=$("#"+Application.BACKGROUND_VIDEO_ID+" video");var k=$(window).width();var c=$(window).height();var f=k/c;var b=1280;var e=720;var h=b/e;if(f>h){var a=(k/b)*e;var g=k}else{var a=c;var g=(c/e)*b}var i=0-((a-c)/2);var j=0-((g-k)/2);$("#"+Section.SECTIONS_CONTAINER_ID).css({width:k,height:c});$("#"+Application.BACKGROUND_VIDEO_ID).css({width:g,height:a,top:i,left:j});$("#"+Application.BACKGROUND_VIDEO_ID+" video").css({width:g,height:a});$("#"+Application.BACKGROUND_VIDEO_ID+" object").attr("width",g).attr("height",a);$("#malla").css({width:k,height:c});$("#"+Menu.ID).css({height:c});$("#"+Application.CONTAINER).css({width:k,height:c})},getSectionIndex:function(b){for(var a=0;a<this.sections.length;a++){if(this.sections[a].id==b){return a}}return 0}};Application.CONTAINER="container";Application.BACKGROUND_VIDEO_ID="backgroundVideo";var SectionFactory=function(a){this.application=a};SectionFactory.prototype={createSection:function(b){var a;switch(b){case SectionFactory.EVOLUTION:a=new Evolution(this.application,b);break;case SectionFactory.FRIZZE:a=new Frizze(this.application,b);break;case SectionFactory.FACEBOOK:a=new Facebook(this.application,b);break;case SectionFactory.TWITTER:a=new Twitter(this.application,b);break;case SectionFactory.YOUTUBE:a=new Youtube(this.application,b);break;case SectionFactory.CONTACTO:a=new Contacto(this.application,b);break}return a}};SectionFactory.EVOLUTION="evolution";SectionFactory.FRIZZE="frizze";SectionFactory.FACEBOOK="facebook";SectionFactory.TWITTER="twitter";SectionFactory.YOUTUBE="youtube";SectionFactory.CONTACTO="contacto";jQuery.fx.interval=30;var app=new Application();function startApp(a){if(a==1){app.startApplication()}}function onYouTubePlayerReady(a){if(a==Application.BACKGROUND_VIDEO_ID){var b=document.getElementById(Application.BACKGROUND_VIDEO_ID);b.addEventListener("onStateChange","startApp")}}$(document).ready(function(){app.initialize()});
