// JavaScript Document
/* CONOSOLE*/
window.log = function(){
  log.history = log.history || [];   // store logs to an array for reference
  log.history.push(arguments);
  arguments.callee = arguments.callee.caller;  
  if(this.console) console.log( Array.prototype.slice.call(arguments) );
};
//CONSOLE LOG
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();)b[a]=b[a]||c})(window.console=window.console||{});


(function($) {
// jQuery SWFObject v1.1.1 MIT/GPL @jon_neal
// http://jquery.thewikies.com/swfobject
(function(f,h,i){function k(a,c){var b=(a[0]||0)-(c[0]||0);return b>0||!b&&a.length>0&&k(a.slice(1),c.slice(1))}function l(a){if(typeof a!=g)return a;var c=[],b="";for(var d in a){b=typeof a[d]==g?l(a[d]):[d,m?encodeURI(a[d]):a[d]].join("=");c.push(b)}return c.join("&")}function n(a){var c=[];for(var b in a)a[b]&&c.push([b,'="',a[b],'"'].join(""));return c.join(" ")}function o(a){var c=[];for(var b in a)c.push(['<param name="',b,'" value="',l(a[b]),'" />'].join(""));return c.join("")}var g="object",m=true;try{var j=i.description||function(){return(new i("ShockwaveFlash.ShockwaveFlash")).GetVariable("$version")}()}catch(p){j="Unavailable"}var e=j.match(/\d+/g)||[0];f[h]={available:e[0]>0,activeX:i&&!i.name,version:{original:j,array:e,string:e.join("."),major:parseInt(e[0],10)||0,minor:parseInt(e[1],10)||0,release:parseInt(e[2],10)||0},hasVersion:function(a){a=/string|number/.test(typeof a)?a.toString().split("."):/object/.test(typeof a)?[a.major,a.minor]:a||[0,0];return k(e,a)},encodeParams:true,expressInstall:"expressInstall.swf",expressInstallIsActive:false,create:function(a){if(!a.swf||this.expressInstallIsActive||!this.available&&!a.hasVersionFail)return false;if(!this.hasVersion(a.hasVersion||1)){this.expressInstallIsActive=true;if(typeof a.hasVersionFail=="function")if(!a.hasVersionFail.apply(a))return false;a={swf:a.expressInstall||this.expressInstall,height:137,width:214,flashvars:{MMredirectURL:location.href,MMplayerType:this.activeX?"ActiveX":"PlugIn",MMdoctitle:document.title.slice(0,47)+" - Flash Player Installation"}}}attrs={data:a.swf,type:"application/x-shockwave-flash",id:a.id||"flash_"+Math.floor(Math.random()*999999999),width:a.width||320,height:a.height||180,style:a.style||""};m=typeof a.useEncode!=="undefined"?a.useEncode:this.encodeParams;a.movie=a.swf;a.wmode=a.wmode||"opaque";delete a.fallback;delete a.hasVersion;delete a.hasVersionFail;delete a.height;delete a.id;delete a.swf;delete a.useEncode;delete a.width;var c=document.createElement("div");c.innerHTML=["<object ",n(attrs),">",o(a),"</object>"].join("");return c.firstChild}};f.fn[h]=function(a){var c=this.find(g).andSelf().filter(g);/string|object/.test(typeof a)&&this.each(function(){var b=f(this),d;a=typeof a==g?a:{swf:a};a.fallback=this;if(d=f[h].create(a)){b.children().remove();b.html(d)}});typeof a=="function"&&c.each(function(){var b=this;b.jsInteractionTimeoutMs=b.jsInteractionTimeoutMs||0;if(b.jsInteractionTimeoutMs<660)b.clientWidth||b.clientHeight?a.call(b):setTimeout(function(){f(b)[h](a)},b.jsInteractionTimeoutMs+66)});return c}})(jQuery,"flash",navigator.plugins["Shockwave Flash"]||window.ActiveXObject);


//EASY SLIDER
(function(a){a.fn.easySlider=function(b){var c={prevId:"prevBtn",prevText:"Previous",nextId:"nextBtn",nextText:"Next",controlsShow:true,controlsBefore:"",controlsAfter:"",controlsFade:true,firstId:"firstBtn",firstText:"First",firstShow:false,lastId:"lastBtn",lastText:"Last",lastShow:false,vertical:false,speed:800,auto:false,pause:2e3,continuous:false,numeric:false,numericId:"controls"};var b=a.extend(c,b);this.each(function(){function n(d,j){if(g){g=false;var k=i;switch(d){case"next":i=k>=h?b.continuous?i+1:h:i+1;break;case"prev":i=i<=0?b.continuous?i-1:0:i-1;break;case"first":i=0;break;case"last":i=h;break;default:i=d;break}var l=Math.abs(k-i);var q=l*b.speed;if(!b.vertical){p=i*e*-1;a("ul",c).animate({marginLeft:p},{queue:false,duration:q,complete:m})}else{p=i*f*-1;a("ul",c).animate({marginTop:p},{queue:false,duration:q,complete:m})}if(!b.continuous&&b.controlsFade){if(i==h){a("a","#"+b.nextId).hide();a("a","#"+b.lastId).hide()}else{a("a","#"+b.nextId).show();a("a","#"+b.lastId).show()}if(i==0){a("a","#"+b.prevId).hide();a("a","#"+b.firstId).hide()}else{a("a","#"+b.prevId).show();a("a","#"+b.firstId).show()}}if(j)clearTimeout(o);if(b.auto&&d=="next"&&!j){o=setTimeout(function(){n("next",false)},l*b.speed+b.pause)}}}function m(){if(i>h)i=0;if(i<0)i=h;if(!b.vertical){a("ul",c).css("margin-left",i*e*-1)}else{a("ul",c).css("margin-left",i*f*-1)}g=true;if(b.numeric)l(i)}function l(c){c=parseInt(c)+1;a("li","#"+b.numericId).removeClass("current");a("li#"+b.numericId+c).addClass("current")}var c=a(this);var d=a("li",c).length;var e=a("li",c).width();var f=a("li",c).height();var g=true;c.width(e);c.height(f);c.css("overflow","hidden");var h=d-1;var i=0;a("ul",c).css("width",d*e);if(b.continuous){a("ul",c).prepend(a("ul li:last-child",c).clone().css("margin-left","-"+e+"px"));a("ul",c).append(a("ul li:nth-child(2)",c).clone());a("ul",c).css("width",(d+1)*e)}if(!b.vertical)a("li",c).css("float","left");if(b.controlsShow){var j=b.controlsBefore;if(b.numeric){j+='<ol id="'+b.numericId+'"></ol>'}else{if(b.firstShow)j+='<span id="'+b.firstId+'"><a href="javascript:void(0);">'+b.firstText+"</a></span>";j+=' <span id="'+b.prevId+'"><a href="javascript:void(0);">'+b.prevText+"</a></span>";j+=' <span id="'+b.nextId+'"><a href="javascript:void(0);">'+b.nextText+"</a></span>";if(b.lastShow)j+=' <span id="'+b.lastId+'"><a href="javascript:void(0);">'+b.lastText+"</a></span>"}j+=b.controlsAfter;a(c).after(j)}if(b.numeric){for(var k=0;k<d;k++){a(document.createElement("li")).attr("id",b.numericId+(k+1)).html("<a rel="+k+' href="javascript:void(0);">'+(k+1)+"</a>").appendTo(a("#"+b.numericId)).click(function(){n(a("a",a(this)).attr("rel"),true)})}}else{a("a","#"+b.nextId).click(function(){n("next",true)});a("a","#"+b.prevId).click(function(){n("prev",true)});a("a","#"+b.firstId).click(function(){n("first",true)});a("a","#"+b.lastId).click(function(){n("last",true)})}var o;if(b.auto){o=setTimeout(function(){n("next",false)},b.pause)}if(b.numeric)l(0);if(!b.continuous&&b.controlsFade){a("a","#"+b.prevId).hide();a("a","#"+b.firstId).hide()}})}})(jQuery)

//GOOGLE MAP SCRIPT
var GoogleMap={cur_map:null,menu:null,init:function(){if(jQuery("#map-holder").length>0){this.show();return}else{console.log("NO MAP")}},show:function(){function r(a,b){var c=q();var d=a.split(", ");var e=new Number(d[0].slice(1,d[0].length));var f=new Number(d[1].slice(0,d[1].length-1));e+=c;var g=new google.maps.LatLng(e,f);if(id==1){b.setZoom(2)}else{b.setZoom(2)}b.panTo(g)}function q(){}function p(a){a.target.removeEventListener("click",arguments.callee,false);a.target.ib.close()}function k(b,c,d,e,f){var g=d;var h=e;var i=f;var j=templateUrl+"/images/map-pin.png";var k=new google.maps.Marker({position:b,map:a,icon:j,zIndex:Math.round(b.lat()*-1e5)<<5});google.maps.event.addListener(k,"click",function(){jQuery("#map-overlay").html(g);jQuery("#map-overlay").css("display","block");jQuery(".location").each(function(){if(f!=""){var a=$(this).attr("id");var b=f.search(new RegExp(a));if(b==-1){jQuery(this).css("display","none")}else{jQuery(this).css("display","block")}}else{jQuery(this).css("display","block")}});a.panTo(this.position)});google.maps.event.addListener(k,"mouseover",function(){jQuery("#map-overlay").html(h);jQuery("#map-overlay").css("display","block")});k.setMap(a);return k}var a,b,c,d;var e=2;var f=true;b="http://maps.google.com/maps?ll=18.613514,-16.213541&z=2&t=m";d=new google.maps.LatLng(18.613514,-16.213541);e=2;lngPanOffset=0;f=true;var g=[{featureType:"all",elementType:"all"}];var h={zoom:e,center:d,mapTypeControl:false,navigationControl:true,scrollwheel:false,navigationControlOptions:{style:google.maps.NavigationControlStyle.ZOOM_PAN,position:google.maps.ControlPosition.TOP_LEFT},mapTypeId:google.maps.MapTypeId.ROADMAP};a=new google.maps.Map(document.getElementById("map-holder"),h);var j=new google.maps.InfoWindow({size:new google.maps.Size(190,70)});google.maps.event.addListener(j,"closeclick",function(){jQuery("#map-overlay").css("display","block");jQuery(".location").each(function(){$(this).css("display","block")})});if(markerArray){for(i in markerArray){var l=markerArray[i];var m=new Number(l[0]);var n=new Number(l[1]);var o=new google.maps.LatLng(m,n);k(o,"site-marker"+i,markerRefArray[i],markerTitleArray[i],markerSlugArray[i])}}var s={map:a,name:"tips4php"};var t=new google.maps.StyledMapType(g,s);a.mapTypes.set("tips4php",t);a.setMapTypeId("tips4php")}}



/*******************FEATURE SCROLL THUMB FUNCTIONS*******************/

	var scrollStartPos,scrollWidth,scrollLoc,scrollIndex,scrollIndexMax,maskWidth;
	var speed = 700;
	
	function scrollInit() {
		scrollIndex = 1;
		$("#staff-controls").css('left',scrollStartPos);
		scrollWidth = $("#staff-controls").width();
		//console.log("scrollInit: ",scrollWidth,maskWidth);
		scrollIndexMax = Math.floor(scrollWidth/maskWidth);
		//console.log(scrollIndexMax);
		if (scrollWidth < maskWidth) {
	//		console.log("scrollOff");
			$('#prevBtn a').addClass('off');
			$('#nextBtn a').addClass('off');
		} else {
	//		console.log("scrollOn");
			$('#prevBtn a').removeClass('off');
			$('#nextBtn a').removeClass('off');
		}
	}
	function scrollThumbsRight() {
		
		//scrollWidth = $("#featureThumbsHolder").width();
		scrollLoc = $("#staff-controls").position().left;
		scrollOffset = scrollLoc - maskWidth;
	//	console.log("scrollThumbsLeft"+scrollOffset);
		if (scrollOffset>(-scrollWidth)) {
			scrollAction(scrollOffset);
		}
	}
	
	function scrollThumbsLeft() {
	//	scrollWidth = $("#featureThumbsHolder").width();
		scrollLoc = $("#staff-controls").position().left;
		scrollOffset = scrollLoc + maskWidth;
		
	//	console.log("scrollThumbsRight"+scrollOffset);
		if (scrollOffset<=scrollStartPos) {
			scrollAction(scrollOffset);
		} else {
			scrollAction(scrollStartPos);
		}
	}
	
	function scrollAction(num) {
		$("#staff-controls").animate({ left:num },{ queue:false, duration:speed, complete:scrollAdjust });
	}
	
	function scrollAdjust() {
		
	}
/**************************************/
	
	
	function addFlash(targetDIV,sourceSWF,holderWidth,holderHeight) {
		if ($.flash.available) {
			//console.log('$.flash.available');
			$("#"+targetDIV).flash({
									swf:sourceSWF,
									width: holderWidth,
									height: holderHeight,
									allowFullScreen: true,
									allowscriptaccess: 'always',
									wmode: 'transparent',
									allowScriptAccess:'sameDomain',
									quality:'high',
									swLiveConnect:true
									});	
		}
	}
	
	
	
	function startList() {
		$('#the_menu li').each(function() {
			$(this).mouseover(function(){ $(this).addClass('over'); });
			$(this).mouseout(function(){ $(this).removeClass('over'); });
		});
	}
	
	function updateSiteStyle(whichStyle) {
		$('#bgholder').fadeOut(300, function() {
		// Animation complete.
		$(this).html('<img src="img/'+styleArray[whichStyle]+'.jpg" />');
		$(this).fadeIn(300);
	  });
	}

	
	function ie8SafePreventEvent(e){
		if(e.preventDefault){ e.preventDefault()}
		else{e.stop()};
	
		e.returnValue = false;
		e.stopPropagation();        
	}	
	
	function compareObj(a, b) {
		var x = a.region.toString();
		var y = b.region.toString();
		return y - x;
	}

//moveScrollers(ui.value);

	/*******************RESIZE HANDLER*******************/
	function onResize() {
			var wrapperX;
			var stageWidth = $(window).width();
			//var stageHeight = jQuery(window).height();
			wrapperX = ((stageWidth - 1100)/2);
			//jQuery('#main').css('top',value1+'px');	
			$('#wrapper').css('left',wrapperX+'px');

	//		var $winwidth = $(window).width();
	//		$("img.source-image").attr({
			//		width: $winwidth
	//		});
	}


	
	/*******************DOM READY HANDLER*******************/
	var siteXOffset,siteYOffset;
	
	
	
	$(document).ready(function() {
		//Cufon.now();
		var footHTML = '<div class="legal">';
		if (pageIDNum=='34'||pageIDNum=='393'||pageIDNum=='590'||pageIDNum=='588') {
			footHTML += '<div class="inv-disclaimer"> This information is not intended as an offer to sell, or the solicitation of an offer to buy, a franchise.<br />It is for information purposes only. Various jurisdictions regulate the offer and sale of franchises. We will not offer you a franchise unless and until we have complied with applicable pre-sale registration and disclosure requirements(if any) in your jurisdiction.</div>';
		}
		footHTML += 'copyright &copy;2011 SkyVenture, LLC. | <a href="index.php?page_id=576">Privacy Policy</a> | <a href="index.php?page_id=578">Terms and Conditions</a></div>';
/*		footHTML += 'copyright &copy;2011 SkyVenture, LLC. | <a href="index.php?page_id=576">Privacy Policy</a> | <a href="index.php?page_id=578">Terms and Conditions</a> | <a href="index.php?page_id=580">FAQ</a></div>';
*/		$('#content').append(footHTML);
		
		var $winwidth = $(window).width();
		$("img.source-image").attr({
        	width: $winwidth
        });

		//SPAN FOR EXPANDING DYNAMIC BUTTONS
		$('#menus ul li a, a.exp-button').each(function() {
				var newHTML = $(this).html() + '<span></span>';
				$(this).html(newHTML);
		});
		$('#menus ul li a').each(function() {
				var thisNav = $(this);
				if(thisNav.height() > 27){
					$(this).addClass('expanded');
				}
				$(this).addClass('arrow_button');
		});
		
		//
		
		//PARALAX SETUP
	//	$('#site-bg').html('<div class="homeBG"></div><div class="homeBG"></div><div class="homeBG"></div><div class="homeBG"></div><div class="homeBG"></div><div class="homeBG"></div><div class="homeBG"></div><div class="homeBG"></div><div class="homeBG"></div>');
		$('#site-bg').html('<div class="homeBG"></div><div class="homeBG"></div><div class="homeBG"></div><div class="homeBG"></div><div class="homeBG"></div><div class="homeBG"></div><div class="homeBG"></div>');
	
		//HOMEPAGE NAVIGATION

		$('#jwplayer-1-div').html('')
		addFlash('jwplayer-1-div','iFly_introVid.swf',755,424);
		$('#jwplayer-1-div').append('<div id="video-close"><a class="close_bn" href="javascript:void(0);">Close Video</a></div>');

		$('#video-close a').live("click", function(e){
			$('#one #jwplayer-1-div').css('display','none');
			$('#jwplayer-1-div').html('')
			e.preventDefault();
		});
			
		$('#mainVideo').click(function(e) {
			//console.log('CLICKED');
			if($('#jwplayer-1-div').html() =='') {
				addFlash('jwplayer-1-div','iFly_introVid.swf',755,424);
				$('#jwplayer-1-div').append('<div id="video-close"><a class="close_bn" href="javascript:void(0);">Close Video</a></div>');
			}
			$('#jwplayer-1-div').css('display','block');
			//jwplayer().play();
			e.preventDefault();
			});

		if ($('#content').hasClass('home-page')) {
			
			/*$("#staffSlider").easySlider({
				auto: false,
				controlsShow: true,
				controlsFade: false,
				continuous: true,
				numeric: true,
				numericId: 'staff-controls',
				speed: 500
			});
			$('#staff-controls').wrap('<div id="controls-holder" />');
			$('#staffSlider').prepend('<div id="prevBtn"><a href="javascript:void(0);"></a></div>');
			$('#staffSlider').append('<div id="nextBtn"><a href="javascript:void(0);"></a></div>');
			
			var staffImageArray = new Array();
			
			$('.staff').each(function() {
				var targetIMG = $(this).find('img');
				staffImageArray.push(targetIMG.attr('src'));
			});
			
			var slideCount = staffImageArray.length;
			//console.log(staffImageArray);
			
			for (var i=1; i <= slideCount; i++) {
				var targetThumb = $('li#staff-controls'+i+' a');
				var targetPath = 'url("'+staffImageArray[i]+'")';
				$('li#staff-controls'+i+' a').css('background-image',targetPath);
			}
			
			maskWidth = 752;
			scrollStartPos = $('#staff-controls').position().left;
			scrollInit();*/
		
		
			$('#prevBtn a').live("click", function(e){
				scrollThumbsLeft()
				e.preventDefault();
			});
			
			$('#nextBtn a').live("click", function(e){
				scrollThumbsRight()
				e.preventDefault();
			});
			


			
			if($('#menus ul.sub-menu li.current-menu-item').length > 0) {
				//console.log($('#menus ul.sub-menu li.current-menu-item'));
//				$('#menus ul li.current-menu-parent > ul').prepend('<div id="sub-pointer">•</div>');
//					var itemTop = $('#menus ul.sub-menu li.current-menu-item a').offset().top - $('#menus ul.sub-menu').offset().top+35;
//					$('#sub-pointer').stop().animate({top:itemTop},0);
//					
//					$('#menus ul.sub-menu li a').unbind('click').bind('click',function () {
//					var itemTop = $(this).offset().top - $('#menus ul.sub-menu').offset().top+35;
//					$('#sub-pointer').stop().animate({top:itemTop},300);
//				 });
			}
			
			$('#menus ul.sub-menu li a').each(function() {
//				$(this).mouseover(function () {
//					var itemTop = $(this).offset().top - $(this).parent().parent('ul.sub-menu').offset().top;
//					$('#sub-pointer').stop().animate({top:itemTop},300);
//				 });
					 
				$(this).click(function (e) {
						e.preventDefault();
						
						//prevent instant jump to scroll location
						ie8SafePreventEvent(e);                                             
						
						$('#menus ul.sub-menu li a').each(function() {$(this).removeClass('active-sub');});
//						var itemTop = $(this).offset().top - $('#menus ul.sub-menu').height()+35;
//						$('#sub-pointer').stop().animate({top:itemTop},300);
						
						$(this).addClass('active-sub');
						
						//SCROLL HANDLING
						//get the href value
						
						$('#menus ul.sub-menu li').each(function(){$(this).removeClass('current-menu-item');});
						$(this).parent('li').addClass('current-menu-item');
						
						var targetPos;
						var compHREF = $(this).attr('href');
						$('section').each(function() {
							var whichSubsection =  $(this).attr('id');
							if (compHREF== whichSubsection) {
								
								targetPos = $(this).position().top;
						//		console.log('targetPos',targetPos);
								ie8SafePreventEvent(e);                                      
								       
								$('html,body').stop().animate({ scrollTop: targetPos-80}, 800);
								
							} else {
								//$(this).removeClass('selected');
							}
						});
						
						return false;
	
					});
			});
			
		} else {
			
			if($('#tunnel-swf').length > 0){
				addFlash('tunnel-swf','/wp-content/uploads/2011/11/tunnel_sizes.swf',825,600);
			}

/*			if($('#menus ul.sub-menu li.current-menu-item').length > 0) {
				//console.log($('#menus ul.sub-menu li.current-menu-item'));
				$('#menus ul li.current-menu-parent > ul').prepend('<div id="sub-pointer">•</div>');
					var itemTop = $('#menus ul.sub-menu li.current-menu-item a').offset().top - $('#menus ul.sub-menu').height()+37;
					$('#sub-pointer').stop().animate({top:itemTop},0);
			}
*/
			$('html').css('background','none');
			$('html').css('background-color','#050B22');

			if ($('#content').hasClass('locations-page')) {
				GoogleMap.init();
				startList();

				var mapmenuObj = new Array();
				var i=0;
				$('#map-list .location').each(function() {
					var entryObj = new Object();
					entryObj.region = $(this).attr('class').replace('location ', '');
					entryTitle = $(this).attr('title');
					entryObj.menuItem = '<li><a href="javascript:void(0)" rel="'+$(this).attr('id')+'">'+entryTitle+'</a></li>';
					mapmenuObj.push(entryObj);
					//console.log("entryObj",entryObj);
					//<div class="location <?php echo $location_region?>" title="<?php echo $location_name; ?>" id="<?php echo $location_slug; ?>">
				});
				$('li.image_list_item').each(function() {
					
					var oldIMGcont = $(this).html();
					var IMGsrc = $(this).children("img").attr('src');
					//console.log(IMGsrc,'IMGsrc')
					var newIMGcont = '<a href="'+IMGsrc+'" rel="lightbox">'+oldIMGcont+'</a>';
					$(this).html(newIMGcont);
				});
				
				var sortedMenu = mapmenuObj.sort(compareObj);
				var htmlOutput='';
				
				var feedLength = sortedMenu.length;
				for (var i = 0; i < feedLength; i++) {
						htmlOutput += sortedMenu[i].menuItem.toString();
				}
				htmlOutput.replace('undefined', '');			
				if ($('ul#the_menu_sub').length > 0) {
					 $('ul#the_menu_sub').append(htmlOutput);
					 $('ul#the_menu_sub li a').each(function() {
						 $(this).click(function() {
							 var refRel = $(this).attr('rel');
							// console.log(refRel);
							$('.location').each(function() {
								if(refRel != '') {
								var currentID = $(this).attr('id');
								var isFound = refRel.search(new RegExp(currentID));
								if (isFound == -1) {
									$(this).css('display','none');	
								} else {
									$(this).css('display','block');	
								}
								} else {
									$(this).css('display','block');	
								}
							});
						 });
						 $('ul#the_menu_sub li a.all-locations').unbind('click').bind('click',function (e) {
							e.preventDefault();
							$('.location').each(function() {
								$(this).css('display','block');	
							});
						 });
					 });
				
					var maxHeight = 150;
					$("#the_menu > li").hover(function() {
						//console.log("REACHED");
						 var $container = $(this),
							 $list = $container.find("ul"),
							 $anchor = $container.find("a"),
							 height = $list.height() * 1.1,       // make sure there is enough room at the bottom
							 multiplier = height / maxHeight;     // needs to move faster if list is taller
						
						// need to save height here so it can revert on mouseout            
						$container.data("origHeight", $container.height());
						
						// so it can retain it's rollover color all the while the dropdown is open
						$anchor.addClass("hover");
						
						// make sure dropdown appears directly below parent list item    
						$list
							.show()
							.css({
								paddingTop: $container.data("origHeight")
							});
						
						// don't do any animation if list shorter than max
						if (multiplier > 1) {
							$container
								.css({
									height: maxHeight,
									overflow: "hidden"
								})
								.mousemove(function(e) {
									var offset = $container.offset();
									var relativeY = ((e.pageY - offset.top) * multiplier) - ($container.data("origHeight") * multiplier);
									if (relativeY > $container.data("origHeight")) {
										$list.css("top", -relativeY + $container.data("origHeight"));
									};
								});
						}
						
					}, function() {
					
						var $el = $(this);
						
						// put things back to normal
						$el
							.height($(this).data("origHeight"))
							.find("ul")
							.css({ top: 0 })
							.hide()
							.end()
							.find("a")
							.removeClass("hover");
					
					});
					
					// Add down arrow only to menu items with submenus
//					$(".dropdown > li:has('ul')").each(function() {
//						$(this).find("a:first").append("<img src='images/down-arrow.png' />");
//					});
					
				}

			}
	
					
		};
		
		
		$(this).scroll(function(e) {
			var scrollContent = $('#site-topLayer');
			var scrollContentMax = scrollContent.height();
			var scrollContentScroll = $(this).scrollTop();
			
			var current = $(this);
			var currentScroll = $(this).scrollTop();
			var currentHeight = current.height();
			
			var scrollMod = $('#site-bg');
			var scrollModMax = scrollMod.height();
			
			var targetPos = -(currentScroll/currentHeight) * scrollModMax;

			//console.log(currentScroll,currentHeight,scrollModMax);
			
			
			scrollMod.stop().animate({top:targetPos}, 400, "linear");
		});
		$('li.panel p:first-child').each(function() {
			//$(this).wrapStart(4);
		});
		
	
		Cufon.replace('h1', {
			color: '-linear-gradient(0.7=#FFFFFF, .8=#777777, #333333)'
		});
	
		// Event handlers
		//$(window).resize(function() {onResize();});

		siteXOffset = $("#wrapper").offset().left;
		siteYOffset = $("#wrapper").offset().top;
		//onResize();
		Cufon.refresh();
		$('#wrapper').css('visibility','visible');
		$('#site-bg').css('visibility','visible');

//		$('html').stop().animate({ scrollTop: 2000}, 0, function() {
//			//console.log('SCROLLING');
//			$('#wrapper').css('visibility','visible');
//			$('#site-bg').css('visibility','visible');
//			$('html').stop().animate({ scrollTop: 0}, "slow");
//		});
		
	});
	
})(jQuery);
