// default minimum version of flash required  on site.
var minFlash = 7;

//returns true if browser is IE
function isIE(){  return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);}

// returns numeric value for height.
// requires the appending of 'px' to
// the end for use in DOM/CSS methods.
function getElementHeight(el){
	var height;
	if (isIE()){ height = el.offsetHeight;
	}else{ height = el.clientHeight; }
	return height;
}

// returns numeric value for width.
// requires the appending of 'px' to
// the end for use in DOM/CSS methods.
function getElementWidth(el){
	var width;
	if (isIE()){ width = el.offsetWidth;
	}else{ width = el.clientWidth; }
	return width;
}

// included to allow DOM include of an element [node] after 
// the first childNode [referenceNode] of an element [parent].
function insertAfter(parent, node, referenceNode) {
  parent.insertBefore(node, referenceNode.nextSibling);
}


// checks current version of flash on client browser
// used to determine whether swf rendering should proceed.
// input null to pass back version supported. 
function checkFlash(min){
	var version = 0;
	if(!min) min = 10;
	if (navigator.plugins)  {
		if(navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var desc = navigator.plugins["Shockwave Flash"].description;
			version = parseInt(desc.substring(16));
		}
		else if(navigator.appVersion.indexOf("MSIE")>-1){
			// loop by Geoff Stearns (geoff@deconcept.com, http://blog.deconcept.com/)
			result = false;
	   		for(var i = min; i >= 3 && result != true; i--){
	    		execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
				version = i;
			}
		}
	}
	return version;
}


function rewriteHeading(){
	
	if(checkFlash() >= minFlash){
		var h1_node = document.getElementsByTagName("h1")[0];
		var fl_node = document.createElement("div");
		fl_node.style.height = "38px";
		fl_node.style.width = getElementWidth(h1_node) + "px";
		fl_node.setAttribute("id","flash_node");
		var w = getElementWidth(h1_node);
		var h = "38px";
		h1_node.parentNode.insertBefore(fl_node,h1_node);
		h1_node.parentNode.removeChild(h1_node);
		var queryvalue = h1_node.innerHTML;
		addFlash(minFlash, "/static/swf/main_title", 600, 38,"main_title,flash_node", "", "txt", queryvalue);
	}	
	
}

function rewriteTopmenu(){
	
	if(checkFlash() >= minFlash){
		var topMenu = document.getElementById("topMenu");
		anchors = topMenu.getElementsByTagName("a");
		var hrefs = new Array();
		var text = new Array();
		var hex = new Array();
		for (i=0; i<anchors.length; i++){
			hrefs[i] = anchors[i].href;
			text[i] = anchors[i].innerHTML;
			hex[i] = anchors[i].id;
		}
		var queryvalue= hrefs.join(",") + ",," + text.join(",") + ",," + hex.join(",");
		topMenu.innerHTML = "";
		topMenu.className = "topMenuFlash";
		addFlash(minFlash, "/static/swf/top_menu", 700, 85,"top_menu,topMenu", "", "menu", queryvalue);
	}	
	
}

function showElement(showElement, formId){
	
	if(showElement == true){
		document.getElementById(formId).style.display = 'block';
	}else{
		document.getElementById(formId).style.display = 'none';
	}
}
