FlashObject = function(swf, id, w, h, ver, c) {
	this.swf = swf;
	this.id = id;
	this.width = w;
	this.height = h;
	this.version = ver || 7; 
	this.align = "middle"; 
	this.redirect = "";
	this.sq = document.location.search.split("?")[1] || "";
	this.altTxt = "<a href='http://www.macromedia.com/go/getflashplayer'><img src='/elearning/images/noFlash.png' alt='Get Flash!' border='0'></a>";
	this.bypassTxt = "";
	this.params = new Object();
	this.variables = new Object();
	if (c) this.color = this.addParam('bgcolor', c);
	this.addParam('quality', 'best');
	this.doDetect = getQueryParamValue('detectflash');
}

FlashObject.prototype.addParam = function(name, value) {
	this.params[name] = value;
}

FlashObject.prototype.getParams = function() {
    return this.params;
}

FlashObject.prototype.getParam = function(name) {
    return this.params[name];
}

FlashObject.prototype.addVariable = function(name, value) {
	this.variables[name] = value;
}

FlashObject.prototype.getVariable = function(name) {
    return this.variables[name];
}

FlashObject.prototype.getVariables = function() {
    return this.variables;
}

FlashObject.prototype.getParamTags = function() {
    var paramTags = "";
    for (var param in this.getParams()) {
        paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
    }
    if (paramTags == "") {
        paramTags = null;
    }
    return paramTags;
}

FlashObject.prototype.getHTML = function() {
    var flashHTML = "";
    if (window.ActiveXObject && navigator.userAgent.indexOf('Mac') == -1) {
        flashHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '">';
        flashHTML += '<param name="movie" value="' + this.swf + '" />';
        if (this.getParamTags() != null) {
            flashHTML += this.getParamTags();
        }
        if (this.getVariablePairs() != null) {
            flashHTML += '<param name="flashVars" value="' + this.getVariablePairs() + '" />';
        }
        flashHTML += '</object>';
    }
    else {
        flashHTML += '<embed type="application/x-shockwave-flash" src="' + this.swf + '" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '"';
        for (var param in this.getParams()) {
            flashHTML += ' ' + param + '="' + this.getParam(param) + '"';
        }
        if (this.getVariablePairs() != null) {
            flashHTML += ' flashVars="' + this.getVariablePairs() + '"';
        }
        flashHTML += '></embed>';
    }
    return flashHTML;
}
FlashObject.prototype.getVariablePairs = function() {
    var variablePairs = new Array();
    for (var name in this.getVariables()) {
        variablePairs.push(name + "=" + escape(this.getVariable(name)));
    }
    if (variablePairs.length > 0) {
        return variablePairs.join("&");
    }
    else {
        return null;
    }
}
FlashObject.prototype.write = function(elementId) {
	if(detectFlash(this.version) || this.doDetect=='false') {
		if (elementId) {
			document.getElementById(elementId).innerHTML = this.getHTML();
		} else {
			document.write(this.getHTML());
		}
	} else {
		if (this.redirect != "") {
			document.location.replace(this.redirect);
		} else {
			if (elementId) {
				document.getElementById(elementId).innerHTML = this.altTxt +""+ this.bypassTxt;
			} else {
				document.write(this.altTxt +""+ this.bypassTxt);
			}
		}
	}		
}
function getFlashVersion() {
	var flashversion = 0;
	if (navigator.plugins && navigator.plugins.length) {
		var x = navigator.plugins["Shockwave Flash"];
		if(x){
			if (x.description) {
				var y = x.description;
	   			flashversion = y.charAt(y.indexOf('.')-1);
			}
		}
	} else {
		result = false;
	    for(var i = 15; i >= 3 && result != true; i--){
   			execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
   			flashversion = i;
   		}
	}
	return flashversion;
}
function detectFlash(ver) {	
	if (getFlashVersion() >= ver) {
		return true;
	} else {
		return false;
	}
}
function getQueryParamValue(param) {
	var q = document.location.search;
	var detectIndex = q.indexOf(param);
	var endIndex = (q.indexOf("&", detectIndex) != -1) ? q.indexOf("&", detectIndex) : q.length;
	if(q.length > 1 && detectIndex != -1) {
		return q.substring(q.indexOf("=", detectIndex)+1, endIndex);
	} else {
		return "";
	}
}
if(Array.prototype.push == null){
	Array.prototype.push = function(item){
		this[this.length] = item;
		return this.length;
	}
}

///////////////////

var divTitles = new Array('aboutusMenu','productsMenu','freetoolsMenu','solutionsMenu');
var timerTime = "";
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

function showMenu(button) {
	clearMenus();
	if(browser == 'Internet Explorer' && OS == 'Windows'){
		a = 0;
		p = 84;
		f = 176;
		u = 279;
		s = 376;	
	} else if(browser == 'Safari' && OS == 'Mac'){
		a = 10;
		p = 92;
		f = 178;
		u = 200;
		s = 269;
	} else {
		a = 9;
		p = 88;
		f = 181;
		u = 284;
		s = 382;
	}
	offset = (document.body.clientWidth - 770) / 2;
	if(button == 'aboutusMenu'){
		var x = offset + 25;
		//var x = ((document.body.offsetWidth-992)/2)+a;
	} else if(button == 'productsMenu'){
		var x = offset + 117;
		//var x = ((document.body.offsetWidth-992)/2)+p;
	} else if(button == 'freetoolsMenu'){
		var x = offset + 295;
		//var x = ((document.body.offsetWidth-992)/2)+f;
    	}  else if(button == 'solutionsMenu'){
		var x = offset + 214;
		//var x = ((document.body.offsetWidth-992)/2)+u;		
	} else if(button == 'supportMenu'){
		var x = offset + 390;
		//var x = ((document.body.offsetWidth-992)/2)+s;
	}
	//alert(x);
	
	var y = 20;
	eval ('document.getElementById(\''+button+'\').style.visibility = "visible";');
	eval ('document.getElementById(\''+button+'\').style.left = x + "px";');
	eval ('document.getElementById(\''+button+'\').style.top = y + "px";');
}

function clearMenus(){
	for (x=0; x < divTitles.length; x++){
		eval ('document.getElementById(\''+divTitles[x]+'\').style.visibility = "hidden";');
	}
}

function timeOut(t){
	if (timerTime != ""){
		clearTimeout(timerTime);
	}
    timerTime = setTimeout("clearMenus()", t);
}

function demoItNowLaunch(){
	demoItNowClose_QL();
	presentationClose();
	demoItNowSize();
	eval ('document.getElementById(\'demo_it_now\').style.zIndex = 9000;');
	eval ('document.getElementById(\'demo_it_now\').style.visibility = "visible";');
	window.document.demoItNow.SetVariable("openWindow" , 1);
}

function demoItNowClose(){
	eval ('document.getElementById(\'demo_it_now\').style.visibility = "hidden";');
	eval ('document.getElementById(\'demo_it_now\').style.zIndex = 0;');
	window.document.demoItNow.SetVariable("closeWindow" , 1);
}

function demoItNowSize(){
	var y = 110;
	var x = ((document.body.offsetWidth-720)/2);
	eval ('document.getElementById(\'demo_it_now\').style.left = x + "px";');
	eval ('document.getElementById(\'demo_it_now\').style.top = y + "px";');
}

//Added

function demoItNowLaunch_QL(course, cat){
	demoItNowClose();
	presentationClose();
	demoItNowSize_QL();
	eval ('document.getElementById(\'demo_it_now_QL\').style.zIndex = 9000;');
	eval ('document.getElementById(\'demo_it_now_QL\').style.visibility = "visible";');
	window.document.demoItNow_QL.SetVariable("OneCatSelected", cat);
	window.document.demoItNow_QL.SetVariable("OneCourseSelected", course);	
}

function demoItNowClose_QL(){
	eval ('document.getElementById(\'demo_it_now_QL\').style.visibility = "hidden";');
	eval ('document.getElementById(\'demo_it_now_QL\').style.zIndex = 0;');
	window.document.demoItNow_QL.SetVariable("closeWindow" , 1);
}

function demoItNowSize_QL(){
	var y = 110;
	var x = ((document.body.offsetWidth-720)/2);
	eval ('document.getElementById(\'demo_it_now_QL\').style.left = x + "px";');
	eval ('document.getElementById(\'demo_it_now_QL\').style.top = y + "px";');
}

//End Added

function presentationSizeLaunch(m,p){
	demoItNowClose();
	presentationSize();
	eval ('document.getElementById(\'presentation_Player\').style.zIndex = 9001;');
	eval ('document.getElementById(\'presentation_Player\').style.visibility = "visible";');
	window.document.presentationPlayer.SetVariable("market" , m);
	window.document.presentationPlayer.SetVariable("newPath" , p);
}

function presentationClose(){
	eval ('document.getElementById(\'presentation_Player\').style.visibility = "hidden";');
	eval ('document.getElementById(\'presentation_Player\').style.zIndex = 0;');
	window.document.presentationPlayer.SetVariable("newPath" , 1);
}

function presentationSize(){
	var y = 55;
	var x = ((document.body.offsetWidth-640)/2)+60;
	eval ('document.getElementById(\'presentation_Player\').style.left = x + "px";');
	eval ('document.getElementById(\'presentation_Player\').style.top = y + "px";');
}

function popup(url,high,wide){
	subwin=window.open(url,"","width=" + wide + ",height=" + high + ",location=no,toolbar=no,menubar=yes,status=yes,scrollbars=yes");
}
function doResizes(){
	//clearMenus();
	//demoItNowSize();
	//presentationSize();
}

function clearSearch() {
	document.getElementById('countrySuggestItems').style.display = 'none';
}

function getData(obj) {
	// finds all TDs inside obj
	var arrTD = obj.getElementsByTagName('td');
	// assigns TD value to form field
	document.getElementById('SearchKey').value = arrTD[0].innerHTML;
	// hides the DIV
	document.getElementById('countrySuggestItems').style.display = 'none';
	document.getElementById('searchButton').style.display = 'none';
	document.getElementById('searchingButton').style.display = 'inline';
	document.suggestForm.submit();
}

function htmlFormat(arr) {
	// formats arr as an HTML table
	var output = '<table class="suggestList" cellpadding="5" cellspacing="0" style="height: 30px; overflow: scroll; background-color: #ffffff; text-align: left;"><tbody>';
	for (var i=0;i<arr.length;i++) {
		output = output + '<tr onmouseover="this.style.backgroundColor=0x11509F;this.style.color=0xFFFFFF;" onmouseout="this.style.backgroundColor=0xffffff;this.style.color=0x000000;" onMouseDown="getData(this)" class="suggestItem">' + '<td>' + arr[i] + '</td>' + '</tr>';
	}
	output = output + '</tbody></table>';
	return output;
}
	
function doSearch(searchString) {
	//alert(document.body.clientWidth);
	var curWidth = document.body.clientWidth;
	var curleft = 0;
	var objWidth = document.getElementById('SearchKey').offsetWidth;
	obj = document.getElementById('SearchKey');
	do {
		curleft += obj.offsetLeft;
	}
	while (obj = obj.offsetParent);
	newRight = document.getElementById('countrySuggestItems').style.left;
	//newRight = 61;
	document.getElementById('countrySuggestItems').style.left = newRight; 
	document.getElementById('countrySuggestItems').style.border = "solid 1px #254061"; 
	var sugItems = document.getElementById('countrySuggestItems');
	var timeStamp = new Date().getTime();
	if(searchString.length>0) {
		// creates XMLHttpRequest object
		if (window.XMLHttpRequest) {
			req = new XMLHttpRequest();
		}
		else if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}		// request countries.cfm passing searchString as an URL parameter
		req.open("GET", "/countries.cfm?search=" + searchString + "&time=" + timeStamp, true);
		req.send(null);
		// gives the request object an event handler
		req.onreadystatechange = function() {
			if ((req.readyState == 4) && (req.status == 200)) {
				// creates an array from returned list
				var arr = req.responseText.split(';');
				if (arr.length >= 1) {
					// formats array as an HTML table and shows the DIV
					sugItems.innerHTML = htmlFormat(arr);
					sugItems.style.display = 'block';
				}
				// No items found? Hides the DIV
				else sugItems.style.display = 'none';
				return;
			};
		}
	}
	// Empty searchString? Hides the DIV
	else sugItems.style.display = 'none';
	return;
}	
