// greenhouse public CUSTOM JavaScript configuration - unique to site
// to use full prototype 'lib/prototype.js'
	var aCustomBaseIncludes = ['x_core','x_event','moo/prototype.lite','moo/moo.fx','moo/moo.fx.pack','greenhouse/gh.ajax'];
		Loader.load(aCustomBaseIncludes, 'includes/client/');

//'sifr','sifr-config'
	var aCustomIncludes = ['partnerListing_functions','fla_functions','tween/Tween','tween/OpacityTween','tween/ColorTween','prototype']; 
		Loader.load(aCustomIncludes, 'custom/public/includes/client/');
	var sFullPath = String(document.location);
	
	var SITEBASE = sFullPath.substr(0,sFullPath.lastIndexOf('/')+1 );
	
	//////////////////////////
	function _initPage(){
		if(typeof initDate == "function") initDate();
	 
		if(typeof sIFR == "function"){
			
			// sIFR.replaceElement("#maincontent>.header>h1", named({sFlashSrc: "custom/flash/fonts/hn.swf", sColor: "#F76D00", sCase: "none", sWmode: "transparent", sFlashVars: "textalign=left"}));
			// 
			// sIFR.replaceElement(".partner_featuredlist>.holder>h2", named({sFlashSrc: "custom/flash/fonts/handscript_bold.swf", sColor: "#3A4C6B", sCase: "none", sWmode: "transparent", sFlashVars: "textalign=center"}));
			// sIFR.replaceElement(".partner_sponsorlist>.holder>h2", named({sFlashSrc: "custom/flash/fonts/handscript_bold.swf", sColor: "#3A4C6B", sCase: "none", sWmode: "transparent", sFlashVars: "textalign=center"}));
			// sIFR.replaceElement(".weather>.holder>h2", named({sFlashSrc: "custom/flash/fonts/handscript_bold.swf", sColor: "#3A4C6B", sCase: "none", sWmode: "transparent", sFlashVars: "textalign=center"}));
			// sIFR.replaceElement(".eventlist>.holder>h1", named({sFlashSrc: "custom/flash/fonts/handscript_bold.swf", sColor: "#3A4C6B", sCase: "none", sWmode: "transparent", sFlashVars: "textalign=center"}));
			// sIFR.replaceElement(".specialoffer>.holder>h2", named({sFlashSrc: "custom/flash/fonts/handscript_bold.swf", sColor: "#3A4C6B", sCase: "none", sWmode: "transparent", sFlashVars: "textalign=center"}));
			// sIFR.replaceElement(".eventdetail>.holder>h2", named({sFlashSrc: "custom/flash/fonts/handscript_bold.swf", sColor: "#3A4C6B", sCase: "none", sWmode: "transparent", sFlashVars: "textalign=center"}));
			// sIFR.replaceElement(".specialofferlist>.holder>h2", named({sFlashSrc: "custom/flash/fonts/handscript_bold.swf", sColor: "#3A4C6B", sCase: "none", sWmode: "transparent", sFlashVars: "textalign=center"}));
			// sIFR.replaceElement(".featuredeventslist>.holder>h2", named({sFlashSrc: "custom/flash/fonts/handscript_bold.swf", sColor: "#3A4C6B", sCase: "none", sWmode: "transparent", sFlashVars: "textalign=center"}));
			// sIFR.replaceElement(".scriptheader>h3", named({sFlashSrc: "custom/flash/fonts/handscript_bold.swf", sColor: "#B0633A", sCase: "none", sWmode: "transparent"}));
			// 		
				//sIFR.replaceElement(".charlottecityguide>.holder>ul>li>a", named({sFlashSrc: "custom/flash/fonts/dinengschrift_sifr.swf", sColor: "#333333", sCase: "upper", sWmode: "transparent"}));
			};
		
			/* check and set min height
			var col1H = (xHeight('column1') );//- 250
			var mainH = xHeight('maincontent');
			var dif = (col1H - mainH );
			
			if(col1H > mainH ){
				var newH = (dif > 190)? (col1H - 225) : col1H;
				xHeight('maincontent', (newH));
				//document.getElementById('maincontent').style.padding = '0 0 ' +(col1H - mainH ) + 'px 0';
				//alert('Left: '+col1H+', Main:'+mainH+', difference:'+dif+", new h="+newH);
			}
			*/

			
	}
	
	
	// PRINT
	function printSearchResults(sExtraParams){
		sExtraParams = (String(sExtraParams) == "undefined" ? "default.asp?" :  sExtraParams);
			
		var strPrintLink = sExtraParams + "&print=1";
		//alert("New window:"+strPrintLink);
		_newWindow(strPrintLink,'printWindow',780,600,0,1,1,1,1,1,1,0,0);
	}
		
	// REDIRECTION AND PAGE OPEN
	function gotoPage(s){
		switch(s){
			case "offers":
				document.location.href="?charlotte=60&urlkeyword=Special-Offers-Packages";
				break;
			case "maps":
				document.location.href="?charlotte=63&urlkeyword=Maps-Parking";
				break;
			default:
				alert("gotoPage" + s);
		}
	}
		
	function openBookItWindow(p){
		var sPage = p;
		location.href = sPage;
		//_newWindow(sPage,'Reservations',800,600,1,0,0,0,0,1,1)
	}
	
	function openMapItWindow(sId){   
		//
		//http://maps.mapnetwork.com/charlotte/index.asp?id 
		var sPage = "http://map.mapnetwork.com/";
			sPage += (null != sId && sId != '')? "flash/?rid=15396&pcid=" + sId : "destination/charlotte/";
		
		_newWindow(sPage,'mapit',850,650,0,0,0,0,0,0,1,'center','center');
	}
	
	function openCouponWindow(iPartnerID){
		var sPage = "couponPopUp.asp?partner=" + iPartnerID;
		_newWindow(sPage,'Coupon',700,475,1,0,0,0,0,1,1);
	}



	// FORMS
	function partnerAdminForms(sType) {
		var sPath = "mygreenhouse/forms/maint/";
		var sLink = "";
		switch (String(sType)) {
			case 'profile':
				sLink = sPath + 'adminPartnerContact.asp?id=' + m_strLoginID;
				break;
			case 'partner':
				if (m_strPartnerID > 0)
					sLink = sPath + 'adminPartner.asp?id=' + m_strPartnerID;
				break;
			case 'package':
				if (m_strPartnerID > 0)
					sLink = sPath + 'adminPackage.asp?id=0&partner=' + m_strPartnerID;
				break;
			case 'event':
				sLink = sPath +  'adminCommunityEvent.asp?id=0&partner=' + m_strPartnerID+ '&uid=' + m_strLoginID;
				break;
			case 'coupon':
				if (m_strPartnerID > 0)
					sLink = sPath + 'adminPartner_Coupon.asp?id=' + m_strPartnerID;
				break;
		}
		
		if (sLink != "") {
			sLink += "&LoginType=Partner"
			_newWindow(sLink,"PartnerAdmin",855,600,1,0,0,0,0,1,1,"center","center");
		} else {
			alert('Log in as a partner for this option.');
		}
		
	}
	
	
	// GOOGLE RELATED
	function trackFileDownload(sUrl, sName, w, h){
			pageTracker._link(sUrl);// may want to strip file extension
		var sWinName = (null != sName)? sName : 'Download ' ;
		var sW = (null != w)? w : '200';
		var sH = (null != h)? h : '200';
			_newWindow(sUrl,sWinName,sW,sH,1,0,0,0,0,1,1);
		
	}
	
	function trackUrl(sUrl, sName, w, h, samewin){
		
		if(null != samewin && samewin){
			pageTracker._trackPageview(sUrl);
			document.location.href = sUrl ;
		}else{ 
		   var sWinName = (null != sName)? sName : 'New' ;
			var sW = (null != w)? w : '200';
			var sH = (null != h)? h : '200';  
		  _newWindow(sUrl,sWinName,sW,sH,1,1,1,1,1,1,1);    
		}
			//__utmLinker(sUrl);
			return false;
		
	}     
	
	function trackOVGForm(){  
		trackUrl('http://images.publicaster.com/imagelibrary/account265/documents/new/signup_form.htm','OVGForm',680,880);
	}

	function displayFullDesc(bol,i){
			var shortDesc = (bol)? 'none':'block';
			var fullDesc = (bol)? 'block':'none';
		$('test-short_'+ i).style.display=shortDesc;
		$('test-full_'+ i).style.display=fullDesc;
		
	}
  	function displayFullFYI(bol,i){
			var closeFYI = (bol)? 'none':'block';
			var openFYI = (bol)? 'block':'none';
		$('test-close_'+ i).style.display=closeFYI;
		$('test-open_'+ i).style.display=openFYI;
		
	}
	function openSlideArea(i){
		var slidearea = $('story_swf_'+ i);
		var curH = xHeight(slidearea);
		if (curH==120){	
		fxExpand = new fx.Height(slidearea, {duration: 450 });	
		fxExpand.custom(120,575);
		}
		if (curH==121){		
		fxExpand = new fx.Height(slidearea, {duration: 450 });	
		fxExpand.custom(121,575);
		}
		
	}

	function closeSlideArea(i){
		var slidearea = $('story_swf_'+ i);
		var curH = xHeight(slidearea);
		if (curH==576){
		fxExpand = new fx.Height(slidearea, {duration: 450 });	
		fxExpand.custom(576,120);
		}
		
	}

	// HISTORY TIMELINE - TABS
		var activeTab;
		function setTabs(tabName) {
		var panes = $(tabName).getChildren();
		for (i=0; i<panes.length; i++) {
		if (i!=0) panes[i].setStyle('display', 'none');
		panes[i].setProperty('id', 'pane_'+i);
		}
		var tabs = $(tabName+'_nav').getChildren();
		$(tabName+'_nav').store('activeTab',$(tabName+'_nav').getFirst());
		$(tabName+'_nav').retrieve('activeTab').addClass('active');
		for (i=0; i<tabs.length; i++) {
		tabs[i].setProperty('id', tabName+'_nav_'+i);
		tabs[i].addEvent('click', displayTab.bindWithEvent(this,[tabName,i]));
		//tabs[i].setProperty("onclick", "displayTab(this,'pane',"+i+")");
		}
		}
		// var displayTab = function (obj,i,tabName) {
		// var l = $(tabName+'_nav').getChildren().length;
		// for (j=0; j<l; j++) {
		// $(tabName+'_'+j).setStyle('display', 'none');
		// }
		// $(tabName+'_'+i).setStyle('display', 'block');
		// //var button = $(obj);
		// //button.setProperty('class','active');
		// $(activeTab).toggleClass('active');
		// //activeTab = $(obj);
		//
		// };
		function displayTab(obj,tabName,i) {
		if (activeTab == undefined) {
		activeTab = $(tabName+'_nav').getFirst();
		}
		var l = $(tabName+'_nav').getChildren().length;
		for (j=0; j<l; j++) {
		$(tabName+'_'+j).setStyle('display', 'none');
		}
		$(tabName+'_'+i).setStyle('display', 'block');
		$(tabName+'_nav').retrieve('activeTab').removeClass('active');
		$(tabName+'_nav').store('activeTab',$(tabName+'_nav_'+i));
		$(tabName+'_nav').retrieve('activeTab').addClass('active');
		};
	
	function showTimelineDetail(id,bol) {
		loadTimelineDetail(id);
		// var content = $('timeline_detail');
		// var start = (!bol)? 0 : 100;
		// var end = (!bol)? 100 : 0;
		// var opTween = new OpacityTween(content,Tween.regularEaseOut, start, end, .55);
		// if (bol) {
		// 	var a = new Object();
		// 		a.onMotionFinished = function(){
		// 			loadTimelineDetail(id);
		// 		};									
		// 		opTween.addListener(a);
		// }
		// opTween.start();
	}
	
	function loadTimelineDetail(id) {
		var content = $('timeline_detail');
		new ajax ('processors/proc_getTimelineDetail.asp', {postBody: 'id='+id, update: content, onComplete: function(){
				//showTimelineDetail(id,false);
		}});
	}