//home page ticker
///////////////////////
function homeList() {
	
	//transition speed
	speed = 200;
	//delay before next transition
	delay = 3000;
	//total image count
	total = $('#homeList li').size();
	//current count
	count = 1
	//hover status
	isHovered = false;
	//more info panel status
	isVisible = false;
	
	//set the initial opacity
	$('#homeList li a').css("opacity","0.1");
	$('#homeList li:first-child a').css("opacity","1");
	$('span.more').hide();
	
	//start the interval
	var swapInt = 0;
	swapInt = setInterval ( "swapItem()", delay );
	
	//hover
	$('#homeList li a').hover(function() { //mouse in 
		//if a panel is open, don't run
		if(isVisible == false) {
			//set the hover status
			isHovered = true;
			//set the existing opacity
			currentOpacity = $(this).css("opacity");
			//max the opacity
			$(this).animate({opacity: '1'}, speed); 
			//set the message based on whether or not there is content to show
			if ( $(".es").length > 0 ) {
				if($(this).parent().find("div.details").length > 0){
					$(this).prepend('<span class="more"><span>Haz Click Para Ampliar &gt;</span></span>');
				}else{
					$(this).prepend('<span class="more"><span>Haz Click Para Más Información &gt;</span></span>');
				}
			}else{
				if($(this).parent().find("div.details").length > 0){
					$(this).prepend('<span class="more"><span>Click to Expand &gt;</span></span>');
				}else{
					$(this).prepend('<span class="more"><span>Click for More &gt;</span></span>');
				}
			}
			$(this).find('span.more').hide();
			$(this).find('span.more').fadeIn('fast');
		}
	  }, function() { //mouse out 
		//if a panel is open, don't run
		if(isVisible == false) {
			//othersite set the hover status, fade it, and remove the span
			isHovered = false;
		    $(this).animate({opacity: currentOpacity}, speed); 
			//$(this).find('span.more').fadeOut('fast');
			$(this).find('span.more').fadeOut('fast',function(){$(this).remove();});
		}
	});
	
	//click
	$('#homeList li a').click(function(event) {	
		//do nothing unless there is content to show
		if($(this).parent().find("div.details").length > 0){
			event.preventDefault();
			//if a panle isn't visible
			if(isVisible == false){
				//set the status
				isVisible = true;
				//this makes the hover state "stick"
				$(this).addClass("current");
				//show the details block
				$(this).parent().find("div.details").slideDown("fast");
				//replace the text label
				$(this).find('span.more').remove();
				if ( $(".es").length > 0 ) {
					$(this).prepend('<span class="more"><span>Click to Close (es)</span></span>');
				}else{
					$(this).prepend('<span class="more"><span>Click to Close</span></span>');
				}
			//otherwise if it is visible	
			}else{
				isVisible = false;
				$(this).removeClass("current");
				$(this).parent().find("div.details").slideUp("fast");
				$(this).find('span.more').fadeOut('fast',function(){$(this).remove();});
			}
		}
	});
	
}

function swapItem() {
	//if the span exists, a list item is being hovered over, so don't change
	if ( isHovered == false && isVisible == false ) {
		if(count == total){
			//reset the count
			count = 1;
			//reset all but the current item
			$('#homeList li:not(:nth-child('+count+')) a').animate({opacity: '0.1', paddingTop: '4px', paddingBottom: '4px'}, speed*2);
			//set the current item
			$('#homeList li:nth-child(1) a').animate({opacity: '1', paddingTop: '20px', paddingBottom: '20px'}, speed);
		}else{
			//increment the count
			count ++;
			//reset all but the current item
			$('#homeList li:not(:nth-child('+count+')) a').animate({opacity: '0.1', paddingTop: '4px', paddingBottom: '4px'}, speed*2);
			//set the current item
			$('#homeList li:nth-child('+count+') a').animate({opacity: '1', paddingTop: '20px', paddingBottom: '20px'}, speed);
		}
	}
}
///////////////////////


//Nav Animation
///////////////////////
function animateNav() {
	$('#nav-primary li a').hover(function() { //mouse in 
	$(this).stop().animate({ paddingTop: '10px', paddingBottom: '8px' }, 200); 
	  }, function() { //mouse out 
	    $(this).stop().animate({ paddingTop: '2px', paddingBottom: '2px' }, 300); 
	});	
}	
///////////////////////


//Scalable Background
///////////////////////
function bgImages() {
	// eliminate scaling background for mobile
	if(window.orientation){
		$('.super-single').remove();
	}

	//rotating background
	if ( $(".super-group").length > 0 ) {		
		$.fn.supersized.options = {  
			startwidth: 10,  
			startheight: 8,
			vertical_center: 1,
			slideshow: 1,
			transition: 1,
			slide_interval: 6000  
		};
	    $('#supersize').supersized();
	}
	//static background
	if ( $(".super-single").length > 0 ) {		
		$.fn.supersized.options = {  
			startwidth: 10,  
			startheight: 8,
			vertical_center: 1,
			slideshow: 0
		};
	    $('#supersize').supersized();
	}
}	
///////////////////////


//Shadow Frame
///////////////////////
function loadShadow(){
	//don't load the frame for browsers without opacity support
	if (jQuery.support.opacity == true) {
		$('#wrapper').before('<div id="frame"><div class="s"></div><div class="t"><div class="l"></div><div class="r"></div></div><div class="b"><div class="l"></div><div class="r"></div></div></div>');
	}	
}
///////////////////////


//tool tips
///////////////////////
function toolTip() {
	//Select all anchor tag with rel set to tooltip
	$('.tip').mouseover(function(e) {
		//Grab the title attribute's value and assign it to a variable
		var tip = $(this).attr('title');	
		//Remove the title attribute's to avoid the native tooltip from the browser
		$(this).attr('title','');
		//Append the tooltip template and its value
		$(this).append('<div id="tooltip"><div class="tipBody">' + tip + '</div></div>');		
		//Show the tooltip with faceIn effect
		$('#tooltip').fadeIn('500');
		$('#tooltip').fadeTo('10',0.9);
	}).mousemove(function(e) {
		//Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
		$('#tooltip').css('top', e.pageY + 10 );
		$('#tooltip').css('left', e.pageX + 20 );
	}).mouseout(function() {
		//Put back the title attribute's value
		$(this).attr('title',$('.tipBody').html());
		//Remove the appended tooltip template
		$(this).children('div#tooltip').remove();
	});
}
///////////////////////


//tabs plus hash
///////////////////////
function hashTabs(){
	if ( $("div.tabs").length > 0 ) {
		var tabContainers = $('div.tabs > div');
		tabContainers.hide().filter(':first').show();

		$(window).bind('hashchange', function () {
			//grab the hash in the URL or the hash from the first tab if it's not present
			var hash = window.location.hash || $('div.tabs ul.nav-sub li:first a').attr("href");
			tabContainers.hide();
			tabContainers.filter(hash).show();
			//set the nav state
			$('div.tabs ul.nav-sub li').removeClass('current');
			$('a[hash=' + hash + ']').parent().addClass('current');
		});

		$(window).trigger("hashchange");
	}
}
///////////////////////


//accordion plus hash
///////////////////////

function hashAccordion() {
	if ( $(".accordion").length > 0 ) {
		
		var accordion = $('div.accordion');
		
		//hide the content blocks
		accordion.children('.accordion-body').hide();
		
		$('.accordion-nav a').click(function () {
			var hash = window.location.hash;
			//if there is a hash...
			if(hash != ""){
				//if the current hash is the same as the anchor just clicked...
				if(hash == $(this).attr("href")){
					//close it
					accordion.children('.accordion-body').slideUp(300);
					//remove the link class
					$('.accordion-nav a').removeClass('current');
					//clear the hash
					window.location.hash = "null";
		            return false;
				}
			}
	    })
		
		//when the hash has changed...
		$(window).bind('hashchange', function () {
			//grab the hash in the URL
			var hash = window.location.hash;
			
			//if there is a hash, open a panel
			if(hash != ""){
				accordion.children(hash).slideDown(300).siblings('.accordion-body:visible').slideUp(300);
				$('.accordion-nav a').removeClass('current');
				$('.accordion-nav a[hash=' + hash + ']').addClass('current');
			}
		});

//this sets it to start at once
		$(window).trigger("hashchange");
	}
}

///////////////////////


//Google Analytics
///////////////////////
function trackPage() {
	var _gaq = _gaq || [];
	_gaq.push(['_setAccount', 'UA-17249820-1']);
	_gaq.push(['_trackPageview']);

	(function() {
		var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
		ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
		var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
	})();
}
///////////////////////


//Ready
///////////////////////

$(document).ready(function() {
	animateNav();
	homeList();
	bgImages();
	loadShadow();
	toolTip();
	hashTabs();
	hashAccordion();
	//trackPage();
	$(".zoom").colorbox({transition:'fade', speed:300, opacity:0.7});
	$("#signUp").colorbox({width:"50%", height:"50%", inline:true, href:"#subForm"});
	$(".modal").colorbox();
	//$("#signUp").colorbox({inline:true, href:"#subForm"});
	$('.slides').cycle()
});

///////////////////////


//start plugins
////////////////////////


/*
jQuery hashchange event - v1.2 - 2/11/2010
http://benalman.com/projects/jquery-hashchange-plugin/
Copyright (c) 2010 "Cowboy" Ben Alman
Dual licensed under the MIT and GPL licenses.
http://benalman.com/about/license/
 */
(function($,i,b){var j,k=$.event.special,c="location",d="hashchange",l="href",f=$.browser,g=document.documentMode,h=f.msie&&(g===b||g<8),e="on"+d in i&&!h;function a(m){m=m||i[c][l];return m.replace(/^[^#]*#?(.*)$/,"$1")}$[d+"Delay"]=100;k[d]=$.extend(k[d],{setup:function(){if(e){return false}$(j.start)},teardown:function(){if(e){return false}$(j.stop)}});j=(function(){var m={},r,n,o,q;function p(){o=q=function(s){return s};if(h){n=$('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this);


/*
 * jQuery Cycle Lite Plugin
 * http://malsup.com/jquery/cycle/lite/
 * Copyright (c) 2008 M. Alsup
 * Version: 1.0 (06/08/2008)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Requires: jQuery v1.2.3 or later
 */
;(function($){var ver='Lite-1.0';$.fn.cycle=function(options){return this.each(function(){options=options||{};if(this.cycleTimeout)clearTimeout(this.cycleTimeout);this.cycleTimeout=0;this.cyclePause=0;var $cont=$(this);var $slides=options.slideExpr?$(options.slideExpr,this):$cont.children();var els=$slides.get();if(els.length<2){if(window.console&&window.console.log)
window.console.log('terminating; too few slides: '+els.length);return;}
var opts=$.extend({},$.fn.cycle.defaults,options||{},$.metadata?$cont.metadata():$.meta?$cont.data():{});opts.before=opts.before?[opts.before]:[];opts.after=opts.after?[opts.after]:[];opts.after.unshift(function(){opts.busy=0;});var cls=this.className;opts.width=parseInt((cls.match(/w:(\d+)/)||[])[1])||opts.width;opts.height=parseInt((cls.match(/h:(\d+)/)||[])[1])||opts.height;opts.timeout=parseInt((cls.match(/t:(\d+)/)||[])[1])||opts.timeout;if($cont.css('position')=='static')
$cont.css('position','relative');if(opts.width)
$cont.width(opts.width);if(opts.height&&opts.height!='auto')
$cont.height(opts.height);var first=0;$slides.css({position:'absolute',top:0,left:0}).hide().each(function(i){$(this).css('z-index',els.length-i)});$(els[first]).css('opacity',1).show();if($.browser.msie)els[first].style.removeAttribute('filter');if(opts.fit&&opts.width)
$slides.width(opts.width);if(opts.fit&&opts.height&&opts.height!='auto')
$slides.height(opts.height);if(opts.pause)
$cont.hover(function(){this.cyclePause=1;},function(){this.cyclePause=0;});$.fn.cycle.transitions.fade($cont,$slides,opts);$slides.each(function(){var $el=$(this);this.cycleH=(opts.fit&&opts.height)?opts.height:$el.height();this.cycleW=(opts.fit&&opts.width)?opts.width:$el.width();});$slides.not(':eq('+first+')').css({opacity:0});if(opts.cssFirst)
$($slides[first]).css(opts.cssFirst);if(opts.timeout){if(opts.speed.constructor==String)
opts.speed={slow:600,fast:200}[opts.speed]||400;if(!opts.sync)
opts.speed=opts.speed/2;while((opts.timeout-opts.speed)<250)
opts.timeout+=opts.speed;}
opts.speedIn=opts.speed;opts.speedOut=opts.speed;opts.slideCount=els.length;opts.currSlide=first;opts.nextSlide=1;var e0=$slides[first];if(opts.before.length)
opts.before[0].apply(e0,[e0,e0,opts,true]);if(opts.after.length>1)
opts.after[1].apply(e0,[e0,e0,opts,true]);if(opts.click&&!opts.next)
opts.next=opts.click;if(opts.next)
$(opts.next).bind('click',function(){return advance(els,opts,opts.rev?-1:1)});if(opts.prev)
$(opts.prev).bind('click',function(){return advance(els,opts,opts.rev?1:-1)});if(opts.timeout)
this.cycleTimeout=setTimeout(function(){go(els,opts,0,!opts.rev)},opts.timeout+(opts.delay||0));});};function go(els,opts,manual,fwd){if(opts.busy)return;var p=els[0].parentNode,curr=els[opts.currSlide],next=els[opts.nextSlide];if(p.cycleTimeout===0&&!manual)
return;if(manual||!p.cyclePause){if(opts.before.length)
$.each(opts.before,function(i,o){o.apply(next,[curr,next,opts,fwd]);});var after=function(){if($.browser.msie)
this.style.removeAttribute('filter');$.each(opts.after,function(i,o){o.apply(next,[curr,next,opts,fwd]);});};if(opts.nextSlide!=opts.currSlide){opts.busy=1;$.fn.cycle.custom(curr,next,opts,after);}
var roll=(opts.nextSlide+1)==els.length;opts.nextSlide=roll?0:opts.nextSlide+1;opts.currSlide=roll?els.length-1:opts.nextSlide-1;}
if(opts.timeout)
p.cycleTimeout=setTimeout(function(){go(els,opts,0,!opts.rev)},opts.timeout);};function advance(els,opts,val){var p=els[0].parentNode,timeout=p.cycleTimeout;if(timeout){clearTimeout(timeout);p.cycleTimeout=0;}
opts.nextSlide=opts.currSlide+val;if(opts.nextSlide<0){opts.nextSlide=els.length-1;}
else if(opts.nextSlide>=els.length){opts.nextSlide=0;}
go(els,opts,1,val>=0);return false;};$.fn.cycle.custom=function(curr,next,opts,cb){var $l=$(curr),$n=$(next);$n.css({opacity:0});var fn=function(){$n.animate({opacity:1},opts.speedIn,opts.easeIn,cb)};$l.animate({opacity:0},opts.speedOut,opts.easeOut,function(){$l.css({display:'none'});if(!opts.sync)fn();});if(opts.sync)fn();};$.fn.cycle.transitions={fade:function($cont,$slides,opts){$slides.not(':eq(0)').css('opacity',0);opts.before.push(function(){$(this).show()});}};$.fn.cycle.ver=function(){return ver;};$.fn.cycle.defaults={timeout:4000,speed:1000,next:null,prev:null,before:null,after:null,height:'auto',sync:1,fit:0,pause:0,delay:0,slideExpr:null};})(jQuery);


/*
Supersized - Fullscreen Slideshow jQuery Plugin
By Sam Dunn (www.buildinternet.com // www.onemightyroar.com)
Version: supersized.2.0.js // Relase Date: 5/7/09
Website: www.buildinternet.com/project/supersized
Thanks to Aen for preloading, fade effect, & vertical centering
*/
(function($){$.fn.supersized=function(){$.inAnimation=false;$.paused=false;var options=$.extend($.fn.supersized.defaults,$.fn.supersized.options);$(window).bind("load",function(){$('#loading').hide();$('#supersize').fadeIn('fast');$('#content').show();if($('#slideshow .activeslide').length==0)$('#supersize a:first').addClass('activeslide');if(options.slide_captions==1)$('#slidecaption').html($('#supersize .activeslide').find('img').attr('title'));if(options.navigation==0)$('#navigation').hide();if(options.slideshow==1){if(options.slide_counter==1){$('#slidecounter .slidenumber').html(1);$('#slidecounter .totalslides').html($("#supersize > *").size());}
slideshow_interval=setInterval("nextslide()",options.slide_interval);if(options.navigation==1){$('#navigation a').click(function(){$(this).blur();return false;});$('#nextslide').click(function(){if($.paused)return false;if($.inAnimation)return false;clearInterval(slideshow_interval);nextslide();slideshow_interval=setInterval(nextslide,options.slide_interval);return false;});$('#prevslide').click(function(){if($.paused)return false;if($.inAnimation)return false;clearInterval(slideshow_interval);prevslide();slideshow_interval=setInterval(nextslide,options.slide_interval);return false;});$('#nextslide img').hover(function(){if($.paused==true)return false;$(this).attr("src","images/forward.gif");},function(){if($.paused==true)return false;$(this).attr("src","images/forward_dull.gif");});$('#prevslide img').hover(function(){if($.paused==true)return false;$(this).attr("src","images/back.gif");},function(){if($.paused==true)return false;$(this).attr("src","images/back_dull.gif");});$('#pauseplay').click(function(){if($.inAnimation)return false;var src=($(this).find('img').attr("src")==="images/play.gif")?"images/pause.gif":"images/play.gif";if(src=="images/pause.gif"){$(this).find('img').attr("src","images/play.gif");$.paused=false;slideshow_interval=setInterval(nextslide,options.slide_interval);}else{$(this).find('img').attr("src","images/pause.gif");clearInterval(slideshow_interval);$.paused=true;}
$(this).find('img').attr("src",src);return false;});$('#pauseplay').mouseover(function(){var imagecheck=($(this).find('img').attr("src")==="images/play_dull.gif");if(imagecheck){$(this).find('img').attr("src","images/play.gif");}else{$(this).find('img').attr("src","images/pause.gif");}});$('#pauseplay').mouseout(function(){var imagecheck=($(this).find('img').attr("src")==="images/play.gif");if(imagecheck){$(this).find('img').attr("src","images/play_dull.gif");}else{$(this).find('img').attr("src","images/pause_dull.gif");}
return false;});}}});$(document).ready(function(){$('#supersize').resizenow();});$('#supersize > *').hover(function(){if(options.slideshow==1&&options.pause_hover==1){if(!($.paused)&&options.navigation==1){$('#pauseplay > img').attr("src","images/pause.gif");clearInterval(slideshow_interval);}}
original_title=$(this).find('img').attr("title");if($.inAnimation)return false;else $(this).find('img').attr("title","");},function(){if(options.slideshow==1&&options.pause_hover==1){if(!($.paused)&&options.navigation==1){$('#pauseplay > img').attr("src","images/pause_dull.gif");slideshow_interval=setInterval(nextslide,options.slide_interval);}}
$(this).find('img').attr("title",original_title);});$(window).bind("resize",function(){$('#supersize').resizenow();});$('#supersize').hide();$('#content').hide();};$.fn.resizenow=function(){var options=$.extend($.fn.supersized.defaults,$.fn.supersized.options);return this.each(function(){var ratio=options.startheight/options.startwidth;var imagewidth=$(this).width();var imageheight=$(this).height();var browserwidth=$(window).width();var browserheight=$(window).height();var offset;if((browserheight/browserwidth)>ratio){$(this).height(browserheight);$(this).width(browserheight/ratio);$(this).children().height(browserheight);$(this).children().width(browserheight/ratio);}else{$(this).width(browserwidth);$(this).height(browserwidth*ratio);$(this).children().width(browserwidth);$(this).children().height(browserwidth*ratio);}
if(options.vertical_center==1){$(this).children().css('left',(browserwidth-$(this).width())/2);$(this).children().css('top',(browserheight-$(this).height())/2);}
return false;});};$.fn.supersized.defaults={startwidth:4,startheight:3,vertical_center:1,slideshow:1,navigation:1,transition:1,pause_hover:0,slide_counter:1,slide_captions:1,slide_interval:5000};})(jQuery);function nextslide(){if($.inAnimation)return false;else $.inAnimation=true;var options=$.extend($.fn.supersized.defaults,$.fn.supersized.options);var currentslide=$('#supersize .activeslide');currentslide.removeClass('activeslide');if(currentslide.length==0)currentslide=$('#supersize a:last');var nextslide=currentslide.next().length?currentslide.next():$('#supersize a:first');var prevslide=nextslide.prev().length?nextslide.prev():$('#supersize a:last');if(options.slide_counter==1){var slidecount=$('#slidecounter .slidenumber').html();currentslide.next().length?slidecount++:slidecount=1;$('#slidecounter .slidenumber').html(slidecount);}
$('.prevslide').removeClass('prevslide');prevslide.addClass('prevslide');if(options.slide_captions==1)$('#slidecaption').html($(nextslide).find('img').attr('title'));nextslide.hide().addClass('activeslide')
if(options.transition==0){nextslide.show();$.inAnimation=false;}
if(options.transition==1){nextslide.fadeIn(750,function(){$.inAnimation=false;});}
if(options.transition==2){nextslide.show("slide",{direction:"up"},'slow',function(){$.inAnimation=false;});}
if(options.transition==3){nextslide.show("slide",{direction:"right"},'slow',function(){$.inAnimation=false;});}
if(options.transition==4){nextslide.show("slide",{direction:"down"},'slow',function(){$.inAnimation=false;});}
if(options.transition==5){nextslide.show("slide",{direction:"left"},'slow',function(){$.inAnimation=false;});}
$('#supersize').resizenow();}
function prevslide(){if($.inAnimation)return false;else $.inAnimation=true;var options=$.extend($.fn.supersized.defaults,$.fn.supersized.options);var currentslide=$('#supersize .activeslide');currentslide.removeClass('activeslide');if(currentslide.length==0)currentslide=$('#supersize a:first');var nextslide=currentslide.prev().length?currentslide.prev():$('#supersize a:last');var prevslide=nextslide.next().length?nextslide.next():$('#supersize a:first');if(options.slide_counter==1){var slidecount=$('#slidecounter .slidenumber').html();currentslide.prev().length?slidecount--:slidecount=$("#supersize > *").size();$('#slidecounter .slidenumber').html(slidecount);}
$('.prevslide').removeClass('prevslide');prevslide.addClass('prevslide');if(options.slide_captions==1)$('#slidecaption').html($(nextslide).find('img').attr('title'));nextslide.hide().addClass('activeslide')
if(options.transition==0){nextslide.show();$.inAnimation=false;}
if(options.transition==1){nextslide.fadeIn(750,function(){$.inAnimation=false;});}
if(options.transition==2){nextslide.show("slide",{direction:"down"},'slow',function(){$.inAnimation=false;});}
if(options.transition==3){nextslide.show("slide",{direction:"left"},'slow',function(){$.inAnimation=false;});}
if(options.transition==4){nextslide.show("slide",{direction:"up"},'slow',function(){$.inAnimation=false;});}
if(options.transition==5){nextslide.show("slide",{direction:"right"},'slow',function(){$.inAnimation=false;});}
$('#supersize').resizenow();}



/*	ColorBox v1.3.6 - a full featured, light-weight, customizable lightbox based on jQuery 1.3 */
(function(c){function r(b,d){d=d==="x"?m.width():m.height();return typeof b==="string"?Math.round(b.match(/%/)?d/100*parseInt(b,10):parseInt(b,10)):b}function M(b){b=c.isFunction(b)?b.call(i):b;return a.photo||b.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i)}function Y(){for(var b in a)if(c.isFunction(a[b])&&b.substring(0,2)!=="on")a[b]=a[b].call(i);a.rel=a.rel||i.rel;a.href=a.href||i.href;a.title=a.title||i.title}function Z(b){i=b;a=c.extend({},c(i).data(q));Y();if(a.rel&&a.rel!=="nofollow"){g= c(".cboxElement").filter(function(){return(c(this).data(q).rel||this.rel)===a.rel});j=g.index(i);if(j<0){g=g.add(i);j=g.length-1}}else{g=c(i);j=0}if(!B){C=B=n;N=i;N.blur();c(document).bind("keydown.cbox_close",function(d){if(d.keyCode===27){d.preventDefault();e.close()}}).bind("keydown.cbox_arrows",function(d){if(g.length>1)if(d.keyCode===37){d.preventDefault();D.click()}else if(d.keyCode===39){d.preventDefault();E.click()}});a.overlayClose&&s.css({cursor:"pointer"}).one("click",e.close);c.event.trigger(aa); a.onOpen&&a.onOpen.call(i);s.css({opacity:a.opacity}).show();a.w=r(a.initialWidth,"x");a.h=r(a.initialHeight,"y");e.position(0);O&&m.bind("resize.cboxie6 scroll.cboxie6",function(){s.css({width:m.width(),height:m.height(),top:m.scrollTop(),left:m.scrollLeft()})}).trigger("scroll.cboxie6")}P.add(D).add(E).add(t).add(Q).hide();R.html(a.close).show();e.slideshow();e.load()}var q="colorbox",F="hover",n=true,e,x=c.browser.msie&&!c.support.opacity,O=x&&c.browser.version<7,aa="cbox_open",H="cbox_load",S= "cbox_complete",T="resize.cbox_resize",s,k,u,p,U,V,W,X,g,m,l,I,J,K,Q,P,t,E,D,R,y,z,v,w,i,N,j,a,B,C,$={transition:"elastic",speed:350,width:false,height:false,innerWidth:false,innerHeight:false,initialWidth:"400",initialHeight:"400",maxWidth:false,maxHeight:false,scalePhotos:n,scrolling:n,inline:false,html:false,iframe:false,photo:false,href:false,title:false,rel:false,opacity:0.9,preloading:n,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:false,overlayClose:n, slideshow:false,slideshowAuto:n,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:false,onLoad:false,onComplete:false,onCleanup:false,onClosed:false};e=c.fn.colorbox=function(b,d){var h=this;if(!h.length)if(h.selector===""){h=c("<a/>");b.open=n}else return this;h.each(function(){var f=c.extend({},c(this).data(q)?c(this).data(q):$,b);c(this).data(q,f).addClass("cboxElement");if(d)c(this).data(q).onComplete=d});b&&b.open&&Z(h);return this};e.init=function(){function b(d){return c('<div id="cbox'+ d+'"/>')}m=c(window);k=c('<div id="colorbox"/>');s=b("Overlay").hide();u=b("Wrapper");p=b("Content").append(l=b("LoadedContent").css({width:0,height:0}),J=b("LoadingOverlay"),K=b("LoadingGraphic"),Q=b("Title"),P=b("Current"),t=b("Slideshow"),E=b("Next"),D=b("Previous"),R=b("Close"));u.append(c("<div/>").append(b("TopLeft"),U=b("TopCenter"),b("TopRight")),c("<div/>").append(V=b("MiddleLeft"),p,W=b("MiddleRight")),c("<div/>").append(b("BottomLeft"),X=b("BottomCenter"),b("BottomRight"))).children().children().css({"float":"left"}); I=c("<div style='position:absolute; top:0; left:0; width:9999px; height:0;'/>");c("body").prepend(s,k.append(u,I));if(x){k.addClass("cboxIE");O&&s.css("position","absolute")}p.children().bind("mouseover mouseout",function(){c(this).toggleClass(F)}).addClass(F);y=U.height()+X.height()+p.outerHeight(n)-p.height();z=V.width()+W.width()+p.outerWidth(n)-p.width();v=l.outerHeight(n);w=l.outerWidth(n);k.css({"padding-bottom":y,"padding-right":z}).hide();E.click(e.next);D.click(e.prev);R.click(e.close);p.children().removeClass(F); c(".cboxElement").live("click",function(d){if(d.button!==0&&typeof d.button!=="undefined")return n;else{Z(this);return false}})};e.position=function(b,d){function h(A){U[0].style.width=X[0].style.width=p[0].style.width=A.style.width;K[0].style.height=J[0].style.height=p[0].style.height=V[0].style.height=W[0].style.height=A.style.height}var f=m.height();f=Math.max(f-a.h-v-y,0)/2+m.scrollTop();var o=Math.max(document.documentElement.clientWidth-a.w-w-z,0)/2+m.scrollLeft();b=k.width()===a.w+w&&k.height()=== a.h+v?0:b;u[0].style.width=u[0].style.height="9999px";k.dequeue().animate({width:a.w+w,height:a.h+v,top:f,left:o},{duration:b,complete:function(){h(this);C=false;u[0].style.width=a.w+w+z+"px";u[0].style.height=a.h+v+y+"px";d&&d()},step:function(){h(this)}})};e.resize=function(b){function d(){a.w=a.w||l.width();a.w=a.mw&&a.mw<a.w?a.mw:a.w;return a.w}function h(){a.h=a.h||l.height();a.h=a.mh&&a.mh<a.h?a.mh:a.h;return a.h}function f(G){e.position(G,function(){if(B){if(x){A&&l.fadeIn(100);k[0].style.removeAttribute("filter")}if(a.iframe)l.append("<iframe id='cboxIframe'"+ (a.scrolling?" ":"scrolling='no'")+" name='iframe_"+(new Date).getTime()+"' frameborder=0 src='"+a.href+"' "+(x?"allowtransparency='true'":"")+" />");l.show();Q.show().html(a.title);if(g.length>1){P.html(a.current.replace(/\{current\}/,j+1).replace(/\{total\}/,g.length)).show();E.html(a.next).show();D.html(a.previous).show();a.slideshow&&t.show()}J.hide();K.hide();c.event.trigger(S);a.onComplete&&a.onComplete.call(i);a.transition==="fade"&&k.fadeTo(L,1,function(){x&&k[0].style.removeAttribute("filter")}); m.bind(T,function(){e.position(0)})}})}if(B){var o,A,L=a.transition==="none"?0:a.speed;m.unbind(T);if(b){l.remove();l=c('<div id="cboxLoadedContent"/>').html(b);l.hide().appendTo(I).css({width:d(),overflow:a.scrolling?"auto":"hidden"}).css({height:h()}).prependTo(p);c("#cboxPhoto").css({cssFloat:"none"});O&&c("select:not(#colorbox select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("cbox_cleanup",function(){this.style.visibility="inherit"});a.transition=== "fade"&&k.fadeTo(L,0,function(){f(0)})||f(L);if(a.preloading&&g.length>1){b=j>0?g[j-1]:g[g.length-1];o=j<g.length-1?g[j+1]:g[0];o=c(o).data(q).href||o.href;b=c(b).data(q).href||b.href;M(o)&&c("<img />").attr("src",o);M(b)&&c("<img />").attr("src",b)}}else setTimeout(function(){var G=l.wrapInner("<div style='overflow:auto'></div>").children();a.h=G.height();l.css({height:a.h});G.replaceWith(G.children());e.position(L)},1)}};e.load=function(){var b,d,h,f=e.resize;C=n;i=g[j];a=c.extend({},c(i).data(q)); Y();c.event.trigger(H);a.onLoad&&a.onLoad.call(i);a.h=a.height?r(a.height,"y")-v-y:a.innerHeight?r(a.innerHeight,"y"):false;a.w=a.width?r(a.width,"x")-w-z:a.innerWidth?r(a.innerWidth,"x"):false;a.mw=a.w;a.mh=a.h;if(a.maxWidth){a.mw=r(a.maxWidth,"x")-w-z;a.mw=a.w&&a.w<a.mw?a.w:a.mw}if(a.maxHeight){a.mh=r(a.maxHeight,"y")-v-y;a.mh=a.h&&a.h<a.mh?a.h:a.mh}b=a.href;J.show();K.show();if(a.inline){c('<div id="cboxInlineTemp" />').hide().insertBefore(c(b)[0]).bind(H+" cbox_cleanup",function(){c(this).replaceWith(l.children())}); f(c(b))}else if(a.iframe)f(" ");else if(a.html)f(a.html);else if(M(b)){d=new Image;d.onload=function(){var o;d.onload=null;d.id="cboxPhoto";c(d).css({margin:"auto",border:"none",display:"block",cssFloat:"left"});if(a.scalePhotos){h=function(){d.height-=d.height*o;d.width-=d.width*o};if(a.mw&&d.width>a.mw){o=(d.width-a.mw)/d.width;h()}if(a.mh&&d.height>a.mh){o=(d.height-a.mh)/d.height;h()}}if(a.h)d.style.marginTop=Math.max(a.h-d.height,0)/2+"px";f(d);g.length>1&&c(d).css({cursor:"pointer"}).click(e.next); if(x)d.style.msInterpolationMode="bicubic"};d.src=b}else c("<div />").appendTo(I).load(b,function(o,A){A==="success"?f(this):f(c("<p>Request unsuccessful.</p>"))})};e.next=function(){if(!C){j=j<g.length-1?j+1:0;e.load()}};e.prev=function(){if(!C){j=j>0?j-1:g.length-1;e.load()}};e.slideshow=function(){function b(){t.text(a.slideshowStop).bind(S,function(){h=setTimeout(e.next,a.slideshowSpeed)}).bind(H,function(){clearTimeout(h)}).one("click",function(){d();c(this).removeClass(F)});k.removeClass(f+ "off").addClass(f+"on")}var d,h,f="cboxSlideshow_";t.bind("cbox_closed",function(){t.unbind();clearTimeout(h);k.removeClass(f+"off "+f+"on")});d=function(){clearTimeout(h);t.text(a.slideshowStart).unbind(S+" "+H).one("click",function(){b();h=setTimeout(e.next,a.slideshowSpeed);c(this).removeClass(F)});k.removeClass(f+"on").addClass(f+"off")};if(a.slideshow&&g.length>1)a.slideshowAuto?b():d()};e.close=function(){c.event.trigger("cbox_cleanup");a.onCleanup&&a.onCleanup.call(i);B=false;c(document).unbind("keydown.cbox_close keydown.cbox_arrows"); m.unbind(T+" resize.cboxie6 scroll.cboxie6");s.css({cursor:"auto"}).fadeOut("fast");k.stop(n,false).fadeOut("fast",function(){c("#colorbox iframe").attr("src","about:blank");l.remove();k.css({opacity:1});try{N.focus()}catch(b){}c.event.trigger("cbox_closed");a.onClosed&&a.onClosed.call(i)})};e.element=function(){return c(i)};e.settings=$;c(e.init)})(jQuery);