// set this to true if you want the login links in the header to float with the screen size
var floatLogin = false;

function init(){
	checkBodySize();
	
  // init sIFR and text resize scripts to support sIFR
  applySIFR();
  applyResizeCheck();
  
  if (floatLogin){
    window.onresize = function(){
      windowResize();
    }
    windowResize();
  }
  
}
function windowResize(){
  var subMenu = document.getElementById('topSubMenuContainer');
  if (subMenu)
  {
    var leftGutterW = 260 + 1; // logo plus border
    var headerBaseW = 699;
    var windowW = document.documentElement.clientWidth;
    if (windowW > (leftGutterW+headerBaseW)){
      subMenu.style.width= headerBaseW+'px';
    } else {
      var newW = windowW-leftGutterW;
      subMenu.style.width= newW+'px';
    }
  }
}

/* checkBodySize
 * Make content size relative to left nav if content shorter than the left nav
 * @offsetH int that describes the offset Height in pixels
 */
function checkBodySize(offsetH) {	
	var ln = $("#leftNav");	
	var cnt = $("#contentArea");	
	if (ln && cnt) {				
		var	hVal = ln.height();
		if (ln.height() > (cnt.height() - 75)){						
			if ($("#mainContentImage")){
				hVal = hVal - $("#mainContentImage").height();			
			}			
			$("#mainContentArea").css("height",hVal);			
			$("#mainContentAreaFullWidth").css("height",hVal);						
		}
		if (offsetH != null) {
			hVal += offsetH;
			$("#mainContentArea").css("height",hVal);			
			$("#mainContentAreaFullWidth").css("height",hVal);
		}
	}
}
/* sIFR and font resize support */
function applySIFR(){
	if(typeof sIFR == "function"){
		sIFR.replaceElement("h1", named({sFlashSrc: "/fonts/chalet.swf", sColor: "#355463", sBGColor: "#FFFFFF", sWmode: "transparent", nPaddingTop: "5", nPaddingBottom: "5"}));
		sIFR.replaceElement(".h1", named({sFlashSrc: "/fonts/chalet.swf", sColor: "#355463", sBGColor: "#FFFFFF", sWmode: "transparent", nPaddingTop: "5", nPaddingBottom: "5"}));
		//sIFR.replaceElement("h2", named({sFlashSrc: "/fonts/chalet.swf", sColor: "#082533", sBGColor: "#FFFFFF", sWmode: "transparent", nPaddingTop: "8", nPaddingBottom: "1"}));
		//sIFR.replaceElement("h3", named({sFlashSrc: "/fonts/chalet.swf", sColor: "#355463", sBGColor: "#FFFFFF", sWmode: "transparent"}));
		//sIFR.replaceElement("span.ad", named({sFlashSrc: "/fonts/chalet.swf", sColor: "#082533", sBGColor: "#FFFFFF", sWmode: "transparent", nPaddingTop: "8", nPaddingBottom: "1"}));
		//sIFR.replaceElement("span.adLink", named({sFlashSrc: "/fonts/chalet.swf", sColor: "#4e84c4", sBGColor: "#FFFFFF", sWmode: "transparent", nPaddingTop: "8", nPaddingBottom: "1"}));
	};
}
function applyResizeCheck(){
	// add a resize element to the page so we don't have to rely on it being coded on the page
	var resizeCheck = document.createElement('span');
	resizeCheck.id='resizeCheck';
	resizeCheck.innerHTML='&nbsp;';
	resizeCheck.style.position="absolute";
	resizeCheck.style.left="-9999px";
	var body = document.getElementsByTagName("body")[0]; 
	body.appendChild(resizeCheck);
	// add the resize events
	TextResizeDetector.TARGET_ELEMENT_ID = 'resizeCheck'; //id of element to check for and insert control
	TextResizeDetector.USER_INIT_FUNC = resizeInit; //function to call once TextResizeDetector has init'd
}
function resizeInit()  {
	var iBase = TextResizeDetector.addEventListener(onFontResize,null);
}
function onFontResize(e,args) {
	sIFR.rollback();
	applySIFR();
}
/* modal popup window - required mootools and smoothbox files  */
function showModal(url,height,width){
	 TB_show('',url+'?TB_iframe=true&height='+height+'&width='+width,false);
}

/* For View More Info SmoothBox */
function showModalNew(url,height,width,modal){
	if(url.indexOf("?") == -1){
		 TB_show('',url+'?TB_iframe=true&height='+height+'&width='+width+'&modal='+modal,false);
	}else{
		 TB_show('',url+'&TB_iframe=true&height='+height+'&width='+width+'&modal='+modal,false);
	}
}