


var site_root = 'http://206.102.88.36/_projects/els/site/';


//	Browser detection
var w3c = (document.getElementById) ? true : false;
var ie = (document.all && w3c) ? true : false;
var ie7 = (document.all && document.getElementById && window.XMLHttpRequest) ? true : false;
var ie6 = (ie && !ie7) ? true : false;
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;


// Styles applied by JavaScript before the page loads
var the_styles = '';
the_styles += '<style type="text/css">';
the_styles += '';
the_styles += '</style>';

document.write(the_styles);
// End styles applied by JavaScript before the page loads


// Flash content control.
var pages_with_flash = new Array();
pages_with_flash[0] = new Array('sitewide','flash_intro/dhi_intro.swf',256,523,'dhiIntro');

// Page elements declared for global use
var body_tag;
var mother_div;
var banner_div;
var content_div;
var subMenu_div;
var footer_div;

function init() {
	body_tag = document.getElementsByTagName('BODY')[0];
	mother_div = document.getElementById('mother');
	banner_div = document.getElementById('banner');
	content_div = document.getElementById('content');
	subMenu_div = document.getElementById('subMenu');
	footer_div = document.getElementById('footer');
	
	
	//startLists();
	
	runFlash();
	
	setPopupLinks();
	
}

if (w3c) { window.onload=init; }


function setPopupLinks() {
	var all_links = document.getElementsByTagName('A');
	
	for (var aa=0; aa<all_links.length; aa++) {
		this_targ = all_links[aa].getAttribute('target');
		if (this_targ) {
			//all_links[aa].attr = '';
			all_links[aa].onclick = openPopup;
		}
	}	
}



function openPopup () {
	if (!this.attr) {
		this.attr = 'menubar=yes,toolbar=no,status=yes,scrollbars=yes,resizable=yes,width=850,height=600';
	}
	this.attr += ',left=0,top=0,screenX=0,screenY=0';
	new_win = window.open(this,this.target,this.attr);
	new_win.focus();
}


function runFlash() {
	
	var this_url = location.href;
	var swf_url;
	var swf_name;
	var swf_height;
	var swf_width;
	var swf_element_id;
	var swf_element;
	
	for (var aa=0; aa<pages_with_flash.length; aa++) {
		
		swf_url = pages_with_flash[aa][0];
		swf_name = pages_with_flash[aa][1];
		swf_height = pages_with_flash[aa][2];
		swf_width = pages_with_flash[aa][3];
		swf_element_id = pages_with_flash[aa][4];
		swf_element = document.getElementById(swf_element_id);
		
		if ((this_url.indexOf(swf_url) != -1  || swf_url == 'sitewide') && swf_element) {
			
			swf_element.style.height = swf_height + 'px';
			swf_element.style.width = swf_width + 'px';
			insertFlash(swf_name,swf_height,swf_width,swf_element_id);
			
		}
	}
}


function ieHoverHelper(parent_id, hover_element, class_name) {
	if (ie6) {
		var rollies = document.getElementById(parent_id).getElementsByTagName(hover_element);
		
		for (aa=0; aa<rollies.length; aa++) {

			rollies[aa].onmouseenter = function() {
				if (this.className == '') {
					this.className = class_name;
				} else {
					this.className = class_name +  ' ' + this.className;
				}
			}
			rollies[aa].onmouseleave = function() {
				if (this.className == class_name) {
					this.className = '';
				} else {
					str = class_name+' ';
					if (this.className.indexOf(str) != -1) {
						remove_class = this.className.split(str);
						this.className = remove_class[1];
					}
				}
			}
		}
	}
}


//	FLASH PLAYER CHECK
//	Variable [hasRightVersion] will be set to true or false

var requiredVersion = 8;
var hasRightVersion = false;


if (navigator.plugins) {
	if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]
	&& navigator.mimeTypes["application/x-shockwave-flash"] 
	&& navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {		
		var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
		var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
		var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
		
	}
}

//	Write VBScript on IE Windows
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;
if (isIE && isWin){
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
  	document.write('on error resume next \n');
	document.write('hasFlash6 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
	document.write('hasFlash7 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
	document.write('hasFlash8 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');
	document.write('hasFlash9 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n');
	document.write('hasFlash10 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.10"))) \n');
	document.write('hasFlash11 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.11"))) \n');
	document.write('hasFlash12 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.12"))) \n');
  	document.write('</SCR' + 'IPT\> \n');
	
	for (var i=6; i <= requiredVersion; i++) {  
		if (eval("hasFlash" + i) == true) {
			flashVersion = i;
		}
	}
}

if (flashVersion >= requiredVersion) {
	hasRightVersion = true;
}//	End Flash Player check


var site_bg = '#000';
//	This function returns the <object> and <embed> tags in variable [oeTags]
function makeFlashTags(the_swf,the_height,the_width) {
	var flashTag;
	if (isIE && isWin) {
		flashTag = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
		+ 'width="'+the_width+'" height="'+the_height+'"'
		+ 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
		+ '<param name="movie" value="'+the_swf+'" />'
		+ '<param name="play" value="true" />'
		+ '<param name="quality" value="high" />'
		+ '<param name="menu" value="false" />'
		+ '<param name="bgcolor" value="' + site_bg + '" />'
		//	+ '<param name="loop" value="false" />'
		+ '</object>';
	} else {
		flashTag = '<embed src="'+the_swf+'"'
		+ 'width="'+the_width+'" height="'+the_height+'"'
		+ 'play="true"'
		+ 'quality="high"'
		+ 'menu="false"'
		+ 'bgcolor="' + site_bg + '"'
		+ 'type="application/x-shockwave-flash"'
		+ 'pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
		//	+ 'loop="false"'
		+ '</embed>';			
	}
	return flashTag;
	
}
//	This function swaps innerHTML of [the_container] with makeOETags()
function insertFlash(the_swf,the_height,the_width,the_container) {
	if (hasRightVersion) {
		document.getElementById(the_container).style.display = '';
		document.getElementById(the_container).innerHTML = makeFlashTags(the_swf,the_height,the_width);
		document.getElementById(the_container).style.display = 'block';
	}
}


