var QueryLoader = {
	/*
	 * QueryLoader		Preload your site before displaying it!
	 * Author:			Gaya Kessler
	 * Date:			23-09-09
	 * URL:				http://www.gayadesign.com
	 * Version:			1.0
	 * 
	 * A simple jQuery powered preloader to load every image on the page and in the CSS
	 * before displaying the page to the user.
	 */
	
	overlay: "",
	loadBar: "",
	preloader: "",
	items: new Array(),
	doneStatus: 0,
	doneNow: 0,
	selectorPreload: "body",
	ieLoadFixTime: 2000,
	ieTimeout: "",
		
	init: function() {
		if (navigator.userAgent.match(/MSIE (\d+(?:\.\d+)+(?:b\d*)?)/) == "MSIE 6.0,6.0") {
			//break if IE6			
			return false;
		}
		if (QueryLoader.selectorPreload == "body") {
			QueryLoader.spawnLoader();
			QueryLoader.getImages(QueryLoader.selectorPreload);
			QueryLoader.createPreloading();
		} else {
			jQuery(document).ready(function() {
				QueryLoader.spawnLoader();
				QueryLoader.getImages(QueryLoader.selectorPreload);
				QueryLoader.createPreloading();
			});
		}
		
		//help IE drown if it is trying to die :)
		QueryLoader.ieTimeout = setTimeout("QueryLoader.ieLoadFix()", QueryLoader.ieLoadFixTime);
	},
	
	ieLoadFix: function() {
		var ie = navigator.userAgent.match(/MSIE (\d+(?:\.\d+)+(?:b\d*)?)/);
		//if (ie[0].match("MSIE")) {
//			while ((100 / QueryLoader.doneStatus) * QueryLoader.doneNow < 100) {
//				QueryLoader.imgCallback();
//			}
		//}
	},
	
	imgCallback: function() {
		QueryLoader.doneNow ++;
		QueryLoader.animateLoader();
	},
	
	getImages: function(selector) {
		var everything = jQuery(selector).find("*:not(script)").each(function() {
			var url = "";
			
			if (jQuery(this).css("background-image") != "none") {
				var url = jQuery(this).css("background-image");
			} else if (typeof(jQuery(this).attr("src")) != "undefined" && jQuery(this).attr("tagName").toLowerCase() == "img") {
				var url = jQuery(this).attr("src");
			}
			
			url = url.replace("url(\"", "");
			url = url.replace("url(", "");
			url = url.replace("\")", "");
			url = url.replace(")", "");
			
			if (url.length > 0) {
				QueryLoader.items.push(url);
			}
		});
	},
	
	createPreloading: function() {
		QueryLoader.preloader = jQuery("<div></div>").appendTo(QueryLoader.selectorPreload);
		jQuery(QueryLoader.preloader).css({
			height: 	"0px",
			width:		"0px",
			overflow:	"hidden"
		});
		
		var length = QueryLoader.items.length; 
		QueryLoader.doneStatus = length;
		
		for (var i = 0; i < length; i++) {
			var imgLoad = jQuery("<img></img>");
			jQuery(imgLoad).attr("src", QueryLoader.items[i]);
			jQuery(imgLoad).unbind("load");
			jQuery(imgLoad).bind("load", function() {
				QueryLoader.imgCallback();
			});
			jQuery(imgLoad).appendTo(jQuery(QueryLoader.preloader));
		}
	},

	spawnLoader: function() {
		if (QueryLoader.selectorPreload == "body") {
			var height = jQuery(window).height();
			var width = jQuery(window).width();
			var position = "fixed";
		} else {
			var height = jQuery(QueryLoader.selectorPreload).outerHeight();
			var width = jQuery(QueryLoader.selectorPreload).outerWidth();
			var position = "absolute";
		}
		var left = jQuery(QueryLoader.selectorPreload).offset()['left'];
		var top = jQuery(QueryLoader.selectorPreload).offset()['top'];
		
		QueryLoader.overlay = jQuery("<div>Loading Section 30 - Primary Interface<span id='loadPer'></span></div>").appendTo(jQuery(QueryLoader.selectorPreload));
		jQuery(QueryLoader.overlay).addClass("QOverlay");
		jQuery(QueryLoader.overlay).css({
			position: position,
			top: top,
			left: left,
			width: width + "px",
			height: height + "px"
		});
		
		QueryLoader.loadBar = jQuery("<div></div>").appendTo(jQuery(QueryLoader.overlay));
		jQuery(QueryLoader.loadBar).addClass("QLoader");
		
		jQuery(QueryLoader.loadBar).css({
			position: "relative",
			top: "50%",
			width: "0%"
		});
	},
	
	animateLoader: function() {
		var perc = (100 / QueryLoader.doneStatus) * QueryLoader.doneNow;
		if (perc > 99) {
			 document.getElementById("loadPer").innerHTML = " - "+Math.round(perc) +"%";
			jQuery(QueryLoader.loadBar).stop().animate({
				width: perc + "%"
			}, 500, "linear", function() { 
				QueryLoader.doneLoad();
			});
		} else {
			 document.getElementById("loadPer").innerHTML = " - "+Math.round(perc) +"%";
			jQuery(QueryLoader.loadBar).stop().animate({
				width: perc + "%"
			}, 500, "linear", function() {});
			
		}
	},
	
	doneLoad: function() {
		//prevent IE from calling the fix
		clearTimeout(QueryLoader.ieTimeout);
		
		//determine the height of the preloader for the effect
		if (QueryLoader.selectorPreload == "body") {
			var height = jQuery(window).height();
		} else {
			var height = jQuery(QueryLoader.selectorPreload).outerHeight();
		}
		
		//The end animation, adjust to your likings
		jQuery(QueryLoader.loadBar).animate({
			opacity: 0.0
		}, 800, "linear", function() {
			jQuery(QueryLoader.overlay).fadeOut(800);
			jQuery(QueryLoader.preloader).remove();
		});
	}
}
;jQuery.preloadCssImages = function(settings){
	settings = jQuery.extend({
		statusTextEl: null,
		statusBarEl: null,
		errorDelay: 999, // handles 404-Errors in IE
		simultaneousCacheLoading: 2
	}, settings);
	var allImgs = [],
		loaded = 0,
		imgUrls = [],
		thisSheetRules,	
		errorTimer;
	
	function onImgComplete(){
		clearTimeout(errorTimer);
		if (imgUrls && imgUrls.length && imgUrls[loaded]) {
			loaded++;
			if (settings.statusTextEl) {
				var nowloading = (imgUrls[loaded]) ? 
					'Now Loading: <span>' + imgUrls[loaded].split('/')[imgUrls[loaded].split('/').length - 1] : 
					jQuery(".QOverlay").fadeOut();  // wrong status-text bug fixed
				//jQuery(settings.statusTextEl).html('<span class="numLoaded">' + loaded + '</span> of <span class="numTotal">' + imgUrls.length + '</span> loaded (<span class="percentLoaded">' + (loaded / imgUrls.length * 100).toFixed(0) + '%</span>) <span class="currentImg">' + nowloading + '</span></span>');
				jQuery(settings.statusTextEl).html('<span class="percentLoaded">' + (loaded / imgUrls.length * 100).toFixed(0) + '%</span> <span class="currentImg"></span></span>');
			}
			if (settings.statusBarEl) {
				var barWidth = jQuery(settings.statusBarEl).width();
				jQuery(settings.statusBarEl).css('background-position', -(barWidth - (barWidth * loaded / imgUrls.length).toFixed(0)) + 'px 50%');
			}
			loadImgs();
		}
	}
	
	function loadImgs(){
		//only load 1 image at the same time / most browsers can only handle 2 http requests, 1 should remain for user-interaction (Ajax, other images, normal page requests...)
		// otherwise set simultaneousCacheLoading to a higher number for simultaneous downloads
		if(imgUrls && imgUrls.length && imgUrls[loaded]){
			var img = new Image(); //new img obj
			img.src = imgUrls[loaded];	//set src either absolute or rel to css dir
			if(!img.complete){
				jQuery(img).bind('error load onreadystatechange', onImgComplete);
			} else {
				onImgComplete();
			}
			errorTimer = setTimeout(onImgComplete, settings.errorDelay); // handles 404-Errors in IE
		}
	}
	
	function parseCSS(sheets, urls) {
		var w3cImport = false,
			imported = [],
			importedSrc = [],
			baseURL;
		var sheetIndex = sheets.length;
		while(sheetIndex--){//loop through each stylesheet
			
			var cssPile = '';//create large string of all css rules in sheet
			
			if(urls && urls[sheetIndex]){
				baseURL = urls[sheetIndex];
			} else {
				var csshref = (sheets[sheetIndex].href) ? sheets[sheetIndex].href : 'window.location.href';
				var baseURLarr = csshref.split('/');//split href at / to make array
				baseURLarr.pop();//remove file path from baseURL array
				baseURL = baseURLarr.join('/');//create base url for the images in this sheet (css file's dir)
				if (baseURL) {
					baseURL += '/'; //tack on a / if needed
				}
			}
			if(sheets[sheetIndex].cssRules || sheets[sheetIndex].rules){
				thisSheetRules = (sheets[sheetIndex].cssRules) ? //->>> http://www.quirksmode.org/dom/w3c_css.html
					sheets[sheetIndex].cssRules : //w3
					sheets[sheetIndex].rules; //ie 
				var ruleIndex = thisSheetRules.length;
				while(ruleIndex--){
					if(thisSheetRules[ruleIndex].style && thisSheetRules[ruleIndex].style.cssText){
						var text = thisSheetRules[ruleIndex].style.cssText;
						if(text.toLowerCase().indexOf('url') != -1){ // only add rules to the string if you can assume, to find an image, speed improvement
							cssPile += text; // thisSheetRules[ruleIndex].style.cssText instead of thisSheetRules[ruleIndex].cssText is a huge speed improvement
						}
					} else if(thisSheetRules[ruleIndex].styleSheet) {
						imported.push(thisSheetRules[ruleIndex].styleSheet);
						w3cImport = true;
					}
					
				}
			}
			//parse cssPile for image urls
			var tmpImage = cssPile.match(/[^\("]+\.(gif|jpg|jpeg|png)/g);//reg ex to get a string of between a "(" and a ".filename" / '"' for opera-bugfix
			if(tmpImage){
				var i = tmpImage.length;
				while(i--){ // handle baseUrl here for multiple stylesheets in different folders bug
					var imgSrc = (tmpImage[i].charAt(0) == '/' || tmpImage[i].match('://')) ? // protocol-bug fixed
						tmpImage[i] : 
						baseURL + tmpImage[i];
					
					if(jQuery.inArray(imgSrc, imgUrls) == -1){
						imgUrls.push(imgSrc);
					}
				}
			}
			
			if(!w3cImport && sheets[sheetIndex].imports && sheets[sheetIndex].imports.length) {
				for(var iImport = 0, importLen = sheets[sheetIndex].imports.length; iImport < importLen; iImport++){
					var iHref = sheets[sheetIndex].imports[iImport].href;
					iHref = iHref.split('/');
					iHref.pop();
					iHref = iHref.join('/');
					if (iHref) {
						iHref += '/'; //tack on a / if needed
					}
					var iSrc = (iHref.charAt(0) == '/' || iHref.match('://')) ? // protocol-bug fixed
						iHref : 
						baseURL + iHref;
					
					importedSrc.push(iSrc);
					imported.push(sheets[sheetIndex].imports[iImport]);
				}
				
				
			}
		}//loop
		if(imported.length){
			parseCSS(imported, importedSrc);
			return false;
		}
		var downloads = settings.simultaneousCacheLoading;
		while( downloads--){
			setTimeout(loadImgs, downloads);
		}
	}
	parseCSS(document.styleSheets);
	return imgUrls;
};

$(document).ready(function(){
 //jQuery("body").addClass("prePreLoad")
 QueryLoader.init();
 jQuery("<div class='QOverlay' style='background:none;color='#ccc';'>Loading Section 30 - Background Images - <span id='loadPer2'></span></div>").appendTo("#topLogo");
  jQuery("body").removeClass("prePreLoad")
  jQuery.preloadCssImages({statusTextEl: '#loadPer2'}); 
}); 

// End Preloader

//Begin Sifr
var sIFR=new function(){var O=this;var E={ACTIVE:"sIFR-active",REPLACED:"sIFR-replaced",IGNORE:"sIFR-ignore",ALTERNATE:"sIFR-alternate",CLASS:"sIFR-class",LAYOUT:"sIFR-layout",FLASH:"sIFR-flash",FIX_FOCUS:"sIFR-fixfocus",DUMMY:"sIFR-dummy"};E.IGNORE_CLASSES=[E.REPLACED,E.IGNORE,E.ALTERNATE];this.MIN_FONT_SIZE=6;this.MAX_FONT_SIZE=126;this.FLASH_PADDING_BOTTOM=5;this.VERSION="436";this.isActive=false;this.isEnabled=true;this.fixHover=true;this.autoInitialize=true;this.setPrefetchCookie=true;this.cookiePath="/";this.domains=[];this.forceWidth=true;this.fitExactly=false;this.forceTextTransform=true;this.useDomLoaded=true;this.useStyleCheck=false;this.hasFlashClassSet=false;this.repaintOnResize=true;this.replacements=[];var L=0;var R=false;function Y(){}function D(c){function d(e){return e.toLocaleUpperCase()}this.normalize=function(e){return e.replace(/\n|\r|\xA0/g,D.SINGLE_WHITESPACE).replace(/\s+/g,D.SINGLE_WHITESPACE)};this.textTransform=function(e,f){switch(e){case"uppercase":return f.toLocaleUpperCase();case"lowercase":return f.toLocaleLowerCase();case"capitalize":return f.replace(/^\w|\s\w/g,d)}return f};this.toHexString=function(e){if(e.charAt(0)!="#"||e.length!=4&&e.length!=7){return e}e=e.substring(1);return"0x"+(e.length==3?e.replace(/(.)(.)(.)/,"$1$1$2$2$3$3"):e)};this.toJson=function(g,f){var e="";switch(typeof(g)){case"string":e='"'+f(g)+'"';break;case"number":case"boolean":e=g.toString();break;case"object":e=[];for(var h in g){if(g[h]==Object.prototype[h]){continue}e.push('"'+h+'":'+this.toJson(g[h]))}e="{"+e.join(",")+"}";break}return e};this.convertCssArg=function(e){if(!e){return{}}if(typeof(e)=="object"){if(e.constructor==Array){e=e.join("")}else{return e}}var l={};var m=e.split("}");for(var h=0;h<m.length;h++){var k=m[h].match(/([^\s{]+)\s*\{(.+)\s*;?\s*/);if(!k||k.length!=3){continue}if(!l[k[1]]){l[k[1]]={}}var g=k[2].split(";");for(var f=0;f<g.length;f++){var n=g[f].match(/\s*([^:\s]+)\s*\:\s*([^;]+)/);if(!n||n.length!=3){continue}l[k[1]][n[1]]=n[2].replace(/\s+$/,"")}}return l};this.extractFromCss=function(g,f,i,e){var h=null;if(g&&g[f]&&g[f][i]){h=g[f][i];if(e){delete g[f][i]}}return h};this.cssToString=function(f){var g=[];for(var e in f){var j=f[e];if(j==Object.prototype[e]){continue}g.push(e,"{");for(var i in j){if(j[i]==Object.prototype[i]){continue}var h=j[i];if(D.UNIT_REMOVAL_PROPERTIES[i]){h=parseInt(h,10)}g.push(i,":",h,";")}g.push("}")}return g.join("")};this.escape=function(e){return escape(e).replace(/\+/g,"%2B")};this.encodeVars=function(e){return e.join("&").replace(/%/g,"%25")};this.copyProperties=function(g,f){for(var e in g){if(f[e]===undefined){f[e]=g[e]}}return f};this.domain=function(){var f="";try{f=document.domain}catch(g){}return f};this.domainMatches=function(h,g){if(g=="*"||g==h){return true}var f=g.lastIndexOf("*");if(f>-1){g=g.substr(f+1);var e=h.lastIndexOf(g);if(e>-1&&(e+g.length)==h.length){return true}}return false};this.uriEncode=function(e){return encodeURI(decodeURIComponent(e))};this.delay=function(f,h,g){var e=Array.prototype.slice.call(arguments,3);setTimeout(function(){h.apply(g,e)},f)}}D.UNIT_REMOVAL_PROPERTIES={leading:true,"margin-left":true,"margin-right":true,"text-indent":true};D.SINGLE_WHITESPACE=" ";function U(e){var d=this;function c(g,j,h){var k=d.getStyleAsInt(g,j,e.ua.ie);if(k==0){k=g[h];for(var f=3;f<arguments.length;f++){k-=d.getStyleAsInt(g,arguments[f],true)}}return k}this.getBody=function(){return document.getElementsByTagName("body")[0]||null};this.querySelectorAll=function(f){return window.parseSelector(f)};this.addClass=function(f,g){if(g){g.className=((g.className||"")==""?"":g.className+" ")+f}};this.removeClass=function(f,g){if(g){g.className=g.className.replace(new RegExp("(^|\\s)"+f+"(\\s|$)"),"").replace(/^\s+|(\s)\s+/g,"$1")}};this.hasClass=function(f,g){return new RegExp("(^|\\s)"+f+"(\\s|$)").test(g.className)};this.hasOneOfClassses=function(h,g){for(var f=0;f<h.length;f++){if(this.hasClass(h[f],g)){return true}}return false};this.ancestorHasClass=function(g,f){g=g.parentNode;while(g&&g.nodeType==1){if(this.hasClass(f,g)){return true}g=g.parentNode}return false};this.create=function(f,g){var h=document.createElementNS?document.createElementNS(U.XHTML_NS,f):document.createElement(f);if(g){h.className=g}return h};this.getComputedStyle=function(h,i){var f;if(document.defaultView&&document.defaultView.getComputedStyle){var g=document.defaultView.getComputedStyle(h,null);f=g?g[i]:null}else{if(h.currentStyle){f=h.currentStyle[i]}}return f||""};this.getStyleAsInt=function(g,i,f){var h=this.getComputedStyle(g,i);if(f&&!/px$/.test(h)){return 0}return parseInt(h)||0};this.getWidthFromStyle=function(f){return c(f,"width","offsetWidth","paddingRight","paddingLeft","borderRightWidth","borderLeftWidth")};this.getHeightFromStyle=function(f){return c(f,"height","offsetHeight","paddingTop","paddingBottom","borderTopWidth","borderBottomWidth")};this.getDimensions=function(j){var h=j.offsetWidth;var f=j.offsetHeight;if(h==0||f==0){for(var g=0;g<j.childNodes.length;g++){var k=j.childNodes[g];if(k.nodeType!=1){continue}h=Math.max(h,k.offsetWidth);f=Math.max(f,k.offsetHeight)}}return{width:h,height:f}};this.getViewport=function(){return{width:window.innerWidth||document.documentElement.clientWidth||this.getBody().clientWidth,height:window.innerHeight||document.documentElement.clientHeight||this.getBody().clientHeight}};this.blurElement=function(g){try{g.blur();return}catch(h){}var f=this.create("input");f.style.width="0px";f.style.height="0px";g.parentNode.appendChild(f);f.focus();f.blur();f.parentNode.removeChild(f)}}U.XHTML_NS="http://www.w3.org/1999/xhtml";function H(r){var g=navigator.userAgent.toLowerCase();var q=(navigator.product||"").toLowerCase();var h=navigator.platform.toLowerCase();this.parseVersion=H.parseVersion;this.macintosh=/^mac/.test(h);this.windows=/^win/.test(h);this.linux=/^linux/.test(h);this.quicktime=false;this.opera=/opera/.test(g);this.konqueror=/konqueror/.test(g);this.ie=false/*@cc_on||true@*/;this.ieSupported=this.ie&&!/ppc|smartphone|iemobile|msie\s5\.5/.test(g)/*@cc_on&&@_jscript_version>=5.5@*/;this.ieWin=this.ie&&this.windows/*@cc_on&&@_jscript_version>=5.1@*/;this.windows=this.windows&&(!this.ie||this.ieWin);this.ieMac=this.ie&&this.macintosh/*@cc_on&&@_jscript_version<5.1@*/;this.macintosh=this.macintosh&&(!this.ie||this.ieMac);this.safari=/safari/.test(g);this.webkit=!this.konqueror&&/applewebkit/.test(g);this.khtml=this.webkit||this.konqueror;this.gecko=!this.khtml&&q=="gecko";this.ieVersion=this.ie&&/.*msie\s(\d\.\d)/.exec(g)?this.parseVersion(RegExp.$1):"0";this.operaVersion=this.opera&&/.*opera(\s|\/)(\d+\.\d+)/.exec(g)?this.parseVersion(RegExp.$2):"0";this.webkitVersion=this.webkit&&/.*applewebkit\/(\d+).*/.exec(g)?this.parseVersion(RegExp.$1):"0";this.geckoVersion=this.gecko&&/.*rv:\s*([^\)]+)\)\s+gecko/.exec(g)?this.parseVersion(RegExp.$1):"0";this.konquerorVersion=this.konqueror&&/.*konqueror\/([\d\.]+).*/.exec(g)?this.parseVersion(RegExp.$1):"0";this.flashVersion=0;if(this.ieWin){var l;var o=false;try{l=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")}catch(m){try{l=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");this.flashVersion=this.parseVersion("6");l.AllowScriptAccess="always"}catch(m){o=this.flashVersion==this.parseVersion("6")}if(!o){try{l=new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(m){}}}if(!o&&l){this.flashVersion=this.parseVersion((l.GetVariable("$version")||"").replace(/^\D+(\d+)\D+(\d+)\D+(\d+).*/g,"$1.$2.$3"))}}else{if(navigator.plugins&&navigator.plugins["Shockwave Flash"]){var n=navigator.plugins["Shockwave Flash"].description.replace(/^.*\s+(\S+\s+\S+$)/,"$1");var p=n.replace(/^\D*(\d+\.\d+).*$/,"$1");if(/r/.test(n)){p+=n.replace(/^.*r(\d*).*$/,".$1")}else{if(/d/.test(n)){p+=".0"}}this.flashVersion=this.parseVersion(p);var j=false;for(var k=0,c=this.flashVersion>=H.MIN_FLASH_VERSION;c&&k<navigator.mimeTypes.length;k++){var f=navigator.mimeTypes[k];if(f.type!="application/x-shockwave-flash"){continue}if(f.enabledPlugin){j=true;if(f.enabledPlugin.description.toLowerCase().indexOf("quicktime")>-1){c=false;this.quicktime=true}}}if(this.quicktime||!j){this.flashVersion=this.parseVersion("0")}}}this.flash=this.flashVersion>=H.MIN_FLASH_VERSION;this.transparencySupport=this.macintosh||this.windows||this.linux&&(this.flashVersion>=this.parseVersion("10")&&(this.gecko&&this.geckoVersion>=this.parseVersion("1.9")||this.opera));this.computedStyleSupport=this.ie||!!document.defaultView.getComputedStyle;this.fixFocus=this.gecko&&this.windows;this.nativeDomLoaded=this.gecko||this.webkit&&this.webkitVersion>=this.parseVersion("525")||this.konqueror&&this.konquerorMajor>this.parseVersion("03")||this.opera;this.mustCheckStyle=this.khtml||this.opera;this.forcePageLoad=this.webkit&&this.webkitVersion<this.parseVersion("523");this.properDocument=typeof(document.location)=="object";this.supported=this.flash&&this.properDocument&&(!this.ie||this.ieSupported)&&this.computedStyleSupport&&(!this.opera||this.operaVersion>=this.parseVersion("9.61"))&&(!this.webkit||this.webkitVersion>=this.parseVersion("412"))&&(!this.gecko||this.geckoVersion>=this.parseVersion("1.8.0.12"))&&(!this.konqueror)}H.parseVersion=function(c){return c.replace(/(^|\D)(\d+)(?=\D|$)/g,function(f,e,g){f=e;for(var d=4-g.length;d>=0;d--){f+="0"}return f+g})};H.MIN_FLASH_VERSION=H.parseVersion("8");function F(c){this.fix=c.ua.ieWin&&window.location.hash!="";var d;this.cache=function(){d=document.title};function e(){}this.restore=function(){if(this.fix){setTimeout(e,0)}}}function S(l){var e=null;function c(){try{if(l.ua.ie||document.readyState!="loaded"&&document.readyState!="complete"){document.documentElement.doScroll("left")}}catch(n){return setTimeout(c,10)}i()}function i(){if(l.useStyleCheck){h()}else{if(!l.ua.mustCheckStyle){d(null,true)}}}function h(){e=l.dom.create("div",E.DUMMY);l.dom.getBody().appendChild(e);m()}function m(){if(l.dom.getComputedStyle(e,"marginLeft")=="42px"){g()}else{setTimeout(m,10)}}function g(){if(e&&e.parentNode){e.parentNode.removeChild(e)}e=null;d(null,true)}function d(n,o){l.initialize(o);if(n&&n.type=="load"){if(document.removeEventListener){document.removeEventListener("DOMContentLoaded",d,false)}if(window.removeEventListener){window.removeEventListener("load",d,false)}}}function j(){l.prepareClearReferences();if(document.readyState=="interactive"){document.attachEvent("onstop",f);setTimeout(function(){document.detachEvent("onstop",f)},0)}}function f(){document.detachEvent("onstop",f);k()}function k(){l.clearReferences()}this.attach=function(){if(window.addEventListener){window.addEventListener("load",d,false)}else{window.attachEvent("onload",d)}if(!l.useDomLoaded||l.ua.forcePageLoad||l.ua.ie&&window.top!=window){return}if(l.ua.nativeDomLoaded){document.addEventListener("DOMContentLoaded",i,false)}else{if(l.ua.ie||l.ua.khtml){c()}}};this.attachUnload=function(){if(!l.ua.ie){return}window.attachEvent("onbeforeunload",j);window.attachEvent("onunload",k)}}var Q="sifrFetch";function N(c){var e=false;this.fetchMovies=function(f){if(c.setPrefetchCookie&&new RegExp(";?"+Q+"=true;?").test(document.cookie)){return}try{e=true;d(f)}catch(g){}if(c.setPrefetchCookie){document.cookie=Q+"=true;path="+c.cookiePath}};this.clear=function(){if(!e){return}try{var f=document.getElementsByTagName("script");for(var g=f.length-1;g>=0;g--){var h=f[g];if(h.type=="sifr/prefetch"){h.parentNode.removeChild(h)}}}catch(j){}};function d(f){for(var g=0;g<f.length;g++){document.write('<script defer type="sifr/prefetch" src="'+f[g].src+'"><\/script>')}}}function b(e){var g=e.ua.ie;var f=g&&e.ua.flashVersion<e.ua.parseVersion("9.0.115");var d={};var c={};this.fixFlash=f;this.register=function(h){if(!g){return}var i=h.getAttribute("id");this.cleanup(i,false);c[i]=h;delete d[i];if(f){window[i]=h}};this.reset=function(){if(!g){return false}for(var j=0;j<e.replacements.length;j++){var h=e.replacements[j];var k=c[h.id];if(!d[h.id]&&(!k.parentNode||k.parentNode.nodeType==11)){h.resetMovie();d[h.id]=true}}return true};this.cleanup=function(l,h){var i=c[l];if(!i){return}for(var k in i){if(typeof(i[k])=="function"){i[k]=null}}c[l]=null;if(f){window[l]=null}if(i.parentNode){if(h&&i.parentNode.nodeType==1){var j=document.createElement("div");j.style.width=i.offsetWidth+"px";j.style.height=i.offsetHeight+"px";i.parentNode.replaceChild(j,i)}else{i.parentNode.removeChild(i)}}};this.prepareClearReferences=function(){if(!f){return}__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){}};this.clearReferences=function(){if(f){var j=document.getElementsByTagName("object");for(var h=j.length-1;h>=0;h--){c[j[h].getAttribute("id")]=j[h]}}for(var k in c){if(Object.prototype[k]!=c[k]){this.cleanup(k,true)}}}}function K(d,g,f,c,e){this.sIFR=d;this.id=g;this.vars=f;this.movie=null;this.__forceWidth=c;this.__events=e;this.__resizing=0}K.prototype={getFlashElement:function(){return document.getElementById(this.id)},getAlternate:function(){return document.getElementById(this.id+"_alternate")},getAncestor:function(){var c=this.getFlashElement().parentNode;return !this.sIFR.dom.hasClass(E.FIX_FOCUS,c)?c:c.parentNode},available:function(){var c=this.getFlashElement();return c&&c.parentNode},call:function(c){var d=this.getFlashElement();if(!d[c]){return false}return Function.prototype.apply.call(d[c],d,Array.prototype.slice.call(arguments,1))},attempt:function(){if(!this.available()){return false}try{this.call.apply(this,arguments)}catch(c){if(this.sIFR.debug){throw c}return false}return true},updateVars:function(c,e){for(var d=0;d<this.vars.length;d++){if(this.vars[d].split("=")[0]==c){this.vars[d]=c+"="+e;break}}var f=this.sIFR.util.encodeVars(this.vars);this.movie.injectVars(this.getFlashElement(),f);this.movie.injectVars(this.movie.html,f)},storeSize:function(c,d){this.movie.setSize(c,d);this.updateVars(c,d)},fireEvent:function(c){if(this.available()&&this.__events[c]){this.sIFR.util.delay(0,this.__events[c],this,this)}},resizeFlashElement:function(c,d,e){if(!this.available()){return}this.__resizing++;var f=this.getFlashElement();f.setAttribute("height",c);this.getAncestor().style.minHeight="";this.updateVars("renderheight",c);this.storeSize("height",c);if(d!==null){f.setAttribute("width",d);this.movie.setSize("width",d)}if(this.__events.onReplacement){this.sIFR.util.delay(0,this.__events.onReplacement,this,this);delete this.__events.onReplacement}if(e){this.sIFR.util.delay(0,function(){this.attempt("scaleMovie");this.__resizing--},this)}else{this.__resizing--}},blurFlashElement:function(){if(this.available()){this.sIFR.dom.blurElement(this.getFlashElement())}},resetMovie:function(){this.sIFR.util.delay(0,this.movie.reset,this.movie,this.getFlashElement(),this.getAlternate())},resizeAfterScale:function(){if(this.available()&&this.__resizing==0){this.sIFR.util.delay(0,this.resize,this)}},resize:function(){if(!this.available()){return}this.__resizing++;var g=this.getFlashElement();var f=g.offsetWidth;if(f==0){return}var e=g.getAttribute("width");var l=g.getAttribute("height");var m=this.getAncestor();var o=this.sIFR.dom.getHeightFromStyle(m);g.style.width="1px";g.style.height="1px";m.style.minHeight=o+"px";var c=this.getAlternate().childNodes;var n=[];for(var k=0;k<c.length;k++){var h=c[k].cloneNode(true);n.push(h);m.appendChild(h)}var d=this.sIFR.dom.getWidthFromStyle(m);for(var k=0;k<n.length;k++){m.removeChild(n[k])}g.style.width=g.style.height=m.style.minHeight="";g.setAttribute("width",this.__forceWidth?d:e);g.setAttribute("height",l);if(sIFR.ua.ie){g.style.display="none";var j=g.offsetHeight;g.style.display=""}if(d!=f){if(this.__forceWidth){this.storeSize("width",d)}this.attempt("resize",d)}this.__resizing--},replaceText:function(g,j){var d=this.sIFR.util.escape(g);if(!this.attempt("replaceText",d)){return false}this.updateVars("content",d);var f=this.getAlternate();if(j){while(f.firstChild){f.removeChild(f.firstChild)}for(var c=0;c<j.length;c++){f.appendChild(j[c])}}else{try{f.innerHTML=g}catch(h){}}return true},changeCSS:function(c){c=this.sIFR.util.escape(this.sIFR.util.cssToString(this.sIFR.util.convertCssArg(c)));this.updateVars("css",c);return this.attempt("changeCSS",c)},remove:function(){if(this.movie&&this.available()){this.movie.remove(this.getFlashElement(),this.id)}}};var X=new function(){this.create=function(p,n,j,i,f,e,g,o,l,h,m){var k=p.ua.ie?d:c;return new k(p,n,j,i,f,e,g,o,["flashvars",l,"wmode",h,"bgcolor",m,"allowScriptAccess","always","quality","best"])};function c(s,q,l,h,f,e,g,r,n){var m=s.dom.create("object",E.FLASH);var p=["type","application/x-shockwave-flash","id",f,"name",f,"data",e,"width",g,"height",r];for(var o=0;o<p.length;o+=2){m.setAttribute(p[o],p[o+1])}var j=m;if(h){j=W.create("div",E.FIX_FOCUS);j.appendChild(m)}for(var o=0;o<n.length;o+=2){if(n[o]=="name"){continue}var k=W.create("param");k.setAttribute("name",n[o]);k.setAttribute("value",n[o+1]);m.appendChild(k)}l.style.minHeight=r+"px";while(l.firstChild){l.removeChild(l.firstChild)}l.appendChild(j);this.html=j.cloneNode(true)}c.prototype={reset:function(e,f){e.parentNode.replaceChild(this.html.cloneNode(true),e)},remove:function(e,f){e.parentNode.removeChild(e)},setSize:function(e,f){this.html.setAttribute(e,f)},injectVars:function(e,g){var h=e.getElementsByTagName("param");for(var f=0;f<h.length;f++){if(h[f].getAttribute("name")=="flashvars"){h[f].setAttribute("value",g);break}}}};function d(p,n,j,h,f,e,g,o,k){this.dom=p.dom;this.broken=n;this.html='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="'+f+'" width="'+g+'" height="'+o+'" class="'+E.FLASH+'"><param name="movie" value="'+e+'"></param></object>';var m="";for(var l=0;l<k.length;l+=2){m+='<param name="'+k[l]+'" value="'+k[l+1]+'"></param>'}this.html=this.html.replace(/(<\/object>)/,m+"$1");j.style.minHeight=o+"px";j.innerHTML=this.html;this.broken.register(j.firstChild)}d.prototype={reset:function(f,g){g=g.cloneNode(true);var e=f.parentNode;e.innerHTML=this.html;this.broken.register(e.firstChild);e.appendChild(g)},remove:function(e,f){this.broken.cleanup(f)},setSize:function(e,f){this.html=this.html.replace(e=="height"?/(height)="\d+"/:/(width)="\d+"/,'$1="'+f+'"')},injectVars:function(e,f){if(e!=this.html){return}this.html=this.html.replace(/(flashvars(=|\"\svalue=)\")[^\"]+/,"$1"+f)}}};this.errors=new Y(O);var A=this.util=new D(O);var W=this.dom=new U(O);var T=this.ua=new H(O);var G={fragmentIdentifier:new F(O),pageLoad:new S(O),prefetch:new N(O),brokenFlashIE:new b(O)};this.__resetBrokenMovies=G.brokenFlashIE.reset;var J={kwargs:[],replaceAll:function(d){for(var c=0;c<this.kwargs.length;c++){O.replace(this.kwargs[c])}if(!d){this.kwargs=[]}}};this.activate=function(){if(!T.supported||!this.isEnabled||this.isActive||!C()||a()){return}G.prefetch.fetchMovies(arguments);this.isActive=true;this.setFlashClass();G.fragmentIdentifier.cache();G.pageLoad.attachUnload();if(!this.autoInitialize){return}G.pageLoad.attach()};this.setFlashClass=function(){if(this.hasFlashClassSet){return}W.addClass(E.ACTIVE,W.getBody()||document.documentElement);this.hasFlashClassSet=true};this.removeFlashClass=function(){if(!this.hasFlashClassSet){return}W.removeClass(E.ACTIVE,W.getBody());W.removeClass(E.ACTIVE,document.documentElement);this.hasFlashClassSet=false};this.initialize=function(c){if(!this.isActive||!this.isEnabled){return}if(R){if(!c){J.replaceAll(false)}return}R=true;J.replaceAll(c);if(O.repaintOnResize){if(window.addEventListener){window.addEventListener("resize",Z,false)}else{window.attachEvent("onresize",Z)}}G.prefetch.clear()};this.replace=function(x,u){if(!T.supported){return}if(u){x=A.copyProperties(x,u)}if(!R){return J.kwargs.push(x)}if(this.onReplacementStart){this.onReplacementStart(x)}var AM=x.elements||W.querySelectorAll(x.selector);if(AM.length==0){return}var w=M(x.src);var AR=A.convertCssArg(x.css);var v=B(x.filters);var AN=x.forceSingleLine===true;var AS=x.preventWrap===true&&!AN;var q=AN||(x.fitExactly==null?this.fitExactly:x.fitExactly)===true;var AD=q||(x.forceWidth==null?this.forceWidth:x.forceWidth)===true;var s=x.ratios||[];var AE=x.pixelFont===true;var r=parseInt(x.tuneHeight)||0;var z=!!x.onRelease||!!x.onRollOver||!!x.onRollOut;if(q){A.extractFromCss(AR,".sIFR-root","text-align",true)}var t=A.extractFromCss(AR,".sIFR-root","font-size",true)||"0";var e=A.extractFromCss(AR,".sIFR-root","background-color",true)||"#FFFFFF";var o=A.extractFromCss(AR,".sIFR-root","kerning",true)||"";var AW=A.extractFromCss(AR,".sIFR-root","opacity",true)||"100";var k=A.extractFromCss(AR,".sIFR-root","cursor",true)||"default";var AP=parseInt(A.extractFromCss(AR,".sIFR-root","leading"))||0;var AJ=x.gridFitType||(A.extractFromCss(AR,".sIFR-root","text-align")=="right")?"subpixel":"pixel";var h=this.forceTextTransform===false?"none":A.extractFromCss(AR,".sIFR-root","text-transform",true)||"none";t=/^\d+(px)?$/.test(t)?parseInt(t):0;AW=parseFloat(AW)<1?100*parseFloat(AW):AW;var AC=x.modifyCss?"":A.cssToString(AR);var AG=x.wmode||"";if(!AG){if(x.transparent){AG="transparent"}else{if(x.opaque){AG="opaque"}}}if(AG=="transparent"){if(!T.transparencySupport){AG="opaque"}else{e="transparent"}}else{if(e=="transparent"){e="#FFFFFF"}}for(var AV=0;AV<AM.length;AV++){var AF=AM[AV];if(W.hasOneOfClassses(E.IGNORE_CLASSES,AF)||W.ancestorHasClass(AF,E.ALTERNATE)){continue}var AO=W.getDimensions(AF);var f=AO.height;var c=AO.width;var AA=W.getComputedStyle(AF,"display");if(!f||!c||!AA||AA=="none"){continue}c=W.getWidthFromStyle(AF);var n,AH;if(!t){var AL=I(AF);n=Math.min(this.MAX_FONT_SIZE,Math.max(this.MIN_FONT_SIZE,AL.fontSize));if(AE){n=Math.max(8,8*Math.round(n/8))}AH=AL.lines}else{n=t;AH=1}var d=W.create("span",E.ALTERNATE);var AX=AF.cloneNode(true);AF.parentNode.appendChild(AX);for(var AU=0,AT=AX.childNodes.length;AU<AT;AU++){var m=AX.childNodes[AU];if(!/^(style|script)$/i.test(m.nodeName)){d.appendChild(m.cloneNode(true))}}if(x.modifyContent){x.modifyContent(AX,x.selector)}if(x.modifyCss){AC=x.modifyCss(AR,AX,x.selector)}var p=P(AX,h,x.uriEncode);AX.parentNode.removeChild(AX);if(x.modifyContentString){p.text=x.modifyContentString(p.text,x.selector)}if(p.text==""){continue}var AK=Math.round(AH*V(n,s)*n)+this.FLASH_PADDING_BOTTOM+r;if(AH>1&&AP){AK+=Math.round((AH-1)*AP)}var AB=AD?c:"100%";var AI="sIFR_replacement_"+L++;var AQ=["id="+AI,"content="+A.escape(p.text),"width="+c,"renderheight="+AK,"link="+A.escape(p.primaryLink.href||""),"target="+A.escape(p.primaryLink.target||""),"size="+n,"css="+A.escape(AC),"cursor="+k,"tunewidth="+(x.tuneWidth||0),"tuneheight="+r,"offsetleft="+(x.offsetLeft||""),"offsettop="+(x.offsetTop||""),"fitexactly="+q,"preventwrap="+AS,"forcesingleline="+AN,"antialiastype="+(x.antiAliasType||""),"thickness="+(x.thickness||""),"sharpness="+(x.sharpness||""),"kerning="+o,"gridfittype="+AJ,"flashfilters="+v,"opacity="+AW,"blendmode="+(x.blendMode||""),"selectable="+(x.selectable==null||AG!=""&&!sIFR.ua.macintosh&&sIFR.ua.gecko&&sIFR.ua.geckoVersion>=sIFR.ua.parseVersion("1.9")?"true":x.selectable===true),"fixhover="+(this.fixHover===true),"events="+z,"delayrun="+G.brokenFlashIE.fixFlash,"version="+this.VERSION];var y=A.encodeVars(AQ);var g=new K(O,AI,AQ,AD,{onReplacement:x.onReplacement,onRollOver:x.onRollOver,onRollOut:x.onRollOut,onRelease:x.onRelease});g.movie=X.create(sIFR,G.brokenFlashIE,AF,T.fixFocus&&x.fixFocus,AI,w,AB,AK,y,AG,e);this.replacements.push(g);this.replacements[AI]=g;if(x.selector){if(!this.replacements[x.selector]){this.replacements[x.selector]=[g]}else{this.replacements[x.selector].push(g)}}d.setAttribute("id",AI+"_alternate");AF.appendChild(d);W.addClass(E.REPLACED,AF)}G.fragmentIdentifier.restore()};this.getReplacementByFlashElement=function(d){for(var c=0;c<O.replacements.length;c++){if(O.replacements[c].id==d.getAttribute("id")){return O.replacements[c]}}};this.redraw=function(){for(var c=0;c<O.replacements.length;c++){O.replacements[c].resetMovie()}};this.prepareClearReferences=function(){G.brokenFlashIE.prepareClearReferences()};this.clearReferences=function(){G.brokenFlashIE.clearReferences();G=null;J=null;delete O.replacements};function C(){if(O.domains.length==0){return true}var d=A.domain();for(var c=0;c<O.domains.length;c++){if(A.domainMatches(d,O.domains[c])){return true}}return false}function a(){if(document.location.protocol=="file:"){if(O.debug){O.errors.fire("isFile")}return true}return false}function M(c){if(T.ie&&c.charAt(0)=="/"){c=window.location.toString().replace(/([^:]+)(:\/?\/?)([^\/]+).*/,"$1$2$3")+c}return c}function V(d,e){for(var c=0;c<e.length;c+=2){if(d<=e[c]){return e[c+1]}}return e[e.length-1]||1}function B(g){var e=[];for(var d in g){if(g[d]==Object.prototype[d]){continue}var c=g[d];d=[d.replace(/filter/i,"")+"Filter"];for(var f in c){if(c[f]==Object.prototype[f]){continue}d.push(f+":"+A.escape(A.toJson(c[f],A.toHexString)))}e.push(d.join(","))}return A.escape(e.join(";"))}function Z(d){var e=Z.viewport;var c=W.getViewport();if(e&&c.width==e.width&&c.height==e.height){return}Z.viewport=c;if(O.replacements.length==0){return}if(Z.timer){clearTimeout(Z.timer)}Z.timer=setTimeout(function(){delete Z.timer;for(var f=0;f<O.replacements.length;f++){O.replacements[f].resize()}},200)}function I(f){var g=W.getComputedStyle(f,"fontSize");var d=g.indexOf("px")==-1;var e=f.innerHTML;if(d){f.innerHTML="X"}f.style.paddingTop=f.style.paddingBottom=f.style.borderTopWidth=f.style.borderBottomWidth="0px";f.style.lineHeight="2em";f.style.display="block";g=d?f.offsetHeight/2:parseInt(g,10);if(d){f.innerHTML=e}var c=Math.round(f.offsetHeight/(2*g));f.style.paddingTop=f.style.paddingBottom=f.style.borderTopWidth=f.style.borderBottomWidth=f.style.lineHeight=f.style.display="";if(isNaN(c)||!isFinite(c)||c==0){c=1}return{fontSize:g,lines:c}}function P(c,g,s){s=s||A.uriEncode;var q=[],m=[];var k=null;var e=c.childNodes;var o=false,p=false;var j=0;while(j<e.length){var f=e[j];if(f.nodeType==3){var t=A.textTransform(g,A.normalize(f.nodeValue)).replace(/</g,"&lt;");if(o&&p){t=t.replace(/^\s+/,"")}m.push(t);o=/\s$/.test(t);p=false}if(f.nodeType==1&&!/^(style|script)$/i.test(f.nodeName)){var h=[];var r=f.nodeName.toLowerCase();var n=f.className||"";if(/\s+/.test(n)){if(n.indexOf(E.CLASS)>-1){n=n.match("(\\s|^)"+E.CLASS+"-([^\\s$]*)(\\s|$)")[2]}else{n=n.match(/^([^\s]+)/)[1]}}if(n!=""){h.push('class="'+n+'"')}if(r=="a"){var d=s(f.getAttribute("href")||"");var l=f.getAttribute("target")||"";h.push('href="'+d+'"','target="'+l+'"');if(!k){k={href:d,target:l}}}m.push("<"+r+(h.length>0?" ":"")+h.join(" ")+">");p=true;if(f.hasChildNodes()){q.push(j);j=0;e=f.childNodes;continue}else{if(!/^(br|img)$/i.test(f.nodeName)){m.push("</",f.nodeName.toLowerCase(),">")}}}if(q.length>0&&!f.nextSibling){do{j=q.pop();e=f.parentNode.parentNode.childNodes;f=e[j];if(f){m.push("</",f.nodeName.toLowerCase(),">")}}while(j==e.length-1&&q.length>0)}j++}return{text:m.join("").replace(/^\s+|\s+$|\s*(<br>)\s*/g,"$1"),primaryLink:k||{}}}};
var parseSelector=(function(){var B=/\s*,\s*/;var A=/\s*([\s>+~(),]|^|$)\s*/g;var L=/([\s>+~,]|[^(]\+|^)([#.:@])/g;var F=/(^|\))[^\s>+~]/g;var M=/(\)|^)/;var K=/[\s#.:>+~()@]|[^\s#.:>+~()@]+/g;function H(R,P){P=P||document.documentElement;var S=R.split(B),X=[];for(var U=0;U<S.length;U++){var N=[P],W=G(S[U]);for(var T=0;T<W.length;){var Q=W[T++],O=W[T++],V="";if(W[T]=="("){while(W[T++]!=")"&&T<W.length){V+=W[T]}V=V.slice(0,-1)}N=I(N,Q,O,V)}X=X.concat(N)}return X}function G(N){var O=N.replace(A,"$1").replace(L,"$1*$2").replace(F,D);return O.match(K)||[]}function D(N){return N.replace(M,"$1 ")}function I(N,P,Q,O){return(H.selectors[P])?H.selectors[P](N,Q,O):[]}var E={toArray:function(O){var N=[];for(var P=0;P<O.length;P++){N.push(O[P])}return N}};var C={isTag:function(O,N){return(N=="*")||(N.toLowerCase()==O.nodeName.toLowerCase())},previousSiblingElement:function(N){do{N=N.previousSibling}while(N&&N.nodeType!=1);return N},nextSiblingElement:function(N){do{N=N.nextSibling}while(N&&N.nodeType!=1);return N},hasClass:function(N,O){return(O.className||"").match("(^|\\s)"+N+"(\\s|$)")},getByTag:function(N,O){return O.getElementsByTagName(N)}};var J={"#":function(N,P){for(var O=0;O<N.length;O++){if(N[O].getAttribute("id")==P){return[N[O]]}}return[]}," ":function(O,Q){var N=[];for(var P=0;P<O.length;P++){N=N.concat(E.toArray(C.getByTag(Q,O[P])))}return N},">":function(O,R){var N=[];for(var Q=0,S;Q<O.length;Q++){S=O[Q];for(var P=0,T;P<S.childNodes.length;P++){T=S.childNodes[P];if(T.nodeType==1&&C.isTag(T,R)){N.push(T)}}}return N},".":function(O,Q){var N=[];for(var P=0,R;P<O.length;P++){R=O[P];if(C.hasClass([Q],R)){N.push(R)}}return N},":":function(N,P,O){return(H.pseudoClasses[P])?H.pseudoClasses[P](N,O):[]}};H.selectors=J;H.pseudoClasses={};H.util=E;H.dom=C;return H})();

//End Sifr

//******************************************************************************************************************************************************************************************************

// Enable Browser History
jQuery.extend({
	historyCurrentHash: undefined,
	historyCallback: undefined,
	historyIframeSrc: undefined,
	historyNeedIframe: jQuery.browser.msie && (jQuery.browser.version < 8 || document.documentMode < 8),
	
	historyInit: function(callback, src){
		jQuery.historyCallback = callback;
		if (src) jQuery.historyIframeSrc = src;
		var current_hash = location.hash.replace(/\?.*$/, '');
		
		jQuery.historyCurrentHash = current_hash;
		if (jQuery.historyNeedIframe) {
			// To stop the callback firing twice during initilization if no hash present
			if (jQuery.historyCurrentHash == '') {
				jQuery.historyCurrentHash = '#';
			}
		
			// add hidden iframe for IE
			jQuery("body").prepend('<iframe id="jQuery_history" style="display: none;"'+
				' src="javascript:false;"></iframe>'
			);
			var ihistory = jQuery("#jQuery_history")[0];
			var iframe = ihistory.contentWindow.document;
			iframe.open();
			iframe.close();
			iframe.location.hash = current_hash;
		}
		else if (jQuery.browser.safari) {
			// etablish back/forward stacks
			jQuery.historyBackStack = [];
			jQuery.historyBackStack.length = history.length;
			jQuery.historyForwardStack = [];
			jQuery.lastHistoryLength = history.length;
			
			jQuery.isFirst = true;
		}
		if(current_hash)
			jQuery.historyCallback(current_hash.replace(/^#/, ''));
		setInterval(jQuery.historyCheck, 100);
	},
	
	historyAddHistory: function(hash) {
		// This makes the looping function do something
		jQuery.historyBackStack.push(hash);
		
		jQuery.historyForwardStack.length = 0; // clear forwardStack (true click occured)
		this.isFirst = true;
	},
	
	historyCheck: function(){
		if (jQuery.historyNeedIframe) {
			// On IE, check for location.hash of iframe
			var ihistory = jQuery("#jQuery_history")[0];
			var iframe = ihistory.contentDocument || ihistory.contentWindow.document;
			var current_hash = iframe.location.hash.replace(/\?.*$/, '');
			if(current_hash != jQuery.historyCurrentHash) {
			
				location.hash = current_hash;
				jQuery.historyCurrentHash = current_hash;
				jQuery.historyCallback(current_hash.replace(/^#/, ''));
				
			}
		} else if (jQuery.browser.safari) {
			if(jQuery.lastHistoryLength == history.length && jQuery.historyBackStack.length > jQuery.lastHistoryLength) {
				jQuery.historyBackStack.shift();
			}
			if (!jQuery.dontCheck) {
				var historyDelta = history.length - jQuery.historyBackStack.length;
				jQuery.lastHistoryLength = history.length;
				
				if (historyDelta) { // back or forward button has been pushed
					jQuery.isFirst = false;
					if (historyDelta < 0) { // back button has been pushed
						// move items to forward stack
						for (var i = 0; i < Math.abs(historyDelta); i++) jQuery.historyForwardStack.unshift(jQuery.historyBackStack.pop());
					} else { // forward button has been pushed
						// move items to back stack
						for (var i = 0; i < historyDelta; i++) jQuery.historyBackStack.push(jQuery.historyForwardStack.shift());
					}
					var cachedHash = jQuery.historyBackStack[jQuery.historyBackStack.length - 1];
					if (cachedHash != undefined) {
						jQuery.historyCurrentHash = location.hash.replace(/\?.*$/, '');
						jQuery.historyCallback(cachedHash);
					}
				} else if (jQuery.historyBackStack[jQuery.historyBackStack.length - 1] == undefined && !jQuery.isFirst) {
					// back button has been pushed to beginning and URL already pointed to hash (e.g. a bookmark)
					// document.URL doesn't change in Safari
					if (location.hash) {
						var current_hash = location.hash;
						jQuery.historyCallback(location.hash.replace(/^#/, ''));
					} else {
						var current_hash = '';
						jQuery.historyCallback('');
					}
					jQuery.isFirst = true;
				}
			}
		} else {
			// otherwise, check for location.hash
			var current_hash = location.hash.replace(/\?.*$/, '');
			if(current_hash != jQuery.historyCurrentHash) {
				jQuery.historyCurrentHash = current_hash;
				jQuery.historyCallback(current_hash.replace(/^#/, ''));
			}
		}


	},
	historyLoad: function(hash){
		var newhash;
		hash = decodeURIComponent(hash.replace(/\?.*$/, ''));
		
		if (jQuery.browser.safari) {
			newhash = hash;
		}
		else {
			newhash = '#' + hash;
			location.hash = newhash;
		}
		jQuery.historyCurrentHash = newhash;
		
		if (jQuery.historyNeedIframe) {
			var ihistory = jQuery("#jQuery_history")[0];
			var iframe = ihistory.contentWindow.document;
			iframe.open();
			iframe.close();
			iframe.location.hash = newhash;
			jQuery.lastHistoryLength = history.length;
			jQuery.historyCallback(hash);
		}
		else if (jQuery.browser.safari) {
			jQuery.dontCheck = true;
			// Manually keep track of the history values for Safari
			this.historyAddHistory(hash);
			
			// Wait a while before allowing checking so that Safari has time to update the "history" object
			// correctly (otherwise the check loop would detect a false change in hash).
			var fn = function() {jQuery.dontCheck = false;};
			window.setTimeout(fn, 200);
			jQuery.historyCallback(hash);
			// N.B. "location.hash=" must be the last line of code for Safari as execution stops afterwards.
			//      By explicitly using the "location.hash" command (instead of using a variable set to "location.hash") the
			//      URL in the browser and the "history" object are both updated correctly.
			location.hash = newhash;
		}
		else {
		  jQuery.historyCallback(hash);
		}
	}
});

//End Enable Browser History

//******************************************************************************************************************************************************************************************************

//Activate Sifr

function ActivateSifr() 
{
  sIFR.replace(report42, {
  selector: '#StaticTitle, h2.archive, .BioSubTitle',
  css: '.sIFR-root { background-color: #CCCCCC; color: #FFFFFF; }',
  wmode: 'transparent'
  });
}

// End Activate Sifr
// Get the SWF file
var report42 = { src: '/resources/somedayTheme/report42.swf' };
//var Franklin = { src: '/Resources/SomedayTheme/Franklin.swf' };
sIFR.activate(report42);
ActivateSifr();

//******************************************************************************************************************************************************************************************************

// End Activation

function CallPageFunction() 
{
	//Unload GoogleMaps if coming from the tour page.
	if (GoogleMapLoad == 1) {
	GoogleMapLoad = 0;
	GUnload();
	}

	if (document.getElementById('privateFunction')) {
		var FunctionLoad = document.getElementById('privateFunction').innerHTML;
			if (FunctionLoad) {
				var launchFunct = new Function(FunctionLoad);
				launchFunct(); 
				}
	}

}

//******************************************************************************************************************************************************************************************************

function gotoURL(url)
{
	if (url == 1)
	{
		window.open("http://www.amazon.com/Someday/dp/B001VJXTQG");
	}
	else if (url == 2)
	{
		window.open("http://itunes.apple.com/us/album/someday/id306891147");
	}
	
	else if (url == 3)
	{
		window.open("http://www.cdbaby.com/cd/section30");
	}
}

function albumOver(itemLocation) 
{
	document.getElementById(itemLocation).style.display ="block";	
}

function albumOut(itemLocation) 
{
	document.getElementById(itemLocation).style.display ="none";	
}

function contactUsTextOver(itemName) 
{
	document.getElementById("contactUsText").style.backgroundImage = "url('/resources/somedayTheme/images/body/content/" + itemName +".jpg')";
}

function contactUsTextOut(itemLocation) 
{
	document.getElementById("contactUsText").style.backgroundImage = "url('/resources/somedayTheme/images/body/content/contactUsContactText.jpg')";
}

//******************************************************************************************************************************************************************************************************

function getContactForm(contactForm)
{
	// Need to rewrite the hidden HTML container for SMCF onclick
	if(contactForm == 'Book')
	{
		document.getElementById("ContactJavaUpdate").innerHTML ="<div class='smcf-top'></div><div class='smcf-content'><div class='content2'><h1 class='smcf-title'>Book Section 30</h1><div class='smcf-loading' style='display:none'></div><div class='smcf-message' style='display:none'></div>		<form action='/smcf/smcf_data.php' style='display:none'><label for='smcf-name'>*Venue:</label><input type='text' id='smcf-name' class='smcf-input' name='name' value='' tabindex='1001' /><br/><label for='smcf-email'>*Email:</label><input type='text' id='smcf-email' class='smcf-input' name='email' value='' tabindex='1002' /><br/><label for='smcf-contactName'>Name:</label><input type='text' id='smcf-contactName' class='smcf-input' name='contactName' value='' tabindex='1003' /><br/><label for='smcf-phone'>Phone:</label><input type='text' id='smcf-phone' class='smcf-input' name='phone' value='' tabindex='1004' /><br/><br/><label>&nbsp;</label><button type='submit' class='smcf-button smcf-send' tabindex='1006'>Send</button>&nbsp;&nbsp;&nbsp;<button type='submit' class='smcf-button smcf-cancel simplemodal-close' tabindex='1007'>Cancel</button><input type='hidden' name='subject' value='Booking Add'/><br/></form></div></div><div class='smcf-bottom'></div>";

	}
	else if(contactForm == 'Newsletter')
	{
		document.getElementById("ContactJavaUpdate").innerHTML ="<div class='smcf-top'></div><div class='smcf-content'><div class='content2'><h1 class='smcf-title'>Section 30 Newsletter</h1><div class='smcf-loading' style='display:none'></div><div class='smcf-message' style='display:none'></div><form action='/smcf/smcf_data.php' style='display:none'><label for='smcf-name'>*Name:</label><input type='text' id='smcf-name' class='smcf-input' name='name' value='' tabindex='1001' /><label for='smcf-email'>*Email:</label><input type='text' id='smcf-email' class='smcf-input' name='email' value='' tabindex='1002' /><br/><br/><label>&nbsp;</label><button type='submit' class='smcf-button smcf-send' tabindex='1006'>Send</button>&nbsp;&nbsp;&nbsp;<button type='submit' class='smcf-button smcf-cancel simplemodal-close' tabindex='1007'>Cancel</button><input type='hidden' name='subject' value='Newsletter Add'/><br/></form></div></div><div class='smcf-bottom'></div>";
	
	}
	
	else if(contactForm == 'Contact')
	{
		document.getElementById("ContactJavaUpdate").innerHTML ="<div class='smcf-top'></div><div class='smcf-content'><div class='content2'><h1 class='smcf-title'>Contact Section 30</h1><div class='smcf-loading' style='display:none'></div><div class='smcf-message' style='display:none'></div>		<form action='/smcf/smcf_data.php' style='display:none'><label for='smcf-name'>*Name:</label><input type='text' id='smcf-name' class='smcf-input' name='name' value='' tabindex='1001' /><label for='smcf-email'>*Email:</label><input type='text' id='smcf-email' class='smcf-input' name='email' value='' tabindex='1002' /><label for='smcf-message'>Message:</label><textarea id='smcf-message' class='smcf-input' name='message' cols='40' rows='4' tabindex='1004'></textarea><br/><br/><label>&nbsp;</label><button type='submit' class='smcf-button smcf-send' tabindex='1006'>Send</button>&nbsp;&nbsp;&nbsp;<button type='submit' class='smcf-button smcf-cancel simplemodal-close' tabindex='1007'>Cancel</button><input type='hidden' name='subject' value='Contact'/><br/></form></div></div><div class='smcf-bottom'></div>";
	
	}
}

//******************************************************************************************************************************************************************************************************

function myTimestamp()
{    
	tstmp = new Date();        
	return tstmp.getTime();
} 

//******************************************************************************************************************************************************************************************************

function createMusicPlayer() {
	var thePlayer = document.getElementById("musicPlayerFl")
	thePlayer.innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="224" height="290" id="mp3player"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="http://www.section30band.com/resources/player/mp3player.swf" /> <param name="quality" value="high" /> <param name="wmode" value="transparent" /><param name="bgcolor" value="#1f2528" /> <embed src="http://www.section30band.com/resources/player/mp3player.swf" quality="high" wmode="transparent" width="224"  height="290" name="mp3player" allowscriptaccess="samedomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" swLiveConnect="true" /> </object>'
}

//******************************************************************************************************************************************************************************************************



function RenderVideo(video)
{
	PauseMP3Player();
	
	swfobject.embedSWF
    (
      'http://www.youtube.com/v/' + video + '&enablejsapi=1&rel=0&fs=1',
      'DynamicVideo',
      '425',
      '344',
      '8',
      null,
      null,
      {
        allowScriptAccess: 'always',
        allowFullScreen: 'true'
      },
      {
        id: 'YouTubeVideo'
      }
    );


}

//******************************************************************************************************************************************************************************************************

function RemoveVideo()
{
	swfobject.removeSWF("YouTubeVideo");
	UnpauseMP3Player();
}

//********************************************************************************************************************************************************************************************

var markerRemember = [];
function removeGMemory() {
	markerRemember[0]='';
	markerRemember[1]='';
	markerRemember[2]='';

}

var stopLocation = '';
var GMie7= ''
var GoogleMapLoad = 0;

function StartTheGoogleMap() {	

//////////////////////
//Start the Google Map Code Beginning Functions
/////////////////////
GoogleMapLoad = 1;

function HtmlControl(html, options){
	this.html=html;
	this.isVisible=true;
	this.isPrintable=true;	
	this.isSelectable=false;
	if(options){
		this.isVisible=(options.visible===false)?false:true;
		this.isPrintable=(options.printable===true)?true:false;
		this.isSelectable=(options.selectable===true)?true:false;
	}
}

HtmlControl.prototype=new GControl();

HtmlControl.prototype.initialize=function(map){
	this.div=document.createElement('div');
	this.div.innerHTML=this.html;
	this.setVisible(this.isVisible);
	map.getContainer().appendChild(this.div);
	return this.div;
};

HtmlControl.prototype.getDefaultPosition=function(){
	return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(0,0));
};

HtmlControl.prototype.selectable=function(){
	return this.isSelectable;
};

HtmlControl.prototype.printable=function(){
	return this.isPrintable;
};

HtmlControl.prototype.setVisible=function(bool){
	this.div.style.display=bool ? '':'none';
	this.isVisible=bool;
};

HtmlControl.prototype.visible=function(){
	return this.isVisible;
}

//Create New Info Windows - Based on ewindow
function EStyle(stemImage, stemSize, boxClass, boxOffset) {
        this.stemImage = stemImage;
        this.stemSize = stemSize;
        this.boxClass = boxClass;
        this.boxOffset = boxOffset;
        //this.border = border;
        
        // Known fudge factors are:
        // Firefox 1.0, 1.5, 2.0      5, -1
        // Firefox 3.0                4, -1
        // IE 6.0                     0, -1
        // Opera 8.54                 3, -1
        // Opera 9                    4, -1
        // Netscape (7.2, 8.0)        5, -1
        // Safari                     5, -1
        // Chrome                     5, -1        
        
        var agent = navigator.userAgent.toLowerCase();
        
        var fudge = 5;  // assume Netscape if no match found
       
        if (agent.indexOf("opera/9") > -1) {
          fudge = 4;
        }   
        else if (agent.indexOf("opera") > -1) {
          fudge = 3;
        }   
        else if (agent.indexOf("firefox/3") > -1) {
          fudge = 4;
        }   
        else if (agent.indexOf("firefox") > -1) {
          fudge = 5;
        }   
        else if (agent.indexOf("chrome") > -1) {
          fudge = 5;
        }   
        else if (agent.indexOf("safari") > -1) {
          fudge = 5;
        }   
        else if (agent.indexOf("msie") > -1) {
          fudge = 0;
        }
        this.fudge = fudge;
      }
      

      var E_STYLE_7 = new EStyle("http://www.section30band.com/resources/somedayTheme/images/body/maps/images/infWindow/anchor.png", new GSize(29,15),  "estyle2", new GPoint(-10,11));


      function EWindow(map,estyle) {
        // parameters
        this.map=map;
        this.estyle=estyle;
        // internal variables
        this.visible = false;
        // browser - specific variables
        this.ie = false;
        var agent = navigator.userAgent.toLowerCase();
        if ((agent.indexOf("msie") > -1) && (agent.indexOf("opera") < 1)){ this.ie = true} else {this.ie = false}
      } 
      
      EWindow.prototype = new GOverlay();

      EWindow.prototype.initialize = function(map) {
        var div1 = document.createElement("div");
        div1.style.position = "absolute";
        map.getPane(G_MAP_FLOAT_PANE).appendChild(div1);
        var div2 = document.createElement("div");
        div2.style.position = "absolute";
        div2.style.width = this.estyle.stemSize.width+"px";
        map.getPane(G_MAP_FLOAT_PANE).appendChild(div2);
        this.div1 = div1;
        this.div2 = div2;
      }

      EWindow.prototype.openOnMap = function(point, html, offset) {
        this.offset = offset||new GPoint(0,0);
        this.point = point;
        this.div1.innerHTML = '<div class="' + this.estyle.boxClass + '"><nobr>' + html + '</nobr></div>';
        if (this.ie && this.estyle.stemImage.toLowerCase().indexOf(".png")>-1) {
          var loader = "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.estyle.stemImage+"', sizingMethod='scale');";
          this.div2.innerHTML = '<div style="height:' +this.estyle.stemSize.height+ 'px; width:'+this.estyle.stemSize.width+'px; ' +loader+ '" ></div>';
        } else {
          this.div2.innerHTML = '<img src="' + this.estyle.stemImage + '" width="' + this.estyle.stemSize.width +'" height="' + this.estyle.stemSize.height +'">';
        }
        var z = GOverlay.getZIndex(this.point.lat());
        this.div1.style.zIndex = z;
        this.div2.style.zIndex = z+1;
        this.visible = true;
        this.show();
        this.redraw(true);
      }
      
      EWindow.prototype.openOnMarker = function(marker,html) {
        var vx = marker.getIcon().iconAnchor.x - marker.getIcon().infoWindowAnchor.x;
        var vy = marker.getIcon().iconAnchor.y - marker.getIcon().infoWindowAnchor.y;
        this.openOnMap(marker.getPoint(), html, new GPoint(vx,vy));
	
		
      }
      

      EWindow.prototype.redraw = function(force) {
        if (!this.visible) {return;}
        var p = this.map.fromLatLngToDivPixel(this.point);
        this.div2.style.left   = (p.x + this.offset.x) + "px";
        this.div2.style.bottom = (-p.y + this.offset.y -this.estyle.fudge) + "px";
        this.div1.style.left   = (p.x + this.offset.x + this.estyle.boxOffset.x) + "px";
        this.div1.style.bottom = (-p.y + this.offset.y + this.estyle.boxOffset.y) + "px";
      }

      EWindow.prototype.remove = function() {
        this.div1.parentNode.removeChild(this.div1);
        this.div2.parentNode.removeChild(this.div2);
        this.visible = false;
      }

      EWindow.prototype.copy = function() {
        return new EWindow(this.map, this.estyle);
      }

      EWindow.prototype.show = function() {
        this.div1.style.display="";
        this.div2.style.display="";
        this.visible = true;
      }
      
      EWindow.prototype.hide = function() {
        this.div1.style.display="none";
        this.div2.style.display="none";
        this.visible = false;

		
		
      }
      
      EWindow.prototype.isHidden = function() {
        return !this.visible;
      }
      
      EWindow.prototype.supportsHide = function() {
        return true;
		
      }

      EWindow.prototype.zindex = function(zin) {
        var z = GOverlay.getZIndex(this.point.lat());
        this.div1.style.zIndex = z+zin;
        this.div2.style.zIndex = z+1+zin;
      }
	  



//Create new 

// Create Array from XML file -- gigLocations is the array
//Column One is the Row - Column two is the detail
//1 - Date
//2 - Street Addr
//3 - City
//4 - State
//5 - Zip
//6 - Lat
//7 - Lng
//**8  - If the location is closest to the end user - This will not be found in the XML file the code reserves it - It is created later
//9 - description 
//10 and above - we can attach any addtional information to the XML file

var gigLocations = [];

function loadXMLGig(dname)
{
	if (window.XMLHttpRequest)
  	{
 	 xhttp=new XMLHttpRequest();
 	 }
	else
 	 {
 	 xhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
xhttp.open("GET",dname,false);
xhttp.send("");
return xhttp.responseXML;
} 

XMLgigs = loadXMLGig("http://www.section30band.com/resources/somedayTheme/futureGigs.xml");

CountPlaces=XMLgigs.getElementsByTagName("places").length;

for (i=0;i<CountPlaces; i++) {gigLocations[i]=new Array();}

for (MapLoop1=0; MapLoop1<CountPlaces; MapLoop1++) {
	var countNodeNumber = 0
	x=XMLgigs.getElementsByTagName("places")[MapLoop1].childNodes;
	y=XMLgigs.getElementsByTagName("places")[MapLoop1].firstChild;
	for (i=0;i<x.length;i++)
	{
		if (y.nodeType==1)
 	 {
		
		if (XMLgigs.getElementsByTagName(y.nodeName)[MapLoop1].childNodes[0] != null) {
 	
		valueOfNode = XMLgigs.getElementsByTagName(y.nodeName)[MapLoop1].childNodes[0].nodeValue;
 		if (countNodeNumber == 8) {countNodeNumber++;}

			gigLocations[MapLoop1][countNodeNumber]=valueOfNode;
 			}
		countNodeNumber++;
  		}
		y=y.nextSibling;
	}
}

//End Array


//******************************************************************************************************************************************************************************************************

///////////////////
//End Google Map Code non Jquery Functions
//////////////////
//////////////////
//////////////////

	/////////////////////
	//Begin Jquery Functions For Gmaps
	////////////////////
jQuery(document).ready(function($) {
	

 // Start the Google Map
// Using a var zoom level because it changes via an interface external to Gmaps.
var currentZoomLevel = 10;
//markers array for multiple show listings
var markers = [];
var map = null;
var compareMarker = [];
var GigMenu = '';
var CreateWindowHTML = [];
var gmarkers = [];
var gigCloseLoc = [];

var stateActiveGoog = document.getElementById("accordion").innerHTML.indexOf('ui-state-active');
				   
		var userLat = google.loader.ClientLocation.latitude;
		var userLng = google.loader.ClientLocation.longitude;
		var centerPoint = new GLatLng(userLat, userLng );
		
						   
	 	//Set the blue overlay to style the map - it will be called later on.
		var tilelayer = new GTileLayer();
		tilelayer.isPng = function() { return true;}; 

		tilelayer.getTileUrl =  function(tile, zoom) { 
  			return "http://www.section30band.com/resources/somedayTheme/images/body/maps/overlay.png"; 
			} 
			
		var myTileLayer = new GTileLayerOverlay(tilelayer);
		
		//Set the custom icon for the map
		var baseIcon = new GIcon(); 
		var closeIcon = new GIcon(); 
		//baseIcon.shadow = "http://www.section30band.com/resources/somedayTheme/images/body/maps/images/markerShadow.png";
		baseIcon.image = "http://www.section30band.com/resources/somedayTheme/images/body/maps/marker.png";
		baseIcon.shadowSize = new GSize(0, 0); 
		baseIcon.iconSize = new GSize(42, 46); 
		baseIcon.iconAnchor = new GPoint(21, 23); 
		baseIcon.infoWindowAnchor = new GPoint(28, 23); 
		
		closeIcon.image = "http://www.section30band.com/resources/somedayTheme/images/body/maps/markerclose.png";
		closeIcon.shadowSize = new GSize(0, 0); 
		closeIcon.iconSize = new GSize(42, 46); 
		closeIcon.iconAnchor = new GPoint(21, 23);
		closeIcon.infoWindowAnchor = new GPoint(28, 23); 
		
		//Set up the bounds for auto calculation
		var bounds = new GLatLngBounds();
		//Set up the map
        var map = new GMap2(document.getElementById("Google_map_canvas"));
		
		
		
		//Set the center and zoom - This will change later on
        map.setCenter(new GLatLng(0,0),currentZoomLevel);
		//Determine the type of map - we are using topographical
		map.setMapType(G_PHYSICAL_MAP);
		//Setting the min and max res for the scroller - So it doesn't look stupid.
		G_PHYSICAL_MAP.getMinimumResolution = function() { return 4; }
		G_PHYSICAL_MAP.getMaximumResolution = function() { return 15; }
		//Adding the blue overlay to change the color of the map
  		map.addOverlay(myTileLayer);
		//Yes - you can use the scoll wheel to zoom.
		//map.enableScrollWheelZoom();
		
	  ew = new EWindow(map, E_STYLE_7);      
      map.addOverlay(ew);
	  
	  function styleGoogleWindow(a,b,directions) {
        return '<div id="GwinContainer">  <div id="GwinUpperLeft"></div>  <div id="GwinUpperRight"><a href="javascript:ew.hide();removeGMemory();">X</a></div>  <div id="GwinMidLeft">    <div id="GwinContent" class="googleWindow"><table><tr><td><div class="gooleWindowDate">'+a+'</div>'+b+'</td></tr></table></div>    <div id="GwinMidRight"></div>  </div>  <div id="GwinBottom"><div class="GwinDirections"><a href="http://maps.google.com/maps?daddr='+directions+'('+a+')" target="_blank">Directions</a></div></div></div>';
      }
	 //  GEvent.addListener(map, "click", function(overlay,point) {
//        if (!overlay) {
//          ew.hide();
//        }
     // });




	// Set images on the map -- Decoration
		
		//This is the upper right corner image
		html='<div class="GoogleUpRightPanel"></div>';
		var GoogleUpRightPanel=new HtmlControl(html, { visible:false, selectable:true });
		map.addControl(GoogleUpRightPanel, new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(0, 0)));
		GoogleUpRightPanel.setVisible(!GoogleUpRightPanel.isVisible);
		
		//This is the upper shadow div - CSS controled
		html='<div class="GoogleUpPanel"></div>';
		var GoogleUpPanel=new HtmlControl(html, { visible:false, selectable:true });
		map.addControl(GoogleUpPanel, new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(32, 0)));
		GoogleUpPanel.setVisible(!GoogleUpPanel.isVisible);
		
		//This is the upper left corner div - CSS controled
		html='<div class="GoogleUpLeftPanel"></div>';
		var GoogleUpLeftPanel=new HtmlControl(html, { visible:false, selectable:true });
		map.addControl(GoogleUpLeftPanel, new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(0, 0)));
		GoogleUpLeftPanel.setVisible(!GoogleUpLeftPanel.isVisible);
		
		//This is the left shadow div - CSS controled
		html='<div class="GoogleLeftPanel"></div>';
		var GoogleLeftPanel=new HtmlControl(html, { visible:false, selectable:true });
		map.addControl(GoogleLeftPanel, new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(0, 34)));
		GoogleLeftPanel.setVisible(!GoogleLeftPanel.isVisible);
		
		//This is the bottom left corner div - CSS controled
		html='<div class="GoogleBottomLeftPanel"></div>';
		var GoogleBottomLeftPanel=new HtmlControl(html, { visible:false, selectable:true });
		map.addControl(GoogleBottomLeftPanel, new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(0, 0)));
		GoogleBottomLeftPanel.setVisible(!GoogleBottomLeftPanel.isVisible);
		
		//This is the right shadow div - CSS controled
		html='<div class="GoogleRightPanel"></div>';
		var GoogleRightPanel=new HtmlControl(html, {visible:false, selectable:true });
		map.addControl(GoogleRightPanel, new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(0, 34)));
		GoogleRightPanel.setVisible(!GoogleRightPanel.isVisible);
		
		//This is the bottom right corner div - CSS controled
		html='<div class="GoogleBottomRightPanel"></div>';
		var GoogleBottomRightPanel=new HtmlControl(html, {visible:false, selectable:true });
		map.addControl(GoogleBottomRightPanel, new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(0, 0)));
		GoogleBottomRightPanel.setVisible(!GoogleBottomRightPanel.isVisible);
		
function addGigLocation(itemnumber) {
	lat = gigLocations[itemnumber][6];
	lng = gigLocations[itemnumber][7];
	var point = new GLatLng(lat,lng);
	comparePoint = (point.distanceFrom(centerPoint) / 1609).toFixed(2);
	gigLocations[itemnumber][8] = comparePoint;
}



function createGigLocation(lat, lng, html, placeName, itemNumber) {
	
	
	if (Math.min.apply(Math, gigCloseLoc) == gigLocations[itemNumber][8]) {

	markerOptions = { icon:closeIcon, title:placeName };
	}
	else
	{
		markerOptions = { icon:baseIcon, title:placeName }; 
		}
		
	  var point = new GLatLng(lat,lng);
     	 var marker = new GMarker(point, markerOptions);
		 markers.push(point);
		 map.addOverlay(marker);
		gmarkers[itemNumber] = marker;
		GEvent.addListener(marker, "click", function() {
		OpenInfoWindowG(marker,html,0,true);
		if (GMie7 != 1){
		$("#myGigDetal").css({marginTop:-stopLocation-2+"px"} );
		$("#accordion").accordion('activate', parseInt(itemNumber));
		}
        });
		
	var SelectionContainer = '';
	var TheATag = '';
		GEvent.addListener(marker, "mouseover", function() {
		SelectionContainer = document.getElementById("GigHead"+itemNumber);
		TheATag = SelectionContainer.getElementsByTagName('a')[0];
		SelectionContainer.style.backgroundImage = "url('http://www.section30band.com/resources/somedayTheme/images/body/maps/images/menu/infoPanelOver.png')";								 		
		TheATag.style.color = "#FFF";
		marker.setImage((marker.getIcon().image).replace(".png", "Over.png")); 
		
		
		});
		GEvent.addListener(marker, "mouseout", function() {
		SelectionContainer.style.backgroundImage = "";
		TheATag.style.color = "";
		marker.setImage(marker.getIcon().image); 
		})
	}
	

for (i in gigLocations) {
addGigLocation(i);
gigCloseLoc.push(gigLocations[i][8])

}
for (i in gigLocations) {
placeName = gigLocations[i][0];
placeDate = gigLocations[i][1].replace(", 2010", "");
placeTime = gigLocations[i][2];
placeAddr = gigLocations[i][3];
placeCity = gigLocations[i][4];
placeState = (gigLocations[i][5].replace("Minnesota", "MN")).replace("Wisconsin", "WI").replace("Iowa", "IA");
placeLat = gigLocations[i][6];
placeLng = gigLocations[i][7];
placeDescr = gigLocations[i][9];
if (placeDescr == null) {placeDescr = '';}
if (i != gigLocations.length-1) {GigArSeperate = ',';}else {GigArSeperate = '';}

GigMenu = GigMenu+ '<h3 id="GigHead'+i+'"><a href="#"><span class="GigTitle1">'+placeDate+'</span><span class="GigTitle2">'+placeTime+'</span><span class="GigTitle3">'+placeName+'</span><span class="GigTitle4">'+placeCity+'</span><span class="GigTitle5">'+placeState+'</span></a></h3><div id="GigDescr'+i+'">'+placeDescr+'<span class="GigDir"><a href="http://maps.google.com/maps?daddr='+placeLat+'%2C'+placeLng+'('+placeName+')" target="_blank">Get Directions</a></span></div>'

var placeAddrHTML = '';
if (placeAddr != null) {placeAddrHTML = '<br />'+placeAddr}
CreateWindowHTML[i] = styleGoogleWindow(placeName, placeDate+placeAddrHTML+'<br />'+placeCity+', '+placeState+' '+'<br />', placeLat+'%2C'+placeLng);
 
createGigLocation(gigLocations[i][6],gigLocations[i][7], CreateWindowHTML[i], gigLocations[i][0], i); 
}

document.getElementById('accordion').innerHTML = GigMenu;

 function OpenInfoWindowG(marker,html,zoom,pastOpen) {
		if (zoom > 0){map.setCenter(marker.getLatLng(), zoom);}
		
		p1 = map.fromLatLngToContainerPixel(marker.getLatLng());
		p1.x = p1.x +80;
		p1.y = p1.y -80;
		p2 = map.fromContainerPixelToLatLng(p1);
		map.panTo(p2);
		ew.openOnMarker(marker,html);
		if (pastOpen == true){
			markerRemember[0]=marker;
			markerRemember[1]=html;
			markerRemember[2]=zoom;
			}
		
		
	
}
 
function OpenInfoWindowG2(i,zoom) {
	OpenInfoWindowG(gmarkers[i],CreateWindowHTML[i],zoom,false)
	}

// Looks at markers and extends the Map Bounds	
	for (GLoop in markers) {
		bounds.extend(markers[GLoop]);
		}
// Centers the map, sets the zoom based on the markers array
	map.setCenter(bounds.getCenter());
	map.setZoom(map.getBoundsZoomLevel(bounds));
	//resetting zoom level for the UI
	currentZoomLevel =map.getBoundsZoomLevel(bounds);
	
//******************************************************************************************************************************************************************************************************	

  // Slider, buttons for navigation Pan and zoom
  $(function() {
			// slider target
			var target = $('#zoom-slider #zoom-path');
			
			// create the slider
			target.slider({
				orientation: 	'vertical',
				value: 			currentZoomLevel,
				min: 			parseInt(G_PHYSICAL_MAP.getMinimumResolution()),
				max: 			parseInt(G_PHYSICAL_MAP.getMaximumResolution()),
				step: 			1,
				animate: 		true,
				stop: function() {
					map.setZoom(parseInt(target.slider('option','value')));
				}
				
			});
			
			// update slider on zoom with double click
			GEvent.addListener(map, 'moveend', function() { target.slider('option','value', map.getZoom()); });
			
			// maximum slider value
			var maxValue = parseInt(target.slider('option', 'max'));
			
			// minimum slider value
			var minValue = parseInt(target.slider('option', 'min'));
			
			// hook increase zoom control
			$('#zoom-control-plus').click(function() {
				// current slider value
				var currentValue = parseInt(target.slider('option','value'));

				// current slider value increased by 1
				var newValue = currentValue+1;
				
				// is new value greater than max value?
				if(newValue <= maxValue) {
					// increase slider value
				
					target.slider('option', 'value', newValue);
					map.setZoom(newValue);
					
				} else {
					// slider is at max value
					target.slider('option', 'value', maxValue);
					map.setZoom(maxValue);
				}
				return false;
			});
			
			
			// hook decrease zoom control
			$('#zoom-control-minus').click(function() {
				// current slider value
				var currentValue = parseInt(target.slider('option','value'));

				// current slider value increased by 1
				var newValue = currentValue-1;

				// is new value greater than max value?
				if(newValue >= minValue) {
					// increase slider value
					target.slider('option', 'value', newValue);
					map.setZoom(newValue);
				} else {
					// slider is at max value
					target.slider('option', 'value', minValue);
					map.setZoom(minValue);
				}
				return false;
			});
			//pan controls for the compass - Center takes you back to the original lat,long and zoom. A home button
			  $('#pan-control-center').click(function() {
	
				map.setCenter(bounds.getCenter());
				map.setZoom(map.getBoundsZoomLevel(bounds));
				return false;
				});
		
		$('#pan-control-north').click(function() {
			//Pan the map north
				map.panDirection(0,+1);
				return false;
				});
		
		$('#pan-control-south').click(function() {
		//Pan the map south
				map.panDirection(0,-1);
				return false;
				});
		
		$('#pan-control-east').click(function() {
			//Pan the map east
				map.panDirection(-1,0);
				return false;
				});
		
		$('#pan-control-west').click(function() {
			//Pan the map west
				map.panDirection(+1,0);
				return false;
				});
			  
			  
			  
		});
  
  //Start the Menu that shows locations.
  //removed , autoHeight: false, active: false 
  
  	$("#accordion").accordion({ collapsible: true, active: false, autoHeight: false  });
		var accordionContainer = $("#accordion"); 
		var LocationsMenuContainer = $("#LocationsMenu");
		var accordionoffsetStatic = accordionContainer.offset().top - LocationsMenuContainer.offset().top;
		
 



		
	function ChangeGoogMenu(y) {
		var inner_container = accordionContainer.children(':first');
		var accordionoffsetMove = ((accordionContainer.offset().top - LocationsMenuContainer.offset().top) -accordionoffsetStatic)*-1

		
	
		setScrollValue = y*(accordionContainer.height() /LocationsMenuContainer.height())

		maxValue =Math.max(accordionContainer.height(), LocationsMenuContainer.height());
		minValue =Math.min(accordionContainer.height(), LocationsMenuContainer.height());																			   
		stopLocation = maxValue-(((minValue / maxValue)*90)/100)*maxValue;																		   

 if (accordionContainer.height() > LocationsMenuContainer.height()){
			if ( stopLocation > setScrollValue){
			$("#myGigDetal").css({ 
				marginTop:-setScrollValue+"px"} );  
			}
			if ( setScrollValue > stopLocation && accordionoffsetMove < stopLocation){
			$("#myGigDetal").css({ 
				marginTop:-stopLocation+2+"px"} );  
			}
}
else {$("#myGigDetal").css({ 
				marginTop:"0px"} );}
	}

$("#LocationsMenu").bind('accordionchange', function(e){
		var y = e.pageY - this.offsetTop;
		ChangeGoogMenu(y);
													 });

	$("#LocationsMenu").mousemove(function(e){
		var y = e.pageY - this.offsetTop;
		ChangeGoogMenu(y);


  		 });

	$("#accordion h3").mouseenter(function(e) {
			stateActiveGoog = document.getElementById("accordion").innerHTML.indexOf('ui-state-active');
     		if (stateActiveGoog == -1) {OpenInfoWindowG2((this.id).replace('GigHead', ''),0)}
			
			 });
	
	$("#accordion").mouseleave(function(e) {
				if (stateActiveGoog == -1){ew.hide();} 
				if (markerRemember[0] && stateActiveGoog == -1) {
				OpenInfoWindowG(markerRemember[0],markerRemember[1],markerRemember[2],true);}
				else {
					if (map.getZoom() == map.getBoundsZoomLevel(bounds)) {
					map.setCenter(bounds.getCenter());
					map.setZoom(map.getBoundsZoomLevel(bounds));
					}
				}
				});

	$("#accordion h3").click(function(e) {
   
		    stateActiveGoog = document.getElementById("accordion").innerHTML.indexOf('ui-state-active');
			if (stateActiveGoog != -1) {OpenInfoWindowG2((this.id).replace('GigHead', ''),13)}
			else
			{OpenInfoWindowG2((this.id).replace('GigHead', ''),currentZoomLevel)}
		
			 });
// This is a IE 7 fix for the menu



getInternetExplorerVersion();

if ( ver > -1 ){
	if ( ver <= 7 )
	{$('#LocationsMenu').addClass('GooMenuIE7Fix');GMie7= 1;}
	}

$("#tourContainer").mouseenter(function(){
	
	$("#tourNavigationContainer").removeClass("tourNavigationContainerOut").addClass("tourNavigationContainerOver");
										});

$("#tourContainer").mouseleave(function(){
	$("#tourNavigationContainer").removeClass("tourNavigationContainerOver").addClass("tourNavigationContainerOut")
										});
 
//////////////
//////////////
//End Jquery Functions For Gmaps
//////////////
//////////////
	});	
}

//******************************************************************************************************************************************************************************************************
//Get Version of IE
var ver = ''
function getInternetExplorerVersion()

{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
	var ver = rv;
	
	return true;
}
//End Get Version of IE

//******************************************************************************************************************************************************************************************************
var hitHomePg = null;
var homePgTimer = null;
var homePgTimerPer = null;
function HomePageSliderFun() {
	hitHomePg = 1;		
	
	jQuery(document).ready(function($)
	{


	
(function($){
	
    $.homePageSlider = function(el, options){
		
        // To avoid scope issues, use 'base' instead of 'this'
        // to reference this class from internal events and functions.
        var base = this;

        // Access to jQuery and DOM versions of element
        base.$el = $(el);
        base.el = el; 
		

		// Set up a few defaults
        base.currentPage = 1;
		base.timer = null;
		base.playing = false;
		base.timerPer = null;
		var Numberit =0;
		var oldPage = null;
		
		


        // Add a reverse reference to the DOM object
        base.$el.data("homePageSlider", base);
       
        base.init = function(){
            base.options = $.extend({},$.homePageSlider.defaults, options);
			
			// Cache existing DOM elements for later 
			base.$homePageSliderWrapper = base.$el.find('> div').css('overflow', 'hidden');
            base.$slider  = base.$homePageSliderWrapper.find('> ul');
            base.$items   = base.$slider.find('> li');
            base.$single  = base.$items.filter(':first');

			// Build the navigation if needed
			if(base.options.buildNavigation) base.buildNavigation();
        
        	// Get the details
            base.singleWidth = base.$single.outerWidth();
            base.pages = base.$items.length;

            // Top and tail the list with 'visible' number of items, top has the last section, and tail has the first
			// This supports the "infinite" scrolling
			base.$items.filter(':first').before(base.$items.filter(':last').clone().addClass('cloned'));
            base.$items.filter(':last' ).after(base.$items.filter(':first').clone().addClass('cloned'));

			// We just added two items, time to re-cache the list
            base.$items = base.$slider.find('> li'); // reselect
            
			// Setup our forward/backward navigation
			base.buildNextBackButtons();
		
			// If autoPlay functionality is included, then initialize the settings
			if(base.options.autoPlay) {
				base.playing = !base.options.startStopped; // Sets the playing variable to false if startStopped is true
				base.buildAutoPlay();
			};
			
			// If pauseOnHover then add hover effects
			if(base.options.pauseOnHover) {
				
				base.$el.hover(function(){
					base.clearTimer();
				}, function(){
					base.startStop(base.playing);
				});
			}
			
			// If a hash can not be used to trigger the plugin, then go to page 1
			if((base.options.hashTags == true && !base.gotoHash()) || base.options.hashTags == false){
				base.setCurrentPage(1);
			};
        };

		base.gotoPage = function(page, autoplay){
			//if (oldPage != page) {$(".homeSlideContentInside").animate({"left": "-=20px"}, "slow");}
				
			
			// When autoplay isn't passed, we stop the timer
			if(autoplay !== true) autoplay = false;
			if(!autoplay) base.startStop(false);
		
			
			if(typeof(page) == "undefined" || page == null) {
				page = 1;
				base.setCurrentPage(1);
			};
			
			
			// Just check for bounds
			if(page > base.pages + 1) page = base.pages;
			if(page < 0 ) page = 1;
			
			var dir = page < base.currentPage ? -1 : 1,
                n = Math.abs(base.currentPage - page),
                left = base.singleWidth * dir * n;
			
			base.$homePageSliderWrapper.filter(':not(:animated)').animate({
                scrollLeft : '+=' + left
            }, base.options.animationTime, base.options.easing, function () {
              if (page == 0) {
					
                    base.$homePageSliderWrapper.scrollLeft(base.singleWidth * base.pages);
					page = base.pages;
                } else if (page > base.pages) {
                    base.$homePageSliderWrapper.scrollLeft(base.singleWidth);
                    // reset back to start position
                    page = 1;
                };
				base.setCurrentPage(page);
				
            });
			//if (oldPage != page) {$(".homeSlideContentInside").animate({"left": "+=20px"}, "slow", "linear");}
			};
		
		base.setCurrentPage = function(page, move){
			// Set visual
			
			if(base.options.buildNavigation){
				
				bottomTransitionHomeSlide = $(".homePageSliderWrapper > ul> li:eq("+[page]+") > div > div.homeSlideBottomTrans");
				rightTransitionHomeSlide = $(".homePageSliderWrapper > ul> li:eq("+[page]+") > div > div.homeSlideRightTrans"); 
				leftTransitionHomeSlide = $(".homePageSliderWrapper > ul> li:eq("+[page]+") > div > div.homeSlideLeftTrans");
				topTransitionHomeSlide = $(".homePageSliderWrapper > ul> li:eq("+[page]+") > div > div.homeSlideTopTrans");
				
				if (bottomTransitionHomeSlide.length > 0) {
				//bottomTransitionHomeSlide.height("200px")
				bottomTransitionHomeSlide.show()
				.animate({"bottom": "0"}, "slow", "linear");
				}
				if (rightTransitionHomeSlide.length > 0) {
				//rightTransitionHomeSlide.width("200px")
				rightTransitionHomeSlide.show()
				.animate({"right": "0"}, "slow", "linear");
				}
				if (leftTransitionHomeSlide.length > 0) {
				//leftTransitionHomeSlide.width("200px")
				leftTransitionHomeSlide.show()
				.animate({"left": "0"}, "slow", "linear");
				}
				if (topTransitionHomeSlide.length > 0) {
				//topTransitionHomeSlide.height("200px")
				topTransitionHomeSlide.show()
				.animate({"top": "0"}, "slow", "linear");
				}
			
			
				if (oldPage && oldPage != page) {
					
				bottomTransitionHomeSlide = $(".homePageSliderWrapper > ul> li:eq("+[oldPage]+") > div > div.homeSlideBottomTrans");
				rightTransitionHomeSlide = $(".homePageSliderWrapper > ul> li:eq("+[oldPage]+") > div > div.homeSlideRightTrans");
				leftTransitionHomeSlide = $(".homePageSliderWrapper > ul> li:eq("+[oldPage]+") > div > div.homeSlideLeftTrans");
				topTransitionHomeSlide = $(".homePageSliderWrapper > ul> li:eq("+[oldPage]+") > div > div.homeSlideTopTrans");
				
				if (bottomTransitionHomeSlide.length > 0) {
				bottomTransitionHomeSlide.animate({"bottom": "-210px"}, "slow", "linear")
				.hide();
				}
				
				if (rightTransitionHomeSlide.length > 0) {
				rightTransitionHomeSlide.animate({"right": "-458px"}, "slow", "linear")
				.hide();
				}
				
				if (leftTransitionHomeSlide.length > 0) {
				leftTransitionHomeSlide.animate({"left": "-458px"}, "slow", "linear")
				.hide();
				}
				
				if (topTransitionHomeSlide.length > 0) {
				topTransitionHomeSlide.animate({"top": "-210px"}, "slow", "linear")
				.hide();
				}
				
				base.$nav.find('.Current'+oldPage).removeClass('Current'+oldPage); }
				
				$(base.$navLinks[page - 1]).addClass('Current'+page);
				oldPage = page;
				
				//alert(pageAnimate.innerHTML)
			
				
				//alert(pageAnimate)
			};
			
			// Only change left if move does not equal false
			if(move !== false) base.$homePageSliderWrapper.scrollLeft(base.singleWidth * page);

			// Update local variable
			base.currentPage = page;
			
		};
		
		base.goForward = function(autoplay){
			if(autoplay !== true) autoplay = false;
			base.gotoPage(base.currentPage + 1, autoplay);
			$("#viewWindowHomePlayerAnimate").width("100%")
			$("#start-stop").addClass("start-stopAdd");
			$("#viewWindowHomePlayerAnimate").animate({width: ["0%", 'swing']}, function () {$("#start-stop").removeClass("start-stopAdd");})
			Numberit = 0;
			
			
			
		};
		
		base.goBack = function(){
			base.gotoPage(base.currentPage - 1);
				$("#viewWindowHomePlayerAnimate").width("20%")
			$("#viewWindowHomePlayerAnimate").animate({width: ["0%", 'swing']})
			
		};
		
		// This method tries to find a hash that matches panel-X
		// If found, it tries to find a matching item
		// If that is found as well, then that item starts visible
		base.gotoHash = function(){
			if(/^#?panel-\d+$/.test(window.location.hash)){
				var index = parseInt(window.location.hash.substr(7));
				var $item = base.$items.filter(':eq(' + index + ')');
				if($item.length != 0){
					base.setCurrentPage(index);
					return true;
				};
			};
			return false; // A item wasn't found;
		};
        
		// Creates the numbered navigation links
		base.buildNavigation = function(){
			base.$nav = $("<div id='homePageThumbNav'></div>").appendTo('#viewWindowHomeItemLocContainer');
			base.$items.each(function(i,el){
				var index = i + 1;
				var $a = $("<a class = 'viewWindowHomeItemLoc"+index+"' href='#' title='Slide #"+index+"'></a>");
				
				// If a formatter function is present, use it
				if( typeof(base.options.navigationFormatter) == "function"){
					$a.html(base.options.navigationFormatter(index, $(this)));
				} else {
					$a.text(index);
				}
				$a.click(function(e){
                    base.gotoPage(index);
                    
                    if (base.options.hashTags)
						base.setHash('panel-' + index);
						
                    e.preventDefault();
				});
				base.$nav.append($a);
			});
			base.$navLinks = base.$nav.find('> a');
		};
		
		
		// Creates the Forward/Backward buttons
		base.buildNextBackButtons = function(){
			var $forward = $('<a class="arrow forward" href="#" title="Forward">Forward</a>'),
				$back    = $('<a class="arrow back" href="#" title="Back">Back</a>');
				
            // Bind to the forward and back buttons
            $back.click(function(e){
                base.goBack();
				
				e.preventDefault();
				
				return false;
            });

            $forward.click(function(e){
                base.goForward();
				
				e.preventDefault();
			
				return false;
            });

			// Append elements to page
		
			 $($back).appendTo(".viewWindowHomePlayerButtonLeft")
			 $($forward).appendTo(".viewWindowHomePlayerButtonRight")

		};
		
		// Creates the Start/Stop button
		base.buildAutoPlay = function(){

			base.$startStop = $("<a href='#' id='start-stop'></a>").html(base.playing ? base.options.stopText :  base.options.startText);
			//base.$el.append(base.$startStop); 
			
			$(base.$startStop).appendTo(".viewWindowHomePlayerButtonCenter")
            base.$startStop.click(function(e){
				base.startStop(!base.playing);
				
				e.preventDefault();
            });

			// Use the same setting, but trigger the start;
			base.startStop(base.playing);
		};
		
		// Handles stopping and playing the slideshow
		// Pass startStop(false) to stop and startStop(true) to play
		base.startStop = function(playing){
			if(playing !== true) playing = false; // Default if not supplied is false
			
			// Update variable
			base.playing = playing;
			$('#start-stop').attr("title", "play");
			
			
			// Toggle playing and text
			if(base.options.autoPlay) {base.$startStop.toggleClass("playing", playing).html( playing ? base.options.stopText : base.options.startText ); }
			
			if(playing){
				base.clearTimer();
				// Just in case this was triggered twice in a row
				$('#start-stop').attr("title", "pause");
				base.timer = window.setInterval(function(){
					base.goForward(true);
				
				}, (base.options.delay*1000));
				
				base.timerPer = window.setInterval(function(){
					
					Numberit++;
					theNumberCountHome = Math.round(Numberit/base.options.delay*10) +"%";
					
					$("#viewWindowHomePlayerAnimate").width(theNumberCountHome)
					
					}, 100);
			homePgTimer = base.timer;
			homePgTimerPer = base.timerPer;
				
			} else {
				base.clearTimer();
				
			};
		};
	
		base.clearTimer = function(){
			// Clear the timer only if it is set
			
			if(base.timer) window.clearInterval(base.timer);
			if(base.timerPer) {window.clearInterval(base.timerPer); Numberit = 0;};
			$("#viewWindowHomePlayerAnimate").width("0%")
			
		};

		
		// Taken from AJAXY jquery.history Plugin
		base.setHash = function ( hash ) {
			// Write hash
			if ( typeof window.location.hash !== 'undefined' ) {
				if ( window.location.hash !== hash ) {
					window.location.hash = hash;
				};
			} else if ( location.hash !== hash ) {
				location.hash = hash;
			};
			
			// Done
			return hash;
		};
		// <-- End AJAXY code
		

		// Trigger the initialization
        base.init();
		
	
		
    };


    $.homePageSlider.defaults = {
        easing: "swing",                // Anything other than "linear" or "swing" requires the easing plugin
        autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not
        startStopped: false,            // If autoPlay is on, this can force it to start stopped
        delay: 9,                    // How long between slide transitions in AutoPlay mode
        animationTime: 600,             // How long the slide transition takes
        hashTags: false,                 // Should links change the hashtag in the URL?
        buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
        pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
		startText: "Start",             // Start text
		stopText: "Stop",               // Stop text
		navigationFormatter: null,       // Details at the top of the file on this use (advanced use)
		destroy: false
    };
	

    $.fn.homePageSlider = function(options){
		if(typeof(options) == "object"){
		    return this.each(function(i){			
				(new $.homePageSlider(this, options));

	            // This plugin supports multiple instances, but only one can support hash-tag support
				// This disables hash-tags on all items but the first one
				options.hashTags = false;
	        });	
		} else if (typeof(options) == "number") {

			return this.each(function(i){
				var anySlide = $(this).data('homePageSlider');
				if(anySlide){
					anySlide.gotoPage(options);
				}
			});
		}
    };

	
})(jQuery);


//******************************************************************************************************************************************************************************************************

function formatText(index, panel) {
  return index + "";
}


	$('.homePageSlider').homePageSlider({
		easing: "swing",        // Anything other than "linear" or "swing" requires the easing plugin
		autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
		delay: 14,                    // How long between slide transitions in AutoPlay mode (seconds)
		startStopped: false,            // If autoPlay is on, this can force it to start stopped
		animationTime: 600,             // How long the slide transition takes
		hashTags: false,                 // Should links change the hashtag in the URL?
		buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
		pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
		startText: "&nbsp;",             // Start text
		stopText: "&nbsp;",               // Stop text
		destroy: false,
		navigationFormatter: formatText       // Details at the top of the file on this use (advanced use)
		
	});

	$("#slide-jump").click(function(){
		$('.homePageSlider').homePageSlider(6);
	});





}
)}


//******************************************************************************************************************************************************************************************************


function streachColumn() {
	jQuery(document).ready(function($)
	{
		 var biggestHeight = 0; 
		 var nameOfBigDIV = 0;
		$('.S30column').height('auto'); 
    $('.S30column').each(function(){  
					  
         if($(this).height() > biggestHeight){  
             biggestHeight = $(this).height(); 
			 nameOfBigDIV = $(this).attr('id');	
         }  
     });  
  $('.S30column').height(biggestHeight); 
  $('#'+nameOfBigDIV).height('auto'); 


	});	
}

//******************************************************************************************************************************************************************************************************

function AjaxProcessPost(file, form)
{
	
	jQuery(document).ready(function($)
	{		
		
		if(file == "process")
		{
			target = "http://www.section30band.com/login/process.php";	
		}
		else if(file == "adminprocess")
		{
			target = "http://www.section30band.com/login/admin/adminprocess.php";
		}

		// Serialize posted values
		var postString = $(form).serialize();
		var isLogin = false;
		var isNewPost = false;
		var urlString;
		
		// String manips to pop the right data into the url= attribute
		if(postString.indexOf("&avatargroup=default1") > -1)
		{
			urlString = postString.substr(postString.indexOf("&url="));
			restOfString = urlString.substr(urlString.indexOf("&sub"));
			postString = postString.replace(urlString, restOfString);
			postString = postString.replace("&avatargroup=default1", "&url=http://www.section30band.com/resources/somedayTheme/images/body/content/theFeed/avatar/s30A1.jpg");
			
		}
		else if(postString.indexOf("&avatargroup=default2") > -1)
		{
			urlString = postString.substr(postString.indexOf("&url="));
			restOfString = urlString.substr(urlString.indexOf("&sub"));
			postString = postString.replace(urlString, restOfString);
			postString = postString.replace("&avatargroup=default2", "&url=http://www.section30band.com/resources/somedayTheme/images/body/content/theFeed/avatar/s30A2.jpg");
			
		}
		else if(postString.indexOf("&avatargroup=default3") > -1)
		{
			urlString = postString.substr(postString.indexOf("&url="));
			restOfString = urlString.substr(urlString.indexOf("&sub"));
			postString = postString.replace(urlString, restOfString);
			postString = postString.replace("&avatargroup=default3", "&url=http://www.section30band.com/resources/somedayTheme/images/body/content/theFeed/avatar/s30A3.jpg");
			
		}
		else if(postString.indexOf("&avatargroup=default4") > -1)
		{
			urlString = postString.substr(postString.indexOf("&url="));
			restOfString = urlString.substr(urlString.indexOf("&sub"));
			postString = postString.replace(urlString, restOfString);
			postString = postString.replace("&avatargroup=default4", "&url=http://www.section30band.com/resources/somedayTheme/images/body/content/theFeed/avatar/s30A4.jpg");
			
		}
		else if(postString.indexOf("&avatargroup=default5") > -1)
		{
			urlString = postString.substr(postString.indexOf("&url="));
			restOfString = urlString.substr(urlString.indexOf("&sub"));
			postString = postString.replace(urlString, restOfString);
			postString = postString.replace("&avatargroup=default5", "&url=http://www.section30band.com/resources/somedayTheme/images/body/content/theFeed/avatar/s30A5.jpg");
			
		}
		else if(postString.indexOf("&avatargroup=default6") > -1)
		{
			urlString = postString.substr(postString.indexOf("&url="));
			restOfString = urlString.substr(urlString.indexOf("&sub"));
			postString = postString.replace(urlString, restOfString);
			postString = postString.replace("&avatargroup=default6", "&url=http://www.section30band.com/resources/somedayTheme/images/body/content/theFeed/avatar/s30A6.jpg");
			
		}
		else if(postString.indexOf("&avatargroup=default7") > -1)
		{
			urlString = postString.substr(postString.indexOf("&url="));
			restOfString = urlString.substr(urlString.indexOf("&sub"));
			postString = postString.replace(urlString, restOfString);
			postString = postString.replace("&avatargroup=default7", "&url=http://www.section30band.com/resources/somedayTheme/images/body/content/theFeed/avatar/s30A7.jpg");
			
		}
		else if(postString.indexOf("&avatargroup=default8") > -1)
		{
			urlString = postString.substr(postString.indexOf("&url="));
			restOfString = urlString.substr(urlString.indexOf("&sub"));
			postString = postString.replace(urlString, restOfString);
			postString = postString.replace("&avatargroup=default8", "&url=http://www.section30band.com/resources/somedayTheme/images/body/content/theFeed/avatar/s30A8.jpg");
			
		}
		else if(postString.indexOf("&avatargroup=defaultten") > -1)
		{
			urlString = postString.substr(postString.indexOf("&url="));
			restOfString = urlString.substr(urlString.indexOf("&sub"));
			postString = postString.replace(urlString, restOfString);
			postString = postString.replace("&avatargroup=defaultten", "&url=http://www.section30band.com/resources/somedayTheme/images/body/content/theFeed/avatar/s30A10.jpg");
			
		}
		
		else if(postString.indexOf("&avatargroup=custom") > -1)
		{
			urlString = postString.substr(postString.indexOf("&url="));
			restOfString = urlString.substr(urlString.indexOf("&sub"));
			if(urlString.indexOf("&url=&") > -1)
			{
				newUrlString = "&url=http://www.section30band.com/resources/somedayTheme/images/body/content/noPhoto_icon.jpg";
				postString = postString.replace(urlString, newUrlString + restOfString);
			}
			
			
			postString = postString.replace("&avatargroup=custom","")
			
		}
		
		else if(form == "#LoginForm")
		{
			isLogin = true;	
		}
		
		$.post(target, postString,function(){
														
			
			// On logout return to home
			if(form == "Logout")
			{
				incomingURL = "http://www.section30band.com/#/";
				URLArray = incomingURL.split("#");
				
				$("#LoginContainer").fadeOut(1000, function()
				{
					$("#LoginContainer").load(URLArray[1]+"?Loc=1" + " #LoginData", function()
					{
						$("#LoginContainer").fadeIn(1000);
						
					});
				});
				
				AjaxLoad($, URLArray);
				HistoryInd = 1;
			}		
			
			else if(form == "#LoginForm")
			{
				incomingURL = window.location.href;
				URLArray = incomingURL.split("#");
				
				$("#LoginContainer").fadeOut(1000, function()
				{
					$("#LoginContainer").load(URLArray[1]+"?Loc=1" + " #LoginData", function()
					{
						$("#LoginContainer").fadeIn(1000);
						
					});
				});
				
				AjaxLoad($, URLArray);
				HistoryInd = 1;
			}
			
			else if(form == "#NewPostForm")
			{
				incomingURL = window.location.href;
				URLArray = incomingURL.split("#");
				
				$("#NewPostCurtain").fadeOut(800, function()
				{
					$("#NewPostContainer").slideUp(800, function()
					{
						$("#feedContainer3").fadeOut(800, function()
						{
							$("#feedContainer2").load(URLArray[1]+"?Loc=1" + " #feedContainer3", function()
							{
								$("#feedContainer3").fadeIn(1000);
							});
						});
					});
				});
			
			}
			
			else
			{
				alert("Other");
				incomingURL = window.location.href;
				URLArray = incomingURL.split("#");
				AjaxLoad($, URLArray);
				HistoryInd = 1;
			}
			
		});
	});
	
}

//******************************************************************************************************************************************************************************************************

function CKEditor()
{
	jQuery(document).ready(function($)
	{
		if(CKEDITOR.instances.message)
		{
			CKEDITOR.remove(CKEDITOR.instances.message);
		}
	
		$('.CKEditor').ckeditor(
		{ 
			height: '77px',
			width: '330px',
			startupFocus: true,
			resize_enabled: false,
			toolbarCanCollapse: false,
			enterMode: CKEDITOR.ENTER_DIV,
			//extraPlugins : 'uicolor',
			toolbar :
			[
				[ 'Bold', 'Italic', '-', 'Link'],
				[ 'UIColor' ]
			]


		});
		
	});
}

//**********************************************************************************************************************************************************************************************************


function MoreComments() 
{
	jQuery(document).ready(function($)
	{
		$(".MoreCommentsA").die();
		$(".MoreCommentsA").live('click', function()
		{
			$(this).parents(".AllCommentsContainer").children(".HiddenComment").slideDown(600);
			$(this).parents(".AllCommentsContainer").children(".CommentsMoreContainer").children(".MoreCommentsA").html("<div class=\"MoreCommentsA\">Less Comments</div>");
			LessComments();		
			return false;
		});						
										
	});	
															
}

//**********************************************************************************************************************************************************************************************************


function LessComments() 
{
	jQuery(document).ready(function($)
	{
		$(".MoreCommentsA").die();
		$(".MoreCommentsA").live('click', function()
		{
			$(this).parents(".AllCommentsContainer").children(".HiddenComment").slideUp(600);
			$(this).parents(".AllCommentsContainer").children(".CommentsMoreContainer").children(".MoreCommentsA").html("<div class=\"MoreCommentsA\">More Comments</div>");
			MoreComments();
			return false;
			
		});
	});	
															
}


//******************************************************************************************************************************************************************************************************


function AddNewPost()
{	
	jQuery(document).ready(function($)
	{	
		$("#NewPostContainer").slideDown(800, function(){
			$("#NewPostCurtain").fadeIn(800);											   
		});
		
	});
	
	CKEditor();
}

function CloseNewPost()
{
	jQuery(document).ready(function($)
	{	
		$("#NewPostCurtain").fadeOut(800, function(){
			$("#NewPostContainer").slideUp(800);										   
		});
		
	});

}

//******************************************************************************************************************************************************************************************************


function AddNewComment(thislink)
{	

	jQuery(document).ready(function($)
	{	
		var containDiv = thislink.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
		
		newHTML = containDiv.innerHTML + '<div id="NewCommentContainer"><div id="NewCommentCurtain"><a onclick="CloseNewComment(); return false;">Close</a></div></div>';
		containDiv.innerHTML = newHTML;
		$("#NewCommentContainer").slideDown(800, function(){
			$("#NewCommentCurtain").fadeIn(800);											   
		});
		
	});
	
	CKEditor();
	
}

function CloseNewComment()
{
	jQuery(document).ready(function($)
	{	
		$("#NewCommentCurtain").fadeOut(800, function(){
			$("#NewCommentContainer").slideUp(800, function(){
				$("#NewCommentContainer").remove();
			});	
		});
		
	});

}


//******************************************************************************************************************************************************************************************************

var HistoryInd = 1;

function CreateErrorPage(response, status, xhr) {
	
	
	jQuery(document).ready(function($)
	{	
		//if (xhr.status == 404) {
		$("#AjaxContainer").load("404.php" + NewQueryAppend + " #AjaxContentContainer", function(){
			document.title = "Section 30 - " + xhr.status +" " + xhr.statusText;
			streachColumn();
			document.getElementById("StaticTitle").innerHTML = xhr.status +" " + xhr.statusText;
			ActivateSifr(); 
		//}
		});
	});
}

//******************************************************************************************************************************************************************************************************

if (typeof jQuery == "function")
{
	jQuery(document).ready(function($)
	{
		// Initialize MP3 player
		createMusicPlayer();
			
		function pageload(hash) {
		// alert("pageload: " + hash);
		// hash doesn't contain the first # character.
			if(hash) {
			// restore ajax loaded state
			
				//$("#LoadHistory").load(hash + ".html");
				incomingURL = window.location.href;
				URLArray = incomingURL.split("#");
				
				if (HistoryInd != 1) {AjaxLoad($, URLArray);}
				HistoryInd = 0;
			
			} 
		
			else {
			// start page
				rootURL = URLArray[0]+"#/"
				rootURL = rootURL.split("#");
			
				if (HistoryInd != 1) {AjaxLoad($, rootURL);HistoryInd =2;}
			}
		}

		// Initialize history plugin.
		// The callback is called at once by present location.hash. 
		$.historyInit(pageload, "/");
		// set onlick event for buttons
		$("a[rel='history']").click(function(){
			// 
			var hash = this.href;
			hash = hash.replace(/^.*#/, '');
			// moves to a new page. 
			// pageload is called at once. 
			// hash don't contain "#", "?"
			$.historyLoad(hash);
			
			return false;
		});

		// Change nav links to # links
		$("#NavContainer a.NavLink").each(function()
		{
			href = $(this).attr('href');	
			href = href.replace(".com", ".com/#/");
			href = href.replace("/#//", "/#/");
			$(this).attr('href', href);
			
		});

		// Attach click event to .JQueryLink items
		$(".OutsideJQueryLink").live('click',function()
		{
			// Grab home URL from meta tag
			site = $("meta[name='home']").attr("content");
			
			// Grab href attribute of <a>
			URLArray = $(this).attr("href").split("#");
			
			// Load the content
			AjaxLoad($, URLArray);
			HistoryInd = 1;

			return false;

		});
		
		// Display the container
		$("#AjaxContainer").css("display", "block");
		
		// Secrets...
		var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65"; 
		$(document).keydown(function(e) 
		{
			kkeys.push( e.keyCode );
			
			if ( kkeys.toString().indexOf( konami ) >= 0 )
			{
				$(document).unbind('keydown',arguments.callee);
				alert("Wow, you are a nerd...");          
			}
			
			
		});
		
		var statskeys = [], stats = "83,83,83";
		$(document).keydown(function(f) 
		{
			statskeys.push( f.keyCode );
			
			if ( statskeys.toString().indexOf( stats ) >= 0 )
			{
				$(document).unbind('keydown',arguments.callee);
				alert("Someday");
				LoadSomeday();
			}
			
			
		});
		
		var testkeys = [], testset = "84,84,84";
		$(document).keydown(function(g) 
		{
			testkeys.push( g.keyCode );
			
			if ( testkeys.toString().indexOf( testset ) >= 0 )
			{
				$(document).unbind('keydown',arguments.callee);
				alert("Live");
				LoadLive();
			}
			
			
		});
		
		
		// Initialize the container with some data
		init(jQuery, "#AjaxContainer");

	});
	
	function init($, id)
	{
		// assign the animation to a variable
		img = "<img src='/resources/somedayTheme/images/body/content/loading.gif' alt='Loading' style='padding-top: 75px; padding-left: 180px;' />";
		
		incomingURL = window.location.href;
		
		// If "index.php" (direct link from RSS) is in the URL, skip the URL grab
		if(incomingURL.search("index.php") < 1)
		{
			URLArray = incomingURL.split("#");
			
			// If the URLArray has 2 elements (ex: a # URL), catch it and load the content
			if(URLArray.length > 1)
			{
				// Load the content
				AjaxLoad($, URLArray);
				HistoryInd = 1;

			} 
		}
	
		// Display the container with the new data
		$("#AjaxContainer").css("display", "block");
		
		
		// Attach click event to all Nav Links
		$("#NavContainer a.NavLink").click(function()
		{
			// Grab home URL from meta tag
			site = $("meta[name='home']").attr("content");
			
			// Grab href attribute of <a>
			URLArray = $(this).attr("href").split("#");
			
			// Load the content
			
			AjaxLoad($, URLArray);
			HistoryInd = 1;
			return false;
			
		});	
		
		
		return false;
	}
	
	
	function AjaxLoad($, URLArray)
	{		
	if (hitHomePg == 1) {window.clearInterval(homePgTimer); window.clearInterval(homePgTimerPer);hitHomePg = null;}	
			//Look for Query String
			QueryString = URLArray[1].split("?");
			NewQueryAppend = "?Loc=1"
			if (QueryString[1] != null) {
			NewQueryAppend = "?Loc=1&" + QueryString[1]
			//Loc=1 is needed to not redirect pages
			}
			$("#AjaxContainer").html(img).load(QueryString[0]+NewQueryAppend + " #AjaxContentContainer", function(response, status, xhr)
			{
				
				rootURL = URLArray[0];		
				
				if($("#AjaxContainer").html() == "" ) 
				{
					alert("Sorry, there was a problem loading the content");
					// If the container is empty, default back to the homepage
					window.location.href = rootURL;
					return false;
				}

				if (status == "error") { 
					CreateErrorPage(response, status, xhr);
					return false;
				}
				
				// Read the hidden input tag, get a title
				//document.title = $("input[type='hidden'][name='title']").attr("value");
			
				// If it's a # link, get the home URL and append #, then append the sub directory
				
				if(URLArray.length > 1)
				{
					rootURL += "#" + URLArray[1];
				}
	
				// Attach the TourContainer click event
				$(".TourContainer").click(function()
				{
					$(this).children(".TourHidden").slideDown(600);
					
					return false;
				});

				// Attach lightbox to photos
				$(".S30Photo").lightBox();
				
				// Attach click event to .JQueryLink items
				$(".JQueryLink").click(function()
				{
					// Grab home URL from meta tag
					site = $("meta[name='home']").attr("content");
					
					// Grab href attribute of <a>
					URLArray = $(this).attr("href").split("#");
					
					// Load the content
					AjaxLoad($, URLArray);
					HistoryInd = 1;
		
					return false;
	
				});
				
				// Attach click event to YouTube thumbnails
				$(".YouTubeThumb").click(function()
				{
					// Get video info from thumbnail				
					var video = $(this).attr("rev");		
					
					// Dynamically add the divs for the YouTube vid
					$("body").append('<div id="ModalOverlay"></div>');
					
					// Change opacity of overlay (for ease of cross browser compatibility)
					$("#ModalOverlay").animate({opacity:0.5}, 200, function(){
						$("body").append('<div id="DynamicVideoContainer"><div id="DynamicVideo"></div></div>');
						// Embed the YouTube video dynamically
						RenderVideo(video);
					});
					// Attach click event so user can "exit" the video
					$("#ModalOverlay").click(function()
					{
						$("#DynamicVideoContainer").remove();
						$("#ModalOverlay").animate({opacity:0}, 200, function(){										
							$("#ModalOverlay").remove();
							$('#ModalOverlay').unbind('click');
							RemoveVideo();
						});
					});

					
					
					return false;
					
				});
				
				// Content rotators
				$("#MediaFeatured").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 7000, true);  
				$("#BioPictures").tabs({fx:{opacity: "toggle", duration: 2000}}).tabs("rotate", 8000, true);				
				
				
				// Rewrite URL to ajaxed location
				
				
				if (HistoryInd !=2) {
				window.location.href = rootURL;
				}
				
					// Rewrite title after new page is loaded
				ActivateSifr();	
				//strech Columns to equal length
				streachColumn();
				//Call Internal Javascript Functions
				CallPageFunction();	
				document.title = $("input[type='hidden'][name='title']").attr("value");
				
				return false;
				
					
			});	



	}
	
}

//******************************************************************************************************************************************************************************************************

function getFlashMovie(movieName) 
{   
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];  
}

// Calls to MP3 player to pause and unpause the player
function PauseMP3Player()
{
	getFlashMovie("mp3player").pauseMP3Player();
}

function UnpauseMP3Player()
{
	getFlashMovie("mp3player").unpauseMP3Player();
}

function LoadSomeday()
{
	getFlashMovie("mp3player").loadSomeday();
}

function LoadLive()
{
	getFlashMovie("mp3player").loadLive();
}