// POPUP WINDOWS


	// object creator for handling image swappers
		function swapImg(url, width, height, rate, parent, interval) {
			root            = this;
		// globals
			root.docsArr    = [];
			root.current    = false;
			root.total      = false;
			root.timer      = false;
			interval        = (interval) ? interval*1000 : 15000;
		// populates docs array
			root.init    = function(arrayData, interval) {
				if (typeof(arrayData) == 'string') {
					try {
						arrayData = eval(arrayData)
					} catch (e) {
						//alert(arrayData)
					}
				}
			// create DOM structure
				root.domStruct              = document.createElement('a');
				root.domStruct              = parent.appendChild(root.domStruct);
				root.domStruct.style.width  = width  + 'px';
				root.domStruct.style.height = height + 'px';
				root.domStruct.href         = '#';
				root.domStruct.className    = 'imgFadeSwap';
			// set custom attributes
			// set initial values
				root.domStruct.docsArr  = arrayData;
				root.domStruct.current  = 0;
				root.domStruct.total    = arrayData.length;
				root.domStruct.interval = interval;
			// make botttom image
				var botImage                = document.createElement('img');
					botImage                = root.domStruct.appendChild(botImage);
					botImage.width          = width;
					botImage.height         = height;
					botImage.className      = 'bottom';
					botImage.style.position = 'absolute';
				// initiates an image swap
					botImage.onload = function() {
						if (client.engine != 'gecko') {
							motion.set(this.nextSibling, 'opacity', ['1.0', '0.0'], 0.1);
						} else {
							this.style.visibility = 'hidden';
						}
					}
			// make top image
				var topImage               = document.createElement('img');
					topImage               = root.domStruct.appendChild(topImage);
					topImage.width         = width;
					topImage.height        = height;
					topImage.className     = 'top';
					topImage.style.position = 'absolute';
				// initiates an image swap
					topImage.onload = function() {
						var src    = this.getAttribute('src');
						var top    = this;
						var parent = this.parentNode;
						var bottom = this.previousSibling;
					// transfer top image to bottom image
						var setBase = function() {
							bottom.src = src;
						}
						var nextImage = function() {
							parent.current = (parent.current + 1) % parent.total;
							top.src        = parent.docsArr[parent.current][0];
							parent.href    = parent.docsArr[parent.current][1];
						}
					// do it
						if (client.engine != 'gecko') {
							motion.set(this, 'opacity', ['0.0', '1.0'], 0.5, setBase);
						} else {
							this.style.visibility = 'visible';
						}
						root.timer = setTimeout(nextImage, this.parentNode.interval);
				}
			// set initial appearance.
				topImage.src        = root.domStruct.docsArr[0][0];
				root.domStruct.href = root.domStruct.docsArr[0][1];
			}
		// make reqest and initialize
			ajax.get(url, root.init, [interval]);
			return false;
		}


	// FLASH LINKS
		function goLink(arg1, arg2, arg3) {

			if (arguments.length == 2) {
				
			}
			if (arguments.length == 3) {
				document.location.href = arg3;
			}
		}

	// PROMO CODE
		function processPromo(promoSite, promoCode)	{
			var fullUrl = promoSite + "&promo_code=" + promoCode;
			window.open(fullUrl,'ecom').focus();
		}
	// PRINT FUNCTIONS
	function PageQuery(q) {
		this.queryString = (q.indexOf("?") == 0 ? q.substring(1, q.length) : q);
		this.nameValuePairs = this.queryString.split("&");
		this.getValue = function(s) {
			for (var i=0; i<this.nameValuePairs.length; i++) {
				if (this.nameValuePairs[i].split("=")[0] == s) {
					return this.nameValuePairs[i].split("=")[1];
				}
			}
			return "";
		}
	}


	function sendFriend() {
	    var url = escape(location.href);
		window.open('/global/asp/sendfriend/sendfriend.aspx?url=' + url,'sendfriend','height=420,width=375,resizable=0,scrollbars=0,location=0,toolbar=0,status=0,left=100,top=100,screenX=100,screenY=100').focus;
	}

	var qs = (location.search) ? new PageQuery(location.search) : new PageQuery('');


	var nationalFlashDiv = false;
	var nationalFlashMov = false;


	function nationalFlash() {
		var pageQuery  = new queryHandler(document.location.href);
	// set default flashvars
		var flashQuery = new queryHandler('\
?bg_xml=%2Fglobal%2Fasp%2Fcode%2Fhomepageheroxml.aspx%3Fpage%3D%7Cglobal%7Cxml%7CactivatePromo%7Cnational%7CHomepageHero.xml\
&promo_xml=%2Fglobal%2Fasp%2Fcode%2Fhomepagerightpromo.aspx%3Fparkname%3Dnational\
&ticker_xml=%2Fglobal%2Fasp%2Fcode%2Fticker.aspx%3Fparkname%3Dnational');
	// override flashvars with any supplied values
		if (pageQuery.bg_xml)     { flashQuery.bg_xml     = pageQuery.bg_xml;     }
		if (pageQuery.promo_xml)  { flashQuery.promo_xml  = pageQuery.promo_xml;  }
		if (pageQuery.ticker_xml) { flashQuery.ticker_xml = pageQuery.ticker_xml; }
	// construct screwy qs for flash
		var flashVars = 'bg_xml=' + unescape(flashQuery.bg_xml) + '&promo_xml=' + unescape(flashQuery.promo_xml) + '&ticker_xml=' + unescape(flashQuery.ticker_xml);
	// make and set
		nationalFlashDiv = document.getElementById('flash-home');
		nationalFlashMov = swf.movie('/global/assets/swf/sixflags_national.swf', 965, 377, 8, '/noflash.html');
		nationalFlashMov.setParam('wmode', 'opaque');
		nationalFlashMov.setParam('flashvars', flashVars);
		nationalFlashMov = nationalFlashDiv.appendChild(nationalFlashMov);
	}

	function updateNationalSwf(varValue) {
		if (nationalFlashDiv && nationalFlashDiv) {
			nationalFlashMov.setVar('a.bgxml_', varValue);
		}
	}