// jquery.jparallax.js
// 0.9.1
// Stephen Band
//
// Dependencies:
// jQuery 1.2.6 (jquery.com)
//
// Project and documentation site:
// http://webdev.stephband.info/parallax.html
(function(jQuery){function stripFiletype(ref){var x=ref.replace('.html','');return x.replace('#','')}function initOrigin(l){if(l.xorigin=='left'){l.xorigin=0}else if(l.xorigin=='middle'||l.xorigin=='centre'||l.xorigin=='center'){l.xorigin=0.5}else if(l.xorigin=='right'){l.xorigin=1}if(l.yorigin=='top'){l.yorigin=0}else if(l.yorigin=='middle'||l.yorigin=='centre'||l.yorigin=='center'){l.yorigin=0.5}else if(l.yorigin=='bottom'){l.yorigin=1}}function positionMouse(mouseport,localmouse,virtualmouse){var difference={x:0,y:0,sum:0};if(!mouseport.ontarget){difference.x=virtualmouse.x-localmouse.x;difference.y=virtualmouse.y-localmouse.y;difference.sum=Math.sqrt(difference.x*difference.x+difference.y*difference.y);virtualmouse.x=localmouse.x+difference.x*mouseport.takeoverFactor;virtualmouse.y=localmouse.y+difference.y*mouseport.takeoverFactor;if(difference.sum<mouseport.takeoverThresh&&difference.sum>mouseport.takeoverThresh*-1){mouseport.ontarget=true}}else{virtualmouse.x=localmouse.x;virtualmouse.y=localmouse.y}}function setupPorts(viewport,mouseport){var offset=mouseport.element.offset();jQuery.extend(viewport,{width:viewport.element.width(),height:viewport.element.height()});jQuery.extend(mouseport,{width:mouseport.element.width(),height:mouseport.element.height(),top:offset.top,left:offset.left})}function parseTravel(travel,origin,dimension){var offset;var cssPos;if(typeof(travel)==='string'){if(travel.search(/^\d+\s?px$/)!=-1){travel=travel.replace('px','');travel=parseInt(travel,10);offset=origin*(dimension-travel);cssPos=origin*100+'%';return{travel:travel,travelpx:true,offset:offset,cssPos:cssPos}}else if(travel.search(/^\d+\s?%$/)!=-1){travel.replace('%','');travel=parseInt(travel,10)/100}else{travel=1}}offset=origin*(1-travel);return{travel:travel,travelpx:false,offset:offset}}function setupLayer(layer,i,mouseport){var xStuff;var yStuff;var cssObject={};layer[i]=jQuery.extend({},{width:layer[i].element.width(),height:layer[i].element.height()},layer[i]);xStuff=parseTravel(layer[i].xtravel,layer[i].xorigin,layer[i].width);yStuff=parseTravel(layer[i].ytravel,layer[i].yorigin,layer[i].height);jQuery.extend(layer[i],{diffxrat:mouseport.width/(layer[i].width-mouseport.width),diffyrat:mouseport.height/(layer[i].height-mouseport.height),xtravel:xStuff.travel,ytravel:yStuff.travel,xtravelpx:xStuff.travelpx,ytravelpx:yStuff.travelpx,xoffset:xStuff.offset,yoffset:yStuff.offset});if(xStuff.travelpx){cssObject.left=xStuff.cssPos}if(yStuff.travelpx){cssObject.top=yStuff.cssPos}if(xStuff.travelpx||yStuff.travelpx){layer[i].element.css(cssObject)}}function setupLayerContents(layer,i,viewportOffset){var contentOffset;jQuery.extend(layer[i],{content:[]});for(var n=0;n<layer[i].element.children().length;n++){if(!layer[i].content[n])layer[i].content[n]={};if(!layer[i].content[n].element)layer[i].content[n]['element']=layer[i].element.children().eq(n);if(!layer[i].content[n].anchor&&layer[i].content[n].element.children('a').attr('name')){layer[i].content[n]['anchor']=layer[i].content[n].element.children('a').attr('name')}if(layer[i].content[n].anchor){contentOffset=layer[i].content[n].element.offset();jQuery.extend(layer[i].content[n],{width:layer[i].content[n].element.width(),height:layer[i].content[n].element.height(),x:contentOffset.left-viewportOffset.left,y:contentOffset.top-viewportOffset.top});jQuery.extend(layer[i].content[n],{posxrat:(layer[i].content[n].x+layer[i].content[n].width/2)/layer[i].width,posyrat:(layer[i].content[n].y+layer[i].content[n].height/2)/layer[i].height})}}}function moveLayers(layer,xratio,yratio){var xpos;var ypos;var cssObject;for(var i=0;i<layer.length;i++){xpos=layer[i].xtravel*xratio+layer[i].xoffset;ypos=layer[i].ytravel*yratio+layer[i].yoffset;cssObject={};if(layer[i].xparallax){if(layer[i].xtravelpx){cssObject.marginLeft=xpos*-1+'px'}else{cssObject.left=xpos*100+'%';cssObject.marginLeft=xpos*layer[i].width*-1+'px'}}if(layer[i].yparallax){if(layer[i].ytravelpx){cssObject.marginTop=ypos*-1+'px'}else{cssObject.top=ypos*100+'%';cssObject.marginTop=ypos*layer[i].height*-1+'px'}}layer[i].element.css(cssObject)}}jQuery.fn.jparallax=function(options){var settings=jQuery().extend({},jQuery.fn.jparallax.settings,options);var settingsLayer={xparallax:settings.xparallax,yparallax:settings.yparallax,xorigin:settings.xorigin,yorigin:settings.yorigin,xtravel:settings.xtravel,ytravel:settings.ytravel};var settingsMouseport={element:settings.mouseport,takeoverFactor:settings.takeoverFactor,takeoverThresh:settings.takeoverThresh};if(settings.mouseport)settingsMouseport['element']=settings.mouseport;var layersettings=[];for(var a=1;a<arguments.length;a++){layersettings.push(jQuery.extend({},settingsLayer,arguments[a]))}return this.each(function(){var localmouse={x:0.5,y:0.5};var virtualmouse={x:0.5,y:0.5};var timer={running:false,frame:settings.frameDuration,fire:function(x,y){positionMouse(mouseport,localmouse,virtualmouse);moveLayers(layer,virtualmouse.x,virtualmouse.y);this.running=setTimeout(function(){if(localmouse.x!=x||localmouse.y!=y||!mouseport.ontarget){timer.fire(localmouse.x,localmouse.y)}else if(timer.running){timer.running=false}},timer.frame)}};var viewport={element:jQuery(this)};var mouseport=jQuery.extend({},{element:viewport.element},settingsMouseport,{xinside:false,yinside:false,active:false,ontarget:false});var layer=[];function matrixSearch(layer,ref,callback){for(var i=0;i<layer.length;i++){var gotcha=false;for(var n=0;n<layer[i].content.length;n++){if(layer[i].content[n].anchor==ref){callback(i,n);return[i,n]}}}return false}setupPorts(viewport,mouseport);for(var i=0;i<viewport.element.children().length;i++){layer[i]=jQuery.extend({},settingsLayer,layersettings[i],{element:viewport.element.children('*:eq('+i+')')});setupLayer(layer,i,mouseport);if(settings.triggerResponse){setupLayerContents(layer,i,viewport.element.offset())}}viewport.element.children().css('position','absolute');moveLayers(layer,0.5,0.5);if(settings.mouseResponse){jQuery().mousemove(function(mouse){mouseport.xinside=(mouse.pageX>=mouseport.left&&mouse.pageX<mouseport.width+mouseport.left)?true:false;mouseport.yinside=(mouse.pageY>=mouseport.top&&mouse.pageY<mouseport.height+mouseport.top)?true:false;if(mouseport.xinside&&mouseport.yinside&&!mouseport.active){mouseport.ontarget=false;mouseport.active=true}if(mouseport.active){if(mouseport.xinside){localmouse.x=(mouse.pageX-mouseport.left)/mouseport.width}else{localmouse.x=(mouse.pageX<mouseport.left)?0:1}if(mouseport.yinside){localmouse.y=(mouse.pageY-mouseport.top)/mouseport.height}else{localmouse.y=(mouse.pageY<mouseport.top)?0:1}}if(mouseport.xinside&&mouseport.yinside){if(!timer.running)timer.fire(localmouse.x,localmouse.y)}else if(mouseport.active){mouseport.active=false}})}if(settings.triggerResponse){viewport.element.bind("jparallax",function(event,ref){ref=stripFiletype(ref);matrixSearch(layer,ref,function(i,n){localmouse.x=layer[i].content[n].posxrat*(layer[i].diffxrat+1)-(0.5*layer[i].diffxrat);localmouse.y=layer[i].content[n].posyrat*(layer[i].diffyrat+1)-(0.5*layer[i].diffyrat);if(!settings.triggerExposesEdges){if(localmouse.x<0)localmouse.x=0;if(localmouse.x>1)localmouse.x=1;if(localmouse.y<0)localmouse.y=0;if(localmouse.y>1)localmouse.y=1}mouseport.ontarget=false;if(!timer.running)timer.fire(localmouse.x,localmouse.y)})})}jQuery(window).resize(function(){setupPorts(viewport,mouseport);for(var i=0;i<layer.length;i++){setupLayer(layer,i,mouseport)}})})};jQuery.fn.jparallax.settings={mouseResponse:true,mouseActiveOutside:false,triggerResponse:true,triggerExposesEdges:false,xparallax:true,yparallax:true,xorigin:0.5,yorigin:0.5,xtravel:1,ytravel:1,takeoverFactor:0.65,takeoverThresh:0.002,frameDuration:25};initOrigin(jQuery.fn.jparallax.settings);jQuery(function(){})})(jQuery);

/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);

/**
 * jQuery.LocalScroll - Animated scrolling navigation, using anchors.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 3/11/2009
 * @author Ariel Flesler
 * @version 1.2.7
 **/
;(function($){var l=location.href.replace(/#.*/,'');var g=$.localScroll=function(a){$('body').localScroll(a)};g.defaults={duration:1e3,axis:'y',event:'click',stop:true,target:window,reset:true};g.hash=function(a){if(location.hash){a=$.extend({},g.defaults,a);a.hash=false;if(a.reset){var e=a.duration;delete a.duration;$(a.target).scrollTo(0,a);a.duration=e}i(0,location,a)}};$.fn.localScroll=function(b){b=$.extend({},g.defaults,b);return b.lazy?this.bind(b.event,function(a){var e=$([a.target,a.target.parentNode]).filter(d)[0];if(e)i(a,e,b)}):this.find('a,area').filter(d).bind(b.event,function(a){i(a,this,b)}).end().end();function d(){return!!this.href&&!!this.hash&&this.href.replace(this.hash,'')==l&&(!b.filter||$(this).is(b.filter))}};function i(a,e,b){var d=e.hash.slice(1),f=document.getElementById(d)||document.getElementsByName(d)[0];if(!f)return;if(a)a.preventDefault();var h=$(b.target);if(b.lock&&h.is(':animated')||b.onBefore&&b.onBefore.call(b,a,f,h)===false)return;if(b.stop)h.stop(true);if(b.hash){var j=f.id==d?'id':'name',k=$('<a> </a>').attr(j,d).css({position:'absolute',top:$(window).scrollTop(),left:$(window).scrollLeft()});f[j]='';$('body').prepend(k);location=e.hash;k.remove();f[j]=d}h.scrollTo(f,b).trigger('notify.serialScroll',[f])}})(jQuery);

/*
 * jQuery.SerialScroll - Animated scrolling of series
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 06/14/2009
 * @author Ariel Flesler
 * @version 1.2.2
 * http://flesler.blogspot.com/2008/02/jqueryserialscroll.html
 */
;(function(a){var b=a.serialScroll=function(c){return a(window).serialScroll(c)};b.defaults={duration:1e3,axis:"x",event:"click",start:0,step:1,lock:!0,cycle:!0,constant:!0};a.fn.serialScroll=function(c){return this.each(function(){var t=a.extend({},b.defaults,c),s=t.event,i=t.step,r=t.lazy,e=t.target?this:document,u=a(t.target||this,e),p=u[0],m=t.items,h=t.start,g=t.interval,k=t.navigation,l;if(!r){m=d()}if(t.force){f({},h)}a(t.prev||[],e).bind(s,-i,q);a(t.next||[],e).bind(s,i,q);if(!p.ssbound){u.bind("prev.serialScroll",-i,q).bind("next.serialScroll",i,q).bind("goto.serialScroll",f)}if(g){u.bind("start.serialScroll",function(v){if(!g){o();g=!0;n()}}).bind("stop.serialScroll",function(){o();g=!1})}u.bind("notify.serialScroll",function(x,w){var v=j(w);if(v>-1){h=v}});p.ssbound=!0;if(t.jump){(r?u:d()).bind(s,function(v){f(v,j(v.target))})}if(k){k=a(k,e).bind(s,function(v){v.data=Math.round(d().length/k.length)*k.index(this);f(v,this)})}function q(v){v.data+=h;f(v,this)}function f(B,z){if(!isNaN(z)){B.data=z;z=p}var C=B.data,v,D=B.type,A=t.exclude?d().slice(0,-t.exclude):d(),y=A.length,w=A[C],x=t.duration;if(D){B.preventDefault()}if(g){o();l=setTimeout(n,t.interval)}if(!w){v=C<0?0:y-1;if(h!=v){C=v}else{if(!t.cycle){return}else{C=y-v-1}}w=A[C]}if(!w||t.lock&&u.is(":animated")||D&&t.onBefore&&t.onBefore(B,w,u,d(),C)===!1){return}if(t.stop){u.queue("fx",[]).stop()}if(t.constant){x=Math.abs(x/i*(h-C))}u.scrollTo(w,x,t).trigger("notify.serialScroll",[C])}function n(){u.trigger("next.serialScroll")}function o(){clearTimeout(l)}function d(){return a(m,p)}function j(w){if(!isNaN(w)){return w}var x=d(),v;while((v=x.index(w))==-1&&w!=p){w=w.parentNode}return v}})}})(jQuery);

/**
 * jQuery multi Coda Slider - Easy element scrolling using jQuery.
 * Copyright (c) 2008 Paco Toledo - pacotole(at)gmail(dot)com | http://www.milrayas.com
 * Licensed under GPL.
 * Date: 15/9/2008
 * @author Paco Toledo
 * @version 1.0
 *
 * based on Coda Slider Effect on http://jqueryfordesigners.com/coda-slider-effect/
 */
jQuery.fn.codaSlider=function(i){i=jQuery.extend({horizontal:true},i);return this.each(function(){var c=$(this);var d=c.find('.scroll');var e=c.find('.scroll li');var f=c.find('.scroll ul');f.width(f.width()*e.length);function selectNav(){$(this).parents('ul').find('a').removeClass('selected').end().end().addClass('selected')}c.find('.navigation ul a').click(selectNav);function trigger(a){var b=c.find('.navigation a[href$="'+a.id+'"]').get(0);selectNav.call(b)}c.find('.navigation ul a:first').click();var g=parseInt(f.css('paddingTop')||0)*-1;var h={target:d,items:e,navigation:'.navigation ul a',prev:'a.left',next:'a.right',axis:'x',onAfter:trigger,offset:g,duration:500,easing:'swing'};c.serialScroll(h)})}

/* ------------------------------------------------------------------------
	prettyCheckboxes

	Developped By: Stephane Caron (http://www.no-margin-for-errors.com)
	Inspired By: All the non user friendly custom checkboxes solutions ;)
	Version: 1.1

	Copyright: Feel free to redistribute the script/modify it, as
			   long as you leave my infos at the top.
------------------------------------------------------------------------- */
jQuery.fn.prettyCheckboxes=function(a){a=jQuery.extend({checkboxWidth:12,checkboxHeight:17,className:"prettyCheckbox",display:"list"},a);$(this).each(function(){$label=$('label[for="'+$(this).attr("id")+'"]');$label.prepend("<span class='holderWrap'><span class='holder'></span></span>");if($(this).is(":checked")){$label.addClass("checked")}$label.addClass(a.className).addClass($(this).attr("type")).addClass(a.display);$label.find("span.holderWrap").width(a.checkboxWidth).height(a.checkboxHeight);$label.find("span.holder").width(a.checkboxWidth);$(this).addClass("hiddenCheckbox");$label.bind("click",function(){$("input#"+$(this).attr("for")).triggerHandler("click");if($("input#"+$(this).attr("for")).is(":checkbox")){$(this).toggleClass("checked");$("input#"+$(this).attr("for")).checked=true;$(this).find("span.holder").css("top",0)}else{$toCheck=$("input#"+$(this).attr("for"));$('input[name="'+$toCheck.attr("name")+'"]').each(function(){$('label[for="'+$(this).attr("id")+'"]').removeClass("checked")});$(this).addClass("checked");$toCheck.checked=true}});$("input#"+$label.attr("for")).bind("keypress",function(b){if(b.keyCode==32){if($.browser.msie){$('label[for="'+$(this).attr("id")+'"]').toggleClass("checked")}else{$(this).trigger("click")}return false}})})};checkAllPrettyCheckboxes=function(b,a){if($(b).is(":checked")){$(a).find("input[type=checkbox]:not(:checked)").each(function(){$('label[for="'+$(this).attr("id")+'"]').trigger("click");if($.browser.msie){$(this).attr("checked","checked")}else{$(this).trigger("click")}})}else{$(a).find("input[type=checkbox]:checked").each(function(){$('label[for="'+$(this).attr("id")+'"]').trigger("click");if($.browser.msie){$(this).attr("checked","")}else{$(this).trigger("click")}})}};

/**
 * milrayas javascript
 * http://www.milrayas.com
 */
is_IE='\v'=='v';
email_reg=/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.([a-z]){2,4})$/
function load_proy(data){$('#our_work').append(data);li=$('#our_work').find('li.loaded');li.find('a').hover(function(){this.over=true;e=this;setTimeout("if(e.over) $(e).stop().animate({'marginTop':'-43px'},200);",200)},function(){this.over=false;$(this).stop().animate({'marginTop':'0px'},200)});$('#our_work').animate({height:'+='+(Math.ceil(li.length/3)*226)},1000,function(){li.fadeIn().removeClass('loaded')});if($('.endpage').length>0)$('#div_more').hide();else{$('#div_more a').show().parent().removeClass('loading');$('#div_more .loading').hide()}}$(document).ready(function(){$('body').addClass('js');if(is_IE)$('body').addClass('ie');if(!is_IE){$('h1 a').each(function(){$(this).html('<span>'+$(this).text()+'</span>')}).hover(function(){$(this).find('span').stop().animate({'opacity':1},200)},function(){$(this).find('span').stop().animate({'opacity':0},1200)});$('.lateral a').each(function(){$(this).html('<span>'+$(this).text()+'</span>')}).hover(function(){$(this).find('span').stop().animate({'opacity':1},200)},function(){$(this).find('span').stop().animate({'opacity':0},200)})}$('#our_work a').hover(function(){this.over=true;e=this;setTimeout("if(e.over) $(e).stop().animate({'marginTop':'-43px'},200);",200)},function(){this.over=false;$(this).stop().animate({'marginTop':'0px'},200)});$('#outstanding').codaSlider();outstanding_hover=false;$('#outstanding').hover(function(){outstanding_hover=true},function(){outstanding_hover=false});setInterval("if (!outstanding_hover) $('.scrollButtons.right').click();",8000);$('#top_bg ul').jparallax({linkResponse:false,yparallax:false,frameDuration:40,mouseport:$('#page')},{},{xtravel:-1},{},{},{xtravel:-1});if($('#tag_submenu').length==1)$('#tag_order').selectReplace({onchange:function(){$('#tag_submenu .list').hide();$('#'+$('#tag_order').val()+'_list').fadeIn(400)}});$.localScroll({filter:'.lateral a.top, #menu a'});if($('#div_more').length>0){$('#div_more a').click(function(){$(this).hide().parent().addClass('loading');$('#div_more .loading').fadeIn();var url=this.href.split('/');for(i=0;i<url.length;i++)if(url[i]=='work')j=i+1;var n=$('#our_work li').length;if(url[j]=='pag')data={'action':url[j],'items':n};else data={'action':url[j],'value':url[j+1],'items':n};$.get('mod_proyectos_ajax.php',data,load_proy);return false})}$('#love a').click(function(){$.get('mod_proyectos_ajax.php',{'action':'ilove','value':$(this).attr('href').substr(1)},function(data){if(!isNaN(data)&&data>0){$('#love').find('span').html(data);$('#love').find('a').replaceWith('<span>milgracias</span>')}else $('#love').find('a').replaceWith('<span title="Se ha producido un error">arrea!</span>')});return false});$('#accept').prettyCheckboxes();$('#newsletter .txt').focus(function(){if(this.value=='your@email.com')this.value=''}).blur(function(){if(this.value=='')this.value='your@email.com'});$('#newsletter').submit(function(){email=$('#newsletter .txt').val();if(email=='your@email.com'){alert('Escribe tu dirección de email.');return false}else if(!email_reg.test(email)){alert('Escribe una dirección de email válida.');return false}else if(!$('#accept').is(':checked')){alert('Debes aceptar los Términos.');return false}else return true});$('a.blank, a[rel=external]').attr('target','_blank')});


