
function swapImgRestore() { //v3.0
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function findObj(n, d) { //v4.0
  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=findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function fncLoad() {
	preloadImages('/img/home-dn.jpg','/img/about-dn.jpg','/img/products-dn-.jpg','/img/adventure-travel-dn.jpg','/img/news-and-events-dn.jpg','/img/workshops-dn.jpg','/img/brands-dn.jpg','/img/contact-dn.jpg','/img/location-dn.jpg','img/images/kayaks-dn.jpg','img/images/fishing-gear-dn.jpg','img/images/hunting-gear-dn.jpg','/img/adventure-travel-tile-dn.jpg','/img/tour-our-store-tile-dn.jpg','/img/internal-pages/adventure-title-dn.jpg','img/images/popular-view-all-dn.jpg','/img/internal-pages/tour-our-store-dn.jpg','/img/internal-pages/our-commitment-dn.jpg','/img/fly-fishing-dn.jpg','/img/fly-fishing-up.jpg','/img/internal-pages/fly-fishing-dn.jpg','/img/internal-pages/hunting-dn.jpg','/img/internal-pages/archery-dn.jpg','/img/internal-pages/camping-dn.jpg','/img/internal-pages/firearms-dn.jpg','/img/internal-pages/optics-dn.jpg','/img/internal-pages/apparel-dn.jpg','/img/internal-pages/gifts-dn.jpg')
}

// REMOVE IE LINK BOX //

function CSRemoveIEbox(){
if (document.images&&navigator.userAgent.indexOf("MSIE")!=-1){
	for(i=0;i<document.links.length;i++){
		target=eval("document.links[i]")
		target.onfocus=blurHandler
		}
	}
}

function blurHandler(){
obj=window.event.srcElement
if(obj.tagName == "A"||obj.tagName=="AREA") obj.blur()
}

//require fields in a form and redirect to url
function fncSubmit(obj,url) {
	var req = obj.required_fields;
	var submitflag = true;
	var notice = "Some of the required fields are blank:\n\n";
	if (req) {
		//Means the required fields are present, let's check for values
		var arrFields = obj.required_fields.value.split("|")
		for(var x=0; x<=arrFields.length-1; x++) {
			var arrName = arrFields[x].split(",");
			arrLabel=arrName[0];
			
			if (obj.elements[arrLabel]){
				var str = "if (obj."+arrName[0]+".value == '') { notice += '-->  "+arrName[1]+"\\n'; submitflag = false;}";
				eval(str);
			}
    }
		notice += "\nPlease fill in these fields and resubmit!";
	} else {
		//Means there isn't a required fields parameter; keep going
	}
	if (submitflag) {
		
		obj.action = url;
		obj.submit();
	} else {
		alert(notice);
	}
}

function fncCenteredChildWindow(URL,vHeight,vWidth,vScroll,vStatus) {
	if (screen.width) {
		var winl=(screen.width-vWidth)/2;
		var wint=(screen.height-vHeight)/2;
	} else { 
		winl=0;wint=0;
	}
	if(winl<0)winl=0;
	if(wint<0)wint=0;
	window.open(URL,'myWin','height='+vHeight+',width='+vWidth+',scrollbars='+vScroll+',status='+vStatus+',top='+wint+',left='+winl+',resizable=no')
}


/*	CarryOn specific functions		*/

//this function changes the background styles for the choose your package screen
function packageSelect(type){
	//declare all the elements we need to change
	var rh = document.getElementById('request_header');
	var rc = document.getElementById('request_cell');
	var sh = document.getElementById('send_header');
	var sc = document.getElementById('send_cell');
	
	if(type=='send'){
		//person is sending their own boxes
		rh.className='request-not';
		rc.className='choose-not';
		sh.className='send-selected';
		sc.className='choose-yes';
	}else{
		//person is requesting boxes be sent
		rh.className='request-selected';
		rc.className='choose-yes';
		sh.className='send-not';
		sc.className='choose-not';
	}
}

function submitPackageChoice(){
	document.packaging.submit();
}