// POPUP WINDOWS


function sendFriend() {

	window.open('send_friend.html','sendfriend','height=420,width=375,resizable=0,scrollbars=0,location=0,toolbar=0,status=0,left=100,top=100,screenX=100,screenY=100').focus;
}


	// object creator for handling image swappers
		function swapImg(url, width, height, rate, parent, interval, strTarget) {
			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) {
				arrayData = (typeof(arrayData) == 'string') ? eval(arrayData) : 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';
				root.domStruct.target       = strTarget;
			// 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];
							//***  070301  HMO  Se soporta que tome el target desde el arreglo, si viene especificado...
							if(parent.docsArr[parent.current].length>=3 && parent.docsArr[parent.current][3]!=undefined)
								parent.target = parent.docsArr[parent.current][3];
						}
					// 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];
				//***  070301  HMO  Se soporta que tome el target desde el arreglo, si viene especificado...
				if(root.domStruct.docsArr[0].length>=3 && root.domStruct.docsArr[0][3]!=undefined)
					parent.target = root.domStruct.docsArr[0][3];
			}
		// make reqest and initialize
			ajaxReq(url, root.init, [interval]);
			//***  070306  HMO  Nuevo formato, pero no pasado aún a la librería JS de SixFlags México...
			//ajax.get(url, root.init, [interval]);
			return false;
		}



	// FLASH LINKS
		function goLink(arg1, arg2, arg3) {
			if (arguments.length == 2) {
				
			}
			if (arguments.length == 3) {
				if (arg3.indexOf('//') != -1) {
					var thsDomain = document.location.href.split('//')[1].split('/')[0];
					var thsProtoc = document.location.href.split('//')[0];
					var lnkDomain = arg3.split('//')[1].split('/')[0];
						lnkDomain = lnkDomain.split('.')[lnkDomain.split('.').length-2];
						lnkPath   = arg3.split('sixflags.com/')[1];
					if (lnkDomain == 'sixflags') {
						arg3 = thsProtoc + '//' + thsDomain + '/' + lnkPath;
					}
				}
				document.location.href = arg3;
			}
		}

	// PROMO CODE
		function processPromo(promoSite, promoCode)	{
			var fullUrl = promoSite + "&promo_code=" + promoCode;
				if (fullUrl.indexOf('//') != -1) {
					var thsDomain = document.location.href.split('//')[1].split('/')[0];
					var thsProtoc = document.location.href.split('//')[0];
					var lnkDomain = fullUrl.split('//')[1].split('/')[0];
						lnkDomain = lnkDomain.split('.')[lnkDomain.split('.').length-2];
						lnkPath   = fullUrl.split('sixflags.com/')[1];
					if (lnkDomain == 'sixflags') {
						fullUrl = thsProtoc + '//' + thsDomain + '/' + lnkPath;
					}
				}
			window.open(fullUrl,'ecom').focus();

		}
		
		
		function openpopup(){
			var strArg, strFeatures='';
			strArg = arguments[0];
		    if (arguments.length==1) strFeatures = 'width=486,height=452';
		    else strFeatures = arguments[1];
		    winpops=window.open(strArg,"",strFeatures);
		}

		function openpopup2(){
			var strArg, strFeatures='';
			strArg = arguments[0];
		    if (arguments.length==1) strFeatures = 'width=750,height=850';
		    else strFeatures = arguments[1];
		    winpops=window.open(strArg,"",strFeatures);
		}

		function popupEjecutivos(){
			var strArg, strFeatures='';
			strArg = arguments[0];
		    if (arguments.length==1) strFeatures = 'width=550,height=470';
		    else strFeatures = arguments[1];
		    winpops=window.open(strArg,"",strFeatures);
		}


//JCV 100804 - se agregan funcions para imgs roll-over
function exa_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function exa_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=exa_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function exa_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=exa_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function exa_swapImage() { //v3.0
  var i,j=0,x,a=exa_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=exa_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}