﻿// JScript File

    function getMap(sMapName )
    {
        if (sMapName != '')
        {
	        var duhWin = null; 
	        duhWin = window.open('PDF/' + sMapName, 'map','width=455,height=435,status,resizable');
	        duhWin.focus();
        }
    }

    function InitializeMenu(mn) {
	    window.status = "Menu Initialized";
    }
    function ItemChecked(mn, id, bChecked) {
	    var item = igmenu_getItemById(id);
	    if(bChecked)
		    alert(item.getText() + " is being checked on");
	    else
		    alert(item.getText() + " is being checked off");
    }
    function ItemClick(mn, id) {
	    var item = igmenu_getItemById(id);
	    var tag = item.getTag();
	    if(tag != null)
		    document.body.style.backgroundColor = tag;
	    return false;
    }
    function ItemHover(mn, id, bOver) {
	    var item = igmenu_getItemById(id);
	    if(bOver)
		    window.status = item.getText();
	    else
		    window.status = "";
	    return false;
    }
    function SubMenuDisplay(mn, id, bShow) {
	    if(bShow && (id == "UltraWebMenu1_1M" || id == "UltraWebMenu1_2M"))
		    igmenu_getElementById("DropDownList1").style.visibility = "hidden";
	    else
	    if(!bShow && (id == "UltraWebMenu1_1M" || id == "UltraWebMenu1_2M"))
		    igmenu_getElementById("DropDownList1").style.visibility = "visible";
	    return false;
    }	


    
    //Used to determine if the "Dock Panel" is pinned or not
        var _pinned = true;

        //Toggles the "Dock Panel" to either Pinned or Docked State
        function toggleDockPanel(){
            //var theMainMenuText = document.getElementById('theMainMenuText');
            var theListBar = document.getElementById('wb');
            var theImage = document.getElementById('theDockPanelImage');
            //var theFrameSet = top.frameset?top.frameset:top.document.getElementById("frameSet2");
            var theHeader = document.getElementById('Mainbg');
            var thedotdot = document.getElementById('dotdot');

            if (_pinned){
	            //theFrameSet.setAttribute("cols", "28, *");          		           		
	            
        		theListBar.style.display = 'inline';
	            theMainMenuText.style.display = '';
	            theImage.src='Images/menuIcons/pushPin.gif';
	            

            }else{
        		
	            //theFrameSet.setAttribute("cols", "30%, 70%");
	            theListBar.style.display = 'none';
	            theMainMenuText.style.display = 'none';
	            theImage.src='Images/menuIcons/pushPinClose.gif';		   
	            theHeader.style.backgroundRepeat = "no-repeat";
	            
        		
            }
            _pinned = !_pinned;
        }


  
  //Initialize
function init(){	
	var lnArr = getElementsByClass("ln");
	for (var i = 0; i < lnArr.length; i++)
		if(lnArr[i].addEventListener){
			lnArr[i].addEventListener('mouseover', function(event) { rollOver(this, 'ovr'); showRMNav(this,'ovr'); }, false);			
			lnArr[i].addEventListener('mouseout', function(event) { rollOver(this, 'out'); showRMNav(this,'out'); }, false);
			} else {
			lnArr[i].onmouseover = function() { rollOver(this, 'ovr'); showRMNav(this,'ovr'); };
			lnArr[i].onmouseout = function() { rollOver(this, 'out'); showRMNav(this,'out'); };
		}
	
	var bArr = getElementsByClass("mn");
	for (var i = 0; i < bArr.length; i++)
		if(bArr[i].addEventListener){
			bArr[i].addEventListener('mouseover', function(event) { rollOver(this, 'ovr'); }, false);
			bArr[i].addEventListener('mouseout', function(event) { rollOver(this, 'out'); }, false);
			} else {
			bArr[i].onmouseover = function() { rollOver(this, 'ovr'); };
			bArr[i].onmouseout = function() { rollOver(this, 'out'); };
		}

	var gArr = getElementsByClass("btnGo");
	for (var i = 0; i < gArr.length; i++)
		if(gArr[i].addEventListener){
			gArr[i].addEventListener('mouseover', function(event) { rollOver(this, 'ovr'); }, false);
			gArr[i].addEventListener('mouseout', function(event) { rollOver(this, 'out'); }, false);
			} else {
			gArr[i].onmouseover = function() { rollOver(this, 'ovr'); };
			gArr[i].onmouseout = function() { rollOver(this, 'out'); };
		}
}

// Image Rollovers
function rollOver(img, ovrOut){
	if(img.toString().indexOf('[object') == -1){img=getObj(img);}
	var imgMim = img.src.split('.')[img.src.split('.').length - 1];
	switch(ovrOut) {
		case 'ovr':
			if(img.src.substring(img.src.lastIndexOf(".")-3, img.src.lastIndexOf("."))!= "-on"){
			img.src = img.src.substring(0, img.src.lastIndexOf(".")) + "-on." + imgMim;}
		break;
		case 'out':
			if(img.src.substring(img.src.lastIndexOf(".")-3, img.src.lastIndexOf("."))== "-on"){
			img.src = img.src.substring(0, img.src.lastIndexOf(".")-3) + "." + imgMim;}
		break;
	}
}

function toggleToolbox(state) {
var foo;
	switch(state) {
		case 'open':
			foo = rollOver('toolboxClosed', 'out');
			getObj('toolboxClosed').style.display = 'none';
			getObj('toolboxOpen').style.display = 'block';
			getObj('toolbox').style.width = '229px';
			getObj('toolbox').style.left = '748px';
		break;
		case 'close':
			foo = rollOver('toolboxhdr', 'out');
			getObj('toolboxOpen').style.display = 'none';
			getObj('toolboxClosed').style.display = 'block';
			getObj('toolbox').style.width = '30px';
			getObj('toolbox').style.left = '947px';
		break;
	}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////                                                                                                          ////
////    BEGIN BROWSER DETECTION AND DETECTION OF OTHER ENVIRONMENTAL VARIABLES                                ////
////                                                                                                          ////
////    QUESTIONS? BUGS? COMMENTS? PLEASE EMAIL ME. jose@jcao.com, jose.caogarcia@ogilvy.com                  ////
////                                                                                                          ////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////


	//// CONVERT USERAGENT STRINGS TO LOWER CASE TO MAKE STRING SEARCHES EASIER
		var agt = navigator.userAgent.toLowerCase();
		var app = navigator.appName.toLowerCase();
		var sys = navigator.platform.toLowerCase();
		var opera_spoofing_ie = ((agt.indexOf('msie') != -1) || (agt.indexOf('opera') == -1));

	//// GET OPERATING SYSTEM
		var is_mac = (sys.indexOf('macppc')) != -1;

	//// DIFFERENTIATE BETWEEN OPERA 6 AND 7
		if (is_op6 == is_childNodes) var is_op7 = true;
		if (is_op6 == is_childNodes) var is_op6 = false;

	//// OBJECT-BASED BROWSER SNIFFING
		var is_op5 = ((window.opera && typeof(window.opera) != -1 && typeof(window.opera) != -1) && (window.print && typeof(window.print) != -1 && typeof(window.print) == -1) ? typeof(window.print) : window.print) ? false:true; 
		var is_op6 = ((window.opera && typeof(window.opera) != -1 && typeof(window.opera) != -1) && (window.print && typeof(window.print) != -1 && typeof(window.print) != -1) ? typeof(window.print) : window.print) ? true:false; 
		var is_childNodes = ((document.childNodes && typeof(document.childNodes)!= -1 && typeof(document.childNodes) != -1) ? typeof(document.childNodes) : document.childNodes) ? true : false; 

	//// NON-OBJECT BROWSER SNIFFING
		var is_moz = (app.indexOf('netscape')) != -1 && (navigator.appVersion.charAt(0) >= 5);
		var is_ie = (agt.indexOf('msie')) != -1;
		var is_netscape_4 = (app.indexOf('netscape')) != -1 && (navigator.appVersion.charAt(0) < 5);
		var is_opera = (agt.indexOf('opera')) != -1;
	//// BE SMARTER THAN BROWSERS SPOOFING IE/MOZ
		if (is_opera || is_moz || is_omniweb || is_safari || is_konq) var is_ie = false;
		if (is_safari) var is_moz = false;
	//// SPECIAL TEST FOR MAC IE...
		var is_macie = (is_mac) && (is_ie) ? true:false;
	//// SPECIAL TEST FOR WIN IE...
		var is_winie = (!is_mac) && (is_ie) ? true:false;
	//// TEST FOR ICAB
		var is_icab = (agt.indexOf(' icab ') != -1) ? true:false;
	//// TEST FOR ICAB VERSION
		if (is_icab) {
			var icab_version = parseFloat(agt.split(';')[1].substring(6, agt.split(';')[1].length));
		} else {
			var icab_version = false;
		}
	//// GET OPERA VERSION #
		if (is_opera) {
			var opera_version = parseFloat(agt.split(')')[1].substring(7, agt.split(')')[1].length));
		} else {
			var opera_version = false;
		}
		var is_opera2   = (agt.indexOf('opera 2') != -1 || agt.indexOf('opera/2') != -1) ? true:false; if (is_opera2) { opera_version = 2; };
		var is_opera3   = (agt.indexOf('opera 3') != -1 || agt.indexOf('opera/3') != -1) ? true:false; if (is_opera3) { opera_version = 3; };
		var is_opera4   = (agt.indexOf('opera 4') != -1 || agt.indexOf('opera/4') != -1) ? true:false; if (is_opera4) { opera_version = 4; };
		var is_opera5   = (agt.indexOf('opera 5') != -1 || agt.indexOf('opera/5') != -1) ? true:false; if (is_opera5) { opera_version = 5; };
		var is_opera6   = (agt.indexOf('opera 6') != -1 || agt.indexOf('opera/6') != -1) ? true:false; if (is_opera6) { opera_version = 6; };
		var is_opera7   = (agt.indexOf('opera 7') != -1 || agt.indexOf('opera/7') != -1) ? true:false; if (is_opera7) { opera_version = 7; };
		var is_opera8   = (agt.indexOf('opera 8') != -1 || agt.indexOf('opera/8') != -1) ? true:false; if (is_opera8) { opera_version = 8; };
		var is_khtml    = (navigator.vendor == 'KDE')?true:false;
		var is_konq     = (navigator.vendor == 'KDE') || (document.childNodes) && (!document.all) && (!navigator.taintEnabled) ? true:false;
		var is_safari   = (document.childNodes) && (!document.all) && (!navigator.taintEnabled) && (!navigator.accentColorName) ? true:false;
		var is_omniweb  = (document.childNodes) && (!document.all) && (!navigator.taintEnabled) && (navigator.accentColorName) ? true:false;

	//// GET IE VERSION #
		if (is_ie) {
			var ie_version = parseFloat(agt.split(';')[1].substring(6, agt.split(';')[1].length));
		} else {
			ie_version = false;
		}

	//// GET VIEWPORT WIDTH
		function viewportWidth(windowName) {
			if (!windowName) var windowName = 'self';
			if (self.innerHeight) {
				widthProperty = '.innerWidth';
			} else if (document.documentElement && document.documentElement.clientHeight) {
				widthProperty = '.document.documentElement.clientWidth';
			} else if (document.body) {
				widthProperty = '.document.body.clientWidth';
			}
			eval('var viewportWidth = ' + windowName + widthProperty);
			return viewportWidth;
		}

	//// GET VIEWPORT HEIGHT
		function viewportHeight(windowName) {
			if (!windowName) var windowName = 'self';
				if (self.innerHeight) {
					heightProperty = '.innerHeight';
				} else if (document.documentElement && document.documentElement.clientHeight) {
					heightProperty = '.document.documentElement.clientHeight';
				} else if (document.body) {
					heightProperty = '.document.body.clientHeight';
				}
			eval('var viewportHeight = ' + windowName + heightProperty);
			return viewportHeight;
		}
	

	//// GET ABSOLUTE SCREEN WIDTH
		function screenWidth() {
			var screenWidthValue = screen.width;
			return screenWidthValue;
		}

	//// GET ABSOLUTE SCREEN HEIGHT
		function screenHeight() {
			var screenHeightValue = screen.height;
			return screenHeightValue;
		}

	//// GET AVAILABLE SCREEN WIDTH
		function screenAvailWidth() {
			var screenWidthValue = screen.availWidth;
			return screenWidthValue;
		}

	//// GET AVAILABLE SCREEN HEIGHT
		function screenAvailHeight() {
			var screenHeightValue = screen.availHeight;
			return screenHeightValue;
		}

		function getElementDom(targetElement) {
			var elementsArray = new Array();
				for (var contLoop = 0; contLoop < targetElement.childNodes.length; contLoop++) {
					if (targetElement.childNodes[contLoop].nodeType == 1) {
						elementsArray[elementsArray.length++] = targetElement.childNodes[contLoop];
					}
				}
			return elementsArray;
		}


		function getRelatedDom(obj, upDown, nodesNum) {
		// make sure nodesNum is a number and not a string
		var nodesNum = parseInt(nodesNum);
			if (upDown == 'up') {
			// here we are moving UP the dom (towards the body tag, to general elements)
				var getParentStr = '.parentNode';
				var getFinalObj = '';
				for (loop = 0; loop <= nodesNum; loop++) { getFinalObj = getFinalObj + getParentStr; }
				var targetElement = eval('obj' + getFinalObj);
			} else {
			// here we are moving DOWN the dom (away from the body tag, to specific elements)
				var targetElement = getElementDom(obj)[nodesNum];
			}
		return targetElement;
		}


		function getWhichParentChild(obj) {
			var parentObj = obj.parentNode;
			var parentChildrenArr = getElementDom(parentObj);
			for (loop = 0; loop < parentChildrenArr.length; loop++) {
				if (obj == parentChildrenArr[loop]) {
					return loop;
				}
			}
		}


//--- General purpose functions ---//
function getObj(name){
  if(document.getElementById) this.obj = document.getElementById(name);
  else if(document.all) this.obj = document.all[name];
  return this.obj;
}
function getElementsByClass(val){ 
	var all = document.all || document.getElementsByTagName('*');
	var arr = [];
	for(var k = 0; k < all.length; k++) if(all[k].className == val) arr[arr.length] = all[k];
	return arr;
}
function getChildNodes(thisObj) {
	var elArray = new Array();
	for(var i = 0; i < thisObj.childNodes.length; i++)
		if (thisObj.childNodes[i].nodeType == 1) elArray[elArray.length++] = thisObj.childNodes[i];
	return elArray;
}
function addEvent(el, type, f, capture){ // Attach events to elements i.e. addEvent(window, 'load', function, false);
	if(el.addEventListener){ el.addEventListener(type, f, capture); return true; }
	else if(el.attachEvent){ var o = el.attachEvent('on' + type, f); return o; }
	else{ el['on' + type] = f; }
}



var menuKillTimer;
var mouseOutLag   = 250;

function showRMNav(thisObj, ovrOut) {
	var listObj = getRelatedDom(thisObj.parentNode, 'dn', 1); //langDDmenu
	switch(ovrOut) {
		case 'ovr':
			clearTimeout(menuKillTimer);
			getObj('langDDmenu').style.display = 'block';
			getObj('langDD').style.background = 'url(../assets/images/bkgnd_dropdown-on.gif) bottom no-repeat';
		break;
		case 'out':
			menuKillTimer = setTimeout('this.killMenu()', (mouseOutLag));
		break;
	}
	this.killMenu = function() {
		getObj('langDDmenu').style.display = 'none';
		getObj('langDD').style.background = 'url(../assets/images/bkgnd_dropdown.gif) top no-repeat';
	}
}

function swapDiv(thisObj, nxtdiv){
	var thisDiv = thisObj.parentNode.parentNode.parentNode;
	thisDiv.style.display = "none";
	getObj(nxtdiv).style.display = "block";
}

function goLink(input) {	
	
	window.location = unescape(getObj(input).value);
}

function swapCaseStudy(input) {
	if (caseStudy != ''){
		var caseStudy = getObj(input).value;
		getObj('caseStudyMain').innerHTML = getObj(caseStudy).innerHTML
	}
}

function showDiv(input) {		
		getObj('caseStudyMain').innerHTML = getObj(input).innerHTML
}

function searchFocusBlur(action) {
	var searchInput = document.searchForm.elements[0];
	switch (action) {
		case "focus":
			if (searchInput.value == 'Search Site') {searchInput.value = "";}
		break;
		case "blur":
			if (searchInput.value == '') {searchInput.value = 'Search Site';}
		break;
	}
}

function resetForm(formID){
	var items = getElementsByClass("ddSelected");
	for(var i = 0; i < items.length; i++){
		var copy = items[i].parentNode.id.split("-");
		getObj(copy[0]).value = "";
		items[i].innerHTML = "Select "+copy[0];
		items[i].style.textTransform = 'capitalize';
	}
	if(formID == 'contactFrm'){
		getObj('state-DD').style.display = 'block'
		getObj('stateAlternative').style.display = 'none'
	}
	getObj(formID).reset();
	return false;
}

function videoPopup(url){
	popwindow=window.open(url,'popname','scrollbars=0,menubar=0,resizable=0,status=0,width=680,height=470');
	if (window.focus) {popwindow.focus()}
}

function videoPopupSingle(url){
	popwindow=window.open(url,'popname','scrollbars=0,menubar=0,resizable=0,status=0,width=390,height=470');
	if (window.focus) {popwindow.focus()}
}

function emailPopup(url){
	popwindow=window.open(url,'popname','scrollbars=0,menubar=0,resizable=0,status=0,width=430,height=600');
	if (window.focus) {popwindow.focus()}

}

function careerPopup(url){
popwindow=window.open(url,'careers','width=675,height=675,scrollbars=yes,toolbar=no,status=yes,resizable=yes,top=5px,left=250px');	
	if (window.focus) {popwindow.focus()}

}

function helpMenuPopup(url){

    popwindow=window.open(url,'help','width=600,height=700,scrollbars=yes,toolbar=no,status=yes,resizable=yes,top=5px,left=250px');	
	if (window.focus) {popwindow.focus()}

}

var HelpWindowRef = null;

function ShowTileHelp(htmFilePath)
{
	if(HelpWindowRef!=null && !HelpWindowRef.closed)
	{
		HelpWindowRef.close();
	}	

	
	var windowName = "winHelpTile"
	var canvasSize = screen.availHeight;
	var winHeight = 550;
	
	var y = (canvasSize / 2) - 250;
	
	if (y < 0) {
		y = 100;
	}
	
	if ((canvasSize - 100) <= winHeight) {
		//Window is too big - scale it down
		winHeight = (canvasSize - 250);
	
	}
	
	var x = window.screenLeft + (document.body.clientWidth / 2) - 325;
	var positioning = ",left=" + x + ",top=" + y;
	
		
	var windowOptions = "height=" + winHeight + ",width=700,titlebar=no,toolbar=no,dependent=yes,status=no,location=no,menubar=no,resizable=no,scrollbars=yes" + positioning;
	HelpWindowRef = window.open(htmFilePath, windowName, windowOptions);
	
	if (event!=null)
		event.cancelBubble=true;
	document.onclick = CloseTileHelp;
		
}
function CloseTileHelp()
{
	if(HelpWindowRef==null)
		return;
		
	HelpWindowRef.close();
	HelpWindowRef=null;
}