//INSERT PLUGINS HERE
/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 2/19/2008
 * @author Ariel Flesler
 * @version 1.3.3
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function($){var o=$.scrollTo=function(a,b,c){o.window().scrollTo(a,b,c)};o.defaults={axis:'y',duration:1};o.window=function(){return $($.browser.safari?'body':'html')};$.fn.scrollTo=function(l,m,n){if(typeof m=='object'){n=m;m=0}n=$.extend({},o.defaults,n);m=m||n.speed||n.duration;n.queue=n.queue&&n.axis.length>1;if(n.queue)m/=2;n.offset=j(n.offset);n.over=j(n.over);return this.each(function(){var a=this,b=$(a),t=l,c,d={},w=b.is('html,body');switch(typeof t){case'number':case'string':if(/^([+-]=)?\d+(px)?$/.test(t)){t=j(t);break}t=$(t,this);case'object':if(t.is||t.style)c=(t=$(t)).offset()}$.each(n.axis.split(''),function(i,f){var P=f=='x'?'Left':'Top',p=P.toLowerCase(),k='scroll'+P,e=a[k],D=f=='x'?'Width':'Height';if(c){d[k]=c[p]+(w?0:e-b.offset()[p]);if(n.margin){d[k]-=parseInt(t.css('margin'+P))||0;d[k]-=parseInt(t.css('border'+P+'Width'))||0}d[k]+=n.offset[p]||0;if(n.over[p])d[k]+=t[D.toLowerCase()]()*n.over[p]}else d[k]=t[p];if(/^\d+$/.test(d[k]))d[k]=d[k]<=0?0:Math.min(d[k],h(D));if(!i&&n.queue){if(e!=d[k])g(n.onAfterFirst);delete d[k]}});g(n.onAfter);function g(a){b.animate(d,m,n.easing,a&&function(){a.call(this,l)})};function h(D){var b=w?$.browser.opera?document.body:document.documentElement:a;return b['scroll'+D]-b['client'+D]}})};function j(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
/**
 * jQuery[a] - Animated scrolling of series
 * Copyright (c) 2007-2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 3/20/2008
 * @author Ariel Flesler
 * @version 1.2.1
 *
 * http://flesler.blogspot.com/2008/02/jqueryserialscroll.html
 */
;(function($){var a='serialScroll',b='.'+a,c='bind',C=$[a]=function(b){$.scrollTo.window()[a](b)};C.defaults={duration:1e3,axis:'x',event:'click',start:0,step:1,lock:1,cycle:1,constant:1};$.fn[a]=function(y){y=$.extend({},C.defaults,y);var z=y.event,A=y.step,B=y.lazy;return this.each(function(){var j=y.target?this:document,k=$(y.target||this,j),l=k[0],m=y.items,o=y.start,p=y.interval,q=y.navigation,r;if(!B)m=w();if(y.force)t({},o);$(y.prev||[],j)[c](z,-A,s);$(y.next||[],j)[c](z,A,s);if(!l.ssbound)k[c]('prev'+b,-A,s)[c]('next'+b,A,s)[c]('goto'+b,t);if(p)k[c]('start'+b,function(e){if(!p){v();p=1;u()}})[c]('stop'+b,function(){v();p=0});k[c]('notify'+b,function(e,a){var i=x(a);if(i>-1)o=i});l.ssbound=1;if(y.jump)(B?k:w())[c](z,function(e){t(e,x(e.target))});if(q)q=$(q,j)[c](z,function(e){e.data=Math.round(w().length/q.length)*q.index(this);t(e,this)});function s(e){e.data+=o;t(e,this)};function t(e,a){if(!isNaN(a)){e.data=a;a=l}var c=e.data,n,d=e.type,f=y.exclude?w().slice(0,-y.exclude):w(),g=f.length,h=f[c],i=y.duration;if(d)e.preventDefault();if(p){v();r=setTimeout(u,y.interval)}if(!h){n=c<0?0:n=g-1;if(o!=n)c=n;else if(!y.cycle)return;else c=g-n-1;h=f[c]}if(!h||d&&o==c||y.lock&&k.is(':animated')||d&&y.onBefore&&y.onBefore.call(a,e,h,k,w(),c)===!1)return;if(y.stop)k.queue('fx',[]).stop();if(y.constant)i=Math.abs(i/A*(o-c));k.scrollTo(h,i,y).trigger('notify'+b,[c])};function u(){k.trigger('next'+b)};function v(){clearTimeout(r)};function w(){return $(m,l)};function x(a){if(!isNaN(a))return a;var b=w(),i;while((i=b.index(a))==-1&&a!=l)a=a.parentNode;return i}})}})(jQuery);
/**
 * jQuery - Set Sibling Hover
 * Copyright (c) 2008 - 2009 Mike Slater
 * @author Mike Slater
 *
 */
;(function($){
  $.fn.setSiblingHover = function(options) {
  	var settings = $.extend({
  		fadeLevel : 0.25,
  		overSpeed : 250,
  		sibSpeed : 500
  	},options||{});
	var item = $(this)
	item.hover(
		function(){
			$(this).stop()
			.fadeTo(settings.overSpeed, 1.0)
			.siblings()
			.stop()
			.fadeTo(settings.sibSpeed, settings.fadeLevel);
		}, function(){
			item.parent().children()
			.stop()
			.fadeTo(settings.sibSpeed, 1.0);
	});
    return this;
  };
})(jQuery);
/*
 * Superfish v1.4.8 - jQuery menu widget
 * Copyright (c) 2008 Joel Birch
 *
 * Dual licensed under the MIT and GPL licenses:
 * 	http://www.opensource.org/licenses/mit-license.php
 * 	http://www.gnu.org/licenses/gpl.html
 *
 * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
 */

;(function($){$.fn.superfish=function(op){var sf=$.fn.superfish,c=sf.c,$arrow=$(['<span class="',c.arrowClass,'"> &#187;</span>'].join('')),over=function(){var $$=$(this),menu=getMenu($$);clearTimeout(menu.sfTimer);$$.showSuperfishUl().siblings().hideSuperfishUl()},out=function(){var $$=$(this),menu=getMenu($$),o=sf.op;clearTimeout(menu.sfTimer);menu.sfTimer=setTimeout(function(){o.retainPath=($.inArray($$[0],o.$path)>-1);$$.hideSuperfishUl();if(o.$path.length&&$$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path)}},o.delay)},getMenu=function($menu){var menu=$menu.parents(['ul.',c.menuClass,':first'].join(''))[0];sf.op=sf.o[menu.serial];return menu},addArrow=function($a){$a.addClass(c.anchorClass).append($arrow.clone())};return this.each(function(){var s=this.serial=sf.o.length;var o=$.extend({},sf.defaults,op);o.$path=$('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){$(this).addClass([o.hoverClass,c.bcClass].join(' ')).filter('li:has(ul)').removeClass(o.pathClass)});sf.o[s]=sf.op=o;$('li:has(ul)',this)[($.fn.hoverIntent&&!o.disableHI)?'hoverIntent':'hover'](over,out).each(function(){if(o.autoArrows)addArrow($('>a:first-child',this))}).not('.'+c.bcClass).hideSuperfishUl();var $a=$('a',this);$a.each(function(i){var $li=$a.eq(i).parents('li');$a.eq(i).focus(function(){over.call($li)}).blur(function(){out.call($li)})});o.onInit.call(this)}).each(function(){var menuClasses=[c.menuClass];if(sf.op.dropShadows&&!($.browser.msie&&$.browser.version<7))menuClasses.push(c.shadowClass);$(this).addClass(menuClasses.join(' '))})};var sf=$.fn.superfish;sf.o=[];sf.op={};sf.IE7fix=function(){var o=sf.op;if($.browser.msie&&$.browser.version>6&&o.dropShadows&&o.animation.opacity!=undefined)this.toggleClass(sf.c.shadowClass+'-off')};sf.c={bcClass:'sf-breadcrumb',menuClass:'sf-js-enabled',anchorClass:'sf-with-ul',arrowClass:'sf-sub-indicator',shadowClass:'sf-shadow'};sf.defaults={hoverClass:'sfHover',pathClass:'overideThisToUse',pathLevels:1,delay:400,animation:{opacity:'show'},speed:'normal',autoArrows:true,dropShadows:true,disableHI:false,onInit:function(){},onBeforeShow:function(){},onShow:function(){},onHide:function(){}};$.fn.extend({hideSuperfishUl:function(){var o=sf.op,not=(o.retainPath===true)?o.$path:'';o.retainPath=false;var $ul=$(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass).find('>ul').hide().css('visibility','hidden');o.onHide.call($ul);return this},showSuperfishUl:function(){var o=sf.op,sh=sf.c.shadowClass+'-off',$ul=this.addClass(o.hoverClass).find('>ul:hidden').css('visibility','visible');sf.IE7fix.call($ul);o.onBeforeShow.call($ul);$ul.animate(o.animation,o.speed,function(){sf.IE7fix.call($ul);o.onShow.call($ul)});return this}})})(jQuery);
/*
 * jQuery corner plugin
 *
 * version 1.92 (12/18/2007)
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
(function($){$.fn.corner=function(o){var ie6=$.browser.msie&&/MSIE 6.0/.test(navigator.userAgent);function sz(el,p){return parseInt($.css(el,p))||0};function hex2(s){var s=parseInt(s).toString(16);return(s.length<2)?'0'+s:s};function gpc(node){for(;node&&node.nodeName.toLowerCase()!='html';node=node.parentNode){var v=$.css(node,'backgroundColor');if(v.indexOf('rgb')>=0){if($.browser.safari&&v=='rgba(0, 0, 0, 0)')continue;var rgb=v.match(/\d+/g);return'#'+hex2(rgb[0])+hex2(rgb[1])+hex2(rgb[2])}if(v&&v!='transparent')return v}return'#ffffff'};function getW(i){switch(fx){case'round':return Math.round(width*(1-Math.cos(Math.asin(i/width))));case'cool':return Math.round(width*(1+Math.cos(Math.asin(i/width))));case'sharp':return Math.round(width*(1-Math.cos(Math.acos(i/width))));case'bite':return Math.round(width*(Math.cos(Math.asin((width-i-1)/width))));case'slide':return Math.round(width*(Math.atan2(i,width/i)));case'jut':return Math.round(width*(Math.atan2(width,(width-i-1))));case'curl':return Math.round(width*(Math.atan(i)));case'tear':return Math.round(width*(Math.cos(i)));case'wicked':return Math.round(width*(Math.tan(i)));case'long':return Math.round(width*(Math.sqrt(i)));case'sculpt':return Math.round(width*(Math.log((width-i-1),width)));case'dog':return(i&1)?(i+1):width;case'dog2':return(i&2)?(i+1):width;case'dog3':return(i&3)?(i+1):width;case'fray':return(i%2)*width;case'notch':return width;case'bevel':return i+1}};o=(o||"").toLowerCase();var keep=/keep/.test(o);var cc=((o.match(/cc:(#[0-9a-f]+)/)||[])[1]);var sc=((o.match(/sc:(#[0-9a-f]+)/)||[])[1]);var width=parseInt((o.match(/(\d+)px/)||[])[1])||10;var re=/round|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dog/;var fx=((o.match(re)||['round'])[0]);var edges={T:0,B:1};var opts={TL:/top|tl/.test(o),TR:/top|tr/.test(o),BL:/bottom|bl/.test(o),BR:/bottom|br/.test(o)};if(!opts.TL&&!opts.TR&&!opts.BL&&!opts.BR)opts={TL:1,TR:1,BL:1,BR:1};var strip=document.createElement('div');strip.style.overflow='hidden';strip.style.height='1px';strip.style.backgroundColor=sc||'transparent';strip.style.borderStyle='solid';return this.each(function(index){var pad={T:parseInt($.css(this,'paddingTop'))||0,R:parseInt($.css(this,'paddingRight'))||0,B:parseInt($.css(this,'paddingBottom'))||0,L:parseInt($.css(this,'paddingLeft'))||0};if($.browser.msie)this.style.zoom=1;if(!keep)this.style.border='none';strip.style.borderColor=cc||gpc(this.parentNode);var cssHeight=$.curCSS(this,'height');for(var j in edges){var bot=edges[j];if((bot&&(opts.BL||opts.BR))||(!bot&&(opts.TL||opts.TR))){strip.style.borderStyle='none '+(opts[j+'R']?'solid':'none')+' none '+(opts[j+'L']?'solid':'none');var d=document.createElement('div');$(d).addClass('jquery-corner');var ds=d.style;bot?this.appendChild(d):this.insertBefore(d,this.firstChild);if(bot&&cssHeight!='auto'){if($.css(this,'position')=='static')this.style.position='relative';ds.position='absolute';ds.bottom=ds.left=ds.padding=ds.margin='0';if($.browser.msie)ds.setExpression('width','this.parentNode.offsetWidth');else ds.width='100%'}else if(!bot&&$.browser.msie){if($.css(this,'position')=='static')this.style.position='relative';ds.position='absolute';ds.top=ds.left=ds.right=ds.padding=ds.margin='0';var bw=0;if(ie6||!$.boxModel)bw=sz(this,'borderLeftWidth')+sz(this,'borderRightWidth');ie6?ds.setExpression('width','this.parentNode.offsetWidth - '+bw+'+ "px"'):ds.width='100%'}else{ds.margin=!bot?'-'+pad.T+'px -'+pad.R+'px '+(pad.T-width)+'px -'+pad.L+'px':(pad.B-width)+'px -'+pad.R+'px -'+pad.B+'px -'+pad.L+'px'}for(var i=0;i<width;i++){var w=Math.max(0,getW(i));var e=strip.cloneNode(false);e.style.borderWidth='0 '+(opts[j+'R']?w:0)+'px 0 '+(opts[j+'L']?w:0)+'px';bot?d.appendChild(e):d.insertBefore(e,d.firstChild)}}}})};$.fn.uncorner=function(o){return $('.jquery-corner',this).remove()}})(jQuery);
/*
 * Thickbox 3.1-byrne - One Box To Rule Them All.
 * By Cody Lindley (http://www.codylindley.com)
 * Modifications by Byrne Reese (http://www.majordojo.com/)
 * Copyright (c) 2007 Cody Lindley
 * Copyright (c) 2009 Byrne Reese
 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
*/
(function($){$.fn.thickbox=function(options){var settings=$.extend({},$.fn.thickbox.defaults,options);var imgLoader=new Image();imgLoader.src=settings.loadingImage;return this.each(function(){obj=$(this);obj.click(function(){var t=this.title||this.name||null;var a=this.href||this.alt;var g=this.rel||false;tb_show(t,a,g);this.blur();return false})});function tb_show(caption,url,imageGroup){try{if(typeof document.body.style.maxHeight==="undefined"){$("body","html").css({height:"100%",width:"100%"});$("html").css("overflow","hidden");if(document.getElementById("TB_HideSelect")===null){$("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");$("#TB_overlay").click(tb_remove)}}else{if(document.getElementById("TB_overlay")===null){$("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");$("#TB_overlay").click(tb_remove)}}if(tb_detectMacXFF()){$("#TB_overlay").addClass("TB_overlayMacFFBGHack");$("#TB_overlay").css({'background-image':'url('+settings.macFFBgHack+')','background-repeat':'repeat'})}else{$("#TB_overlay").addClass("TB_overlayBG")}if(caption===null){caption=""}$("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");$('#TB_load').show();var baseURL;if(url.indexOf("?")!==-1){baseURL=url.substr(0,url.indexOf("?"))}else{baseURL=url}var urlString=/\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;var urlType=baseURL.toLowerCase().match(urlString);if(urlType=='.jpg'||urlType=='.jpeg'||urlType=='.png'||urlType=='.gif'||urlType=='.bmp'){TB_PrevCaption="";TB_PrevURL="";TB_PrevHTML="";TB_NextCaption="";TB_NextURL="";TB_NextHTML="";TB_imageCount="";TB_FoundURL=false;if(imageGroup){TB_TempArray=$("a[rel="+imageGroup+"]").get();for(TB_Counter=0;((TB_Counter<TB_TempArray.length)&&(TB_NextHTML===""));TB_Counter++){var urlTypeTemp=TB_TempArray[TB_Counter].href.toLowerCase().match(urlString);if(!(TB_TempArray[TB_Counter].href==url)){if(TB_FoundURL){TB_NextCaption=TB_TempArray[TB_Counter].title;TB_NextURL=TB_TempArray[TB_Counter].href;TB_NextHTML="<span id='TB_next'>&nbsp;&nbsp;<a href='#'>Next &gt;</a></span>"}else{TB_PrevCaption=TB_TempArray[TB_Counter].title;TB_PrevURL=TB_TempArray[TB_Counter].href;TB_PrevHTML="<span id='TB_prev'>&nbsp;&nbsp;<a href='#'>&lt; Prev</a></span>"}}else{TB_FoundURL=true;TB_imageCount="Image "+(TB_Counter+1)+" of "+(TB_TempArray.length)}}}imgPreloader=new Image();imgPreloader.onload=function(){imgPreloader.onload=null;var pagesize=tb_getPageSize();var x=pagesize[0]-150;var y=pagesize[1]-150;var imageWidth=imgPreloader.width;var imageHeight=imgPreloader.height;if(imageWidth>x){imageHeight=imageHeight*(x/imageWidth);imageWidth=x;if(imageHeight>y){imageWidth=imageWidth*(y/imageHeight);imageHeight=y}}else if(imageHeight>y){imageWidth=imageWidth*(y/imageHeight);imageHeight=y;if(imageWidth>x){imageHeight=imageHeight*(x/imageWidth);imageWidth=x}}TB_WIDTH=imageWidth+30;TB_HEIGHT=imageHeight+60;$("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>"+"<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>"+TB_imageCount+TB_PrevHTML+TB_NextHTML+"</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a></div>");$("#TB_closeWindowButton").click(tb_remove);if(!(TB_PrevHTML==="")){function goPrev(){if($(document).unbind("click",goPrev)){$(document).unbind("click",goPrev)}$("#TB_window").remove();$("body").append("<div id='TB_window'></div>");tb_show(TB_PrevCaption,TB_PrevURL,imageGroup);return false}$("#TB_prev").click(goPrev)}if(!(TB_NextHTML==="")){function goNext(){$("#TB_window").remove();$("body").append("<div id='TB_window'></div>");tb_show(TB_NextCaption,TB_NextURL,imageGroup);return false}$("#TB_next").click(goNext)}document.onkeydown=function(e){if(e==null){keycode=event.keyCode}else{keycode=e.which}if(keycode==27){tb_remove()}else if(keycode==190){if(!(TB_NextHTML=="")){document.onkeydown="";goNext()}}else if(keycode==188){if(!(TB_PrevHTML=="")){document.onkeydown="";goPrev()}}};tb_position();$("#TB_load").remove();$("#TB_ImageOff").click(tb_remove);$("#TB_window").css({display:"block"})};imgPreloader.src=url}else{TB_WIDTH=(settings.width)+30;TB_HEIGHT=(settings.height)+40;ajaxContentW=TB_WIDTH-30;ajaxContentH=TB_HEIGHT-45;if(settings.iframe){urlNoQuery=url.split('TB_');$("#TB_iframeContent").remove();if(!settings.modal){$("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a> or Esc Key</div></div><iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW+29)+"px;height:"+(ajaxContentH+17)+"px;' > </iframe>")}else{$("#TB_overlay").unbind();$("#TB_window").append("<iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW+29)+"px;height:"+(ajaxContentH+17)+"px;'> </iframe>")}}else{if($("#TB_window").css("display")!="block"){if(!settings.modal){$("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>close</a> or Esc Key</div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px'></div>")}else{$("#TB_overlay").unbind();$("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>")}}else{$("#TB_ajaxContent")[0].style.width=ajaxContentW+"px";$("#TB_ajaxContent")[0].style.height=ajaxContentH+"px";$("#TB_ajaxContent")[0].scrollTop=0;$("#TB_ajaxWindowTitle").html(caption)}}$("#TB_closeWindowButton").click(tb_remove);if(settings.inlineId){$("#TB_ajaxContent").append($('#'+settings.inlineId).children());$("#TB_window").unload(function(){$('#'+settings.inlineId).append($("#TB_ajaxContent").children())});tb_position();$("#TB_load").remove();$("#TB_window").css({display:"block"})}else if(settings.iframe){tb_position();if($.browser.safari){$("#TB_load").remove();$("#TB_window").css({display:"block"})}}else{$("#TB_ajaxContent").load(url+="&random="+(new Date().getTime()),function(){tb_position();$("#TB_load").remove();$("#TB_ajaxContent a.thickbox").thickbox(settings);$("#TB_window").css({display:"block"})})}}if(!settings.modal){document.onkeyup=function(e){if(e==null){keycode=event.keyCode}else{keycode=e.which}if(keycode==27){tb_remove()}}}}catch(e){}};function tb_showIframe(){$("#TB_load").remove();$("#TB_window").css({display:"block"})};function tb_remove(){$("#TB_imageOff").unbind("click");$("#TB_closeWindowButton").unbind("click");$("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove()});$("#TB_load").remove();if(typeof document.body.style.maxHeight=="undefined"){$("body","html").css({height:"auto",width:"auto"});$("html").css("overflow","")}document.onkeydown="";document.onkeyup="";return false};function tb_position(){$("#TB_window").css({marginLeft:'-'+parseInt((TB_WIDTH/2),10)+'px',width:TB_WIDTH+'px'});if(!(jQuery.browser.msie&&jQuery.browser.version<7)){$("#TB_window").css({marginTop:'-'+parseInt((TB_HEIGHT/2),10)+'px'})}};function tb_getPageSize(){var de=document.documentElement;var w=window.innerWidth||self.innerWidth||(de&&de.clientWidth)||document.body.clientWidth;var h=window.innerHeight||self.innerHeight||(de&&de.clientHeight)||document.body.clientHeight;arrayPageSize=[w,h];return arrayPageSize};function tb_detectMacXFF(){var userAgent=navigator.userAgent.toLowerCase();if(userAgent.indexOf('mac')!=-1&&userAgent.indexOf('firefox')!=-1){return true}}};$.fn.thickbox.defaults={modal:0,inlineId:null,iframe:false,width:600,height:400,macFFBgHack:'../images/macFFBgHack.png',loadingImage:'../images/thickbox-loading.gif'}})(jQuery);

//GLOBAL VARIABLES
var galXmlURL;
var $galInfo;
var $galXML;

//GLOBAL FUNCTIONS
function popup(mylink, windowname)
{
	var href;
	if (! window.focus)
	{
		return true;
	}
	if (typeof(mylink) == 'string')
	{
		href=mylink;
	}
	else
	{
		href=mylink.href;
	}
	window.open(href, windowname, "width=700,height=700,resizable=yes,location=yes,scrollbars=yes");
	return false;
};

var setGalInfo = function(num)
{
	var $theItem = $galXML.find('item:eq('+num+')');
	$galInfo.find('.gal_title').text($theItem.find('title').text());
	if($theItem.find('size').text() !== '')
	{
		$galInfo.find('.gal_size').text('Size : ' + $theItem.find('size').text());
	}
	if($theItem.find('year').text() !== '')
	{
		$galInfo.find('.gal_year').text('Year : ' + $theItem.find('year').text());
	}
	if($theItem.find('price').text() !== '')
	{
		$galInfo.find('.gal_price').text('Price : ' + $theItem.find('price').text());
	}
	
	$galInfo.find('.gal_medium').text($theItem.find('medium').text());
	$galInfo.find('.gal_desc').text($theItem.find('desc').text());
	
	var itemType = $theItem.attr('type');
	if(parseInt($theItem.find('original').text()) === 1)
	{
		$galInfo.find('.gal_original').html('<a href="/unsold'+itemType+'.php">Original is available for purchase</a>');
	}
	else
	{
		$galInfo.find('.gal_original').empty();
	}
	if(parseInt($theItem.find('print').text()) === 1)
	{
		$galInfo.find('.gal_print').html('<a href="/prints.php">Prints Available</a>');
	}
	else
	{
		$galInfo.find('.gal_print').empty();
	}
};

var setupGalleryAnimation = function()
{
	
	
	//SET IMAGE SLIDER WIDTH
	var pages = $('#pane ul > li').size();
	var pagewidth = $('#pane ul > li:first-child').width();
	var total = pages * pagewidth;
	$('#pane > ul').width(total);

	//CACHE WRAPPER VARIABLES
	var $prev = $('#prev'),		//prev button
		$next = $('#next');		//next button
	
	var $pane = $('#pane'), 			//the item being scrolled
		$items = $pane.find('li.item');	//the scrolled items
	
	var numItems = $items.length;
		
	$prev.fadeTo(1, 0.1);
	$next.addClass('hand');
	
	var isRefresh = true;
	var imgNum = getUrlVars()["img"];
	
	if(imgNum) { isRefresh = false; }
	
	//MAKE THE SCROLLER WORK
	$pane.serialScroll(
	{
	    items:$items,
	    prev:$prev,
	    next:$next,
	    cycle:false,
	    stop:true,
	    force:isRefresh,
	    constant:false,
		onBefore:function( e, elem, $pane, $items, pos )
		{			
						
			pos = (pos % numItems);

			$('.pag').text((pos + 1) + ' of ' + numItems);

			if( pos > 0 ) {
				$prev.fadeTo(1, 1.0).addClass('hand');
			}
			
			if( pos < numItems ) {
				$next.fadeTo(1, 1.0).addClass('hand');
			}

			if( pos === 0 ) {
				$prev.fadeTo(1, 0.1).removeClass('hand');
			}
			else if( (pos + 1) === numItems ) {
				$next.fadeTo(1, 0.1).removeClass('hand');
			}

			setGalInfo(pos);

		}
	});
	
	var loaded = 0;
	
	$items.each(function(index) 
	{
		$(this).find('img').load(function()
		{
			var imgHeight = ($(this).height());
			if (imgHeight < 473)
			{
				var offset = Math.floor((473 - imgHeight)/2);
				$(this).parent().parent().css('padding-top', offset);
			}
			
			loaded++;
						
			if(loaded >= numItems)
			{

				$pane.removeClass('loading').find('ul').removeClass('invisible');
							
				if (imgNum) {
					imgNum--;
					$pane.trigger('goto', [imgNum] ).trigger( 'notify', [imgNum] );
				}
			}

		});		
	});

	$('.pag').text(1 + ' of ' + numItems);
	
	//INITIATE THICKBOX FOR THICKBOX LINKS
	$pane.find('a.thickbox').thickbox({
    	macFFBgHack: '/images/backgrounds/macFFBgHack.png',
    	loadingImage: '/images/loadingIcon.gif'
    });
    
};

//FUNCTION TO RETRIEVE URL VARIABLES
var getUrlVars = function ()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

//ON DOM READY
$(function() {

	$('<a/>', {
		id: 'footer',
		href: 'http://mike.carinslater.com',
		rel: 'external',
		text: 'website by mike slater',
		target: '_blank'
	}).appendTo('#main');

	//ADD THAT COOL FADED LINE TO THE #main DIV
	$('<div/>', {id : 'main_fade'}).appendTo('#main');
	//$('#main').append('<div id="main_fade"></div>');
	
	//SET THE CURRENT NAVIGATION TO ACTIVE
	$('#links.home li.nav_home').addClass('active');
	$('#links.gallery li.nav_gal').addClass('active');
	$('#links.events li.nav_events').addClass('active');
	$('#links.prints li.nav_prints').addClass('active');
	$('#links.contact li.nav_contact').addClass('active');
	
	//INITIATE SUPERFISH
	$('ul.sf-menu').superfish(
	{
		autoArrows: false,
		dropShadows: false,
		disableHI: true,
		speed: 'normal'
	});
	
	//POPULATE THE GALLERY WITH THE XML DATA
	if(document.getElementById('pane'))
	{
		var galName;
		var $container = $('#pane').addClass('loading');
		var $galList = $container.find('ul');
		
		if($galList.hasClass('unsold'))
		{
			galName = $galList.attr('id');
		}
		else
		{
			galName = getUrlVars()["gal"];
			if (!galName)
			{
				galName = '2010';
			}
		}
		
		//galXmlURL = '/XML/' + $galList.attr('id') + '.xml';
		galXmlURL = '/XML/' + galName + '.xml';
		
		//HIDE THE JEWELRY YEAR SELECT
		if(galName == 'jewelry') {
			$('div.gal_filter').hide();
		}
				
		$.get(galXmlURL, function(data)
		{
			if($('gallery item', data).size() > 0)
			{
				$('gallery item', data).each(function()
				{
					var $newImg = $('<img />')
						.attr('alt', '')
						.attr('src', $('theImg', this).text());
					var $newAnchor = $('<a></a>')
						.append($newImg)
						.attr('href', $('theImg', this).text())
						.attr('title', $('title', this).text())
						.addClass('thickbox');
					var $newItem = $('<li></li>')
						.append($newAnchor)
						.addClass('item')
						.appendTo($galList);
				});
				
				$galInfo = $('#rail');
				$galXML = $(data);
				setGalInfo(0);
								
				setupGalleryAnimation();
			}
		});
		
		$('#galleryNav').find('#' + galName).attr('selected', 'selected').end()
		.change(function ()
		{
			var galleryName = $('#galleryNav').val();
			window.location="gallery.php?gal=" + galleryName;
		});
	}
	
	//CORNER NAV
	$('#links').corner('tr 20px');

});

//ON IMAGES READY
$(window).load(function() {
	
	//RUN CODE FOR SMALL POSTCARD GALLERY IF ON PAGE
	if(document.getElementById('postcard_pane'))
	{

		//SET IMAGE SLIDER WIDTH
		var pages = $('#postcard_pane ul > li').size();
		var pagewidth = $('#postcard_pane ul > li:first-child').innerWidth();
		var total = pages * pagewidth;
		$('#postcard_pane > ul').width(total);

		//CACHE WRAPPER VARIABLES
		var $prev = $('#postcard_prev'),		//prev button
			$next = $('#postcard_next');		//next button
		
		var $pane = $('#postcard_pane'), 		//the item being scrolled
			$items = $pane.find('li.item');			//the scrolled items
			
		$prev.fadeTo(1, 0.1);
		$next.addClass('hand');
		
		//MAKE THE SCROLLER WORK
		$pane.serialScroll(
		{
		    items:$items,
		    prev:$prev,
		    next:$next,
		    lock:false,
		    cycle:true,
		    force: true,
		    constant: true,
			onBefore:function( e, elem, $pane, $items, pos )
			{
			
				var numItems = $items.length;
				
				$('.postcard_pag').text('Series ' + (pos + 1) + ' of ' + numItems);
	
				if( pos > 0 ) {
					$prev.fadeTo(1, 1.0).addClass('hand');
				}
				
				if( pos < numItems ) {
					$next.fadeTo(1, 1.0).addClass('hand');
				}
	
				if( pos === 0 ) {
					$prev.fadeTo(1, 0.1).removeClass('hand');
				}
				else if( (pos + 1) === numItems ) {
					$next.fadeTo(1, 0.1).removeClass('hand');
				}
			}
		});
		
		if(document.getElementById('postcard_controls'))

		{
			$items.find('img').each(function() 
			{
				var imgHeight = ($(this).height());
				if (imgHeight < 128)
				{
					var offset = Math.floor((128 - imgHeight)/2);
					$(this).css('padding-top', offset);
				}
			});
			
			var numItems = $items.size();
			$('.postcard_pag').text('Series 1  of ' + numItems);
			
		}
	}

	//RUN CODE FOR INDIVIDUAL TMB GALLERY IF ON PAGE
	if(document.getElementById('printtmb_pane'))
	{

		//SET IMAGE SLIDER WIDTH
		var pages = $('#printtmb_pane ul > li').size();
		var pagewidth = $('#printtmb_pane ul > li:first-child').width();
		var total = pages * pagewidth;
		$('#printtmb_pane > ul').width(total);

		//CACHE WRAPPER VARIABLES
		var $tmbprev = $('#printtmb_prev'),		//prev button
			$tmbnext = $('#printtmb_next');		//next button
		
		var $pane = $('#printtmb_pane'), 		//the item being scrolled
			$items = $pane.find('li.item');			//the scrolled items
			
		$tmbprev.fadeTo(1, 0.1);
		$tmbnext.addClass('hand');
		
		//MAKE THE SCROLLER WORK
		$pane.serialScroll(
		{
		    items:$items,
		    prev:$tmbprev,
		    next:$tmbnext,
		    constant:false,
		    stop: true,
		    lock: false,
		    cycle:true,
		    force: true,
			onBefore:function( e, elem, $pane, $items, pos )
			{
							
				var numItems = $items.length;
				
				$('.printtmb_pag').text((pos + 1) + ' of ' + numItems);
	
				if( pos > 0 ) {
					$tmbprev.fadeTo(1, 1.0).addClass('hand');
				}
				
				if( pos < numItems ) {
					$tmbnext.fadeTo(1, 1.0).addClass('hand');
				}
	
				if( pos === 0 ) {
					$tmbprev.fadeTo(1, 0.1).removeClass('hand');
				}
				else if( (pos + 1) === numItems ) {
					$tmbnext.fadeTo(1, 0.1).removeClass('hand');
				}
			}
		});
		
		if(document.getElementById('printtmb_controls'))

		{
			$items.each(function() 
			{
				var imgHeight = ($(this).find('img').height());
				if (imgHeight < 128)
				{
					var offset = Math.floor((128 - imgHeight)/2);
					$(this).css('padding-top', offset);
				}
			});
			
			var numItems = $items.size();
			$('.printtmb_pag').text(1 + ' of ' + numItems);
			
		}
	}

	//INITIATE THICKBOX FOR THICKBOX LINKS
	$('a.thickbox').thickbox({
    	macFFBgHack: '/images/backgrounds/macFFBgHack.png',
    	loadingImage: '/images/loadingIcon.gif'
    });
	
});