function MM_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 MM_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=MM_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 MM_findObj(n, d) { //v3.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=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd() {
        rnd.seed = (rnd.seed*9301+49297) % 233280;
        return rnd.seed/(233280.0);
};

function randomGuide(){
        var myImage = Math.ceil(rnd()*18);
        document.images["guides"].src = "/images/guides/en/free_guide_ad_" + myImage + ".gif";
}
function jumpMenu(targ,selObj){
   url = selObj.options[selObj.selectedIndex].value;
   if(url != "") parent.document.location.href = url;
}
function submitMainsearch(url,keywords){
   url = url+"?keywords="+keywords.value;
   if(url != "") parent.document.location.href = url;
}

var homeimages = new Array('','/hikecamp','/outdoor','/beaches','/historical','/urban','/museums','/entertainment','/sports','/arts','/shopdine','/fairsfest','/golf','/huntfish','/fairsfest','/historical','/huntfish','/arts','/outdoor','/hikecamp');
var homeurl = "";

function changeParent(url){
   opener.location.href=url;
}


function changeHome(){
   if(homeurl != "") parent.document.location.href = homeurl;
}

var nextimg = "";
var nextlink = "";

function homeImage(first){
       if(document.location.href == web_root+'/contents.html'){    
            if(!first){
                document.images["homeimage"].src = nextimg;
            	homeurl = homeimages[nextlink];
            }
           	var myImage = Math.ceil(rnd()*19);
           	nextimg = "/images/home/en/home" + myImage + ".jpg";
           	nextlink = myImage;
           	MM_preloadImages(file:///C|/Documents%20and%20Settings/store58/Desktop/website/Weblinks/TravelManitoba_files/nextimg);
            
            setTimeout ("homeImage(0)", 10000);
        }
}

function spawnWindow(URL,name,height, width){
	window.open(URL+"?winwidth="+width+"&winheight="+height,name,"menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1,height="+height+",width="+width+" ,left=80,top=20")
}

function showGolf(item){
	width = 450;
	height = 350;

	eval(window.open ('/golf/golfdisplay.html?item_id='+item, 'golf', 'menubar=no, scrollbars=yes,status=no,width='+width+',height='+height+''));
}

function changeLodgeRegion(regions){
	value = regions.options[regions.selectedIndex].value;
	document.images['map'].src='/images/lodge_regions/'+value+'.gif';
}


function changeGolfRegion(regions){
	value = regions.options[regions.selectedIndex].value;
	largemap = "/activity/0"+value+".html";
	document.golf.zone[0].checked = true;
	document.images['map1'].src='/images/mcit_golf_regions/'+value+'.gif';
}

function changeMCITRegion(regions){
	value = regions.options[regions.selectedIndex].value;
	largemap = "/activity/0"+value+".html";
	document.images['map'].src='/images/mcit_golf_regions/'+value+'.gif';
}

function sel_loc(){
	document.golf.zone[1].checked = true;
}

function showActivity(item, region_id){
	width = 600;
	height = 375;

	eval(window.open ('/activity/activitydisplay.html?item_id='+item+'&region_id='+region_id, 'activity', 'menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1,width='+width+',height='+height+''));
}

function showRegionActivity(item, category_id){
	width = 600;
	height = 375;

	eval(window.open ('/maps/activitydisplay.html?item_id='+item+'&category_id='+category_id, 'activity', 'menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1,width='+width+',height='+height+''));
}

function showMCIT(item){
	width = 600;
	height = 375;

	eval(window.open ('/mcit/roomdisplay.html?item_id='+item, 'mcit', 'menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1,width='+width+',height='+height+''));
}

function showMTVG(item){
	width = 600;
	height = 375;

	eval(window.open ('/mtvg/itemdisplay.html?item_id='+item, 'mtvg', 'menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1,width='+width+',height='+height+''));
}

function showLodge(item, region_id){
	width = 600;
	height = 375;

	eval(window.open ('/huntfish/lodgedisplay.html?item_id='+item, 'lodge', 'menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1,width='+width+',height='+height+''));
}

function showOutfit(item, region_id){
	width = 450;
	height = 350;

	eval(window.open ('/huntfish/outfitterdisplay.html?item_id='+item, 'lodge', 'menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1,width='+width+',height='+height+''));
}

function showAccommodations(item, search_type){
	width = 450;
	height = 350;

	eval(window.open ('/accommodations/accommodationsdisplay.html?item_id='+item+'&search_type='+search_type, 'accommodations', 'menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1,width='+width+',height='+height+''));
}

function showAdventure(item){
	width = 400;
	height = 425;

	eval(window.open ('/adventure/adventuredisplay.html?item_id='+item, 'adventure', 'menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1,width='+width+',height='+height+''));
}

function unCheck(formname){
	formname.winter.checked=false;
	formname.nature.checked=false;
	formname.canoeing.checked=false;
	formname.hunting.checked=false;
	formname.fishing.checked=false;
}

var largemap = "first";

function popMap(height, width, current){

	height = 500;
	width = 520;

	if(largemap != "first") url = largemap;
		else url = "/activity/0.html";
		
	if(largemap == "first" && current != "") spawnWindow(current,'map',height, width)
	else spawnWindow(url,'map',height, width)
}


function popMap2(height, width, current){
	
	height = 500;
	width = 520;
	
	if(largemap != "first") url = largemap;
		else url = "/activity/00.html";
		
	if(largemap == "first" && current != "") spawnWindow(current,'map',height, width)
	else spawnWindow(url,'map',height, width)
}

 

function changeRegion(regions){
	value = regions.options[regions.selectedIndex].value;
	largemap = "/activity/"+value+".html";
	document.images['map'].src='/images/regions/'+value+'.gif';
}

function changeRegion1(regions){
	value = regions.options[regions.selectedIndex].value;
	largemap = "/activity/"+value+".html";
	document.images['map'].src='/images/mcit_golf_regions/'+value+'.gif';
}


function changeMTVGRegion(regions){
	value = regions.options[regions.selectedIndex].value;
	largemap = "/activity/"+value+".html";
	document.images['map'].src='/images/regions/'+value+'.gif';
}

function openWindow(theURL,winName,features) {
 	eval(window.open (theURL, winName, features));
}

function printerfriendly(print_string){
	thisval = document.location.href;
	splitArray2 = thisval.split('#');
	thisval = splitArray2[0];
	splitArray = thisval.split('?');
	if(splitArray.length > 1) var printfriend = "printerfriendly=true&"+splitArray[1];
		else var printfriend = "printerfriendly=true";
	if(print_string != "") print_string = "&"+print_string;
	openWindow(splitArray[0]+'?'+printfriend+print_string,'printerfriendly','menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1,width=600,height=450');	
}


function addTravelPlan(src_webpage_id,src_webpage_type,src_item_id,src_item_type,title){
	width = 580;
	height = 450;
	eval(window.open ('/itinerary/add.html?src_webpage_id='+src_webpage_id+'&src_webpage_type='+src_webpage_type+'&src_item_id='+src_item_id+'&src_item_type='+src_item_type+'&item_title='+title, 'travelPlan', 'menubar=0,location=0,toolbar=0,resizable,personalbar=0,status=0,scrollbars=1,width='+width+',height='+height+''));
}

function addTravelPlanBatch(src_webpage_id,src_webpage_type,src_item_type){
 	var total = 0;
	var max = document.acclist.accckbox.length;

	var item_id = "";
	
	if (eval("typeof(max) != 'undefined'") ) { 	
		var splitter = "";
		for (var idx = 0; idx < max; idx++){
			if (eval("document.acclist.accckbox[" + idx + "].checked") == true) {
				this_id = eval("document.acclist.accckbox[" + idx + "].value");
				item_id += splitter + this_id;
				splitter = "|";
			}
		}
	}
	else{
		if (eval("document.acclist.accckbox.checked") == true) {
			item_id = eval("document.acclist.accckbox.value");
 		}	
	}
	
	
	if(item_id == ""){
		alert("You have no items selected.");
	}
	else{
		width = 580;
		height = 450;
		src_item_id = item_id;
		
		//alert(src_item_id);
		
		eval(window.open ('/itinerary/add.html?src_webpage_id='+src_webpage_id+'&src_webpage_type='+src_webpage_type+'&src_item_id='+src_item_id+'&src_item_type='+src_item_type+'&item_title=&batch=yes', 'travelPlan', 'menubar=0,location=0,toolbar=0,resizable,personalbar=0,status=0,scrollbars=1,width='+width+',height='+height+''));
	}
	
}

function launchTravelPlanner(){
	width = 580;
	height = 450;

	eval(window.open ('/itinerary/itinerary.html', 'travelPlan', 'menubar=0,location=0,toolbar=0,resizable,personalbar=0,status=0,scrollbars=1,width='+width+',height='+height+''));

}


function viewWP(img){
	width = 580;
	height = 500;

	eval(window.open ('/freestuff/display_wallpaper.html?image='+img, 'Wallpaper', 'menubar=0,location=0,toolbar=0,resizable,personalbar=0,status=0,scrollbars=1,width='+width+',height='+height+''));

}

function viewLargeImage(img){
	width = 580;
	height = 500;

	eval(window.open ('/freestuff/display_imagelibrary.html?image='+img, 'ImageLibrary', 'menubar=0,location=0,toolbar=0,resizable,personalbar=0,status=0,scrollbars=1,width='+width+',height='+height+''));
}


function checkEnter(event,url){
 	NS4 = (document.layers) ? true : false;

 	var code = 0;
 	
 	if(NS4){
 		code = event.which;
 	}
 	else{
 		code = event.keyCode;
 	}
 	
 	if(code == 13){
		if(url != ""){
			document.sitesearches.action = url;
			document.sitesearches.submit();
 		}
  	}
}
