/*-------------------------------------------------------------------------
Fixes Up the Template (used in <body onload="fixTemplate();">)
-------------------------------------------------------------------------*/
var _isLyteboxInitialized = true;
function fixTemplate(){
	//_cttcSurveyPrompt.init();  //Hidden 5/5/2009 by JM at request of TC
	loadAjax(); // loads AJAX widgets
	if(isExplorer()) {debugExplorer();} // debugs template for Explorer 6
	//if((window.location.search).indexOf('testing=1') > -1) tripIdeasLoad(); // loads the Trip Ideas tab for testing
	//if (initLytebox != null) {initLytebox();}
	loadTitleBubble(); // creates custom bubbles to images with the TITLE attribute
	//removeWeatherScript();
	//unIndentTables(); // fixes eCM default layout to desired style
}

/*-------------------------------------------------------------------------
Home Page and Navigation functions
-------------------------------------------------------------------------*/
var _cttcSubNavigationImage = new Image;
_cttcSubNavigationImage.src = '/_images/subNavigation.png';

function checkSearch() {
	if (document.getElementById("search_header").value == "Search") {
		document.getElementById("search_header").value = "";
	}
}
function setSearch(obj,str1,str2,cls) {
	if (obj.value == str1) {
		obj.value = str2;
		obj.className = cls;
	}
}
function showCountry() {
	document.getElementById("countryBox").style.top = "0px";
}
function hideCountry() {
	document.getElementById("countryBox").style.top = "-600px";
}
function home_load() {
	if (swfobject.hasFlashPlayerVersion("9.0.0")) {
		var lang = "en";
		if (arguments.length == 1 && (typeof arguments[0]) != "object") {lang = arguments[0];}
		if (arguments.length == 2) {lang = arguments[1];}
		var swf_params = { allowScriptAccess: "always", wmode: "transparent", allowFullScreen:"true" };
		var swf_vars =  { "datafeed" : "/assets/xml/datafeed_08_"+lang+".xml"  };
		swfobject.embedSWF("/cttcHomepage_08.swf", "hero_main", "980", "480", "9.0.0", null, swf_vars, swf_params, null);
	} else {
		document.getElementById("hero_alt").style.display = "block";
		scrollHero(0);
	}
	fixTemplate();
}
function home_load_de() {
	home_load("de");
}

var hero_curr = 1;
var hero_tot = 6;
function scrollHero(d) {
	var hero_next = hero_curr + d;
	if (d == 1) {
		if (hero_next > hero_tot) {hero_next = 1;}
	} else {
		if (hero_next < 1) {hero_next = hero_tot;}
	}
	hero_curr = hero_next;

	document.getElementById("hero_"+hero_curr+"_plaque").src = "/_images/nav2009/alt/plaque_"+hero_curr+".jpg";
	document.getElementById("hero_"+hero_curr+"_explore").src = "/_images/nav2009/alt/explore_"+hero_curr+".jpg";
	if (document.getElementById("hero_"+hero_curr+"_img_1")) {
		document.getElementById("hero_"+hero_curr+"_img_1").src = "/_images/nav2009/alt/img_"+hero_curr+"_1.jpg";
	}
	if (document.getElementById("hero_"+hero_curr+"_img_2")) {
		document.getElementById("hero_"+hero_curr+"_img_2").src = "/_images/nav2009/alt/img_"+hero_curr+"_2.jpg";
	}
	document.getElementById("hero_card").innerHTML = document.getElementById("herocard_"+hero_curr).innerHTML;
	document.getElementById("hero_title_img").src = "/_images/nav2009/alt/title_"+hero_curr+".jpg";
	
}

var langs = {
	default_lang : "EN",
	text_choose : {
		EN : "Choose your country for personalised content:",
		DE : "Wählen Sie Ihr Land:",
		JP : "国を選択:",
		KR : "언어를 선택하세요:",
		CT : "選擇你的國家:",
		CS : "选择你的国家:",
		ES : "Elija su país para contenido personalizado:",
		FR : "Choisissez votre pays:",
		IT : "Scelga il vostro paese:",
		PO : "Escolha o país:"
	},
	text_brochure : {
		EN : "Or get online brochures for visiting California in these languages:",
		DE : "Oder wählen Sie California Online-Broschüren in diesen Sprachen:",
		JP : "オンライン資料の言語を選択:",
		KR : "혹은 아래의 언어로 된 캘리포니아 온라인 가이드를 다운 받으세요:",
		CT : "或獲得關於旅遊加尼福尼亞州的多語言網上手冊:",
		CS : "或获得关于旅游加尼福尼亚州的多语言网上手册:",
		ES : "O consiga los folletos electrónicos en la web sobre California en estos idiomas:",
		FR : "Ou obtenez les brochures en ligne pour de visiter la Californie dans ces langues:",
		IT : "O ottenga gli opuscoli in linea sulla visita della California in queste lingue:",
		PO : "Ou consiga folheteria eletrônica visitando a Califórnia nesses idiomas:"
	},
	swap : function(lang) {
		document.getElementById("text_choose_id").innerHTML = this.text_choose[lang];
		document.getElementById("text_brochure_id").innerHTML = this.text_brochure[lang];
	},
	out : function() {
		document.getElementById("text_choose_id").innerHTML = this.text_choose[this.default_lang];
		document.getElementById("text_brochure_id").innerHTML = this.text_brochure[this.default_lang];
	}
}

/*-------------------------------------------------------------------------
Survey
-------------------------------------------------------------------------*/

var _cttcSurveyPrompt = {
	ask : false,
	flush : false,
	init : function(){
		if(_cttcSurveyPrompt.flush) _cttcSurveyPrompt.removeCookie();
		if(_cttcSurveyPrompt.ask) _cttcSurveyPrompt.popUp();
	},
	popUp : function(){
		_cttcSurveyPrompt.setCookie(); 
		window.open('/_library/surveyPrompt.html','survey','width=400,height=200,left=100,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,top=100,screenX=100,screenY=100')
	},
	initObsolete : function(){
		if(_cttcSurveyPrompt.flush) _cttcSurveyPrompt.removeCookie();
		if(_cttcSurveyPrompt.ask) _cttcSurveyPrompt.display()
	},
	display : function(){
		_cttcSurveyPrompt.lyteboxOverlay.show();
		window.scrollTo(0,0);
		var e = document.createElement('div');
		e.id = 'cttcSurveyPromptWindow';
		e.className = 'surveyPrompt';
		e.innerHTML = '<h2>Your Opinion Matters!</h2><p>Tell us what you think about our new site!</p><img class="true" onmouseover="_cttcSurveyPrompt.mouseover(this)" onmouseout="_cttcSurveyPrompt.mouseout(this)" onclick="_cttcSurveyPrompt.click(this)" src="/_images/surveyImages/yes.png" alt="Yes" /><img class="false" src="/_images/surveyImages/no.png" onclick="_cttcSurveyPrompt.click(this)" onmouseover="_cttcSurveyPrompt.mouseover(this)" onmouseout="_cttcSurveyPrompt.mouseout(this)" alt="No" />';
		document.body.appendChild(e);
	},
	click : function(b){
		_cttcSurveyPrompt.setCookie();
		if( (b.alt).toLowerCase() == 'yes') _cttcSurveyPrompt.agree();
		else _cttcSurveyPrompt.disagree();
	},
	mouseover : function(b){ b.src = (b.src).replace('.png','_over.png'); },
	mouseout : function(b){ b.src = (b.src).replace('_over.png','.png'); },
	hide : function(){
		var o = grabElem('cttcSurveyPromptWindow');
		o.parentNode.removeChild(o);
		_cttcSurveyPrompt.lyteboxOverlay.hide();
	},
	agree : function(){
		window.open('http://tourvey.com/eSurvey/default.aspx?CID=CA&MID=9&SID=W1S','survey');
		_cttcSurveyPrompt.hide();
	},
	disagree : function(){
		grabElem('cttcSurveyPromptWindow').innerHTML = '<h2>No Problem!</h2><br><p>We respect your decision and you won\'t be asked again. Thank you.</p>';
		setTimeout(_cttcSurveyPrompt.hide, 4000);
	},
	removeCookie : function(){
		if ( (document.cookie.toUpperCase()).indexOf(_cttcSurveyPrompt.cookieName) > -1 ) document.cookie = _cttcSurveyPrompt.cookieName + "=;expires=Thu, 01-Jan-1970 00:00:01 GMT";
	},
	setCookie : function(){
		document.cookie = _cttcSurveyPrompt.cookieName + "=true"; 
	},
	cookieName : 'CTTCSURVEYPROMPTED',
	lyteboxOverlay : {
		show : function(){
			var pageSize	= myLytebox.getPageSize();
			var objOverlay	= myLytebox.doc.getElementById('lbOverlay');
			var objBody		= myLytebox.doc.getElementsByTagName("body").item(0);
			objOverlay.style.height = pageSize[1] + "px";
			objOverlay.style.display = '';
			myLytebox.appear('lbOverlay', myLytebox.maxOpacity);
			myLytebox.toggleSelects('');
			myLytebox.toggleFlash('');
		},
		hide : function(){
			myLytebox.fade('lbOverlay', 0);
			myLytebox.toggleSelects('visible');
			myLytebox.toggleFlash('visible');
		}
	}
}


/*-------------------------------------------------------------------------
Weather Widget
-------------------------------------------------------------------------*/

var _cttcWeatherLocations, _cttcWeatherLocationCurrent, _cttcWeatherLocationsLoaded, _cttcWeatherDiv, _cttcWeatherStop;
var _cttcWeatherExists = false;
function cttcWeatherWidget(zips, tmout){
	document.write('<div style="position:relative;width:180px;height:150px;" id="weatherWidgetDiv">' + _cttcWeatherWidgetProto.controls() + '</div>');
	if(!zips) _cttcWeatherLocations = _cttcWeatherWidgetProto.array();
	else _cttcWeatherLocations = zips;
	_cttcWeatherLocationCurrent = 0;
	if(!tmout) _cttcWeatherRoationTimeout = 3000;
	else _cttcWeatherRoationTimeout = tmout;
	_cttcWeatherStop = false;
	_cttcWeatherExists = true;
	ajaxPage('/_library/weatherWidget.cfm?parse=false', _cttcWeatherWidgetProto.initialWidget);
	/*var h = document.getElementsByTagName('head')[0];
	var s = document.createElement('script');
	s.id = 'weatherWidgetScript';
	var c = document.createElement('link');
	c.id = 'wx_wow_css';
	c.rel = 'stylesheet';
	c.type = 'text/css';
	c.title = 'wow';
	c.href = 'http://imawow.weather.com/web/common/header/stylesheet/wow.css';
	h.appendChild(s);
	h.appendChild(c);*/
}
function removeWeatherScript(){
	if(!_cttcWeatherExists){
		var s = grabElem('weatherWidgetScript');
		if(s) s.parentNode.removeChild(s);
		var c = grabElem('wx_wow_css');
		if(c) c.parentNode.removeChild(c);
	}
}
var _a;
var _cttcWeatherWidgetProto = {
	// instantiates initial widget
	initialWidget: function(funcs){
		_cttcWeatherDiv = grabElem('weatherWidgetDiv');
		_cttcWeatherLocationsLoaded = new Array();
		ajaxPage('/_library/weatherWidget.cfm?location=' + _cttcWeatherLocations[0], _cttcWeatherWidgetProto.saveContent);
		if(_cttcWeatherLocations.length > 1) setTimeout(_cttcWeatherWidgetProto.rotate, _cttcWeatherRoationTimeout);
	},
	//loops the widget
	rotate: function(){
		if(_cttcWeatherStop == false){
			_cttcWeatherLocationCurrent++;
			if(_cttcWeatherLocationCurrent > _cttcWeatherLocations.length - 1) _cttcWeatherLocationCurrent = 0;
			if(_cttcWeatherLocationsLoaded[_cttcWeatherLocationCurrent]) {
				_cttcWeatherDiv.innerHTML = _cttcWeatherLocationsLoaded[_cttcWeatherLocationCurrent];
			}
			else ajaxPage('/_library/weatherWidget.cfm?location=' + _cttcWeatherLocations[_cttcWeatherLocationCurrent], _cttcWeatherWidgetProto.saveContent);
			setTimeout(_cttcWeatherWidgetProto.rotate, _cttcWeatherRoationTimeout);
		}
	},
	// saves the AJAX-ed content into a variable for future use
	saveContent: function(content){
		_cttcWeatherLocationsLoaded[_cttcWeatherLocationsLoaded.length] = content.replace('class="sevWxText"','class="sevWxText" style="font-size:10px;display:none;"')  + _cttcWeatherWidgetProto.controls();
		_cttcWeatherDiv.innerHTML = _cttcWeatherLocationsLoaded[_cttcWeatherLocationsLoaded.length - 1];
	},
	// obtains the default location from the widget depending on section of website
	array: function(){
		var r = new Array();
		if(isPageOnRegion()){
			switch(identifyRegion()){
				case 'shasta_cascade': r[0] = '96002'; break;
				case 'north_coast': r[0] = '95401'; break;
				case 'central_valley': r[0] = '93301'; break;
				case 'gold_country': r[0] = '95814'; break;
				case 'high_sierra': r[0] = '96145'; break;
				case 'central_coast': r[0] = '93943'; break;
				case 'desert': r[0] = '92264'; break;
				case 'los_angeles': r[0] = '90006'; break;
				case 'orange_county': r[0] = '92802'; break;
				case 'inland_empire': r[0] = '92501'; break;
				case 'san_diego': r[0] = '92108'; break;
				case 'winter_recreation': {
					r[0] = '96150'; //South Lake Tahoe
					r[1] = '93546'; //Mammoth Lakes
				break;}
				default: r[0] = '94106';
			}
		}else{
			r[0] = '94106';
			r[1] = '90006';
			r[2] = '92108';
		}
		return r;
	},
	// handles focus actions on search field
	fieldFocus: function(tField){
		if(tField.value == _cttcWeatherWidgetProto.label()) tField.value = '';
		_cttcWeatherStop = true;
	},
	// handles blur actions on search field
	fieldBlur: function(tField){
		if(tField.value == ''){
			tField.value = _cttcWeatherWidgetProto.label();
			_cttcWeatherStop = false;
			_cttcWeatherWidgetProto.rotate();
			_cttcWeatherWidgetProto.clearSearch();
		}
	},
	// creates controls on top of everything
	controls: function(){
		if(!isExplorer()){
			var c = '<div style="position:absolute;width:10px;height:110px;left:0px;top:10px;background:url(/_images/weatherWidgetOverlay.png) left -10px no-repeat;"></div>' + 
							'<div style="position:absolute;width:180px;height:10px;left:0px;top:0px;background:url(/_images/weatherWidgetOverlay.png) left top no-repeat;"></div>' +
							'<div style="position:absolute;width:10px;height:110px;right:0px;top:10px;background:url(/_images/weatherWidgetOverlay.png) right -10px no-repeat;"></div>' + 
							'<div style="position:absolute;width:180px;height:35px;left:0px;bottom:0px;background:url(/_images/weatherWidgetOverlay.png) left bottom no-repeat;"></div>' + 
							'<div style="position:absolute;width:180px;height:20px;left:0px;bottom:0px;text-align:center;">' + 
								'<span style="position:relative;">' + 
									'<input id="weatherWidgetQuery" onkeyup="_cttcWeatherWidgetProto.keyUp(event);" onfocus="_cttcWeatherWidgetProto.fieldFocus(this);" onblur="_cttcWeatherWidgetProto.fieldBlur(this);" type="text" class="corporate width100" style="width:100px;" value="' + _cttcWeatherWidgetProto.label() + '" />&nbsp;' + 
									'<input onclick="_cttcWeatherWidgetProto.doSearch();" type="submit" class="corporate" value="go" />' + 
									'<img style="position:absolute;left:85px;top:3px;cursor:pointer;" src="/_images/goverlay/close.gif" onclick="_cttcWeatherWidgetProto.clearSearch();">' +
								'</span>' +
							'</div>';
			return c;
		}else{
			return '';
		}
	},
	// performs search function on click
	doSearch: function(){
		var f = grabElem('weatherWidgetQuery');
		if(f.value == '' || f.value == _cttcWeatherWidgetProto.label()){
			alert('Please enter a valid city or zip code');
		}else{
			var getFormValue = function(){
				var stD = ('al,ak,az,ar,ca,co,ct,de,fl,ga,hi,id,il,in,ia,ks,ky,la,me,md,ma,mi,mn,ms,mo,mt,ne,nv,nh,nj,nm,ny,nc,nd,oh,ok,or,pa,ri,sc,sd,tn,tx,ut,vt,va,wa,wv,wi,wy').split(',');
				var stN = ('alabama,alaska,arizona,arkansas,california,colorado,connecticut,delaware,florida,georgia,hawaii,idaho,illinois,indiana,iowa,kansas,kentucky,louisiana,maine,maryland,massachusetts,michigan,minnesota,mississippi,missouri,montana,nebraska,nevada,hampshire,jersey,mexico,new york,carolina,dakota,ohio,oklahoma,oregon,pennsylvania,rhode island,tennessee,texas,utah,vermont,virginia,washington,wisconsin,wyoming').split(',');
				var found = false;
				var v = (f.value).toLowerCase();
				v = (v.split(',')).join(' ');
				for(i = 0; i < stD.length; i++) if( v.indexOf(' ' + stD[i]) > -1 ) found = true;
				for(i = 0; i < stN.length; i++) if( v.indexOf(' ' + stN[i]) > -1 ) found = true;
				if(isNaN(parseFloat(v)) && !found) return f.value + ', CA';
				else return f.value;
			}
			var o = {
				href: "http://wowweb.weather.com/search/enhanced?what=Weather36HourBusinessTravelerCommand&config=SZ=180x150*WX=FHW*LNK=SSNL*UNT=F*BGI=sunset*MAP=null|null*DN=visitcalifornia.com*TIER=0*PID=1045267270*MD5=730cfe73b8c5c78a02858368f27434a1&par=WOWs0_1045267270&site=180x150&cm_ven=WOWs0&cm_cat=180x150&code=link&promo=searchbox&cm_ite=link&cm_pla=searchbox&where=" + getFormValue(),
				rev: "width:800px;height:500px;scrolling:yes;",
				title: "The Weather Channel - Search Results",
				rel: "lyteframe",
				getAttribute: function(a){
					return o[a];
				}
			}
			myLytebox.start(o, false, true);
			_cttcWeatherWidgetProto.clearSearch();
		}
  },
	// clears search and continues loop
	clearSearch: function(){
		grabElem('weatherWidgetQuery').value = _cttcWeatherWidgetProto.label();
		_cttcWeatherStop = false;
		_cttcWeatherWidgetProto.rotate();
	},
	// performs enter actions
	keyUp: function(e){
		if(e.keyCode == 13) _cttcWeatherWidgetProto.doSearch();
	},
	// sets the default value on the text field
	label: function(){return 'city or zip'}
}

/*-------------------------------------------------------------------------
Handles title bubbles and globe
-------------------------------------------------------------------------*/

var titleID = 0;
var isBubbleLoaded = false;
function loadTitleBubble(){
	var imgs = document.getElementsByTagName('img');
	for(i = 0; i < imgs.length; i++){
		if(imgs[i].title != '' && parseFloat(imgs[i].width) == 600 && parseFloat(imgs[i].height) == 360) {
			imgs[i].onmouseoverOrig = imgs[i].onmouseover;
			imgs[i].onmouseover = bubbleMouseOver;
			imgs[i].onmouseoutOrig = imgs[i].onmouseout;
			imgs[i].onmouseout = bubbleMouseOut;
			imgs[i].titleOnBubble = ((((imgs[i].title).split('\n')).join('')).split('\r')).join('');
			//imgs[i].style.cursor = 'help';
			imgs[i].title = '';
			if(imgs[i].id == '') imgs[i].id = 'dynamicTitle' + titleID;
			if(isPageOnRegion() && GBrowserIsCompatible()) createGlobe('dynamicTitle' + titleID);
		}
	}
}
function createBubble(t,x,y, w, h, ti){
	var mC = grabElem('titleBubble');
	if(mC) document.body.removeChild(mC);
	var fV = 'isHTML=true&title=' + t + '&width=' + w + '&drag=false';
	if( ((ti).toLowerCase()).indexOf('region') > -1 ) fV = fV + '&toggleMap=' + ti;
	var t = document.createElement('div');
	t.style.position = 'absolute';
	t.style.width = '10px';
	t.style.height = '10px';
	t.style.left = x + 'px';
	t.style.top = y + 'px';
	t.id = 'titleBubble';
	t.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + w + '" height="' + h + '"><param name="flashVars" value="' + fV + '" /><param name="scale" value="noscale" /><param name="movie" value="/_flashTools/bubble/bubble.swf" /><param name="salign" value="tl" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="menu" value="false" /><embed src="/_flashTools/bubble/bubble.swf" wmode="transparent" menu="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" scale="noscale" salign="tl" width="' + w + '" height="' + h + '" flashVars="' + fV + '"></embed></object>';
	document.body.appendChild(t);
}
function createGlobe(eId){
	var o = grabElem(eId).parentNode;
	var fV = '', w = 150, h = 30;
	var t = document.createElement('div');
	t.style.position = 'absolute';
	t.style.width = w + 'px';
	t.style.height = h + 'px';
	t.style.right = '5px';
	t.style.top = '5px';
	t.id = 'globeBubble';
	t.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + w + '" height="' + h + '"><param name="flashVars" value="' + fV + '" /><param name="scale" value="noscale" /><param name="movie" value="/_flashTools/globe/globe.swf" /><param name="salign" value="tl" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="menu" value="false" /><embed src="/_flashTools/globe/globe.swf" wmode="transparent" menu="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" scale="noscale" salign="tl" width="' + w + '" height="' + h + '" flashVars="' + fV + '"></embed></object>';
	o.style.position = 'relative';
	o.appendChild(t);
}
function bubbleMouseOver(){
	_imgActv = this;
	if(!isBubbleLoaded){
		var l = getElementLeft(this.id);
		var t = getElementTop(this.id);
		var w = getElementWidth(this.id);
		var h = getElementHeight(this.id);
		createBubble(this.titleOnBubble, l+10, t+h-40, w-20, 35, this.id);
		if(typeof(this.onmouseoverOrig) == 'function') this.onmouseoverOrig();
	}
}
function bubbleMouseOut(e){
	//var l = getElementLeft(this.id);
	//var t = getElementTop(this.id);
	//var w = getElementWidth(this.id);
	//var h = getElementHeight(this.id);
	//if(e.pageY <= t || e.page >= t + h || e.pageX <= l || e.pageX >= l + w){
		removeImageRollovers();
		if(typeof(this.onmouseoutOrig) == 'function') this.onmouseoutOrig();
		isBubbleLoaded = false;
	//}else{
	//	isBubbleLoaded = true;
	//}
}
function removeImageRollovers(){
	var mC1 = grabElem('titleBubble');
	if(mC1) document.body.removeChild(mC1);
}
var _cttcMapRegions = new Array('Bay_Area','Central_Coast','Central_Valley','Desert','Gold_Country','High_Sierra','Inland_Empire','Los_Angeles','North_Coast','Orange_County','San_Diego','Shasta_Cascade','Winter_Recreation');
function isPageOnRegion(){
	var l = (window.location.search).toLowerCase();
	var r = false;
	for(i = 0; i < _cttcMapRegions.length; i++){
		if( l.indexOf('section=' + (_cttcMapRegions[i]).toLowerCase()) > -1 ) r = true;
	}
	return r;
}
function identifyRegion(){
	var l = (window.location.search).toLowerCase();
	var r = '';
	for(i = 0; i < _cttcMapRegions.length; i++){
		if( l.indexOf('section=' + (_cttcMapRegions[i]).toLowerCase()) > -1 ){
			r = _cttcMapRegions[i];
			break;
		}
	}
	return r.toLowerCase();
}

/*-------------------------------------------------------------------------
Handles toggle between region map and hero shot
-------------------------------------------------------------------------*/

var _imgActv, _cttcGwhite, _cttcGpattern, _cttcGmap, _cttcGcontrols;
function toggleToRegionMap(){
	removeImageRollovers(); 
	var e = _imgActv;
	var l = getElementLeft(e.id);
	var t = getElementTop(e.id);
	var w = getElementWidth(e.id);
	var h = getElementHeight(e.id);
	// create pattern box
	var patternBox = document.createElement('div');
	patternBox.style.width = w + 'px';
	patternBox.style.height = h + 'px';
	patternBox.style.top = t + 'px';
	patternBox.style.left = l + 'px';
	patternBox.style.zIndex = 1;
	patternBox.style.position = 'absolute';
	patternBox.style.background = 'url(http://www.visitcalifornia.com/_images/goverlay/pattern.png)';
	patternBox.onmouseover = function(){}
	patternBox.onmouseout = function(){}
	patternBox.onclick = function(){}
	// create white box
	var whiteBox = document.createElement('div');
	whiteBox.id = 'gMapOverlay';
	whiteBox.innerHTML = '<img src="http://www.visitcalifornia.com/_images/holder.gif" />';
	whiteBox.maxHeight = h;
	whiteBox.style.position = 'absolute';
	whiteBox.style.width = w + 'px';
	whiteBox.style.height = ableToTransition() ? '1px' : h + 'px';
	whiteBox.style.top = t + 'px';
	whiteBox.style.left = l + 'px';
	whiteBox.style.background = 'url(http://www.visitcalifornia.com/_images/goverlay/whiteBox.png) center bottom no-repeat';
	whiteBox.style.zIndex = 2;
	// create map box
	var mapDiv = document.createElement('div');
	mapDiv.id = 'gMapDisplay';
	mapDiv.style.width = (w - 40) + 'px';
	mapDiv.style.height = (h - 40) + 'px';
	mapDiv.style.position = 'absolute';
	mapDiv.style.left = (l + 20) + 'px';
	mapDiv.style.top = (t + 20) + 'px';
	mapDiv.style.zIndex = 3;
	// create controls box
	var ie6Fix1 = isExplorer() ? 'display:none;' : '';
	var ie6Fix2 = isExplorer() ? '5' : '15';
	var controlsBox = document.createElement('div');
	controlsBox.id = 'gMapControls1';
	controlsBox.style.width = 1 + 'px';
	controlsBox.style.height = 1 + 'px';
	controlsBox.style.position = 'absolute';
	controlsBox.style.left = l + 'px';
	controlsBox.style.top = t + 'px';
	controlsBox.style.display = 'none';
	controlsBox.style.zIndex = 4;
	controlsBox.innerHTML = '' + 
	'<div style="font-family:Arial,Helvetica,Sans-Serif;position:relative;left:0px;top:0px;width:1px;height:1px;">' + 
		'<div style="' + ie6Fix1 + 'width:' + w + 'px;height:45px;position:absolute;top:0px;left:0px;background:url(http://www.visitcalifornia.com/_images/goverlay/controlsBox.png) left top no-repeat;"></div>' + 
		'<div style="' + ie6Fix1 + 'width:35px;height:' + (h - 80) + 'px;position:absolute;left:' + (w - 35) + 'px;top:45px;background:url(http://www.visitcalifornia.com/_images/goverlay/controlsBox.png) right center no-repeat;"></div>' + 
		'<div style="' + ie6Fix1 + 'width:' + w + 'px;height:35px;position:absolute;left:0px;top:' + (h - 35) + 'px;background:url(http://www.visitcalifornia.com/_images/goverlay/controlsBox.png) right bottom no-repeat;"></div>' +
		'<div style="' + ie6Fix1 + 'width:35px;height:' + (h - 80) + 'px;position:absolute;left:0px;top:45px;background:url(http://www.visitcalifornia.com/_images/goverlay/controlsBox.png) left center no-repeat;"></div>' + 
		'<a style="position:absolute;left:40px;top:' + ie6Fix2 + 'px;height:20px;width:70px;display:block;text-align:center;font-size:10px;color:#005c96;" href="javascript:_cttcGmapControls.zoomIn();">zoom <img style="border-width:0px;border:none;" align="absmiddle" src="http://www.visitcalifornia.com/_images/goverlay/zoomIn.gif" /></a>' +
		'<a style="position:absolute;left:110px;top:' + ie6Fix2 + 'px;height:20px;width:70px;display:block;text-align:center;font-size:10px;color:#005c96;" href="javascript:_cttcGmapControls.zoomOut();">zoom <img style="border-width:0px;border:none;" align="absmiddle" src="http://www.visitcalifornia.com/_images/goverlay/zoomOut.gif" /></a>' +
		'<a style="position:absolute;left:180px;top:' + ie6Fix2 + 'px;height:20px;width:50px;display:block;text-align:center;font-size:10px;color:#005c96;background:url(http://www.visitcalifornia.com/_images/goverlay/viewIndicator.gif) center 5px no-repeat;" href="javascript:_cttcGmapControls.normalView();" id="viewToggleMap">map</a>' +
		'<a style="position:absolute;left:230px;top:' + ie6Fix2 + 'px;height:20px;width:70px;display:block;text-align:center;font-size:10px;color:#005c96;" href="javascript:_cttcGmapControls.satelliteView();" id="viewToggleSatellite">satellite</a>' +
		'<a style="position:absolute;left:530px;top:' + ie6Fix2 + 'px;height:20px;width:60px;display:block;text-align:center;font-size:10px;color:#005c96;" href="javascript:toggleToHeroShot();">close <img style="border-width:0px;border:none;" align="absmiddle" src="http://www.visitcalifornia.com/_images/goverlay/close.gif" /></a>' + 
		'<a style="position:absolute;left:500px;top:325px;width:80px;height:15px;display:block;" target="_blank" href="http://www.google.com/intl/en_us/help/terms_maps.html"></a>' +
	'</div>';
	// organize child nodes
	document.body.appendChild(mapDiv);
	document.body.appendChild(whiteBox);
	document.body.appendChild(controlsBox);
	document.body.appendChild(patternBox);
	// assign objects to variables
	_cttcGpattern = patternBox;
	_cttcGwhite = whiteBox;
	_cttcGmap = mapDiv;
	_cttcGcontrols = controlsBox;
	// start expanding box
	if(ableToTransition()) setTimeout(expandOverlay, 200);
	else loadGoogleRegion();
}
function ableToTransition(){return ((navigator.appName).indexOf('Explorer') > -1) ? false : true;}
var curExp = 0;
function expandOverlay(){
	curExp++;
	_cttcGwhite.style.height = Math.min(10 * curExp, _cttcGwhite.maxHeight) + 'px';
	if(curExp < _cttcGwhite.maxHeight) setTimeout(expandOverlay, 10);
	else loadGoogleRegion();
}
function loadGoogleRegion(){
	_cttcGcontrols.style.display = 'block';
	_cttcGoogleMap();
}
function toggleToHeroShot(){
	document.body.removeChild(_cttcGpattern);
	document.body.removeChild(_cttcGwhite);
	document.body.removeChild(_cttcGmap);
	document.body.removeChild(_cttcGcontrols);
	var l = getElementLeft(_imgActv.id);
	var t = getElementTop(_imgActv.id);
	var w = getElementWidth(_imgActv.id);
	var h = getElementHeight(_imgActv.id);
	createBubble(_imgActv.titleOnBubble, l+10, t+h-40, w-20, 35, _imgActv.id);
	createGlobe(l+w-160, t+10);
}


/*-------------------------------------------------------------------------
Manages the google region maps
-------------------------------------------------------------------------*/

var _cttcGmapProto, _cttcGmapCoordinates, _cttcGmapPolygon, _cttcGmapIcon, _cttcGmapIconBase, _cttcGmapCurrentRegion;
var _cttcGmapControls = {
	// handles zoom in
	zoomIn: function(){
		_cttcGmapProto.zoomIn();
	},
	// handles zoom out
	zoomOut: function(){
		_cttcGmapProto.zoomOut();
	},
	// toggles to satellite view
	satelliteView: function(){
	
		var s = grabElem('viewToggleSatellite');
		var m = grabElem('viewToggleMap');
		s.style.background = 'url(http://www.visitcalifornia.com/_images/goverlay/viewIndicator.gif) center 5px no-repeat';
		m.style.background = '';
		
		_cttcGmapProto.removeOverlay(_cttcGmapPolygon);
		_cttcGmapProto.setMapType(G_HYBRID_MAP);
		_cttcGmapPolygon = new GGeoXml('http://www.visitcalifornia.com/widget/RegionKML.aspx/' + _cttcGmapCurrentRegion + '.kml?linecolor=CCFFFFFF&polycolor=33FFFFFF');
		_cttcGmapProto.addOverlay(_cttcGmapPolygon);
	
		_cttcGmapProto.removeOverlay(_cttcGmapIcon);
		var tempIcon = new GIcon(_cttcGmapIconBase);
			tempIcon.image = 'http://www.visitcalifornia.com/_images/goverlay/' + _cttcGmapCurrentRegion + '1.png';
		_cttcGmapIcon = new GMarker(_cttcGmapViewOptions.center, {icon:tempIcon});
		_cttcGmapProto.addOverlay(_cttcGmapIcon);
	
	},
	// toggles to normal view
	normalView: function(){
		
		var s = grabElem('viewToggleSatellite');
		var m = grabElem('viewToggleMap');
		m.style.background = 'url(http://www.visitcalifornia.com/_images/goverlay/viewIndicator.gif) center 5px no-repeat';
		s.style.background = '';
		
		_cttcGmapProto.removeOverlay(_cttcGmapPolygon);
		_cttcGmapProto.setMapType(G_NORMAL_MAP);
		_cttcGmapPolygon = new GGeoXml('http://www.visitcalifornia.com/widget/RegionKML.aspx/' + _cttcGmapCurrentRegion + '.kml?linecolor=CC965c00&polycolor=02965c00');
		_cttcGmapProto.addOverlay(_cttcGmapPolygon);
		
		_cttcGmapProto.removeOverlay(_cttcGmapIcon);
		var tempIcon = new GIcon(_cttcGmapIconBase);
			tempIcon.image = 'http://www.visitcalifornia.com/_images/goverlay/' + _cttcGmapCurrentRegion + '2.png';
		_cttcGmapIcon = new GMarker(_cttcGmapViewOptions.center, {icon:tempIcon});
		_cttcGmapProto.addOverlay(_cttcGmapIcon);
	
	},
	// pans the map to the center of region
	panMap: function(){
		var o = document.createElement('input');
		o.type = "text";
		o.style.position = 'absolute';
		o.style.top = '0px';
		o.style.left = '0px';
		o.style.width = '900px';
		o.value = 'o.center = new GLatLng' + _cttcGmapPolygon.getDefaultBounds().getCenter() + ';o.zoom = ' + _cttcGmapProto.getBoundsZoomLevel(_cttcGmapPolygon.getDefaultBounds()) + ';';
		document.body.appendChild(o);
		_cttcGmapProto.setCenter(_cttcGmapPolygon.getDefaultBounds().getCenter(), _cttcGmapProto.getBoundsZoomLevel(_cttcGmapPolygon.getDefaultBounds()));
	},
	// obtains the zoom level and center
	defaultOptions: function(reg){
		var o = new Object();
		switch(reg){
			case 'shasta_cascade': o.center = new GLatLng(40.673522, -121.815225);o.zoom = 7; break;
			case 'north_coast': o.center = new GLatLng(40.11400799999999, -123.339954);o.zoom = 6; break;
			case 'central_valley': o.center = new GLatLng(37.30798299999999, -120.66925799999999);o.zoom = 6; break;
			case 'gold_country': o.center = new GLatLng(38.427641, -120.45380800000001);o.zoom = 7; break;
			case 'high_sierra': o.center = new GLatLng(37.483675, -119.19773299999999);o.zoom = 6; break;
			case 'central_coast': o.center = new GLatLng(35.490717, -120.43011900000002);o.zoom = 7; break;
			case 'desert': o.center = new GLatLng(35.02199099999999, -116.502991);o.zoom = 6; break;
			case 'los_angeles': o.center = new GLatLng(34.25417600000001, -118.451858);o.zoom = 8; break;
			case 'orange_county': o.center = new GLatLng(33.629018, -117.85600599999998);o.zoom = 9;; break;
			case 'inland_empire': o.center = new GLatLng(34.053658000000006, -117.023458);o.zoom = 8; break;
			case 'san_diego': o.center = new GLatLng(32.986062, -116.83935800000002);o.zoom = 8; break;
			default: o.center = new GLatLng(37.566337, -122.264595);o.zoom = 8; //case 'bay_area':
		}
		return o;
	}
}
function _cttcGoogleMap(){
	
	var trace = false;
	if(trace){_w = document.createElement('input');_w.type='text';_w.style.width='900px';_w.style.position='absolute';_w.style.left='0px';_w.style.top='0px';}
	
	if(!_cttcGmapCurrentRegion || _cttcGmapCurrentRegion == '') _cttcGmapCurrentRegion = identifyRegion();
	_cttcGmapViewOptions = _cttcGmapControls.defaultOptions(_cttcGmapCurrentRegion);
	
	if(trace) _cttcGmapProto = new GMap2(_cttcGmap, {draggableCursor:'crosshair',draggingCursor:'crosshair'});
	else _cttcGmapProto = new GMap2(_cttcGmap);
	_cttcGmapProto.enableScrollWheelZoom();
	_cttcGmapProto.setCenter(_cttcGmapViewOptions.center, _cttcGmapViewOptions.zoom);
	_cttcGmapProto.setMapType(G_NORMAL_MAP);
	
	_cttcGmapPolygon = new GGeoXml('http://www.visitcalifornia.com/widget/RegionKML.aspx/' + _cttcGmapCurrentRegion + '.kml?linecolor=CC965c00&polycolor=02965c00');
	_cttcGmapProto.addOverlay(_cttcGmapPolygon);
	
	_cttcGmapIconBase = new GIcon();
		_cttcGmapIconBase.size = new GSize(200, 30);
		_cttcGmapIconBase.iconAnchor = new GPoint(100, 15);
	
	var tempIcon = new GIcon(_cttcGmapIconBase);
		tempIcon.image = 'http://www.visitcalifornia.com/_images/goverlay/' + _cttcGmapCurrentRegion + '2.png';
	_cttcGmapIcon = new GMarker(_cttcGmapViewOptions.center, {icon:tempIcon});
	_cttcGmapProto.addOverlay(_cttcGmapIcon);
	
	if(trace){
		_cttcGmapCoordinates = getRegionCoordinates();
		var newOverlay = new GPolygon(allCoordinates,"#000000",1,1,"#000000",0);
		function enterCoordinates(lat,lon){
			_w.value += (_w.value == '') ? lat + ',' + (lon * -1) : '|' + lat + ',' + (lon * -1);
			_cttcGmapProto.removeOverlay(newOverlay);
			newOverlay = new GPolygon(coordinates(_w.value),"#000000",1,1,"#000000",0);
			_cttcGmapProto.addOverlay(newOverlay);
		}
		_cttcGmapProto.addOverlay(newOverlay);
		GEvent.addListener(_cttcGmapProto, "click", function(o,l){
			if(!o) enterCoordinates(l.lat(), l.lng());
		});
		GEvent.addListener(_cttcGmapPolygon, "click", function(l){
			enterCoordinates(l.lat(), l.lng());
		});
	}
	
	//setTimeout(_cttcGmapControls.panMap, 5000);
}

function getRegionCoordinates(){
	var createPoints = false;
	if(!Coords){
		var Coords = new String();
		createPoints = true;
	}
	var cleanupCoords = function(v){
		if(v.indexOf('-') > -1){
			var sides = v.split('-');
			var left = parseFloat(sides[0]);
			var right = parseFloat(sides[1]);
			return left + (right / 60);
		}else{
			return parseFloat(v);
		}
	}
	var geoCoords = new Array();
	var geoCodes = Coords.split('|');
	for(i = 0; i < geoCodes.length; i++){
		
		cords = geoCodes[i].split(',');
		var point = new GLatLng( cleanupCoords(cords[0]), cleanupCoords(cords[1]) * -1 );
		
		if(createPoints && _w){
			var marker = new GMarker(point);
			marker.originalCoordinates = geoCodes[i];
			GEvent.addListener(marker,"click",function(){enterCoordinates(this.getLatLng().lat(), this.getLatLng().lng());});
			map.addOverlay(marker);
		}
		
		geoCoords.push(point);;
	}
	geoCoords.push(geoCoords[0]);
	return geoCoords;
}

/*-------------------------------------------------------------------------
Handles Trip Ideas as Shopping Cart
-------------------------------------------------------------------------*/

var tripDynamicId = 0;
var tripHolder, tripIcon;
function tripIdeasLoad(){
	tripHolder = createTripHolder();
	tripIdeasAdd();
	tripIcon = createTripIcon();
	parseTripIdeaItems();
	pullTripIdeas();
}
function pullTripIdeas(){
	for(i = 0; i < 35; i++){
		setTimeout(pushTripIdeasDown, 10 * (i + 1));
	}
}
function pushTripIdeasDown(){
	newY = parseFloat(tripHolder.style.top) + 1;
	tripHolder.style.top = newY + 'px';
}
var currentTripId;
function parseTripIdeaItems(elem){
	if(!elem) allElems = (document.all) ? document.all : document.getElementsByTagName('*');
	else allElems = elem.getElementsByTagName('*');
	for(i = 0; i < allElems.length; i++){
		if( (allElems[i].className).indexOf('tripIdea') > -1 ){
			if(allElems[i].id == ''){
				tripDynamicId++;
				allElems[i].id = 'dynamicId' + tripDynamicId;
			}
			tI = allElems[i].id;
			allElems[i].onmouseover = function(){tripIdeasDisplay(this);}
			allElems[i].onmouseout = function(){tripIdeasHide();}
		}
	}
}
function tripIdeasAdd(){
	page = (currentTripIdea != '') ? '?id=' + currentTripIdea : '';  
	ajaxPage('/_library/tripIdeas.cfm' + page, tripHolder.id);
	tripIdeaBgHighlight();
	setTimeout(tripIdeaBgReturn, 200);
	setTimeout(tripIdeaBgHighlight, 400);
	setTimeout(tripIdeaBgReturn, 600);
	setTimeout(tripIdeaBgHighlight, 800);
	setTimeout(tripIdeaBgReturn, 1000);
}
var isBrowserExplorer = isExplorer();
function tripIdeaBgHighlight(){
	if(isBrowserExplorer == true) tripHolder.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/_images/tripIdeasHighlight.png',sizingMethod='crop')";
	else tripHolder.style.background = 'url(/_images/tripIdeasHighlight.png) top right no-repeat';
}
function tripIdeaBgReturn(){
	if(isBrowserExplorer == true) tripHolder.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/_images/tripIdeas.png',sizingMethod='crop')";
	else tripHolder.style.background = 'url(/_images/tripIdeas.png) top right no-repeat';
}
var currentTripIdea = '';
function tripIdeasDisplay(obj){
	var newX = getElementLeft(obj.id) - 10;
	var newY = getElementTop(obj.id) - 10;
	tripIcon.style.left = newX + 'px';
	tripIcon.style.top = newY + 'px';
	currentTripIdea = stripTripIdeasId(obj.className);
	tripIcon.style.display = 'block';
}
function stripTripIdeasId(st){
	allClasses = st.split(' ');
	ret = '';
	for(i = 0; i < allClasses.length; i++){
		if( (allClasses[i]).indexOf('tripIdea') > -1 ) ret = (allClasses[i]).replace('tripIdea','');
	}
	return ret;
}
function tripIdeasHide(){
	tripIcon.style.diaplsy = 'none'
}
var tripIdeasTemporaryHolder;
function createTripHolder(){
	h = document.createElement('div');
	h.id = 'tripIdeasHolder';
	h.style.left = '50%';
	h.style.top = '-35px';
	h.style.margin = '0px 0px 0px 215px';
	h.style.width = '180px';
	h.style.height = '30px';
	h.style.padding = '5px 5px 0px 25px';
	h.style.color = '#005c96';
	h.style.zIndex = '5';
	h.style.textAlign = 'center';
	h.onmouseover = function(){tripIdeasTemporaryHolder = this.innerHTML;this.innerHTML = 'click here to manage';}
	h.onmouseout = function(){this.innerHTML = tripIdeasTemporaryHolder;}
	//h.onclick = getURL;
	h.style.position = (isBrowserExplorer == true) ? 'absolute' : 'fixed';
	if(isBrowserExplorer == true) h.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/_images/tripIdeas.png',sizingMethod='crop')";
	else h.style.background = 'url(/_images/tripIdeas.png) top right no-repeat';
	document.body.appendChild(h);
	return h;
}
function createTripIcon(){
	ic = document.createElement('div');
	ic.id = 'tripIdeasIcon';
	ic.innerHTML = '<object id="tripIdeasIcon" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="100" height="30"><param name="movie" value="/_images/addToTrip.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="menu" value="false" /><embed src="/_images/addToTrip.swf" wmode="transparent" menu="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="100" height="30"></embed></object>'
	ic.style.position = 'absolute';
	ic.style.left = '0px';
	ic.style.top = '0px';
	ic.style.display = 'none';
	ic.onmouseover = function(){this.style.display = 'block';}
	document.body.appendChild(ic);
	return ic;
}
function createTripIconOld(){
	ic = document.createElement('img');
	ic.id = 'tripIdeasIcon';
	ic.src = '/_images/tripIdea.gif';
	ic.style.position = 'absolute';
	ic.style.left = '0px';
	ic.style.top = '0px';
	ic.style.display = 'none';
	ic.onmouseover = function(){this.style.display = 'block';}
	ic.onmouseout = function(){if(tripIdeasOn == false)this.style.display = 'none';}
	document.body.appendChild(ic);
	return ic;
}

/*-------------------------------------------------------------------------

-------------------------------------------------------------------------*/

function toolsLinksLoad(){
	var toolsLinks = grabElem('toolsLinks');
	if(toolsLinks){
		us = toolsLinks.getElementsByTagName('UL');
		if(us.length > 0){
			lis = us[0].getElementsByTagName('LI');
			if(toolsLinks && us[0].clientHeight < lis.length * 30){
				a1 = document.createElement('a');a1.style.position = 'absolute';a1.style.top = '0px';a1.style.right = '-5px';a1.style.width = '5px';a1.style.height = '30px';a1.style.border = 'none';a1.style.display = 'block';a1.innerHTML = '<img src="/images/holder.gif" />';a1.style.background = 'url(/_images/toolsLinksArrow.gif) center top no-repeat';
				a2 = document.createElement('a');a2.style.position = 'absolute';a2.style.right = '-5px';a2.style.bottom = '0px';a2.style.width = '5px';a2.style.height = '30px';a2.style.border = 'none';a2.style.display = 'block';a2.style.background = 'url(/_images/toolsLinksArrow.gif) center bottom no-repeat';a2.innerHTML = '<img src="/images/holder.gif" />';
				a1.onmouseover = function(){this.style.backgroundImage = 'url(/_images/toolsLinksArrow1.gif)';isToolsLinksUpActive = true;toolsLinksScrollUp();}
				a2.onmouseover = function(){this.style.backgroundImage = 'url(/_images/toolsLinksArrow1.gif)';isToolsLinksDownActive = true;toolsLinksScrollDown();}
				a1.onmouseout = function(){isToolsLinksUpActive = false;this.style.backgroundImage = 'url(/_images/toolsLinksArrow.gif)';}
				a2.onmouseout = function(){isToolsLinksDownActive = false;this.style.backgroundImage = 'url(/_images/toolsLinksArrow.gif)';}
				toolsLinks.appendChild(a1);toolsLinks.appendChild(a2);
				for(i = 0; i < lis.length; i++) lis[i].style.marginLeft = '5px';
			}
		}
	}
}
function toolsLinksScrollUp(){
	var toolsLinks = grabElem('toolsLinks');
	us = toolsLinks.getElementsByTagName('UL');
	if(us.length > 0){
		lis = us[0].getElementsByTagName('LI');
		if(lis.length * 30 > us[0].offsetTop * -1 + us[0].clientHeight){
			newY = (isNaN(parseFloat(us[0].style.top))) ? -5 : parseFloat(us[0].style.top) - 3;
			us[0].style.top = newY + 'px';
			if(isToolsLinksUpActive) setTimeout(toolsLinksScrollUp, 25);
		}
	}
}
function toolsLinksScrollDown(){
	var toolsLinks = grabElem('toolsLinks');
	us = toolsLinks.getElementsByTagName('UL');
	if(us.length > 0){
		if(us[0].offsetTop < 0){
			newY = (isNaN(parseFloat(us[0].style.top))) ? -5 : parseFloat(us[0].style.top) + 3;
			us[0].style.top = newY + 'px';
			if(isToolsLinksDownActive) setTimeout(toolsLinksScrollDown, 25);
		}
	}
}

/*-------------------------------------------------------------------------

-------------------------------------------------------------------------*/

var homeBubble = '';
var homeBubbleOn = false;
function showHomeBubble(elem,st){
	if(homeBubble == ''){
		homeBubble = document.createElement('div');
		homeBubble.style.backgroundColor = '#005c96';
		homeBubble.style.color = '#fff';
		homeBubble.style.padding = '5px';
		homeBubble.style.border = '1px solid #fff';
		homeBubble.style.fontFamily = 'Arial';
		homeBubble.style.fontSize = '11px';
		homeBubble.style.position = 'absolute';
		homeBubble.style.zIndex = 2;
		homeBubble.onmouseover = function(){homeBubbleOn = true;}
		homeBubble.onmouseout = function(){hideHomeBubble();}
		document.body.appendChild(homeBubble);
	}
	coords = (elem.coords).split(',');
	newWidth = parseFloat(coords[2]) - parseFloat(coords[0]) - 12;
	newLeft = elem.offsetLeft + parseFloat(coords[0]);
	newTop = elem.offsetTop + parseFloat(coords[1]);
	homeBubble.style.width = newWidth + 'px';
	homeBubble.style.left = newLeft + 'px';
	homeBubble.style.top = newTop + 'px';
	homeBubble.innerHTML = st;
	homeBubble.style.display = 'block';
}
function hideHomeBubble(){
	if(homeBubbleOn == false){
		homeBubble.innerHTML = '';
		homeBubble.style.display = 'none';
	}
}

/*-------------------------------------------------------------------------
Explorer Fixes for Template and Widgets (used only for IE 6)
-------------------------------------------------------------------------*/

function debugExplorer(){
	
	var navs = new Array('index1','index2','index3','index4','index5');
	for(i = 0; i < navs.length; i++){
		navigationAttachRollovers(navs[i]);
	}
	
	var sW = grabElem('largesearchwidget');
	if(sW){
		var p = sW.parentNode;
		p.style.paddingTop = '8px'
		p.style.height = '100px';
		p.style.position = 'relative';
		sW.style.position = 'absolute';
	}
	
	var a = document.all;
	for(i = 0; i < a.length; i++){
		theStyle = 'columns';
		if(
			 ( (window.location.search).toLowerCase() ).indexOf('section=deals') > -1 &&
			 a[i].tagName == 'TABLE' && parseFloat(a[i].cellPadding) == 10
			){
			
			a[i].cellPadding = 0;
			
		}else if(a[i].className && a[i].className == 'deals_tan_box'){
		
			a[i].style.margin = '16px 0px 16px 0px';
		
		}else if(a[i].tagName == 'UL' && a[i].className == 'areas'){
			
			var lis = a[i].getElementsByTagName('li');
			lis[0].className = 'areasInclude';
			
		}else if(a[i].tagName == 'IMG' && ((a[i].src).toLowerCase()).indexOf('.png') > -1 ){
		
			var tempSrc = a[i].src;
			a[i].style.width = a[i].clientWidth;
			a[i].style.height = a[i].clientHeight;
			a[i].style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\'true\',sizingMethod=crop src="' + tempSrc + '")';
			a[i].src = '/_images/holder.gif';
		
		}else if(a[i].className && (a[i].className).indexOf(theStyle) > -1){
			
			for(s = 0; s < a[i].childNodes.length; s++){
				sE = a[i].childNodes[s];
				// loop through divs only
				if(
					 sE.tagName && (sE.tagName).indexOf('DIV') > -1 && 
					 sE.parentNode.className && 
					 (
						(sE.parentNode.className).indexOf(theStyle) > -1 &&
					 	(sE.parentNode.className).indexOf(theStyle + 'Child') == -1
					 )
					){
					// change styles to childfirst to target directly with css
					switch(sE.className){
						case "first": 
							sE.className = theStyle + 'ChildFirst';
						break;
						case "middle":
							sE.className = theStyle + 'ChildMiddle';
						break;
						case "last": 
							sE.className = theStyle + 'ChildLast';
						break;
					}
					// remove margin from initial grid
					if((sE.parentNode.parentNode.parentNode.parentNode.className).indexOf('columns') > -1) sE.parentNode.parentNode.parentNode.parentNode.style.marginTop = '0px';
					// 
					if((sE.parentNode.className).indexOf('height') > -1){
						parentClasses = (sE.parentNode.className).split(' ');
						grabHeight = 0;
						for(cI = 0; cI < parentClasses.length; cI++){
							cc = parentClasses[cI];
							if(cc.indexOf('height') > -1) grabHeight = parseInt(cc.replace('height',''));
						}
						if(grabHeight > 0) sE.style.height = grabHeight + 'px';
					}
					
				}
			}
		
		}
	}
	
	fixTravelTools.init();
	
	var tB = grabElem('cttcBody');
	tB.style.visibility = 'visible';
	
}

function debuggedIEBg(img){
	if(!isExplorer()) return 'background-image:url(' + img + ');';
	else return "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod=crop src='" + img + "');";
}


function navigationAttachRollovers(theId){
	e = grabElem(theId);
	if(e && e.parentNode.childNodes.length == 3){
		e.onmouseover = function(){this.parentNode.childNodes[2].style.display = 'block';}
		e.onmouseout = function(){this.parentNode.childNodes[2].style.display = 'none';}
		e.parentNode.childNodes[2].onmouseover = function(){this.style.display = 'block';}
		e.parentNode.childNodes[2].onmouseout = function(){this.style.display = 'none';}
	}
}

var fixTravelTools = {
	init : function(){
		ajaxPage('/widget/EventsSmall.aspx?TOP=10', function(r){
			var fArr = document.getElementsByTagName('iframe');
			var tT = new Array();
			for(var xa = 0; xa < fArr.length; xa++) if(fArr[xa].name == 'wid-events') tT[tT.length] = fArr[xa];
			if(tT.length > 0){
				var newLi, newLink;
				var tempDiv = document.createElement('div');
				tempDiv.innerHTML = r;
				var links = tempDiv.getElementsByTagName('a');
				var newDiv = document.createElement('div');
				newDiv.className = 'debuggedTravelTools';
				var newUl = document.createElement('ul');
				newUl.innerHTML = '<li class="header">Events</li>';
				newDiv.appendChild(newUl);
				for(var lx = 0; lx < links.length; lx++){
					if(links[lx].getAttribute('rel')){
						newLi = document.createElement('li');
						newUl.appendChild(newLi);
						newLink = document.createElement('a');
						newLi.appendChild(newLink);
						newLink.href = "javascript:fixTravelTools.linkTo('" + links[lx].href + "')";
						newLink.innerHTML = links[lx].innerHTML;
					}
				}
				var imgLinks = isExplorer() ? '<img src="/_images/eventsCornerTop.gif" class="c1" /><img src="/_images/eventsCornerBottom.gif" style="margin-bottom:5px;" class="c2" />' : '<img src="/_images/eventsCornerTop.png" class="c1" /><img src="/_images/eventsCornerBottom.png" class="c2" />';
				newDiv.innerHTML += '<a class="more" href="/modules/findyourself.aspx?activity=Events&tab=Events" target="_parent">More events...</a><div class="s1"><img src="/_images/holder.gif" /></div><div class="s2"><img src="/_images/holder.gif" /></div>' + imgLinks;
				tT[0].parentNode.parentNode.appendChild(newDiv);
				tT[0].parentNode.parentNode.removeChild(tT[0].parentNode);
			}
		});
	},
	linkTo : function(l){
		var o = {
			href: l,
			rev: "width:800px;height:500px;scrolling:yes;",
			title: "",
			rel: "lyteframe",
			getAttribute: function(a){
				return o[a];
			}
		}
		myLytebox.start(o, false, true);
	}
}

/*-------------------------------------------------------------------------
Removes Padding and Spacing From Default iMis eCM
-------------------------------------------------------------------------*/

function unIndentTables(){
	shellsFound = 0;
	bod = grabElem('cttcBody');
	if(bod){
		aB = bod.getElementsByTagName('DIV');
		for(i = 0; i < aB.length; i++){
			if((aB[i].className).indexOf('shell') > -1){
				shellsFound = shellsFound + 1;
				if(shellsFound == 2){
					for(s = 0; s < aB[i].childNodes.length; s++){
						if(aB[i].childNodes[s].tagName == 'BR'){
							aB[i].removeChild(aB[i].childNodes[s]);
						}
					}
				}else if(shellsFound > 2){
					break;
				}
			}
		}
		aT = bod.getElementsByTagName('TABLE');
		for(i = 0; i < aT.length; i++){
			if(aT[i].cellPadding == 2 || !aT[i].cellPadding || aT.cellPadding == ''){
				aT[i].cellPadding = 0;
				aT[i].cellSpacing = 0;
			}
			if(aT[i].nextSibling && aT[i].nextSibling.tagName == 'BR'){
				aT[i].parentNode.removeChild(aT[i].nextSibling);
			}
		}
	}
}

/*-------------------------------------------------------------------------
Toggles Tabs in Recommendations (used on tabs)
-------------------------------------------------------------------------*/

function toggleRecommendationTabs(pT){
	// grab the list of tabs
	theList = grabElem('recommendationTabs');
	// loop through the child elements and set them to inactive
	var li = 0;
	for(sE = 0; sE < theList.childNodes.length; sE++){
		e = theList.childNodes[sE];
		if(e.tagName == 'LI'){
			li = li + 1;
			cName = (e.className).replace('active','');
			cName = cName.replace(' ','');
			if(pT == li) cName = cName + ' active';
			e.className = cName;
		}
	}
}

/*-------------------------------------------------------------------------
Applies Custom Scrollbars - usage: <div class="scrollbars"><table></table></div>
-------------------------------------------------------------------------*/

var scrollingElement, scrollingAction, keepScrolling, scrollMouseOn;
function scrollElem(){
	eId = scrollingElement;
	action = scrollingAction;
	e = grabElem(eId);
	e.style.position = 'absolute';
	e.style.zIndex = 1;
	for(i = 0; i < e.parentNode.childNodes.length; i++){
		if(e.parentNode.childNodes[i].tagName == 'A'){
			e.parentNode.childNodes[i].style.zIndex = 2;
		}
	}
	if(keepScrolling == true){
			diff = action == 'up' ? -5 : 5;
	}else{
		diff = e.parentNode.clientHeight - 50;
		diff = action == 'up' ? -1 * diff : diff;
	}
	newY = e.offsetTop + diff;
	minScroll = 25;
	maxScroll = e.offsetHeight * -1 + e.parentNode.offsetHeight - 25;
	if(newY < maxScroll && action == 'up'){
		newY = maxScroll;
	}else if(newY > minScroll && action == 'down'){
		newY = minScroll;
	}
	if( (action == 'up' && e.offsetTop > maxScroll ) || (action == 'down' && e.offsetTop < minScroll)){
		e.style.top = newY + 'px';
		if(keepScrolling == true && scrollMouseOn == true) setTimeout(scrollElem, 50);
	}
}
function scrollUp(eId,kS){scrollMouseOn=true;scrollingElement=eId;scrollingAction='up';keepScrolling=kS;scrollElem();}
function scrollDown(eId,kS){scrollMouseOn=true;scrollingElement=eId;scrollingAction='down';keepScrolling=kS;scrollElem();}
function flickerImage(){}

/*-------------------------------------------------------------------------
Obtains HTML Contents Via AJAX - usage: <div class="ajax">http://www.google.com</div>
-------------------------------------------------------------------------*/

var currentAjax = 0;
var rootDomain="http://"+window.location['hostname'];
function loadAjax(){
	var bod = grabElem('cttcBody');
	if(bod){
		var aT = bod.getElementsByTagName('DIV');
		for(i = 0; i < aT.length; i++){
			if(aT[i].className == 'ajax' || (aT[i].className).indexOf('ajax') > -1){
				theURL = aT[i].innerHTML;
				if(theURL.indexOf('http') == -1)theURL = rootDomain + theURL;
				currentAjax = currentAjax + 1;
				if(aT[i].id == ''){
					newID = 'ajaxObject' + currentAjax;
					aT[i].id = newID;
				}else{
					newID = aT[i].id;
				}
				aT[i].innerHTML = '';
				aT[i].style.height = aT[i].parentNode.style.height;
				aT[i].style.width = aT[i].parentNode.style.width;
				aT[i].style.display='block';
				try{
					ajaxPage(theURL,newID);
				}catch(err){
					// do nothing with this widget
				}
			}
		}
	}
}
/*USAGE: ajaxPage('ajaxfiles/external3.htm', 'rightcolumn');*/
function ajaxPage(url, nxt){
	var page_request = false;
	if(window.XMLHttpRequest){
		/*if Mozilla, Safari etc*/
		page_request = new XMLHttpRequest();
	}else if(window.ActiveXObject){
		/*if IE*/
		try{
			page_request = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				page_request = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e){
			}
		}
	}else{
		return false;
	}
	page_request.onreadystatechange = function(){
		if(page_request.readyState == 4 && (page_request.status == 200 || window.location.href.indexOf("http") == -1)){
			if(typeof(nxt) == 'function') nxt(page_request.responseText);
			else writeAjaxContent(page_request, nxt);
		}
	}
	page_request.open('GET', url, true);
	page_request.send(null);
}
function writeAjaxContent(page_request, containerid, toWrite){
	ajaxedElem = grabElem(containerid);
	ajaxedElem.innerHTML = page_request.responseText;
	parseTripIdeaItems(ajaxedElem);
}

/*-------------------------------------------------------------------------
Loads Map throughout site
-------------------------------------------------------------------------*/

function cttcMap1(movieWidth, movieHeight, movieLocation, region){
	//if(movieLocation.indexOf('.swf') > -1)movieLocation = movieLocation.replace('.swf','');
	isHome = ((region.toLowerCase()).indexOf('home') > -1) ? true : false;
	movieLocation = isHome ? 'http://www.visitcalifornia.com/_flashTools/homepageMap/homepageMap' :  'http://www.visitcalifornia.com/_flashTools/worldMap/worldMap';
	if(isHome){
		movieWidth = 400;
		movieHeight = 200;
	}
	flashVars = 'mW=' + movieWidth + '&mH=' + movieHeight;
	if(region) flashVars = flashVars + '&region=' + region;
	AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width', movieWidth,'height', movieHeight,'src', movieLocation,'scale','noscale','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','movie', movieLocation,'menu','false','wmode','transparent','flashVars',flashVars); //end AC code
}
function cttcMap2(movieWidth, movieHeight, movieLocation, region){
	//if(movieLocation.indexOf('.swf') > -1)movieLocation = movieLocation.replace('.swf','');
	isHome = ((region.toLowerCase()).indexOf('home') > -1) ? true : false;
	movieLocation = isHome ? 'http://www.visitcalifornia.com/_flashTools/homepageMap/homepageMap' :  'http://www.visitcalifornia.com/_flashTools/worldMap/worldMap';
	if(isHome){
		movieWidth = 400;
		movieHeight = 200;
	}
	flashVars = 'mW=' + movieWidth + '&mH=' + movieHeight;
	if(region) flashVars = flashVars + '&region=' + region;
	string = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + movieWidth + '" height="' + movieHeight + '"><param name="movie" value="' + movieLocation + '" /><param name="quality" value="high" /><param name="scale" value="noscale" /><param name="menu" value="false" /><param name="flashVars" value="' + flashVars + '" /><param name="wmode" value="transparent" /><embed scale="noscale" wmode="transparent" src="' + movieLocation + '" menu="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + movieWidth + '" height="' + movieHeight + '"></embed></object>';
	document.write(string);
}

/*-------------------------------------------------------------------------
Loads Homepage Map
-------------------------------------------------------------------------*/

function cttcHomeMap1(){
	document.write('<a href="/explore"><img src="/_images/homepageMap.jpg" title="Explore California"></a>');
	//movieLocation = 'http://www.visitcalifornia.com/_flashTools/homepageMap/homepageMap';movieWidth = 400;movieHeight = 200;flashVars = 'mW=' + movieWidth + '&mH=' + movieHeight + '&region=Homepage';
	//AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width', movieWidth,'height', movieHeight,'src', movieLocation,'scale','noscale','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','movie', movieLocation,'menu','false','flashVars',flashVars); //end AC code
}
function cttcHomeMap2(){
	document.write('<a href="/explore"><img src="/_images/homepageMap.jpg" title="Explore California"></a>');
	//movieLocation = 'http://www.visitcalifornia.com/_flashTools/homepageMap/homepageMap';movieWidth = 400;movieHeight = 200;flashVars = 'mW=' + movieWidth + '&mH=' + movieHeight + '&region=Homepage';
	//string = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + movieWidth + '" height="' + movieHeight + '"><param name="movie" value="' + movieLocation + '" /><param name="quality" value="high" /><param name="scale" value="noscale" /><param name="menu" value="false" /><param name="flashVars" value="' + flashVars + '" /><embed scale="noscale" src="' + movieLocation + '" menu="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + movieWidth + '" height="' + movieHeight + '"></embed></object>';
	//document.write(string);
}

/*-------------------------------------------------------------------------
Homepage Grid Loader (uses adobe flash player fix)
-------------------------------------------------------------------------*/

var homepageGrid = '';
var homepageGridSectionNew = new Number();
var homepageGridSectionOld = new Number();
function createGridImage(im,ds){
	if(!im) im = 'http://www.visitcalifornia.com/_images/holder.gif';
	if(!ds) ds = '';
	ds = (ds.split("'")).join("\'");
	if(homepageGrid == '') homepageGrid = 'images=' + im + '?' + ds;
	else if(homepageGridSectionOld != homepageGridSectionNew) homepageGrid = homepageGrid + im + '?' + ds;
	else homepageGrid = homepageGrid + ',' + im + '?' + ds;
	homepageGridSectionOld = homepageGridSectionNew;
}
function createGridSection(){
	homepageGridSectionNew++;
	homepageGrid = homepageGrid + '|';
}
function cttcHomeGrid1(){
	movieWidth = 600;movieHeight=300;movieLocation='http://www.visitcalifornia.com/_flashTools/homepageGrid/homepageGrid';
	AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width', movieWidth,'height', movieHeight,'src', movieLocation,'scale','noscale','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','movie', movieLocation,'menu','false','wmode','transparent','flashVars',homepageGrid); //end AC code
}
function cttcHomeGrid2(){
	movieWidth = 600;movieHeight=300;movieLocation='http://www.visitcalifornia.com/_flashTools/homepageGrid/homepageGrid';
}
var homepageMontage = {
	movieWidth: 600,
	movieHeight: 300,
	movieLocation: 'http://www.visitcalifornia.com/_flashTools/homepageGrid/homepageGrid.swf',
	cleanup:function(v){
		var r = v;
		r = r.replace(/&/g,'{{a}}');
		r = r.replace("?",'{{q}}');
		return r;
	},
	flashVars: function(){
		homepageMontage.checkScript();
		var string = 'images=';
		for(t = 0; t < _homepageMontage.length; t++){
			string += (t > 0) ? '|' : '';
			for(i = 0; i < _homepageMontage[t].length; i++){
				string += (i > 0) ? ',' : '';
				string += homepageMontage.cleanup(_homepageMontage[t][i].image) + '?' + homepageMontage.cleanup(_homepageMontage[t][i].title) + '?' + homepageMontage.cleanup(_homepageMontage[t][i].href);
			}
		}
		return string;
	},
	checkScript: function(){return true},
	checkScriptObsolete: function(){ // function has been commented because it was breaking CTTC's loading on IE7
		if(!_homepageMontage){
			var s = document.createElement('script');
			s.language = 'javascript';
			s.type = 'text/javascript';
			s.src = '/montage/montage.js';
			document.getElementsByTagName('head')[0].appendChild(s);
		}
		return true;
	},
	create1: function(){
		AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width', homepageMontage.movieWidth,'height', homepageMontage.movieHeight,'src',(homepageMontage.movieLocation).replace('.swf',''),'scale','noscale','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','movie',(homepageMontage.movieLocation).replace('.swf',''),'menu','false','wmode','transparent','flashVars',homepageMontage.flashVars());
	},
	create2: function(){
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + homepageMontage.movieWidth + '" height="' + homepageMontage.movieHeight + '"><param name="movie" value="' + homepageMontage.movieLocation + '" /><param name="quality" value="high" /><param name="scale" value="noscale"><param name="menu" value="false" /><param name="flashVars" value="' + homepageMontage.flashVars() + '" /><param name="wmode" value="transparent" /><embed scale="noscale" flashVars="' + homepageMontage.flashVars() + '" wmode="transparent" src="' + homepageMontage.movieLocation + '" menu="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + homepageMontage.movieWidth + '" height="' + homepageMontage.movieHeight + '"></embed></object>');
	}
}

/*-------------------------------------------------------------------------
Map & Weather Widget
-------------------------------------------------------------------------*/

function _cttcMapsWeatherRollOver(l){
	l.style.background = 'url(../_images/ttWeatherMapOverBg.jpg) center no-repeat';
}
function _cttcMapsWeatherRollOut(l){
	l.style.background = ((l.className).indexOf('active') > -1) ? 'url(../_images/ttWeatherMapActiveBg.jpg) center no-repeat' : '';
}
function _cttcMapsWeatherClick(l){
	main = grabElem('cttcMapsWeather');
	lis = main.getElementsByTagName('LI');
	for(i = 0; i < lis.length; i++){
		lis[i].className = (lis[i].className).replace('active ', '');
		lis[i].style.background = '';
	}
	l.className = 'active ' + l.className;
	l.style.background = 'url(../_images/ttWeatherMapActiveBg.jpg) center no-repeat';
}


/*-------------------------------------------------------------------------
Handles CTTC API's for distribution amongst various VCA sites
-------------------------------------------------------------------------*/
var cttcApi = {
	domains : 'visitcalifornia.com,www.visitcalifornia.com,visitcalifornia.co.uk,www.visitcalifornia.co.uk,visitcalifornia.jp,www.visitcalifornia.jp,ccservices.com,www.ccservices.com,cttc.ccservices.com',
	/*================================================================*/
	settings : {
		/*--------------------------------------------------------------*/
		language : 'en',
		/*--------------------------------------------------------------*/
		getLang : function(){
			var rL = '';
			switch( (cttcApi.settings.language).toLowerCase() ){
				case 'english': case 'en':
					rL = '';
				break;
				case 'spanish': case 'sp':
					rL = 'sp';
				break;
				case 'korean': case 'ko':
					rL = 'ko';
				break;
				case 'german': case 'gr':
					rL = 'gr';
				break;
				case 'chinese': case 'ch':
					rL = 'ch';
				break;
				case 'japanese': case 'jp':
					rL = 'jp';
				break;
			}
			return rL;
		},
		/*--------------------------------------------------------------*/
		montage : {
			images : [
				[
					{ 
						title : 'Fine Dining at 21 Oceanfront in Newport Beach', 
						image : 'http://www.visitcalifornia.com/_flashTools2.0/homepageGrid/indulgenceFinals/21Oceanfront.jpg', 
						href : ''
					}, { 
						title : '', 
						image : 'http://www.visitcalifornia.com/_flashTools2.0/homepageGrid/indulgenceFinals/SpasWellness.jpg', 
						href : ''
					},{
						title : '',
						image : 'http://www.visitcalifornia.com/_flashTools2.0/homepageGrid/indulgenceFinals/RodeoDrive.jpg',
						href : ''
					},{
						title : 'Golfing near Napa',
						image : 'http://www.visitcalifornia.com/_flashTools2.0/homepageGrid/indulgenceFinals/GolfChoice2.jpg',
						href : ''
					}
				],[
					{ 
						title : 'Rollerblading in Venice Beach', 
						image : 'http://www.visitcalifornia.com/_flashTools2.0/homepageGrid/familyFinals/VeniceBeachRollerblading-LA.jpg', 
						href : 'http://www.google.com'
					}, { 
						title : '', 
						image : 'http://www.visitcalifornia.com/_flashTools2.0/homepageGrid/familyFinals/Kids_in_Snow.jpg', 
						href : ''
					},{
						title : '',
						image : 'http://www.visitcalifornia.com/_flashTools2.0/homepageGrid/familyFinals/DisneyDreams.jpg',
						href : ''
					},{
						title : 'Paddleboats in Stockton at the Asparagus Festival',
						image : 'http://www.visitcalifornia.com/_flashTools2.0/homepageGrid/familyFinals/Paddleboats_in_Stockton.jpg',
						href : ''
					}
				],[
					{ 
						title : 'El Capitan at Yosemite National Park', 
						image : 'http://www.visitcalifornia.com/_flashTools2.0/homepageGrid/outdoorFinals/yosemite-el-capitan.jpg', 
						href : ''
					}, { 
						title : '', 
						image : 'http://www.visitcalifornia.com/_flashTools2.0/homepageGrid/outdoorFinals/surfer.jpg', 
						href : ''
					},{
						title : '',
						image : 'http://www.visitcalifornia.com/_flashTools2.0/homepageGrid/outdoorFinals/joshua-tree.jpg',
						href : ''
					},{
						title : 'Mountain Biking in the Sierras',
						image : 'http://www.visitcalifornia.com/_flashTools2.0/homepageGrid/outdoorFinals/MountainBiking.jpg',
						href : ''
					}
				],[
					{ 
						title : 'Picnicking in the Wine Country', 
						image : 'http://www.visitcalifornia.com/_flashTools2.0/homepageGrid/romanceFinals/WineCountryCouple.jpg', 
						href : ''
					}, { 
						title : '', 
						image : 'http://www.visitcalifornia.com/_flashTools2.0/homepageGrid/romanceFinals/CoupleLaughing.jpg', 
						href : ''
					},{
						title : '',
						image : 'http://www.visitcalifornia.com/_flashTools2.0/homepageGrid/romanceFinals/WineGlasses.jpg',
						href : ''
					},{
						title : 'A Romance in San Francisco',
						image : 'http://www.visitcalifornia.com/_flashTools2.0/homepageGrid/romanceFinals/SF-Romance.jpg',
						href : ''
					}
				]
			]
		},
		/*--------------------------------------------------------------*/
		exploreCa : {
			regionDetails : 'http://www.visitcalifornia.com/_flashTools2.0/californiaMap/regionDetails.xml',
			getLangXML : function(){
				var rLang = cttcApi.settings.exploreCa.regionDetails;
				var corLang = cttcApi.settings.getLang();
				if( corLang != '') rLang = rLang.replace('.xml', '.' + corLang + '.xml');
				return rLang;
			},
			links : {
				bayArea : 'http://www.visitcalifornia.com/explore/bayArea',
				centralCoast : 'http://www.visitcalifornia.com/explore/centralCoast',
				centralValley : 'http://www.visitcalifornia.com/explore/centralValley',
				desert : 'http://www.visitcalifornia.com/explore/desert',
				goldCountry : 'http://www.visitcalifornia.com/explore/goldCountry',
				highSierra : 'http://www.visitcalifornia.com/explore/highSierra',
				inlandEmpire : 'http://www.visitcalifornia.com/explore/inlandEmpire',
				northCoast : 'http://www.visitcalifornia.com/explore/northCoast',
				orangeCounty : 'http://www.visitcalifornia.com/explore/orangeCounty',
				sanDiego : 'http://www.visitcalifornia.com/explore/sanDiego',
				losAngeles : 'http://www.visitcalifornia.com/explore/losAngeles',
				shastaCascade : 'http://www.visitcalifornia.com/explore/shastaCascade'
			},
			titles : {
				bayArea : 'Bay Area',
				centralCoast : 'Central Coast',
				centralValley : 'Central Valley',
				desert : 'Desert',
				goldCountry : 'Gold Country',
				highSierra : 'High Sierra',
				inlandEmpire : 'Inland Empire',
				northCoast : 'North Coast',
				orangeCounty : 'Orange County',
				sanDiego : 'San Diego',
				losAngeles : 'Los Angeles',
				shastaCascade : 'Shasta Cascade'
			},
			titlesjp : {
				bayArea : 'サンフランシスコ＆ベイエリア',
				centralCoast : 'セントラル・コースト',
				centralValley : 'セントラル・バレー',
				desert : '砂漠地帯',
				goldCountry : 'ゴールド・カントリー',
				highSierra : 'シエラ高原',
				inlandEmpire : 'インランド・エンパイア',
				northCoast : 'ノースコースト',
				orangeCounty : 'オレンジ・カウンティ',
				sanDiego : 'サンディエゴ',
				losAngeles : 'ロサンゼルス',
				shastaCascade : 'シャスタ・カスケード'
			},
			titlesko : {
				bayArea : '샌프란시스코 및 베이 지역 ',
				centralCoast : '센트럴 코스트',
				centralValley : '센트럴 밸리',
				desert : '사막지역 ',
				goldCountry : '골드 컨트리',
				highSierra : '시에라 고원 지역',
				inlandEmpire : '인랜드 엠파이어',
				northCoast : '노스 코스트',
				orangeCounty : '오렌지 카운티',
				sanDiego : '샌디에이고',
				losAngeles : '로스앤젤레스',
				shastaCascade : '샤스타 캐스케이드'
			}
		},
		/*--------------------------------------------------------------*/
		weather : {
			interval : 3,
			zipCodes : ['94106','90006','92108']
		},
		/*--------------------------------------------------------------*/
		region : {
			bayArea : { 
				kml : 'bay_area',
				name: 'Bay Area',
				title : 'The Golden Gate Bridge, San Francisco',
				img : 'http://www.visitcalifornia.com/AM/Images/explore/SF-Bay-Area-cropped.jpg'
			},
			centralCoast : {
				kml : 'central_coast',
				name: 'Central Coast',
				title : 'Views from Highway 1 Overlooking Bixby Bridge, Big Sur',
				img : 'http://www.visitcalifornia.com/AM/Images/explore/Central_Coast_final.jpg'
			},
			centralValley : {
				kml : 'central_valley',
				name: 'Central Valley',
				title : 'The beautiful Blossom Trail near Fresno, Central Valley',
				img : 'http://www.visitcalifornia.com/AM/Images/explore/Central-Valley-cropped.jpg'
			},
			desert : {
				kml : 'desert',
				name: 'Desert',
				title : 'Walking on Dunes in Death Valley National Park',
				img : 'http://www.visitcalifornia.com/AM/Images/explore/Desert_final.jpg'
			},
			goldCountry : {
				kml : 'gold_country',
				name: 'Gold Country',
				title : 'Summer evening in Sacramento, Gold Country',
				img : 'http://www.visitcalifornia.com/AM/Images/explore/Gold-Country-cropped.jpg'
			},
			highSierra : {
				kml : 'high_sierra',
				name: 'High Sierra',
				title : 'Peaceful Yosemite Valley, Yosemite National Park',
				img : 'http://www.visitcalifornia.com/AM/Images/explore/High-Sierra-cropped.jpg'
			},
			inlandEmpire : {
				kml : 'inland_empire',
				name: 'Inland Empire',
				title : 'Flying High at the Temacula Valley Balloon Festival, Inland Empire',	
				img : 'http://www.visitcalifornia.com/AM/Images/explore/Inland-Empire-cropped.jpg'
			},
			northCoast : {
				kml : 'north_coast',
				name: 'North Coast',
				title : 'Mendocino at dawn, North Coast',
				img : 'http://www.visitcalifornia.com/AM/Images/explore/North-Coast-cropped.jpg'
			},
			orangeCounty : {
				kml : 'orange_county',
				name: 'Orange County',
				title : 'Coming in from surfing Huntington Beach, Orange County',
				img : 'http://www.visitcalifornia.com/AM/Images/explore/Orange-County-cropped.jpg'
			},
			sanDiego : {
				kml : 'san_diego',
				name: 'San Diego',
				title : 'Coronado Beach at Dusk, San Diego County',
				img : 'http://www.visitcalifornia.com/AM/Images/explore/San-Diego-cropped.jpg'
			},
			losAngeles : {
				kml : 'los_angeles',
				name: 'Los Angeles',
				title : 'The Hollywood Sign, Los Angeles County',
				img : 'http://www.visitcalifornia.com/AM/Images/explore/Los-Angeles-cropped.jpg'
			},
			shastaCascade : {
				kml : 'shasta_cascade',
				name: 'Shasta Cascade',
				title : 'Magnificent Mt. Shasta, Shasta Cascade Region',
				img : 'http://www.visitcalifornia.com/AM/Images/explore/Shasta-Cascade-cropped.jpg'
			}
		}
	},
	/*================================================================*/
	getSettings : function(){
		var sc = document.getElementsByTagName('script');
		var stn = '';
		for(i = 0; i < sc.length; i++) if( ((sc[i].src).toLowerCase()).indexOf('cttcapisettings.js') > -1){
			stn = sc[i].src;
		}
		if(stn.indexOf('http') == -1){
			var ul = window.location.href;
			if(stn.substr(0,1) == '/'){
				stn = 'http://' + window.location.host + stn;
			}else if((ul.substr(ul.length-1, ul.length) != '/')){
				var ulArray = ul.split('/');
				ulArray.splice(ulArray.length - 1, 1);
				stn = ulArray.join('/') + '/' + stn;
			}else{
				stn = ul + stn;
			}
		}
		return stn;
	},
	/*================================================================*/
	getRedirector : function(){
		if( ((window.location.href).toLowerCase()).indexOf('incapi') == 0 ) return '';
		else{
			var urlVars = ((window.location.search).replace('?','')).split('&');
			var redTor = '';
			for(i = 0; i < urlVars.length; i++) if(urlVars[i].split('=')[0] == 'settings') redTor = decodeURIComponent(urlVars[i].split('=')[1]);
			var redir = redTor.split('/');
			redir.pop();
			var redirURL = redir.join('/');
			return redirURL + ( redirURL != '' ? '/cttcApiRedirector.html' : '' );
		}
	},
	/*================================================================*/
	snow : {
		mw : 600,
		mh : 360,
		ml : 'http://www.visitcalifornia.com/_flashTools/snow/winter-rec-feature2.swf',
		init1 : function(){ AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width', cttcApi.snow.mw,'height', cttcApi.snow.mh,'src',(cttcApi.snow.ml).replace('.swf',''),'scale','noscale','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','movie',(cttcApi.snow.ml).replace('.swf',''),'menu','false','wmode','transparent','flashVars',''); },
		init2 : function(){ document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + cttcApi.snow.mw + '" height="' + cttcApi.snow.mh + '"><param name="movie" value="' + cttcApi.snow.ml + '" /><param name="quality" value="high" /><param name="scale" value="noscale"><param name="menu" value="false" /><param name="flashVars" value="" /><param name="wmode" value="transparent" /><embed scale="noscale" flashVars="" wmode="transparent" src="' + cttcApi.snow.ml + '" menu="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + cttcApi.snow.mw + '" height="' + cttcApi.snow.mh + '"></embed></object>'); },
		init : function(){ document.write('<iframe src="http://www.visitcalifornia.com/_library/cttcApi.cfm?action=snow&settings=" width="' + cttcApi.snow.mw + '" height="' + cttcApi.snow.mh + '" frameborder="0" scrolling="no"></iframe>'); }
	},
	/*================================================================*/
	montage : {
		mw : '600',
		mh : '300',
		ml : 'http://www.visitcalifornia.com/_flashTools2.0/homepageGrid/homepageGrid',
		fv: function(){
			var cleanup = function(v){ return (v.replace(/&/g,'{{a}}')).replace("?",'{{q}}'); };
			var imgs = cttcApi.settings.montage.images;
			var fvStr = 'redirector=' + cttcApi.getRedirector() + '&lang=' + cttcApi.settings.getLang() + '&domains=' + cttcApi.domains + '&images=';
			for(t = 0; t < imgs.length; t++){
				fvStr += (t > 0 ? '|' : '');
				for(i = 0; i < imgs[t].length; i++) fvStr += ((i > 0) ? ',' : '') + (imgs[t][i].image ? cleanup(imgs[t][i].image) : '') + '?' + (imgs[t][i].title ? cleanup(imgs[t][i].title) : '') + '?' + (imgs[t][i].href ? encodeURIComponent(cleanup(imgs[t][i].href)) : '');
			}
			return fvStr;
		},
		init1 : function(){ AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0','width',cttcApi.montage.mw,'height', cttcApi.montage.mh,'src',cttcApi.montage.ml,'scale','noscale','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','movie',cttcApi.montage.ml,'menu','false','wmode','transparent','flashVars',cttcApi.montage.fv()); },
		init2 : function(){ document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + cttcApi.montage.mw + '" height="' + cttcApi.montage.mh + '"><param name="movie" value="' + cttcApi.montage.ml + '" /><param name="quality" value="high" /><param name="scale" value="noscale"><param name="menu" value="false" /><param name="flashVars" value="' + cttcApi.montage.fv() + '" /><param name="wmode" value="transparent" /><embed scale="noscale" flashVars="' + cttcApi.montage.fv() + '" wmode="transparent" src="' + cttcApi.montage.ml + '" menu="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + cttcApi.montage.mw + '" height="' + cttcApi.montage.mh + '"></embed></object>'); },
		init : function(){ document.write('<iframe src="http://www.visitcalifornia.com/_library/cttcApi.cfm?action=montage&settings=' + encodeURIComponent(cttcApi.getSettings()) + '" width="' + cttcApi.montage.mw + '" height="' + cttcApi.montage.mh + '&incApi=true" frameborder="0" scrolling="no"></iframe>'); }
	},
	/*================================================================*/
	exploreCa : {
		mw : 600,
		mh : 600,
		ml : 'http://www.visitcalifornia.com/_flashTools2.0/worldMap/worldMap.swf',
		fv: function(){ 
			var fvString = 'redirector=' + cttcApi.getRedirector() + '&lang=' + cttcApi.settings.getLang() + '&regionDescriptions=' + cttcApi.settings.exploreCa.getLangXML() + '&mW=' + cttcApi.exploreCa.mw + '&mH=' + cttcApi.exploreCa.mw + '&regionLinks';
			var lang = cttcApi.settings.getLang();
			for(r in cttcApi.settings.exploreCa.links) fvString += '|' + r + '!' + cttcApi.settings.exploreCa.links[r] + '!' + cttcApi.settings.exploreCa['titles' + lang][r];
			fvString = fvString.replace('regionLinks|', 'regionLinks=');
			return fvString;
		},
		init1 : function(){ AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width', cttcApi.exploreCa.mw,'height', cttcApi.exploreCa.mh,'src',(cttcApi.exploreCa.ml).replace('.swf',''),'scale','noscale','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','movie',(cttcApi.exploreCa.ml).replace('.swf',''),'menu','false','wmode','transparent','flashVars',cttcApi.exploreCa.fv()); },
		init2 : function(){ document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + cttcApi.exploreCa.mw + '" height="' + cttcApi.exploreCa.mh + '"><param name="movie" value="' + cttcApi.exploreCa.ml + '" /><param name="quality" value="high" /><param name="scale" value="noscale"><param name="menu" value="false" /><param name="flashVars" value="' + cttcApi.exploreCa.fv() + '" /><param name="wmode" value="transparent" /><embed scale="noscale" flashVars="' + cttcApi.exploreCa.fv() + '" wmode="transparent" src="' + cttcApi.exploreCa.ml + '" menu="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + cttcApi.exploreCa.mw + '" height="' + cttcApi.exploreCa.mh + '"></embed></object>'); },
		init : function(){ 
			if( (window.location.host).toLowerCase() == 'visitcalifornia.com' || (window.location.host).toLowerCase() == 'www.visitcalifornia.com' ) cttcApi.exploreCa.init1();
			else document.write('<iframe src="http://www.visitcalifornia.com/_library/cttcApi.cfm?action=exploreCA&settings=' + encodeURIComponent(cttcApi.getSettings()) + '" width="' + cttcApi.exploreCa.mw + '" height="' + cttcApi.exploreCa.mh + '" frameborder="0" scrolling="no"></iframe>');
		}
	},
	/*================================================================*/
	weather : {
		init : function(){
			var sts = new Array();
			if(isExplorer()){
				sts[0] = 'position:absolute;width:180px;height:2px;top:0px;left:0px;background:url(http://www.visitcalifornia.com/_images/weatherWidgetOverlay.png) left top no-repeat;';
				sts[1] = 'position:absolute;width:2px;height:150px;top:0px;right:0px;background:url(http://www.visitcalifornia.com/_images/weatherWidgetOverlay.png) right top no-repeat;';
				sts[2] = 'position:absolute;width:180px;height:30px;bottom:0px;left:0px;background:url(http://www.visitcalifornia.com/_images/weatherWidgetOverlay.png) left bottom no-repeat;';
				sts[3] = 'position:absolute;width:2px;height:150px;top:0px;left:0px;background:url(http://www.visitcalifornia.com/_images/weatherWidgetOverlay.png) left top no-repeat;';
			}else{
				sts[0] = 'position:absolute;width:160px;height:10px;top:0px;left:10px;background:url(http://www.visitcalifornia.com/_images/weatherWidgetOverlay.png) -10px top no-repeat;';
				sts[1] = 'position:absolute;width:10px;height:150px;top:0px;right:0px;background:url(http://www.visitcalifornia.com/_images/weatherWidgetOverlay.png) right top no-repeat;';
				sts[2] = 'position:absolute;width:160px;height:30px;bottom:0px;left:10px;background:url(http://www.visitcalifornia.com/_images/weatherWidgetOverlay.png) -10px bottom no-repeat;';
				sts[3] = 'position:absolute;width:10px;height:150px;top:0px;left:0px;background:url(http://www.visitcalifornia.com/_images/weatherWidgetOverlay.png) left top no-repeat;';
			}
			var fr = '<div style="position:relative;width:180px;height:150px;">' +
					'<iframe src="http://www.visitcalifornia.com/_library/cttcApi.cfm?action=weather&settings=' + encodeURIComponent(cttcApi.getSettings()) + '" width="180" height="123" frameborder="0" scrolling="no"></iframe>' +
					'<div style="' + sts[0] + '"><img src="http://www.visitcalifornia.com/_images/holder.gif" /></div>' + 
					'<div style="' + sts[1] + '"><img src="http://www.visitcalifornia.com/_images/holder.gif" /></div>' + 
					'<div style="' + sts[2] + '"><img src="http://www.visitcalifornia.com/_images/holder.gif" /></div>' + 
					'<div style="' + sts[3] + '"><img src="http://www.visitcalifornia.com/_images/holder.gif" /></div>' +
					'<form onsubmit="cttcApi.weather.submitLoc(this);return false;">' +
						'<input type="text" name="loc" onfocus="cttcApi.weather.tFocus(this)" onblur="cttcApi.weather.tBlur(this)" value="' + cttcApi.weather.textInputInitial + '" style="width:130px;height:18px;color:#aaa;font-size:12px;padding:2px 15px 0px 5px;margin:0px;position:absolute;top:130px;left:10px;background:url(http://www.visitcalifornia.com/_images/inputs.gif) -300px -10px no-repeat;border:none;border-width:0px;" />' +
						'<input type="submit" value="go" style="width:25px;text-transform:uppercase;font-weight:bold;height:20px;position:absolute;right:10px;top:130px;padding:0px;margin:0px;background:url(http://www.visitcalifornia.com/_images/inputs.gif) -10px -100px no-repeat;border:none;border-width:0px;color:white;" />' +
					'</form>' +
				'</div>';
			document.write(fr);
		},
		submitLoc : function(tf){
			if(tf.loc.value == ''){
				alert('Please enter a valid city or zip code');
			}else{
				var getFormValue = function(){
					var stD = ('al,ak,az,ar,ca,co,ct,de,fl,ga,hi,id,il,in,ia,ks,ky,la,me,md,ma,mi,mn,ms,mo,mt,ne,nv,nh,nj,nm,ny,nc,nd,oh,ok,or,pa,ri,sc,sd,tn,tx,ut,vt,va,wa,wv,wi,wy').split(',');
					var stN = ('alabama,alaska,arizona,arkansas,california,colorado,connecticut,delaware,florida,georgia,hawaii,idaho,illinois,indiana,iowa,kansas,kentucky,louisiana,maine,maryland,massachusetts,michigan,minnesota,mississippi,missouri,montana,nebraska,nevada,hampshire,jersey,mexico,new york,carolina,dakota,ohio,oklahoma,oregon,pennsylvania,rhode island,tennessee,texas,utah,vermont,virginia,washington,wisconsin,wyoming').split(',');
					var found = false;
					var v = (tf.loc.value).toLowerCase();
					v = (v.split(',')).join(' ');
					for(i = 0; i < stD.length; i++) if( v.indexOf(' ' + stD[i]) > -1 ) found = true;
					for(i = 0; i < stN.length; i++) if( v.indexOf(' ' + stN[i]) > -1 ) found = true;
					if(isNaN(parseFloat(v)) && !found) return tf.loc.value + ', CA';
					else return tf.loc.value;
				}
				if(cttcApi.weather.openedWindow) cttcApi.weather.openedWindow.close();
				cttcApi.weather.openedWindow = window.open('http://wowweb.weather.com/search/enhanced?what=Weather36HourBusinessTravelerCommand&config=SZ=180x150*WX=FHW*LNK=SSNL*UNT=F*BGI=sunset*MAP=null|null*DN=visitcalifornia.com*TIER=0*PID=1045267270*MD5=730cfe73b8c5c78a02858368f27434a1&par=WOWs0_1045267270&site=180x150&cm_ven=WOWs0&cm_cat=180x150&code=link&promo=searchbox&cm_ite=link&cm_pla=searchbox&where=' + getFormValue(),'wownewwin');
				//tf.loc.value = '';
				//cttcApi.weather.tBlur(tf.loc);
			}
		},
		textInputInitial : 'City / Zip Code',
		tFocus : function(it){
			if(it.value == cttcApi.weather.textInputInitial) it.value = '';
			it.style.color = 'black';
		},
		tBlur : function(it){
			if(it.value == ''){
				it.value = cttcApi.weather.textInputInitial;
				it.style.color = '#aaa';
			}else{
				it.style.color = 'black';
			}
		},
		cW : -1,
		wA : new Array(),
		loadWeather : function(){
			if(cttcApi.weather.cW >= cttcApi.settings.weather.zipCodes.length - 1) cttcApi.weather.cW = -1;
			cttcApi.weather.cW++;
			if(cttcApi.weather.wA.length < cttcApi.settings.weather.zipCodes.length){
				cttcApi.weather.wA[cttcApi.weather.cW] = '';
				ajaxPage(
					'http://www.visitcalifornia.com/_library/weatherWidget.cfm?location=' + cttcApi.settings.weather.zipCodes[cttcApi.weather.cW], 
					function(r){
						cttcApi.weather.wA[cttcApi.weather.wA.length - 1] = r.replace('class="sevWxText"','class="sevWxText" style="font-size:10px;"');
						document.body.innerHTML = cttcApi.weather.wA[cttcApi.weather.wA.length - 1];
					}
				);
			}else if( (cttcApi.weather.wA[cttcApi.weather.cW]).indexOf('>') > -1){
				document.body.innerHTML = cttcApi.weather.wA[cttcApi.weather.cW];
			}
			if(cttcApi.settings.weather.zipCodes.length > 1) setTimeout(cttcApi.weather.loadWeather, cttcApi.settings.weather.interval * 1000);
		}
	},
	/*================================================================*/
	region : {
		init : function(sec){
			var s = ((((sec.split(' ')).join('')).split('_')).join('')).toLowerCase();
			var st;
			switch(s){
				case 'bayarea': 
					st = 'bayArea';
				break;case 'centralcoast':
					st = 'centralCoast';
				break;case 'centralvalley':
					st = 'centralValley';
				break;case 'desert':
					st = 'desert';
				break;case 'goldcountry':
					st = 'goldCountry';
				break;case 'highsierra':
					st = 'highSierra';
				break;case 'inlandempire':
					st = 'inlandEmpire';
				break;case 'northcoast':
					st = 'northCoast';
				break;case 'orangecounty':
					st = 'orangeCounty';
				break;case 'sandiego':
					st = 'sanDiego';
				break;case 'losangeles':
					st = 'losAngeles';
				break;case 'shastacascade':
					st = 'shastaCascade';
				break;default:
					st = 'bayArea';
			}
			cttcApi.region.preloadImages = new Array();
			cttcApi.region.preloadImages[0] =	new Image;
			cttcApi.region.preloadImages[1] =	new Image;
			cttcApi.region.preloadImages[0].src = 'http://www.visitcalifornia.com/_images/goverlay/pattern.png';
			cttcApi.region.preloadImages[1].src = 'http://www.visitcalifornia.com/_images/goverlay/whiteBox.png';
			var set = cttcApi.settings.region[st];
			_cttcGmapCurrentRegion = set.kml;
			cttcApi.region.preloadedRegionName1 = new Image;
			cttcApi.region.preloadedRegionName1.src = 'http://www.visitcalifornia.com/_images/goverlay/' + set.kml + '1.png';
			cttcApi.region.preloadedRegionName2 = new Image;
			cttcApi.region.preloadedRegionName2.src = 'http://www.visitcalifornia.com/_images/goverlay/' + set.kml + '2.png';
			var glb;
			if(isExplorer()){
				cttcApi.region.globeRollover = function(im){ im.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod=crop src='http://www.visitcalifornia.com/_images/globe2.png')"; }
				cttcApi.region.globeRollout = function(im){ im.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod=crop src='http://www.visitcalifornia.com/_images/globe1.png')"; }
				glb = '<img onclick="cttcApi.region.clicked()" onmouseover="cttcApi.region.globeRollover(this)" onmouseout="cttcApi.region.globeRollout(this)" src="http://www.visitcalifornia.com/_images/holder.gif" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop src=\'http://www.visitcalifornia.com/_images/globe1.png\');cursor:pointer;position:absolute;right:5px;top:5px;width:150px;height:30px;" />';
			}else if(isExplorer7()) glb = '<img onclick="cttcApi.region.clicked()" onmouseover="this.src=\'http://www.visitcalifornia.com/_images/globe2.png\'" onmouseout="this.src=\'http://www.visitcalifornia.com/_images/globe1.png\'" src="http://www.visitcalifornia.com/_images/globe1.png" style="cursor:pointer;position:absolute;right:5px;top:5px;" />';
			else glb = '<div id="globeBubble" style="cursor:pointer;position:absolute;width:150px;height:30px;right:5px;top:5px;"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" height="30" width="150"><param name="flashVars" value=""><param name="scale" value="noscale"><param name="movie" value="http://www.visitcalifornia.com/_flashTools2.0/globe/globe.swf"><param name="salign" value="tl"><param name="quality" value="high"><param name="wmode" value="transparent"><param name="menu" value="false"><embed src="http://www.visitcalifornia.com/_flashTools2.0/globe/globe.swf" wmode="transparent" menu="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" scale="noscale" salign="tl" flashvars="" height="30" width="150"></object></div><div onclick="cttcApi.region.clicked()" style="cursor:pointer;position:absolute;width:150px;height:30px;right:5px;top:5px;"></div>';
			var totStr = 
			document.write('<div style="position:relative;width:600px;height:360px;"><img' + (glb != '' ? ' onclick="cttcApi.region.clicked()"' : '') + ' id="cttcDynamicHeroShot" onmouseover="cttcApi.region.rollover(this)" onmouseout="cttcApi.region.rollout(this)" cttctitle="' + set.title + '" src="' + set.img + '" />' + glb + '</div>');
		},
		rollover : function(im){
			cttcApi.region.rollout();
			var w = getElementWidth(im.id) - 20;
			var h = 35;
			var x = getElementLeft(im.id) + 10;
			var y = getElementTop(im.id) + getElementHeight(im.id) - 40;
			var fV = 'isHTML=true&title=' + im.getAttribute('cttctitle') + '&width=' + w + '&drag=false';
			var t = document.createElement('div');
			t.style.position = 'absolute';
			t.style.width = '10px';
			t.style.height = '10px';
			t.style.left = x + 'px';
			t.style.top = y + 'px';
			t.id = 'cttcTitledBubble';
			t.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + w + '" height="' + h + '"><param name="flashVars" value="' + fV + '" /><param name="scale" value="noscale" /><param name="movie" value="http://www.visitcalifornia.com/_flashTools2.0/bubble/bubble.swf" /><param name="salign" value="tl" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="menu" value="false" /><embed src="http://www.visitcalifornia.com/_flashTools2.0/bubble/bubble.swf" wmode="transparent" menu="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" scale="noscale" salign="tl" width="' + w + '" height="' + h + '" flashVars="' + fV + '"></embed></object>';
			document.body.appendChild(t);
		},
		rollout : function(){
			var mC1 = grabElem('cttcTitledBubble');
			if(mC1) mC1.parentNode.removeChild(mC1);
		},
		clicked : function(){
			_imgActv = grabElem('cttcDynamicHeroShot');
			toggleToRegionMap();
		}
	},
	/*================================================================*/
	getURL : function(loc){ top.location.href = location.href + ((location.href).indexOf('?') == -1 ? '?' : '&') + 'redirection=' + loc; },
	/*================================================================*/
	/*getRedirectedLocation : function(){
		var loc = (window.location.search).replace('?location=','');
		parent.window.location = loc;
	},*/
	/*================================================================*/
	getRedirectedLocation : function(){
		var loc = (window.location.search).replace('?location=','');
		loc = ( loc.split('{{pnd}}') ).join('#');
		var ua = (window.navigator.userAgent).toLowerCase();
		if( ua.indexOf('msie') > -1 || true){
			var cvar1 = 'cttcapiredir=' + loc;
			var cvar2 = 'cttcapiredir=noredir';
			if( (document.cookie).indexOf( cvar1 ) == -1 ){
				document.cookie = cvar1 + '; expires=Thu, 2 Aug 3000 00:00:00 UTC; path=/';
				parent.window.location = loc;
			}else{
				document.cookie = cvar2 + '; expires=Thu, 2 Aug 3000 00:00:00 UTC; path=/';
				parent.window.history.back();
			}
		}else{
			parent.window.location = loc;
		}
	}
}

/*-------------------------------------------------------------------------
Adobe Flash Player Fix - Copyright 2006 Adobe Systems, Inc. All rights reserved.
-------------------------------------------------------------------------*/
function AC_AddExtension(src,ext)/*v1.0*/{if(src.indexOf('?')!=-1)return src.replace(/\?/,ext+'?');else return src+ext;}function AC_Generateobj(objAttrs,params,embedAttrs){var str='<object ';for(var i in objAttrs)str+=i+'="'+objAttrs[i]+'" ';str+='>';for(var i in params)str+='<param name="'+i+'" value="'+params[i]+'" /> ';str += '<embed ';for(var i in embedAttrs)str+=i+'="'+embedAttrs[i] + '" ';str+=' ></embed></object>';document.write(str);}function AC_FL_RunContent(){var ret=AC_GetArgs(arguments,".swf","movie","clsid:d27cdb6e-ae6d-11cf-96b8-444553540000","application/x-shockwave-flash");AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);}function AC_SW_RunContent(){var ret=AC_GetArgs(arguments,".dcr","src","clsid:166B1BCA-3F9C-11CF-8075-444553540000",null);AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);}function AC_GetArgs(args, ext, srcParamName, classid, mimeType){var ret=new Object();ret.embedAttrs=new Object();ret.params=new Object();ret.objAttrs=new Object();for(var i=0;i<args.length;i=i+2){var currArg=args[i].toLowerCase();switch(currArg){case"classid":break;case"pluginspage":ret.embedAttrs[args[i]]=args[i+1];break;case"src":case"movie":args[i+1]=AC_AddExtension(args[i+1],ext);ret.embedAttrs["src"]=args[i+1];ret.params[srcParamName]=args[i+1];break;case"onafterupdate":case"onbeforeupdate":case"onblur":case"oncellchange":case"onclick":case"ondblClick":case"ondrag":case"ondragend":case"ondragenter":case"ondragleave":case"ondragover":case"ondrop":case"onfinish":case"onfocus":case"onhelp":case"onmousedown":case"onmouseup":case"onmouseover":case"onmousemove":case"onmouseout":case"onkeypress":case"onkeydown":case"onkeyup":case"onload":case"onlosecapture":case"onpropertychange":case"onreadystatechange":case"onrowsdelete":case"onrowenter":case"onrowexit":case"onrowsinserted":case"onstart":case"onscroll":case"onbeforeeditfocus":case"onactivate":case"onbeforedeactivate":case"ondeactivate":case"type":case"codebase":ret.objAttrs[args[i]]=args[i+1];break;case"width":case"height":case"align":case"vspace":case"hspace":case"class":case"title":case"accesskey":case"name":case"id":case"tabindex":ret.embedAttrs[args[i]]=ret.objAttrs[args[i]]=args[i+1];break;default:ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];}}ret.objAttrs["classid"]=classid;if(mimeType)ret.embedAttrs["type"]=mimeType;return ret;}function AC_AX_RunContent()/*v1.1*/{var ret=AC_AX_GetArgs(arguments);AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);}function AC_AX_GetArgs(args){var ret=new Object();ret.embedAttrs=new Object();ret.params=new Object();ret.objAttrs=new Object();for(var i=0;i<args.length;i=i+2){var currArg=args[i].toLowerCase();switch(currArg){case"pluginspage":case"type":case"src":ret.embedAttrs[args[i]]=args[i+1];break;case"data":case"codebase":case"classid":case"id":case"onafterupdate":case"onbeforeupdate":case"onblur":case"oncellchange":case"onclick":case"ondblClizk":case"ondrag":case"ondragend":case"ondragenter":case"ondragleave":case"ondragover":case"ondrop":case"onfinish":case"onfocus":case"onhelp":case"onmousedown":case"onmouseup":case"onmouseover":case"onmousemove":case"onmouseout":case"onkeypress":case"onkeydown":case"onkeyup":case"onload":case"onlosecapture":case"onpropertychange":case"onreadystatechange":case"onrowsdelete":case"onrowenter":case"onrowexit":case"onrowsinserted":case"onstart":case"onscroll":case"onbeforeeditfocus":case"onactivate":case"onbeforedeactivate":case"ondeactivate":ret.objAttrs[args[i]]=args[i+1];break;case"width":case"height":case"align":case"vspace":case"hspace":case"class":case"title":case"accesskey":case"name":case"tabindex":ret.embedAttrs[args[i]]=ret.objAttrs[args[i]]=args[i+1];break;default:ret.embedAttrs[args[i]]=ret.params[args[i]]=args[i+1];}}return ret;}


/*-------------------------------------------------------------------------
Detects for Explorer 6 (simply returns true/false on IE6) - usage: if(isExplorer()){}
-------------------------------------------------------------------------*/
function isExplorer(){return ( (navigator.appName).indexOf('Explorer') > -1 && (navigator.appVersion).indexOf('MSIE 6') > -1 ) ? true : false;}
/*-------------------------------------------------------------------------
Detects for Explorer 7 (simply returns true/false on IE6) - usage: if(isExplorer()){}
-------------------------------------------------------------------------*/
function isExplorer7(){return ( (navigator.appName).indexOf('Explorer') > -1 && (navigator.appVersion).indexOf('MSIE 7') > -1 ) ? true : false;}

/*-------------------------------------------------------------------------
Grabs an Element (supports different browsers) - usage: e=grabElem('theId');
-------------------------------------------------------------------------*/
function grabElem(theObj,theDoc){var p,i,foundObj;if(!theDoc)theDoc=document;if((p=theObj.indexOf("?"))>0&&parent.frames.length){theDoc=parent.frames[theObj.substring(p+1)].document;theObj=theObj.substring(0,p);}if(!(foundObj=theDoc[theObj])&&theDoc.all)foundObj=theDoc.all[theObj];for(i=0;!foundObj&&i<theDoc.forms.length; i++)foundObj=theDoc.forms[i][theObj];for(i=0;!foundObj&&theDoc.layers&&i<theDoc.layers.length;i++)foundObj=findObj(theObj,theDoc.layers[i].document);if(!foundObj&&document.getElementById) foundObj = document.getElementById(theObj);return foundObj;}

/*-------------------------------------------------------------------------
Obtains Coordinates and Sizes of Objects - usage: e.style.top=getElementTop('theId')+'px';
-------------------------------------------------------------------------*/
function getElementTop(Elem){if(document.getElementById){var elem=document.getElementById(Elem);}else if(document.all){var elem=document.all[Elem];}yPos=elem.offsetTop;tempEl=elem.offsetParent;while(tempEl!=null){yPos+=tempEl.offsetTop;tempEl=tempEl.offsetParent;}return yPos;}
function getElementHeight(Elem){var elem;if(document.getElementById){var elem=document.getElementById(Elem);}else if (document.all){var elem=document.all[Elem];}if((navigator.userAgent.indexOf("Opera 5")!=-1)||(navigator.userAgent.indexOf("Opera/5")!=-1)){xPos = elem.style.pixelHeight;}else{xPos=elem.offsetHeight;}return xPos;}
function getElementLeft(Elem){var elem;if(document.getElementById){var elem=document.getElementById(Elem);}else if(document.all){var elem=document.all[Elem];}xPos=elem.offsetLeft;tempEl=elem.offsetParent;while(tempEl!=null){xPos+=tempEl.offsetLeft;tempEl=tempEl.offsetParent;}return xPos;}
function getElementWidth(Elem){var elem;if(document.getElementById){var elem=document.getElementById(Elem);}else if(document.all){var elem=document.all[Elem];}if((navigator.userAgent.indexOf("Opera 5")!=-1)||(navigator.userAgent.indexOf("Opera/5")!=-1)){xPos=elem.style.pixelWidth;}else{xPos=elem.offsetWidth;}return xPos;}

/*-------------------------------------------------------------------------
Loads an ad - usage: loadAd(document, null,"wid-ad1");
-------------------------------------------------------------------------*/
var adNum = 1;
function loadAd(doc, nil, elementId){
	doc.getElementById(elementId).src = '/widget/Ad.aspx?OutputType=xhtml&ord=' + ord + '&tile=' + adNum;
	doc.getElementById(elementId).style.display = 'block';
	adNum++;
}

/*-------------------------------------------------------------------------
Adds trim functions to a string object
-------------------------------------------------------------------------*/
String.prototype.trim = function(){return this.replace(/^\s+|\s+$/g,"");}
String.prototype.ltrim = function(){return this.replace(/^\s+/,"");}
String.prototype.rtrim = function(){return this.replace(/\s+$/,"");}

