
	// SELECT nav header
	function nav_on(navID) {
		document.getElementById("nav_" + navID).src = "/aaImages/template/nav/" + navID + "_on.gif";
	}
	// SWAP image by reference/state
	function imgSwap(_this, _state) {
		_this.src = "/aaImages/" + _this.id + "_" + _state + ".gif";
	}
	// LOAD page
	function loadPage(PageURL) {
		window.location.href = PageURL;
	}
	// OPEN new window
	function openPage(PageURL,w,h) {
		width=w
		height=h
		winName = PageURL //srtip URL for windowname so that each unique link will have a unique window
		winName = winName.replace(/\./g,"");
		winName = winName.replace(/-/g,"");
		winName = winName.replace(/\(/g,"");
		winName = winName.replace(/\)/g,"");
		winName = winName.replace(/ /g,"");
		winName = winName.replace(/:/g,"");
		winName = winName.replace(/\//g,"");
		window.open(PageURL,winName,'width='+width+',height='+height+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes')
	}
	// HIDE Element by ID
	function hideEle(inID) {
		document.getElementById(inID).style.visibility = "hidden";
	}
	// SHOW Element by ID
	function showEle(inID) {
		document.getElementById(inID).style.visibility = "visible";
	}
	// NONE Element by ID
	function removeEle(inID) {
		try {document.getElementById(inID).style.display = "none";}
		catch (e) {};
	}
	// BLOCK Element by ID
	function displayEle(inID) {
		try {document.getElementById(inID).style.display = "block";}
		catch (e) {};
	}
	// HTTP/HTTPS
	function secit(_secure) {
		var eLink=document.getElementsByTagName("a");
		for(var i=0;i<eLink.length;i++){
			eHref = eLink[i].getAttribute('href')
				if (_secure) eHref = eHref.replace("http","https");
				else eHref = eHref.replace("https","http");
				eLink[i].href = eHref
		}
	}
	// SET JS YEAR to 4 digit
	function y2k(_year) { return (_year < 1000) ? _year + 1900 : _year; }
	
	// FORM VALIDATION
	function checkEmail(_email) {
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(_email)) return true; //alert('YES! Correct email address');
		else return false; //alert('NO! Incorrect email address');
	}
	function checkPhone(_phone) { 
		_phone = _phone.replace(/\./g,"");
		_phone = _phone.replace(/-/g,"");
		_phone = _phone.replace(/\(/g,"");
		_phone = _phone.replace(/\)/g,"");
		_phone = _phone.replace(/ /g,"");
		if (_phone.match(/^\d{3}\d{3}\d{4}$/)) return true; //else if (_phone.match(/^\d{3}\d{4}$/)) return true;
	  	else return false; 
	}
	function checkZip(_zip) {
		filter = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
		if (!filter.test(_zip)) {
			return false;
		} else {
			return true;
		}
	}
	function checkCredit(cardNumber, cardType) {
	  var isValid = false;
	  var ccCheckRegExp = /[^\d ]/;
	  isValid = !ccCheckRegExp.test(cardNumber);
	
	  if (isValid)
	  {
	    var cardNumbersOnly = cardNumber.replace(/ /g,"");cardNumbersOnly = cardNumbersOnly.replace(/-/g,"");
	    var cardNumberLength = cardNumbersOnly.length;
	    var lengthIsValid = false;
	    var prefixIsValid = false;
	    var prefixRegExp;
	
	    switch(cardType)
	    {
	      case "mastercard","MC":
	        lengthIsValid = (cardNumberLength == 16);
	        prefixRegExp = /^5[1-5]/;
	        break;
	
	      case "visa","VI":
	        lengthIsValid = (cardNumberLength == 16 || cardNumberLength == 13);
	        prefixRegExp = /^4/;
	        break;
	
	      case "amex","AX":
	        lengthIsValid = (cardNumberLength == 15);
	        prefixRegExp = /^3(4|7)/;
	        break;
	
		  case "discover","DS":
	        lengthIsValid = (cardNumberLength == 16);
	        prefixRegExp = /^6011/;
	        break;
				   
	      default:
	        prefixRegExp = /^$/;
	        //alert("Card type not found");
			return false;
	    }
	
	    prefixIsValid = prefixRegExp.test(cardNumbersOnly);
	    isValid = prefixIsValid && lengthIsValid;
	  }
	
	  if (isValid)
	  {
	    var numberProduct;
	    var numberProductDigitIndex;
	    var checkSumTotal = 0;
	
	    for (digitCounter = cardNumberLength - 1; 
	      digitCounter >= 0; 
	      digitCounter--)
	    {
	      checkSumTotal += parseInt (cardNumbersOnly.charAt(digitCounter));
	      digitCounter--;
	      numberProduct = String((cardNumbersOnly.charAt(digitCounter) * 2));
	      for (var productDigitCounter = 0;
	        productDigitCounter < numberProduct.length; 
	        productDigitCounter++)
	      {
	        checkSumTotal += 
	          parseInt(numberProduct.charAt(productDigitCounter));
	      }
	    }
	
	    isValid = (checkSumTotal % 10 == 0);
	  }
	
	  return isValid;
	}
	
	// RES
	function makeChange(inURL) {
		if (inURL > "") document.location.href = inURL;
	}
	

 	//Header changes based on user's computer time
	function getTheHours() {
		var theDate = new Date();
		var hours = theDate.getHours();
		
		if ((hours >= 5) && (hours <=8))  {
		document.write("<div id='header_sunrise'>");
		}
		else if ((hours >= 9) && (hours <=16)) {
		document.write("<div id='header'>");
		document.write("<span class='sitemap_position'><a class='sitemap_light' href='http://www.allegiantair.com/sitemap.xml'>Sitemap</a></span>");
		}
		else if ((hours >=17) && (hours <= 20)) {
		document.write("<div id='header_sunset'>");
		}
		else {
		document.write("<div id='header_nighttime'>");
		document.write("<span class='sitemap_position'><a class='sitemap_dark' href='http://www.allegiantair.com/sitemap.xml'>Sitemap</a></span>");
		}
		}

	//Set the focus menu item
	function init() {
            nav_on(Nav_ID);
            }