﻿//user editable variables
wep.expandedLeftMargin = -100;
wep.contractedLeftMargin = 120;
wep.expandedTopMargin = 53;
wep.contractedTopMargin = 53;
wep.expandedWidth = 826;
wep.contractedWidth = 100;
wep.expandedHeight = 480;
wep.contractedHeight = 60;
wep.numSteps = 6;
//derived variables
wep.currentLeftMargin = wep.contractedLeftMargin;
wep.currentTopMargin = wep.contractedTopMargin;
wep.currentWidth = wep.contractedWidth;
wep.currentHeight = wep.contractedHeight;
wep.leftMarginStepSize = (Math.abs(wep.expandedLeftMargin) + Math.abs(wep.contractedLeftMargin)) / wep.numSteps;
wep.topMarginStepSize = (Math.abs(wep.expandedTopMargin) + Math.abs(wep.contractedTopMargin)) / wep.numSteps;
wep.widthStepSize = (wep.expandedWidth - wep.contractedWidth) / wep.numSteps;
wep.heightStepSize = (wep.expandedHeight - wep.contractedWidth) / wep.numSteps;
//elements
wep.expander;
wep.contracter;
wep.mask;
wep.maskbtm;
wep.popup;
wep.expandedContent;
wep.loading;
wep.exppge;
wep.expmen;
wep.shadow;
wep.fader;
wep.currButtonType;
wep.expanderIframe;
//flags
wep.expanding = false;
wep.show = false;
wep.gettingData = false;
wep.paneGettingData = false;
//other
wep.windowedElem = new Array();

wep.expand = function (eButtonId){
	if(this.expandFirstTime && eButtonId == this.currentBtn || !this.expandFirstTime){
		if(this.expmen + '' != 'undefined'){
			if(this.expandFirstTime){
			    this.setActiveContentVisibility('hidden');
    	        this.displayMovies(false);
    	    }
			if(navigator.appName.indexOf("Microsoft")>-1 && this.expandFirstTime) this.fadeBkg(true);
			this.expandFirstTime = false;
			//initiate data retrieval
			if(!this.gettingData){
				this.buttonId = eButtonId;
				this.expmen.innerHTML = '';
				this.exppge.innerHTML = '';
				this.loading.style.display = 'block';
			}
			//expand div
			if(this.currentWidth < this.expandedWidth){
				this.expanding = true;
				this.expander.style.visibility = 'visible';
				this.mask.style.visibility = 'visible';
				this.maskbtm.style.visibility = 'visible';
				
				this.currentLeftMargin = parseInt(this.currentLeftMargin) - parseInt(this.leftMarginStepSize)
				this.currentWidth = parseInt(this.currentWidth) + parseInt(this.widthStepSize)
				this.currentHeight = parseInt(this.currentHeight) + parseInt(this.heightStepSize)

				this.expander.style.marginLeft = this.currentLeftMargin + 'px'
				this.mask.style.marginLeft = this.currentLeftMargin - 2 + 'px'
				this.maskbtm.style.marginLeft = this.currentLeftMargin - 2 + 12 + 'px'
				this.expander.style.width = this.currentWidth + 'px'
				this.expander.style.height = this.currentHeight + 'px'
				this.mask.style.width = this.currentWidth - 2 + 'px'
				this.mask.style.height = this.currentHeight + 'px'
				this.maskbtm.style.width = this.currentWidth - 2 + - 24 + 'px'
				this.maskbtm.style.height = this.currentHeight + 'px'
				
				window.setTimeout('wep.expand(\'' + this.buttonId + '\')', 20)
			}
			else{
				this.mask.style.height = this.currentHeight + 34 + 'px'
				this.mask.style.marginLeft = this.currentLeftMargin - 4 + 'px'
				this.mask.style.width = this.currentWidth + 'px'
				this.maskbtm.style.height = this.currentHeight + 42 + 'px'
				this.maskbtm.style.marginLeft = this.currentLeftMargin - 4 + 12 + 'px'
				this.maskbtm.style.width = this.currentWidth - 24 + 'px'
				this.expander.style.visibility = 'hidden';
				this.expandedContent.style.visibility = 'visible';
				this.expandedContent.style.display = 'block';
				this.shadow.style.visibility = 'visible';
				this.expanding = false;
				if(navigator.appName.indexOf("Microsoft")==-1) this.fadeBkg(true);
				if(!this.gettingData){
					this.getJsonData();
				}
				this.gettingData = true;
				this.expandFirstTime = true;
			}
		}
	}
}

wep.setActiveContentVisibility = function(visibility){
    if(navigator.userAgent.indexOf('Safari')>-1){
        var obs = document.getElementsByTagName('object')
        for(var i=0; i<obs.length; i++){
            if(obs[i].style)obs[i].style.visibility = visibility;
        }
    }
    obs = document.getElementsByTagName('applet')
    for(var i=0; i<obs.length; i++){
        if(obs[i].style)obs[i].style.visibility = visibility;
    }
    if(navigator.userAgent.indexOf('MSIE 6')>-1){
        if(visibility=='hidden'){
            var obs = document.getElementsByTagName('select');
            var j = 0;
            for(var i=0; i<obs.length; i++){
                if(obs[i].id.length>0 && obs[i].style.visibility!='hidden'){
                    wep.windowedElem[j] = obs[i].id;
                    obs[i].style.visibility = visibility;
                    j++;
                }
            }
        }
        else{
            for(var i=0; i<wep.windowedElem.length; i++){
                document.getElementById(wep.windowedElem[i]).style.visibility = 'visible';
            }
        }
    }
}

wep.contract = function(){
 	this.mask.style.visibility = 'hidden';
	this.maskbtm.style.visibility = 'hidden';

	if(this.currentWidth > this.contractedWidth && !this.expanding){
		if(this.contractFirst) {
		    this.fadeBkg(false);
		    this.expanderIframe.style.display = 'none';
		}
		this.contractFirst = false;

		this.setActiveContentVisibility('visible');
		this.expandedContent.style.visibility = 'hidden';
		this.expandedContent.style.display = 'none';
		this.shadow.style.visibility = 'hidden';
		this.expanderIframe.style.display = 'none';
		this.contracter.style.visibility = 'visible';
		
		this.currentLeftMargin = parseInt(this.currentLeftMargin) + parseInt(this.leftMarginStepSize);
		this.currentWidth = parseInt(this.currentWidth) - parseInt(this.widthStepSize);
		this.currentHeight = parseInt(this.currentHeight) - parseInt(this.heightStepSize);

		this.contracter.style.marginLeft = this.currentLeftMargin + 'px';
		this.mask.style.marginLeft = this.currentLeftMargin + 'px';
		this.maskbtm.style.marginLeft = this.currentLeftMargin + 'px';
		this.contracter.style.width = this.currentWidth + 'px';
		this.contracter.style.height = this.currentHeight + 'px';

		window.setTimeout('wep.contract()', 20);
	}
	else{
		this.contracter.style.visibility = 'hidden';
		this.gettingData = false;
		this.initialise();
		this.contractFirst = true;
		this.paneGettingData = false;
	    this.displayMovies(true);
	}
	return;
}

wep.initialise = function(){
	this.popup = document.getElementById('wep_popup');
	this.expandedContent = document.getElementById('wep_expandedContent');
    this.createIframe('wep_mask', this.popup);
    this.createIframe('wep_maskbtm', this.popup);
    this.createIframe('wep_expanderIframe', this.expandedContent);
    this.currentLeftMargin = this.contractedLeftMargin;
    this.currentTopMargin = this.contractedTopMargin;
    this.currentWidth = this.contractedWidth;
    this.currentHeight = this.contractedHeight;
	this.expander = document.getElementById('wep_expander');
	this.contracter = document.getElementById('wep_contracter');
	this.mask = document.getElementById('wep_mask');
	this.maskbtm = document.getElementById('wep_maskbtm');
	this.shadow = document.getElementById('wep_shadow');
	this.expanderMenu = document.getElementById('wep_expandermenu');
	this.expanderPage = document.getElementById('wep_expanderpage');
	this.expanderPageScroller = document.getElementById('wep_expanderpagescroller');
	this.loading = document.getElementById('wep_loading');
	this.exppge = document.getElementById('wep_expanderpagecontent');
	this.expmen = document.getElementById('wep_expandermenucontent');
	this.expanderIframe = document.getElementById('wep_expanderIframe');
	this.fader = document.getElementById('wep_fader');

	this.expander.style.marginLeft = this.contractedLeftMargin + 'px'
	this.expander.style.marginTop = this.contractedTopMargin + 'px'
	this.expander.style.width = this.contractedWidth + 'px'

	this.contracter.style.marginLeft = this.contractedLeftMargin + 'px'
	this.contracter.style.marginTop = this.contractedTopMargin + 'px'
	this.contracter.style.width = this.contractedWidth + 'px'
	this.contracter.style.height = this.contractedHeight + 'px'

	this.mask.style.marginLeft = this.contractedLeftMargin + 'px'
	this.mask.style.marginTop = this.contractedTopMargin + 'px'
	this.mask.style.width = this.contractedWidth + 'px'
	this.mask.style.height = this.contractedHeight + 'px'
	this.maskbtm.style.marginLeft = this.contractedLeftMargin + 'px'
	this.maskbtm.style.marginTop = this.contractedTopMargin + 'px'
	this.maskbtm.style.width = this.contractedWidth + 'px'
	this.maskbtm.style.height = this.contractedHeight + 'px'

	this.expandedContent.style.marginLeft = this.expandedLeftMargin + 'px'
	this.expandedContent.style.marginTop = this.expandedTopMargin + 'px'
	this.expandedContent.style.width = this.expandedWidth + 'px'
	this.expandedContent.style.height = this.expandedHeight + 'px'

	this.shadow.style.marginLeft = this.expandedLeftMargin - 5 + 'px'
	this.shadow.style.marginTop = this.expandedTopMargin + 'px'

	this.expanderMenu.style.height = this.expandedHeight - 21 + 'px'
	this.expanderPageScroller.style.height = this.expandedHeight - 44 + 'px'
	this.expanderPageScroller.style.width = this.expandedWidth - 225 + 'px'
    
    this.expanderIframe.style.height = this.expandedHeight - 44 + 'px'
    this.expanderIframe.style.width = this.expandedWidth - 225 + 'px'
	
	this.loading.style.left = ((this.expandedWidth - 212) / 2) - 20 + 'px'
	this.loading.style.top = ((this.expandedHeight - 21) / 2) - 20 + 'px'
}

//JSON


wep.getJsonData = function() {
    if(!this.paneGettingData){
        this.paneGettingData = true;
        var jsrOb = new jsr.JsonScriptRequest(this.paneServerUrl);
        jsrOb.buildScriptTag();
        jsrOb.addScriptTag();
    }
}
		
wep.pane = function(data) {
    this.paneData = data;
	var items = this.paneData.feed[0].entry;
	var j;
	var menuHtml;
	var item;
	var catUrl;
	var initiallyShowHtmlUrl = '';
	var itemSelected = false;
	var itemHighlighted = false;
	var catToSelect = 0;
	var itemClass;
    var firstTime = true;
    var isSSL;
    var protCatUrl;
    var trackingCode;
    var trackingUrl;


    this.catAry = new Array();
    if(this.feedDomainTBN.slice(0, 8) == "https://" || this.feedDomainFNP.slice(0, 8) == "https://") isSSL = true;

    this.numMenuItems = items.length
	for (var I = 0 ; I < items.length ; I++) {
		item = items[I];
		menuHtml = '';
		catUrl = item.link[0].href;
		itemHighlighted = item.id == item.category[0].term;

		if(item.id==this.getSelectedCatId() || firstTime) {
		    this.selectedItemId = I;
            this.layout = this.paneData.feed[0].entry[I].layout;
		    if(itemHighlighted){
		        this.catId = item.id + '';
		        this.subCatId = '';
		    }
		    else{
		        this.subCatId = item.id + '';
		        this.catId = '';
		    }
		}
		itemClass = itemHighlighted ? 'wep_menuItemCat' : 'wep_menuItemSubcat';

		trackingCode = 'var weps=s_gi(\'' + this.omn.trackingAccount + '\');' +
            'weps.linkTrackVars=\'prop1,prop2,prop3,prop4,prop5,prop45,eVar45\';' +
            'weps.prop1=\'' + this.omn.siteUrl + '\';' +
            'weps.prop2=\'' + this.omn.country + '\';' +
            'weps.prop3=\'' + this.omn.language + '\';' +
            'weps.prop4=\'' + this.omn.brand + '\';' +
            'weps.prop5=\'' + this.omn.audience + '\';' +
            'weps.prop45=\'' + this.buttonId + ' > ' + item.id + '\';' +
            'weps.eVar45=weps.prop45;' +
            'weps.tl(this, \'o\', \'WEP Button\');';

        trackingUrl = catUrl + '';
        if(this.omn.track && trackingUrl.length>0){
            if(trackingUrl.indexOf('?')>-1)separator = '&';
            else separator = '?';
            trackingUrl += separator + 'navigationSource=wep';
        }

		menuHtml += '<div class="' + itemClass;
		menuHtml += '" id="wep_menuitem' + I + '"><div class="wep_padder">';
		menuHtml += '<a href="#"';
		switch(item.layout){
		    case 'html':
		        protCatUrl = isSSL ? catUrl.replace('http://', 'https://') : catUrl;
                menuHtml += ' onclick="wep.selectCategory(' + I + ');wep.clearExpanderPage();wep.getPageHtmlData(\'' + protCatUrl + '\',\'' + item.title + '\')">';
                if(I==this.selectedItemId) initiallyShowHtmlUrl = protCatUrl;
		        break;
		    case 'external':
		        menuHtml += ' onclick="wep.openUrl(\'' + trackingUrl + '\',\'' + item.link[0].target + '\')';
                if(this.omn.track) menuHtml += ';' + trackingCode 
		        menuHtml += '">';
		        break;
		    default:
		        menuHtml += ' onclick="wep.selectCategory(' + I + ');wep.clearExpanderPage();wep.getPageJsonData(\'' + item.id + '\', ' + itemHighlighted + ', \'' + item.layout + '\')">';
		        if(I==this.selectedItemId) initiallyShowHtmlUrl = '';
		        break;
	    }
		menuHtml += item.title
		// store category for tracking
        this.catAry[item.id] = item.title;
		menuHtml += '</a>';
		menuHtml += '</div></div>';
		this.expmen.innerHTML += menuHtml
		firstTime = false
	}
    this.expmen.innerHTML += '<div id="wep_bottomitem"></div>';
    //Show url in RH pane if necessary
	if(initiallyShowHtmlUrl!=''){
	    this.selectCategory(this.selectedItemId);
	    this.clearExpanderPage();
	    this.getPageHtmlData(initiallyShowHtmlUrl);
	    initiallyShowHtmlUrl = '';
	}
	else this.paneRh();
	this.selectCategory(this.selectedItemId);
    this.paneGettingData = false;
    if(this.originalCatId!=null && this.originalCatId+''!='undefined')
        eval('wde.' + this.currButtonType + ' = \'' + this.originalCatId + '\'');

}

wep.getPageHtmlData = function(url,title){
    var separator = url.indexOf('?')>-1 ? '&' : '?';
    var params =  separator + 'wep_siteId=' + this.siteId + '&wep_buttonId=' + this.buttonId;
    this.replaceIFrame(this.expanderIframe, url + params, title);
    //this.expanderIframe.src = url;
    this.expanderIframe.style.display = 'block';
	this.gettingData = false;
}

wep.getPageJsonData = function(catId, isCat, layout) { 
    if(isCat){
        this.catId = catId;
        this.subCatId = '';
    }
    else{
        this.catId = '';
        this.subCatId = catId;
    }
    this.layout = layout;

    this.paneRh()
}

wep.paneRh = function() {
	var items = this.paneData.feed[1].entry;
	var exppge = document.getElementById('wep_expanderpagecontent');
	var pgecont = '';
    var item;
    var singleCol;
    var cellCount = 0;
    var odd = false;
    var isSSL = false;
    var imageUrl;
    var numItems = 0;
    var currPos = 0;
    var subDesc;
    var imageOnly;
    var lastImageOnly = false;
    var trackingCode;
    var trackingUrl;
    var separator;
   	//catId = '';

    if(this.feedDomainTBN.slice(0, 8) == "https://" || this.feedDomainFNP.slice(0, 8) == "https://") isSSL = true;

	this.expanderIframe.style.display = 'none';	

    //count number of items in RH pane for current selected item
	for (var I = 0 ; I < items.length ; I++) {
		item = items[I];
		try{
		if((this.subCatId != '' && item.category[0].term == this.subCatId) || (this.catId != '' && item.category[0].term == this.catId)){
            numItems++;
		}
		}catch(e){this.paneGettingData=false}
    }
	for (var I = 0 ; I < items.length ; I++) {
		item = items[I];
		if((this.subCatId != '' && item.category[0].term == this.subCatId) || (this.catId != '' && item.category[0].term == this.catId)){

		    imageOnly = item.isImageOnly == 'True';

            if(currPos>0&&!odd && !lastImageOnly && !imageOnly)pgecont += '<tr><td width="100%" colspan="2" class="wep_rule"><div class="wep_ruleinner"><img src="' + wep.spacerUrl + '" width="1px" height="1px" alt="" /></div></td></tr>'
            if(currPos>0 && ((lastImageOnly && !imageOnly) || (!lastImageOnly && imageOnly)))pgecont += '<tr><td width="100%" colspan="2" class="wep_spacer"></td></tr>'
            lastImageOnly = false;

		    singleCol = item.isHead == 'True' || this.layout == '1col';
            subDesc = (item.content != null) ? item.content : '';
            imageUrl = item.img[0].src;
            if(isSSL)imageUrl = imageUrl.replace('http://', 'https://');
			trackingCode = 'var weps=s_gi(\'' + this.omn.trackingAccount + '\');' +
                'weps.linkTrackVars=\'prop1,prop2,prop3,prop4,prop5,prop45,eVar45\';' +
                'weps.prop1=\'' + this.omn.siteUrl + '\';' +
                'weps.prop2=\'' + this.omn.country + '\';' +
                'weps.prop3=\'' + this.omn.language + '\';' +
                'weps.prop4=\'' + this.omn.brand + '\';' +
                'weps.prop5=\'' + this.omn.audience + '\';' +
                'weps.prop45=\'' + this.buttonId + ' > ' + item.category[0].term + ' > ' + item.id + '\';' +
                'weps.eVar45=weps.prop45;' +
                'weps.tl(this, \'o\', \'WEP Button\');';

            trackingUrl = item.link[0].href + '';
            if(this.omn.track && trackingUrl.length>0){
                if(trackingUrl.indexOf('?')>-1)separator = '&';
                else separator = '?';
                trackingUrl += separator + 'navigationSource=wep';
            }

	        if(singleCol){
                pgecont += '<tr>'

	            if(imageOnly){
	            
	                pgecont += '<td width="100%" colspan="2" class="wep_imageonly">';
	                if(item.link[0].isClickable!="False"||item.link[0].isClickable==null)pgecont += '<a href="#">';
	                pgecont += '<div class="wep_imageonlywide"><img ';
	                if(item.link[0].isClickable!="False"||item.link[0].isClickable==null){
	                    pgecont += 'onclick="';
		                if(this.omn.track) pgecont += trackingCode
	                    pgecont += 'wep.openUrl(\'' + trackingUrl + '\',\'' + item.link[0].target + '\')" ';
	                }
	                pgecont += 'src="' + imageUrl + '" alt="" border="0" /></div></div>';
	                if(item.link[0].isClickable!="False"||item.link[0].isClickable==null)pgecont += '</a>';
	                pgecont += '</td>';
			        lastImageOnly = true;
	            }
	            else{
	                pgecont += 
		                '<td width="100%" colspan="2"><a href="javascript:wep.openUrl(\'' + escape(trackingUrl) + '\',\'' + item.link[0].target + '\')" onclick="'
	                if(this.omn.track) pgecont += trackingCode 
	                pgecont += '"><div class="wep_thumbnailwide"><img onclick="'
	                if(this.omn.track) pgecont += trackingCode 
	                pgecont += 'wep.openUrl(\'' + trackingUrl + '\',\'' + item.link[0].target + '\')" src="' + imageUrl + '" alt="" border="0" width="86"></div><div class="wep_descrwide">' +
		                '<b>' + item.title + '</b><br />' + 
		                subDesc + '<br /></div></a></td>';
	            }
                pgecont += '</tr>'
                cellCount = 0;
            }
            else{
                odd=cellCount%2==0;
                if(odd) pgecont += '<tr>'
                pgecont += '<td width="50%"'

	            if(imageOnly){
	                if(odd) pgecont += ' class="wep_left wep_imageonly"'
	                pgecont += '>'
	                if(item.link[0].isClickable!="False"||item.link[0].isClickable==null){pgecont += '<a href="#">';}
	                pgecont += '<div class="wep_imageonly"><img ';
	                if(item.link[0].isClickable!="False"||item.link[0].isClickable==null){
	                    pgecont += 'onclick="';
		                if(this.omn.track) pgecont += trackingCode
	                    pgecont += 'wep.openUrl(\'' + trackingUrl + '\',\'' + item.link[0].target + '\')" ';
	                }
	                pgecont += 'src="' + imageUrl + '" alt="" border="0"></div></div>';
	                if(item.link[0].isClickable!="False"||item.link[0].isClickable==null)pgecont += '</a>'
	                pgecont += '</td>';
		            lastImageOnly = true;
	            }
	            else{
                    //Subcategory Name
	                if(odd) pgecont += ' class="wep_left"'
	                pgecont += '><a href="javascript:wep.openUrl(\'' + escape(trackingUrl) + '\',\'' + item.link[0].target + '\')" onclick="'
                    if(this.omn.track) pgecont += trackingCode
                    pgecont += '"><div class="wep_thumbnail"><img onclick="'
                    if(this.omn.track) pgecont += trackingCode
                    pgecont += 'wep.openUrl(\'' + trackingUrl + '\',\'' + item.link[0].target + '\')" src="' + imageUrl + '" alt="" border="0" width="86"></div><div class="wep_descr">' +
	                    '<b>' + item.title + '</b><br />' + 
	                    subDesc + '<br /></div></a></td>';
                }
                if(!odd) pgecont += '</tr>'
                cellCount++;
            }
            currPos++;
        }
	}
    if(odd) pgecont += '<td></td></tr>'
	exppge.innerHTML = '<table class="wep_pane">' + pgecont + '</table>';
	this.loading.style.display = 'none';
	if(this.show)exppge.style.visibility = 'inherit';
	this.show=true;
	this.gettingData = false;
}

wep.clearExpanderPage = function(){
	document.getElementById('wep_expanderpagecontent').innerHTML = ''; 
}

wep.showmenu = function(btnId, btnNum, btnType){
    this.paneServerUrl = this.feedDomainFNP + '/fnp/' + btnId + '/' + this.locale.replace('_', '/') + '/';
    if(!this.paneGettingData){
        this.selectButton(btnNum);
        this.currButtonType = btnType;
	    if(this.currentBtn != btnId && this.currentBtn !== ''){
	        //switching button, so just change menu content
	        this.expanderIframe.style.display = 'none';	
	        this.currentBtn = btnId;
	        this.buttonId = btnId;
	        this.expmen.innerHTML = '';
	        this.exppge.innerHTML = '';
	        this.loading.style.display = 'block';
		    this.getJsonData();
		    this.gettingData = true;
	    }
	    else{
		    if(this.currentBtn == btnId){
			    this.contract();
			    this.currentBtn = '';
		        this.selectButton(-1);
		    }
		    else{
			    //expand menu div
			    this.currentBtn = btnId;
			    this.expand(btnId)
		    }
	    }
    }
}


wep.fadeBkg = function(darken){
    var overrideDocHeight
     overrideDocHeight = true;
    var styleObj = document.createElement("style");
    if(overrideDocHeight){
	    document.body.style.height='auto';
        if(navigator.userAgent.indexOf('IE') == -1){
            styleObj.setAttribute("type", "text/css");
            try{styleObj.innerHTML='html,body{height:auto;}';}catch(e){};
            document.getElementsByTagName("head").item(0).appendChild(styleObj);
        }
    }
	this.resizeFader();
	if(darken){
	    this.fader.style.display = 'inline';
	}
	else{
	    this.fader.style.display = 'none';
        if(overrideDocHeight){
            document.body.style.height='100%';
            if(navigator.userAgent.indexOf('IE') == -1){
                styleObj.setAttribute("type", "text/css");
                try{styleObj.innerHTML='html,body{height:100%;}'}catch(e){};
                document.getElementsByTagName("head").item(0).appendChild(styleObj);
            }
        }
	}
}

wep.resizeFader = function(){
	var pageHeight = document.documentElement.clientHeight;
	if (navigator.appName.indexOf("Microsoft")==-1) pageHeight = document.documentElement.scrollHeight;
	var faderHeight = pageHeight;
    var windowHeight = 0;
    var offset;
    if (parseInt(navigator.appVersion)>3) {
     if (navigator.appName.indexOf("Microsoft")==-1) {
      windowHeight = window.innerHeight;
      offset = 52;
     }
     else {
      windowHeight = document.body.offsetHeight;
      offset = 52;
     }
    }
	if(pageHeight < windowHeight) faderHeight = windowHeight;
	wep.fader.style.height = faderHeight - offset + 'px';      
}

wep.selectCategory = function(itemId){
    var item;
    for(var i=0; i<this.numMenuItems; i++){
        item = document.getElementById('wep_menuitem' + i);
        if(i==parseInt(itemId)){
            if(item.className.indexOf('wep_menuItemCat') > -1)
                item.className = 'wep_menuItemCatSelected';
            else
                item.className = 'wep_menuItemSubcatSelected';
        }
        else {
            if(item.className.indexOf('wep_menuItemCat') > -1)
                item.className = 'wep_menuItemCat';
            else
                item.className = 'wep_menuItemSubcat';
        }
    }
}

wep.selectButton = function(buttonId){
    var item;
    for(var i=0; i<this.numButtons; i++){
        item = document.getElementById('wep_button' + i);
        if(i==parseInt(buttonId)){
            item.className = 'wep_buttonSelected';
        }
        else {
            item.className = 'wep_button';
        }
    }
}

wep.openUrl = function(url,target){target=='blank' ? window.open(url) : document.location.href=url;}

wep.getSelectedCatId = function(){
    return eval('wde.' + this.currButtonType);
}

wep.replaceIFrame = function(iframe, url, title){
    var newIFrame;
    var parent = iframe.parentNode;
    parent.removeChild(iframe);
    newIFrame = document.createElement("iframe");
    newIFrame.setAttribute("id", "wep_expanderIframe");
    newIFrame.setAttribute("frameBorder", "0");
    newIFrame.setAttribute("src", url);
	newIFrame.setAttribute("title", title);
    parent.appendChild(newIFrame);
    this.expanderIframe = document.getElementById('wep_expanderIframe');
    this.expanderIframe.style.height = this.expandedHeight - 44 + 'px'
    this.expanderIframe.style.width = this.expandedWidth - 225 + 'px'
}

wep.createIframe = function(id, parent){
    var newIFrame;
    if(!document.getElementById(id)){
        newIFrame = document.createElement("iframe");
        newIFrame.setAttribute("id", id);
        newIFrame.setAttribute("frameBorder", "0");
        newIFrame.setAttribute("src", this.blankPageUrl);
        parent.appendChild(newIFrame);
    }
}

wep.extractDomain = function(url){
    var urlPat = /(\w+):\/\/([\w.]+)(\/?)(\S*)/;
    var matches = url.match(urlPat);
    if(matches != null){
        if(matches.length > 2)
            return matches[2];
    }
}

wep.displayMovies = function(showHide){
    var obs = document.getElementsByTagName('object');
    var viz = 'hidden';
    if(showHide)viz = 'visible';
    for(var i=0;i<obs.length;i++){
        if(obs[i].className.indexOf('wep_hide')>-1)obs[i].style.visibility = viz;
     }
}

wep.openWepPane = function(buttonType, catId){
    var btnId = this.getButtonId(buttonType);
    var btnNum = this.getButtonNum(buttonType);
    eval('this.originalCatId = wde.' + buttonType);
    eval('wde.' + buttonType + ' = \'' + catId + '\'');
    
    var weps=s_gi(this.omn.trackingAccount);
    weps.linkTrackVars='prop1,prop2,prop3,prop4,prop5,prop44';
    weps.prop1=this.omn.siteUrl;
    weps.prop2=this.omn.country;
    weps.prop3=this.omn.language;
    weps.prop4=this.omn.brand;
    weps.prop5=this.omn.audience;
    weps.prop44=btnId;
    weps.tl(this, 'o', 'openWepPane Call');
    this.showmenu(btnId, btnNum, buttonType);
}
wep.getButtonId = function(buttonType){
    for(var i=0;i<this.btnAry.length;i++){
        if(this.btnAry[i][1]==buttonType)
            return this.btnAry[i][0];
    }   
}
wep.getButtonNum = function(buttonType){
    for(var i=0;i<this.btnAry.length;i++){
        if(this.btnAry[i][1]==buttonType)
            return i;
    }   
}

