RegExp.specials = /([.*+?^${}()|[\]\/\\])/g;
RegExp.escape = function(text) {
	return text.replace(RegExp.specials, '\\$1')
};

var Arkansas = Aris.extend({
	onSite: new RegExp('javascript|mailto|'+RegExp.escape(location.host.replace('www',''))),
	pageReady: function () {
	    Array.forEach = a4e;
		Flash.create({ movie: '/!images/rotator/SlideShow.swf', ver: '8.0.22', width: '641', height: '383',
			bgcolor: '#000000',
			flashvars: { xmlfile: '/!includes/MP-SlideShowXML.aspx' },
			wmode: 'transparent'
		}, 'mp_flash');
		
		Flash.create({ movie: '/!images/int/apt07_int_branding.swf', ver: '8.0.22', width: '773', height: '209',
			bgcolor: '#000000',
			wmode: 'transparent'
		}, 'int_flash');

		this.popUpSafe(document.getElementsByTagName('a'));
		this.setRollovers();
		
	    var FS = new FontSizer('body','upsize','downsize','reset');
	    
	    if ( DOM.match ) {
			DOM.match("input[title]").forEach(function(input) {
				input.value = input.title;
				Event.add(input, 'focus', Arkansas.inputFocus);
				Event.add(input, 'blur', Arkansas.inputBlur);
			});
	    }
	    
	},
	inputFocus: function() {
		if (this.getAttribute('oldval') == null){
			this.setAttribute('oldval',this.value);
			this.value = '';
		} else {
			this.select();
		}
	},
	inputBlur: function() {
		if (this.value == '')
			this.value = this.getAttribute('oldval');
	}, 
	popUpSafe: function(els) {
		if (!els) return;
		var documents = /\.pdf/g;
		var app = this;
		Array.forEach(els, function(el) {
			var r = el.rel || '';
			if (el.target == '_self')
			    return;
			if ( !app.onSite.test(el.href) || documents.test(el.href) ) {
				r = el.rel = r || 'external';
			}
			if (r.indexOf(':') >= 0 || r=="external" )  {
				Event.add(el, 'click', function(e) {
					args = this.rel.split(':');
					if ( Aris.popWin(this.href, args[0], args[1], args[2]) ) {
						Event.preventDefault(e);
						return false;
					}
					return true;
				});
			}
		});
	},
	setRollovers: function () {
		var out = {}, over = {};
		if (!document.images) return;
		var rollover = DOM.getElementsByClass('rollover');
		forEach(rollover, function(ro,idx) {
			out[ idx ] = new Image();
			over[ idx ] = new Image();
			out[ idx ].src = ro.src;
			over[ idx ].src = ro.getAttribute('rollSrc');
			var img = ro;
			img.idx = idx;
			var a = ro.parentNode;
			if ((a && a.tagName.toLowerCase() == 'a') ){
				a.onmouseover = function() { img.src = over[img.idx].src; }
				a.onmouseout = function() { img.src = out[img.idx].src;  }
				a.onfocus = function() { img.src = over[img.idx].src; }
				a.onblur = function() { img.src = out[img.idx].src; }
			}
			else if (ro.tagName.toLowerCase() == 'input') {
				ro.onmouseover = function() { img.src = over[img.idx].src; }
				ro.onmouseout = function() { img.src = out[img.idx].src; }
			}
		});
	}

});

sIFR.replaceElement({sSelector:"#page_info h1", sFlashSrc:"/!images/int/futura_medium.swf", sColor:"#2F3F7A", sBgColor:"#FFFFFF", sWmode:"transparent"});
sIFR.replaceElement({sSelector:"#localfavorites h2", sFlashSrc:"/!images/int/futura_medium.swf", sColor:"#FFDD86", sBgColor:"#F8F4E1", sWmode:"transparent", sCase:"upper"});


var Cookies = {
	add: function(name,value,days) {
		var expires = '';
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			expires = '; expires='+ date.toGMTString();;
		}
		document.cookie = name+"="+escape(value) + expires+"; path=/";
	},
	remove: function(name) {
		this.add(name, '', -1);
	},
	get: function(name) {
		var results = document.cookie.match ( name + '=([^;]*?)(;|$)' );
		if ( results )
			return ( unescape ( results[1] ) );
		else
			return null;
	}
};

var FontSizer = Base.extend( new function() {
	var cookieName;
	var currentSize;
	var stepSize = 2;
	var maxSize = 20;
	var minSize = 9;
	var baseSize = 12;
	return {
		constructor: function(type, upid, downid, resetid) {
			this.type = type;
			
			cookieName = type+'FontSize';
			var x = Cookies.get(cookieName);
			currentSize = x ? parseInt(x) : baseSize;

			if ( currentSize!=baseSize )
				this.update();
			
			Event.add(upid, 'click', this.increase, this);
			Event.add(downid, 'click', this.decrease, this);
			Event.add(resetid, 'click', this.reset, this);
			FontSizer[type] = this;
			return this;
			
		},
		reset: function(e) { 
			Cookies.remove(cookieName);
			currentSize = 12;
			this.update();
			Event.preventDefault(e);
		},
		update: function() {
			Cookies.add(cookieName, currentSize, 7);
			var form = document.getElementsByTagName('form')[0];
			DOM.setStyle(form, 'fontSize', (currentSize/baseSize) +'em');
			
		},
		increase: function(e) {
			currentSize = Math.min(currentSize + stepSize, maxSize);
			this.update();
			Event.preventDefault(e);
		},
		decrease: function(e) {
			currentSize = Math.max(currentSize - stepSize, minSize);
			this.update();
			Event.preventDefault(e);
		}
	};
});

function reloadPage(init) {}
//reloadPage(true);


/******************************
Explore Arkansas Drop-Down
load1 function also contained in the _mp_scripts.js file
*******************************/
function load1(form) {
     var url = form.Llisted.options[form.Llisted.selectedIndex].value;
	     if (url != '') 
		 {
		 
		 	if(url == 'http://www.arkansastravel.com/')
			{
				window.open('http://www.arkansastravel.com/','ArkansasTravel'); /* ,'width=769,height=599,scrollbars=yes,toolbar=yes,location=yes,menubar=yes,status=yes' */
			}
			else{
                location.href = url;
			}
			
	  }
     return false;
}

function loadFree(form) {
     var url = form.Llisted.options[form.Llisted.selectedIndex].value;
	     if (url != '') 
		 {
		 
		 	if(url == 'http://www.arkansastravel.com/')
			{
				window.open('http://www.arkansastravel.com/','ArkansasTravel'); /*,'width=769,height=599,scrollbars=yes,toolbar=yes,location=yes,menubar=yes,status=yes'*/
			}
			//else if(url == '/immersive-tour/')
			//{
			//	OpenITourFree('');
			//}
			else{
			    location.href = url;
			}
			
	  }
     return false;
}

function load2(form) {
     var url = form.mlisted.options[form.mlisted.selectedIndex].value;
	     if (url != '') 
		 {
		 
			location.href = url;
			
		  }
     return false;
}


function getLoc(){
	if (document.forms['sel'])
	{
		var frm = document.forms['sel'].Llisted;
		var loc = window.location.href;
		for (i = 0;i < frm.length;i++){
			if (loc.indexOf(frm[i].value) != -1){
				frm[i].selected = true;
				
				frm.options[frm.selectedIndex].style.backgroundColor = '#FDD663';
				return true;
				}
		}
	}
}
/**************************/


function zipredirect() {
  zip = document.zipform.zip.value;
  //alert(zip);
  strWindow = '/zipsearch.asp?zip=' + zip;
  window.open(strWindow,'zipsearch','width=200,height=220,scrollbars=no,resizable=yes')  
}

    //IMAGE MOUSEOVER SCRIPT
    //only have to change the range in the for loop and array definitions to add menu items
    images_array = new Array(5);
    images_array_r = new Array(5);
    for (i=1; i<6; i++)
    {
       images_array[i]=new Image();
       images_array[i].src="/images/mainpage/adpt_horz_nav_" + i + ".gif";

       images_array_r[i]=new Image();
       images_array_r[i].src="/images/mainpage/adpt_horz_nav_" + i + "m.gif";
    }

    function swap(num)
    {
        image_name = "image" + num;
        if(document.getElementById) document.getElementById(image_name).src = images_array_r[num].src;
        else if(document.images) document.images[image_name].src = images_array_r[num].src;
    }

    function swapOut(num)
    {
        image_name = "image" + num;
        if(document.getElementById) document.getElementById(image_name).src = images_array[num].src;
        else if(document.images) document.images[image_name].src = images_array[num].src;
    }

    if (document.images)
     {
      flashlight1 = new  Image(259,187);
      flashlight1.src = "/images/mainpage/adpt_flashlight_off.gif";

      flashlight2 = new  Image(259,187);
      flashlight2.src = "/images/mainpage/adpt_flashlight_on.gif";
    }

    function hiLite(name, source) {
      var bn = navigator.appName;
      var vn = navigator.appVersion;

    	if (document.images) {
    		document.images[name].src = eval(source + ".src");
      }
    }

    function openBrWindow(theURL,winName,features) { //v2.0
      if (confirm('NOTE: This page is best viewed on newer browsers (5.0+)\nPlease disable any Pop-up Blockers and click \'OK\' to continue...'))
      window.open(theURL,winName,features); }








/*********************************************************************
OPEN WINDOW AND CENTER IT
***********************/
// JDR 2004-02-06 removed centering commands for WebSage compatability
//	!!!! removed from ALL functions below.


// NewWindow('outage_popup.html','OUT',1100,700,'no')
var win = null;
function NewWindow(mypage,myname,w,h,scroll)
{
    if (confirm('NOTE: This page is best viewed on newer browsers (5.0+)\nPlease disable any Pop-up Blockers and click \'OK\' to continue...'))
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	//settings =  'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
	settings =  'height='+h+',width='+w+',scrollbars='+scroll+',resizable'
	win = window.open(mypage,myname,settings)
	win.focus();
}



// OpenPhotoGallery('ID')
var winit = null;
function OpenITour(inputID)
{
   // if (ShowPopupWarning())
	//{
		LeftPosition = (screen.width) ? (screen.width-763)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-527)/2 : 0;
		//settings =  'height=527,width=763,top='+TopPosition+',left='+LeftPosition+',scrollbars=no,resizable';
		settings =  '';//'height=527,width=763,scrollbars=no,resizable';
		winit = window.open('/immersive-tour/default.aspx?id=' + inputID,'ITOUR',settings);
		if (!winit && winit.closed) {
			//alert("NOTE: Please disable any Pop-up Blockers and click \'OK\' to continue...");
			return false;
		}
		else{
			winit.focus();
			return true;
		}
	//}
}

// OpenPhotoGallery('ID')
var winit = null;
function OpenITourFree(inputID)
{
		LeftPosition = (screen.width) ? (screen.width-763)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-527)/2 : 0;
		//settings =  'height=527,width=763,top='+TopPosition+',left='+LeftPosition+',scrollbars=no,resizable';
		settings =  'height=527,width=763,scrollbars=no,resizable';
		winit = window.open('/immersive-tour/default.asp?id=' + inputID,'ITOUR',settings);
		winit.focus();
	
}



// OpenMap('REGION','FORMAT') format -- 1 = gif 2 = PDF
var wim = null;
function OpenMap(inputID,format)
{
    if (ShowPopupWarning())
	{
		LeftPosition = (screen.width) ? (screen.width-750)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-500)/2 : 0;
		//settings =  'height=500,width=750,top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,resizable';
		settings =  'height=500,width=750,scrollbars=yes,resizable';
		wim = window.open('/find_map/regionmap.asp?r=' + inputID + '&f=' + format,'MAP',settings);
		wim.focus();
	}
}

// OpenMapHelp()
var wimh = null;
function OpenMapHelp()
{
    if (ShowPopupWarning())
	{
		LeftPosition = (screen.width) ? (screen.width-485)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-380)/2 : 0;
		//settings =  'height=380,width=485,top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,resizable';
		settings =  'height=380,width=485,scrollbars=yes,resizable';
		wimh = window.open('/find_map/maphelp.html','MAPHELP',settings);
		wimh.focus();
	}
}


// OpenPhotoGallery('ID')
var winpg = null;
function OpenPhotoGallery(inputCity,inputID,region)
{
   // if (ShowPopupWarning())
	//{
		LeftPosition = (screen.width) ? (screen.width-772)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-600)/2 : 0;
		settings =  'height=600,width=772,top='+TopPosition+',left='+LeftPosition+',scrollbars=no,resizable';
		//settings =  'height=527,width=763,scrollbars=no,resizable';
		winpg = window.open('http://www.arkansas.com/photo-gallery/default.asp?city=' + inputCity + '&id=' + inputID + '&region=' + region,'PHOTOGALLERY',settings);
		if (!winpg && winpg.closed) {//alert("NOTE: Please disable any Pop-up Blockers and click \'OK\' to continue...");
			return false;
		}
		else{
			winpg.focus();
			return true;
		}
	//}
}

// OpenAdVideoGallery(id)
var winp = null;
function OpenAdVideoGallery(id)
{
    //if (ShowPopupWarning())
	//{
		LeftPosition = (screen.width) ? (screen.width-788)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-600)/2 : 0;
		//settings = 'height=540,width=787,top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,resizable';
		settings = 'height=540,width=787,scrollbars=yes,resizable';
		winp = window.open('/ad-video-gallery/ad/id/' + id,'ADGALLERY',settings);
		winp.focus();
	//}
}

// OpenAdVideoGallery(id)
var winp = null;
function OpenAdVideoGallery2(id)
{
    //if (ShowPopupWarning())
	//{
		LeftPosition = (screen.width) ? (screen.width-788)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-600)/2 : 0;
		//settings = 'height=540,width=787,top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,resizable';
		settings = 'height=540,width=787,scrollbars=yes,resizable';
		winp = window.open('/ad-video-gallery/ad2/id/' + id,'ADGALLERY',settings);
		winp.focus();
	//}
}



function ShowPopupWarning()
{
	//alert(getCookie("allowpopups"));
	if(!getCookie("allowpopups"))
	{
		var allow = confirm('NOTE: This page is best viewed on newer browsers (5.0+)\nPlease disable any Pop-up Blockers and click \'OK\' to continue...');
	
		if(allow)
		{
			with(expDate = new Date()) setDate(getDate() + 90)
			setCookie("allowpopups", "1", expDate);
		}
	
		return allow;
	}
	else
		return true;
}
	



function openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

function gotosite(site) {
	if (site != "") {
		location.href=site;
	} 
}

function gotositeWindow(site) {
	if (site != "") {
        //alert('did I get to here?');
        window.open(site);
		//location.href=site;
	} 
}

function open_win(hotel_id)
{
	window.open("/load_res.asp?hotel_id=" + hotel_id, "res_win", "height=550,width=700,resizable=yes,scrollbars=yes");
}

function getCookie (name) 
{
	var dcookie = document.cookie; 
	var cname = name + "=";
	var clen = dcookie.length;
	var cbegin = 0;
	
	while (cbegin < clen) 
	{
		var vbegin = cbegin + cname.length;
		
		if (dcookie.substring(cbegin, vbegin) == cname) 
		{ 
			var vend = dcookie.indexOf (";", vbegin);
			if (vend == -1) 
				vend = clen;
			
			return unescape(dcookie.substring(vbegin, vend));
		}
		
		cbegin = dcookie.indexOf(" ", cbegin) + 1;
		
		if (cbegin == 0) break;
	}
	
	return null;
}

function setCookie (name, value, expires) 
{
	if (!expires)
		expires = new Date();

	document.cookie = name + "=" + escape (value) + "; expires=" + expires.toGMTString() +  "; path=/";
}

function delCookie (name) 
{
	var expireNow = new Date();
	
	document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT" +  "; path=/";
}

//Linking policy
function copyText(activeObj) {
	//select all text in active object
	activeObj.focus();
	activeObj.select();
	
	//copy selection to clipboard
	cmdExec('copy');
}

function cmdExec(cmd,opt) {  
  document.execCommand(cmd,"",opt);  
}

function swapImage(source_image_id, mouseover_image_name)
{
    if(document.getElementById) document.getElementById(source_image_id).src = mouseover_image_name;
    else if(document.images) document.images[source_image_id].src = mouseover_image_name;
}

