function browser(){
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent.toLowerCase()
	this.dom=document.getElementById?1:0
	this.op5=(this.agent.indexOf("opera 5")>-1 || this.agent.indexOf("opera/5")>-1) && window.opera 
	this.op6=(this.agent.indexOf("opera 6")>-1 || this.agent.indexOf("opera/6")>-1) && window.opera   
	this.ie5 = (this.agent.indexOf("msie 5")>-1 && !this.op5 && !this.op6)
	this.ie55 = (this.ie5 && this.agent.indexOf("msie 5.5")>-1)
	this.ie6 = (this.agent.indexOf("msie 6")>-1 && !this.op5 && !this.op6)
	this.ie4=(this.agent.indexOf("msie")>-1 && document.all &&!this.op5 &&!this.op6 &&!this.ie5&&!this.ie6)
	this.ie = (this.ie4 || this.ie5 || this.ie6)
	this.mac=(this.agent.indexOf("mac")>-1)
	this.ns6=(this.agent.indexOf("gecko")>-1 || window.sidebar)
	this.ns4=(!this.dom && document.layers)?1:0;
	this.opera=(this.agent.indexOf("opera")>-1)
	this.safari=(this.agent.indexOf("safari")>-1)
	this.firefox=(this.agent.indexOf("firefox")>-1)
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.op5 || this.op6)
	this.usedom= this.ns6//Use dom creation
	this.reuse = this.ie||this.usedom //Reuse layers
	this.px=this.dom&&!this.op5?"px":""
	return this
}
var objBrowser = new browser();

function loadPageMF(type){
    fixit();
    setImageMargin();
    switch(type)
    {
        case 'mf_content':
            var textHeight = $("div#Text").height();
            var infoHeight = $("div#RelatedInfo").height();
            if(infoHeight > textHeight)     textHeight = infoHeight;
            if($("div#NavigationChildren"))
	            $("div#NavigationChildren").height(textHeight + 80);
	        if($("div#HorizontalSeparator"))
	            $("div#HorizontalSeparator").height(textHeight);
	        break;
        case 'mf_section':
            var textHeight = $("div#SectionFrontpage").height();
            if($("div#NavigationChildren"))
	            $("div#NavigationChildren").height(textHeight + 180);
	        if($("div#HorizontalSeparator"))
	            $("div#HorizontalSeparator").height(textHeight);
    }
}

function loadPage(isFrontpage, type){
	fixit();
	var objPage = new pageComponent();
	var objNavigation = document.getElementById('NavigationChildren');
	var objSeparator = document.getElementById('HorizontalSeparator');
	if (isFrontpage) {
	    if (objNavigation) {
	        objNavigation.style.height = objPage.bodyWrapperHeight - 229 + 'px';
	    }
	    if (objSeparator) {
	        switch (type) {
	            case 'main':
	                objSeparator.style.height = objPage.bodyWrapperHeight - 544 + 'px';
	                break;

	            case 'section':
	                objSeparator.style.height = objPage.bodyWrapperHeight - 550 + 'px';
	                break;

	            case 'hub':
	                objSeparator.style.height = objPage.bodyWrapperHeight - 514 + 'px';
	                break;
	                
                case 'mainCruise':
                    objSeparator.style.height = objPage.bodyWrapperHeight - 655 + 'px';
                    break;
					
				case 'mainGreen':
	                objSeparator.style.height = objPage.bodyWrapperHeight - 250 + 'px';
	                break;
	        }

	    }
	} else {
	    var margin = 0;
	    var smargin = 0;
	    if (objNavigation) {
	        objNavigation.style.height = objPage.bodyWrapperHeight - (229 + margin)+ 'px';
	    }
	    if (objSeparator) {
	        objSeparator.style.height = objPage.bodyWrapperHeight - (443 + smargin) + 'px';
	    }
	}
	setImageMargin();
}

function setImageMargin()
{
    var objText = document.getElementById('Text');
	var objTextWide = document.getElementById('TextWide');
	if(objText){
		var colImages = objText.getElementsByTagName('img');
		for(i=0;i<colImages.length;i++){
			if(colImages[i].src.indexOf('media(') >= 0 && colImages[i].vspace != 1){
				colImages[i].style.border = 'solid 5px #F3F2ED';
				colImages[i].style.margin = '6px';
				colImages[i].style.marginTop = '3px';
			}
		}
	}
	if(objTextWide){
		var colImages = objTextWide.getElementsByTagName('img');
		for(i=0;i<colImages.length;i++){
			if(colImages[i].src.indexOf('media(') >= 0 && colImages[i].vspace != 1){
				colImages[i].style.border = 'solid 5px #F3F2ED';
				colImages[i].style.margin = '6px';
				colImages[i].style.marginTop = '3px';
			}
		}
	}
	setExternalLinkTarget();
}

function fixit(){
	theObjects = document.getElementsByTagName("object");
	for (var i = 0; i < theObjects.length; i++) {
		if(theObjects[i].name == 'Banner'){
		theObjects[i].outerHTML = theObjects[i].outerHTML;
		}
	}
}

function setExternalLinkTarget() { 
	// Changes target on external links and media
	// To use this function add this in all body tags: onload="fncOnLoad()"
	if (!(null==document.links) && document.links.length>0) {
		for (i=0;i<document.links.length;i++) {
			if ( document.links[ i ].hostname > '' && 'http:' == document.links[ i ].protocol && (document.links[ i ].pathname.toLowerCase().indexOf('showmedium.asp')>0 || document.links[ i ].pathname.toLowerCase().indexOf('edia(')>0 || document.links[ i ].pathname.toLowerCase().indexOf('.pdf')>0 || (document.links[ i ].hostname.toLowerCase().indexOf(document.location.hostname)==-1 ) ))  
			// Change link target to siteExtern
			document.links[ i ].target = 'siteExtern';
		}
	}
}


function pageComponent(){
	this.bodyWrapperHeight = getHeight('BodyWrapper');
}

function getHeight(elementName){
	var objElement = document.getElementById(elementName);
	if(objElement){
		if(objBrowser.ie){
			return objElement.scrollHeight;
		} else {
			return objElement.scrollHeight;
		}
	}
}

pageComponent.prototype.getOuterHeight = function(){
	//var objPage = document.getElementById('Page');
	//var objAd = document.getElementById('Advertisment');
	if(!objBrowser.ie){
		this.pageHeight = (window.innerHeight + window.pageYOffset);
	} else {
		this.pageHeight = document.body.scrollHeight;
	}
}

pageComponent.prototype.setInnerHeight = function(){
	var lngMozillaAdjust = 0;
	var lngOperaAdjust = 0;
	if(this.isFrontpage){
		if(!objBrowser.ie){lngMozillaAdjust = 70}
		var objSeparator = document.getElementById('HorizontalSeparator');
		if(objSeparator){
			objSeparator.style.height = this.pageHeight - (this.parentNavigationHeight + this.headerHeight + this.focusHeight + this.footerHeight + 65 + lngMozillaAdjust) + 'px';
		}
	} else {
		//var objNavigation = document.getElementById('NavigationChildren');
		//objNavigation.style.height = this.bodyWrapperHeight - 129 + 'px';
		/*
		if(objBrowser.opera){lngOperaAdjust = -10}
		if(!objBrowser.ie){lngMozillaAdjust = 70}
		var objNavigation = document.getElementById('NavigationChildren');
		var objSeparator = document.getElementById('HorizontalSeparator');
		var objContentHeader = document.getElementById('ContentHeader');
		if(objNavigation){
			objNavigation.style.height = this.pageHeight - (this.parentNavigationHeight + this.headerHeight + this.footerHeight + 100 + lngOperaAdjust + lngMozillaAdjust) + 'px';
		}
		if(objSeparator){
			objSeparator.style.height = this.pageHeight - (this.contentHeaderHeight + this.parentNavigationHeight + this.headerHeight + this.footerHeight + 75 + lngMozillaAdjust) + 'px';
		}
		*/
	}
}

pageComponent.prototype.setPageBodyPadding = function(){
	if(objBrowser.ie){
		var objPageBody = document.getElementById('PageBody');
		if(objPageBody){
			objPageBody.style.paddingBottom = '0px';
		}
	}
}

function init(isFrontpage){
	var objPage = new pageComponent();
	objPage.isFrontpage = isFrontpage;
	objPage.setPageBodyPadding();
	objPage.getOuterHeight();
	objPage.setInnerHeight();
}



function setPhotoStyle(){
	var objText = document.getElementById('Text');
}

