var imgHomeOn = new Image();
var imgHomeOff = new Image();
var imgRealWorldOn = new Image();
var imgRealWorldOff = new Image();
var imgIndustriesOn = new Image();
var imgIndustriesOff = new Image();
var imgProductsOn = new Image();
var imgProductsOff = new Image();
var imgSupportNavOn = new Image();
var imgSupportNavOff = new Image();
var imgNewsOn = new Image();
var imgNewsOff = new Image();
var imgContactOn = new Image();
var imgContactOff = new Image();


var imgOverviewOn = new Image();
var imgOverviewOff = new Image();
var imgSpecOn = new Image();
var imgSpecOff = new Image();
var imgSupportOn = new Image();
var imgSupportOff = new Image();

imgHomeOn.src = strPageRoot + "img/nav_home_on.gif";

imgHomeOff.src = strPageRoot + "img/nav_home.gif";
imgRealWorldOn.src = strPageRoot + "img/nav_real_world_on.gif";
imgRealWorldOff.src = strPageRoot + "img/nav_real_world.gif";
imgIndustriesOn.src = strPageRoot + "img/nav_industries_on.gif";
imgIndustriesOff.src = strPageRoot + "img/nav_industries.gif";
imgProductsOn.src = strPageRoot + "img/nav_products_on.gif";
imgProductsOff.src = strPageRoot + "img/nav_products.gif";
imgSupportNavOn.src = strPageRoot + "img/nav_support_on.gif";
imgSupportNavOff.src = strPageRoot + "img/nav_support.gif";
imgNewsOn.src = strPageRoot + "img/nav_news_on.gif";
imgNewsOff.src = strPageRoot + "img/nav_news.gif";
imgContactOn.src = strPageRoot + "img/nav_contact_on.gif";
imgContactOff.src = strPageRoot + "img/nav_contact.gif";

imgOverviewOn.src = strPageRoot + "img/h_prod_overview_on.gif";
imgOverviewOff.src = strPageRoot + "img/h_prod_overview.gif";
imgSpecOn.src = strPageRoot + "img/h_prod_specs_on.gif";
imgSpecOff.src = strPageRoot + "img/h_prod_specs.gif";
imgSupportOn.src = strPageRoot + "img/h_prod_support_on.gif";
imgSupportOff.src = strPageRoot + "img/h_prod_support.gif";

var strlang = "";
var strseason = "";
var currentTime = new Date();
var randTime = currentTime.getTime();
var intHomeVidIndex = 0;
var intHomePageVideos = 2;
var boolAllCollapsed = true;
var strModalBgID = "modalBg";
var strModalBgSelector = "#" + strModalBgID;
var strModalWindowClass = "modalWindow";
var strCurrentModalWindowID;
var boolRwsCollapsed = true;

function fControlEnterKey(e) {
	var output = true;
//alert("e = " + e + "\n");
	if(fEnterKeyPressed(e)) {
		output = fSubmitForm();
	}

	return output;
}

/*
	Validate the form.  If valid, submit the form and proceed user to the main signup form.
*/
function fSubmitForm() {
	var boolValid = true;
	var strError = "";
	var strNameFieldID = "txtName";
	var oNameField = document.getElementById(strNameFieldID)
	var strName = "";
	var strEmailFieldID = "txtEmail";
	var oEmailField = document.getElementById(strEmailFieldID);
	var strEmail = "";
	
	strError += fVerifyInput(strNameFieldID, "Ingresa tu nombre.\n");
	strError += fVerifyInput(strEmailFieldID, "Ingresa tu dirección de correo electrónico.\n");

	if(strError == "") {
		strEmail = fTrim(oEmailField.value);
		strName = fTrim(oNameField.value);
		if(!fVerifyEmail(strEmail)) {
			strError += "Especifica una dirección de correo electrónico válida.\n";
			boolValid = false;
		}
	} else {
		boolValid = false;
	}

	if(boolValid) {
		//	Proceed to main signup form.
		var strAjaxData = "name=" + escape(strName) + "&email=" + escape(strEmail);
		$.ajax({
			type: "POST",
			url: strWebRoot+"proceedToSignup.php",
			data: strAjaxData,
			cache: false,
			success: function(msg){
//alert("strName = " + strName + "\nstrEmail = " + strEmail + "\nstrAjaxData = " + strAjaxData + "\nmsg = " + msg + "\n");
				if(msg == "success") {
					location.href = strWebRoot+"signup.php";
				} else {
					alert(msg);
				}
			},
			error: function (xhr, ajaxOptions, thrownError){
				
			}
		});
	} else {
		alert(strError);
	}

	return false;
}

/*
	Return a boolean indicating whether or not an input string ends with another input string.
	@param aHaystack the string in which the search will occur
	@param aNeedle the string to search for
*/
function fEndsWith(aHaystack, aNeedle) {
	return aHaystack.indexOf(aNeedle) == aHaystack.length - aNeedle.length;
}

/*
 * Return a boolean indicating whether the user pressed the enter key on their keyboard.  Normally this function will be used in the onkeypress event for <input> 
 * elements.
 * @param e an event
 */
function fEnterKeyPressed(e){
    var key;
    if(window.event) {  //  IE
        key = window.event.keyCode;
    } else {    //  Firefox
        key = e.which;
    }
    return key == 13;	//  Code for the enter key
}

/*
	Return the HTML code necessary to embed an SWF, utilizing a cachebuster to prevent it from getting cached.
	@param aPath the path and filename of the Flash
	@param anID an ID to assign to the HTML object/embed tags
	@param aWidth the width of the Flash
	@param aHeight the height of the Flash
	@param strFlashvars the Flashvars
	@param anAlignment where to align the flash
	@param aQuality the quality, defaults to "high"
	@param aWMode the wmode, defaults to "transparent"
	@param aBgColor the background color, defaults to "ffffff"
*/
function fGetFlash(aPath, anID, aWidth, aHeight, strFlashvars, anAlignment, aQuality, aWMode, aBgColor) {
	var boolID = !(anID == undefined || anID == null || anID == "");
	var boolFlashvars = !(strFlashvars == undefined || strFlashvars == null || strFlashvars == "");
	var boolAlignment = !(anAlignment == undefined || anAlignment == null || anAlignment == "");
	if(aQuality == undefined || aQuality == null || aQuality == "") {
		aQuality = "high";
	}
	if(aWMode == undefined || aWMode == null || aWMode == "") {
		aWMode = "transparent";
	}
	if(aBgColor == undefined || aBgColor == null || aBgColor == "") {
		aBgColor = "ffffff";
	}
	if(aBgColor.substr(0, 1) != "#") {
		aBgColor = "#" + aBgColor;
	}
	var strCacheBuster = "?cacheBuster=" + fGetRandomInteger(0, 999);
	var strPath = aPath + strCacheBuster;
	
	//	Assemble the HTML string.
	var output = "";
	output += "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"" + aWidth + "\" height=\"" + aHeight + "\"";
	if(boolID) {
		output += " id=\"" + anID + "\"";
	}
	if(boolAlignment) {
		output += " align=\"" + anAlignment + "\"";
	}
	output += ">\n";
	output += "<param name=\"allowScriptAccess\" value=\"sameDomain\" />\n";
	output += "<param name=\"Movie\" value=\"" + strPath + "\" />\n";
	output += "<param name=\"quality\" value=\"" + aQuality + "\" />\n";
	output += "<param name=\"wmode\" value=\"" + aWMode + "\" />\n";
	output += "<param name=\"bgcolor\" value=\"" + aBgColor + "\">\n";
	if(boolFlashvars) {
		output += "<param name=\"Flashvars\" value=\"" + strFlashvars + "\" />\n";
	}
	output += "<embed src=\"" + strPath + "\"";
	if(boolFlashvars) {
		output += " flashvars=\"" + strFlashvars + "\"";
	}
	output += " wmode=\"" + aWMode + "\" bgcolor=\"" + aBgColor + "\" quality=\"" + aQuality + "\" width=\"" + aWidth + "\" height=\"" + aHeight + "\"";
	if(boolID) {
		output += " name=\"" + anID + "\"";
	}
	if(boolAlignment) {
		output += " align=\"" + anAlignment + "\"";
	}
	output += " allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />\n";
	output += "</object>";
	
	return output;
}

function fGetNoFlash(anImgPath, aWidth, aHeight, anAlt) {
	return "<a href=\"http://www.adobe.com/products/flashplayer/\" target=\"_blank\"><img src=\"" + anImgPath + "\" height=\"" + aHeight + "\" width=\"" + aWidth + "\" alt=\"" + anAlt + "\" border=\"0\" /></a>";
}

/*
	Implode an array into a grammatically correct string containing the items of the array, and then return the string.  If the array has no items or is null, return an empty string.  If it
	has one item, return the text of that one item.  If it has two items, return the text of both items separated by " and ".  If there are more than two items, return a string formatted as
	follows: "item1, item2 and item3"
	@param anArray an array of stuff
*/
function fImplodeGrammatically(anArray) {
	output = "";
	if(anArray != null && anArray != undefined) {
		var intItems = anArray.length;
		if(intItems > 0) {	//	There is at least one item in the array.
			strItem = anArray[0];
			output += strItem;
			if(intItems == 2) {
				output += " and " . anArray[1];
			} else if(intItems > 2) {
				for(i = 1; i < intItems; i++) {
					strItem = anArray[i];
					if(i == intItems - 1) {	//	For the last iteration, separate this item with an " and " instead of a comma.
						output += " and ";
					} else {
						output += ", ";
					}
					output += strItem;
				}
			}
		}
	}
	
	return output;
}

/*
	Toggle the next or previous video, and update the link text accordingly.
	@param oLink the link that was clicked to trigger this function call
*/
function fNextPrevHomeVid(oLink) {
	//alert(intHomeVidIndex + "==" + (parseInt(intHomePageVideos) -1));
	if(intHomeVidIndex == intHomePageVideos - 1) {
		intHomeVidIndex = 0;
	} else {
		intHomeVidIndex++;
	}
	fUpdateHomeVidNextPrevLink(oLink);
	//alert("intHomeVidIndex: "+intHomeVidIndex);

	fSelectHomeVid(intHomeVidIndex);
	return false;
}

/*
 * Select a video on the homepage for the user to see.  Each index in the array contains an inner array which contains the image source and the href attribute of the 
 * link.
 * @param aVidIndex the index of the video in the array.
 */
function fSelectHomeVid(aVidIndex) {
//	alert(aVidIndex);
	intHomeVidIndex = aVidIndex;
	if(aVidIndex == null || aVidIndex == undefined) {
		intHomeVidIndex = 1;
	}
	var strHref = "javascript:fPopHomeVideo(" + intHomeVidIndex + ");";
//alert("intHomeVidIndex = " + intHomeVidIndex + "\nstrHref = " + strHref + "\n");
	var arrVidImages = new Array();
	arrVidImages[0] = "img/img_homeVid2.jpg";
	arrVidImages[1] = "img/img_homeVid1.jpg";
	
	
	//	Video toggler links functionality
	var strActiveClass = "cssGrey";
	$(".lnkHomeVidToggler").removeClass(strActiveClass);
	$("#lnkHomeVid" + intHomeVidIndex).addClass(strActiveClass);
	fUpdateHomeVidNextPrevLink();
	
	//	Video update functionality
	document.getElementById("imgHomeVid").src = arrVidImages[intHomeVidIndex];
	document.getElementById("lnkHomeVid").href = strHref;
	/*
	if(aVidIndex==0){
		_gaq.push(['_trackEvent', 'Video Player', 'Play', 'Product Video']);
	} else {
		_gaq.push(['_trackEvent', 'Video Player', 'Play', 'C12 Demo Video']);
	}
	*/
	return false;
}

function fShowModalBg() {	//	Create and display the transparent background.  When you click it, the modal window should disappear.
	var oModalBg = document.createElement("div");
	oModalBg.setAttribute("id", strModalBgID);
//alert("oModalBg = " + oModalBg + "\n");
	var intHeight = $("#wrapper").outerHeight();
//alert("intHeight = " + intHeight + "\n");
	document.body.appendChild(oModalBg);
	$(strModalBgSelector).height(intHeight);
	
	oModalBg.onclick = function() {
		return fCloseModalWindow();
	}
}

/*
	Display a modal window containing the details of the real world story.
	@param anImage the large image of for the real world story
	@param indicatorIcons the HTML markup for the indicator icons
	@param indicatorDescriptions the text for the indicator descriptions
	@param aTitle the title of the real world story
	@param aStory the meat of the story
*/
function fShowRwsDetail(anImage, indicatorIcons, indicatorDescriptions, aTitle, aStory) {
	fShowModalBg();
	var oModal = document.createElement("div");
	oModal.setAttribute("id", "rwsDetail");
	oModal.setAttribute("class", strModalWindowClass);
	strCurrentModalWindowID = "rwsDetail";
	
//console.log("anImage = " + anImage + "\nindicatorIcons = " + indicatorIcons + "\nindicatorDescriptions = " + indicatorDescriptions + "\naTitle = " + aTitle + "\naStory = " + aStory + "\n");
	var strHtml = "";
	strHtml += "<a href=\"#\" onclick=\"return fCloseModalWindow('rwsDetail');\" style=\"float: right;\"><img src=\"img/modal/btn_modalClose.gif\" height=\"11\" width=\"11\" alt=\"\" border=\"0\" /></a>\n";
	strHtml += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"565\" class=\"cssPaddingTop7\">\n";
	strHtml += "<tr>\n";
	strHtml += "<td width=\"241\" style=\"padding-right: 13px;\">";
	strHtml += "<img src=\"" + anImage + "\" alt=\"\" border=\"0\" class=\"cssDisplayBlock\" />";
	strHtml += indicatorIcons;
	strHtml += "<div style=\"width: 180px;\">" + indicatorDescriptions + "</div>";
	strHtml += "</td>\n";
	strHtml += "<td width=\"311\">";
	strHtml += "<div class=\"title\">" + aTitle + "</div>";
	strHtml += aStory;
	strHtml += "</td>\n";
	strHtml += "</tr>\n";
	strHtml += "</table>\n";
	oModal.innerHTML = strHtml;
	
	document.body.appendChild(oModal);
	
	return true;
}

/*
	Close any modal windows with the specified ID.  If no ID was specified, close all divs with a class of "modalWindow".  Also close the transparent modal overlay.
	@param anID the ID of the modal window to close.
*/
function fCloseModalWindow(anID) {
	var strSelector = "#" + anID;
	if(anID == null || anID == undefined) {
		if(strCurrentModalWindowID == null || strCurrentModalWindowID == undefined) {
			strSelector = "." + strModalWindowClass;
		} else {
			strSelector = "#" + strCurrentModalWindowID;
		}
	}
	$(strSelector).remove();
	$(strModalBgSelector).remove();
	strCurrentModalWindowID = undefined;
	
	return false;
}

/*
	If hidden, reveal all of the Real World Stories.  If shown, hide all Real World Stories except for the first four.
	@param aLink the link object that called this function
*/
function fShowHideRws(aLink) {
	var strHiddenClass = "hidden";
	var strRwsListID = "storyList";
	var strRwsSelector = "#" + strRwsListID + " li";
	var strLinkText = "Visualiza todas las soluciones &raquo;";
	
	if(boolRwsCollapsed) {	//	Reveal all of them.
		$(strRwsSelector).removeClass(strHiddenClass);
		strLinkText = "Colapsar las soluciones &raquo;";
	} else {	//	Hide all but the first ones.
		var intCount = 0;
		$(strRwsSelector).each(function() {
			if($(this).parent().attr("id") == strRwsListID) {	//	This is a Real World Story <li> element, not one of the nested <li> tags.
				if(intCount > 3) {	//	Start hiding them!
					$(this).addClass("hidden");
				}
				intCount++;
			}
		});
	}
	
	aLink.innerHTML = strLinkText;	
	boolRwsCollapsed = !boolRwsCollapsed;
	return false;
}

//Recursive function that returns the passed string with leading and trailing white space removed.
function fTrim(aString) {
var output = aString;

if(aString != undefined && aString != "") {
	var intFirstSpaceIndex = aString.indexOf(" ");
	var intLastSpaceIndex = aString.lastIndexOf(" ");
	var boolLeadingWhiteSpace = intFirstSpaceIndex == 0;
	var intLastCharIndex = aString.length - 1;
	var boolTrailingWhiteSpace = intLastSpaceIndex == intLastCharIndex;
		
//alert("aString = " + aString + "\nintLastSpaceIndex = " + intLastSpaceIndex + "\nboolTrailingWhiteSpace = " + boolTrailingWhiteSpace + "\n");
	if(boolLeadingWhiteSpace) {
		output = fTrim(aString.substr(1));
	} else if(boolTrailingWhiteSpace) {
		output = fTrim(aString.substr(0, intLastCharIndex));
	} else {	//	The base case: no leading or trailing whitespace exists
		output = aString;
	}
}

return output;
}

function fWriteButtonFlash() {
	document.writeln("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"175\" height=\"97\" id=\"armor_home\" align=\"middle\" >");
	document.writeln("<param name=\"allowScriptAccess\" value=\"sameDomain\" />");
	document.writeln("<param name=\"movie\" value=\""+strPageRoot+"flash/lessons_learned_button.swf\" />");
	document.writeln("<param name=\"quality\" value=\"high\" />");
	document.writeln("<param name=\"wmode\" value=\"transparent\" />");
	document.writeln("<embed src=\""+strPageRoot+"flash/lessons_learned_button.swf\" wmode=\"transparent\" quality=\"high\" width=\"175\" height=\"97\" name=\"flash_button\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />");
	document.writeln("<\/object>");
}

function fWriteHomeFlash() {
	document.writeln('<div class="flashContainer">');
	fWriteFlash("flash/home/home_flash.swf", "drs_home", 851, 295);
	document.writeln('</div>');
}

function fWriteHomeNoFlash() {
	document.writeln('<div class="flashContainer">');
	fWriteNoFlash("flash/home/static.jpg", 851, 295, "THE COMMUNICATIONS-EQUIPPED ARMOR X10gx.");
	document.writeln('</div>');
}


function fWriteMapFlash() {
	fWriteFlash(strPageRoot + "flash/drs_map2.swf", "armor_map", 800, 475);
}

function fWriteSideFeaturesFlash() {
	document.writeln('<div class="flashContainer">');
	fWriteFlash(strWebRoot + "flash/specs.swf", "drs_specs", 183, 560, "siteRootPath=" + strWebRoot);
//alert("strWebRoot = " + strWebRoot + "\n");
	document.writeln('</div>');
}

function fWriteSideFeaturesNoFlash() {
	document.writeln('<div class="flashContainer">');
	document.writeln('<img src="img/shim.gif" height="450" width="152" alt="" border="0" />');
	document.writeln('</div>');
}

function fWriteMilitaryIndustryFlash() {
	document.writeln('<div class="flashContainer">');
	document.writeln('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="870" height="195" id="hms_home" align="middle" />');
	document.writeln('<param name="allowScriptAccess" value="sameDomain" />');
	document.writeln('<param name="Movie" value="flash/industries_military_01.swf?cacheBuster=' + randTime + '" />');
	document.writeln('<param name="quality" value="high" />');
	document.writeln('<param name="wmode" value="transparent" />');
	document.writeln('<param name="bgcolor" value="#ffffff">');
	document.writeln('<embed src="flash/industries_military_01.swf?cacheBuster=' + randTime + '" wmode="transparent" bgcolor="#ffffff" quality="high" width="870" height="195" name="hms_home" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.writeln('</object>');
	document.writeln('</div>');
}

function fWriteMilitaryIndustryNoFlash() {
	document.writeln('<div class="flashContainer">');
	document.writeln('<img src="img/industries_military_no_flash.jpg" height="195" width="870" alt="" border="0" />');
	document.writeln('</div>');
}

function fWriteFederalIndustryFlash() {
	document.writeln('<div class="flashContainer">');
	document.writeln('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="870" height="195" id="hms_home" align="middle" />');
	document.writeln('<param name="allowScriptAccess" value="sameDomain" />');
	document.writeln('<param name="Movie" value="flash/industries_public_federal_01.swf?cacheBuster=' + randTime + '" />');
	document.writeln('<param name="quality" value="high" />');
	document.writeln('<param name="wmode" value="transparent" />');
	document.writeln('<param name="bgcolor" value="#ffffff">');
	document.writeln('<embed src="flash/industries_public_federal_01.swf?cacheBuster=' + randTime + '" wmode="transparent" bgcolor="#ffffff" quality="high" width="870" height="195" name="hms_home" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.writeln('</object>');
	document.writeln('</div>');
}

function fWriteFederalIndustryNoFlash() {
	document.writeln('<div class="flashContainer">');
	document.writeln('<img src="img/industries_federal_no_flash.jpg" height="195" width="870" alt="" border="0" />');
	document.writeln('</div>');
}

function fWritePublicIndustryFlash() {
	document.writeln('<div class="flashContainer">');
	document.writeln('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="870" height="195" id="hms_home" align="middle" />');
	document.writeln('<param name="allowScriptAccess" value="sameDomain" />');
	document.writeln('<param name="Movie" value="flash/industries_public_safety_01.swf?cacheBuster=' + randTime + '" />');
	document.writeln('<param name="quality" value="high" />');
	document.writeln('<param name="wmode" value="transparent" />');
	document.writeln('<param name="bgcolor" value="#ffffff">');
	document.writeln('<embed src="flash/industries_public_safety_01.swf?cacheBuster=' + randTime + '" wmode="transparent" bgcolor="#ffffff" quality="high" width="870" height="195" name="hms_home" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.writeln('</object>');
	document.writeln('</div>');
}

function fWritePublicIndustryNoFlash() {
	document.writeln('<div class="flashContainer">');
	document.writeln('<img src="img/industries_public_no_flash.jpg" height="195" width="870" alt="" border="0" />');
	document.writeln('</div>');
}

function fWriteTransportationIndustryFlash() {
	document.writeln('<div class="flashContainer">');
	document.writeln('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="870" height="195" id="hms_home" align="middle" />');
	document.writeln('<param name="allowScriptAccess" value="sameDomain" />');
	document.writeln('<param name="Movie" value="flash/industries_transportation_01.swf?cacheBuster=' + randTime + '" />');
	document.writeln('<param name="quality" value="high" />');
	document.writeln('<param name="wmode" value="transparent" />');
	document.writeln('<param name="bgcolor" value="#ffffff">');
	document.writeln('<embed src="flash/industries_transportation_01.swf?cacheBuster=' + randTime + '" wmode="transparent" bgcolor="#ffffff" quality="high" width="870" height="195" name="hms_home" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.writeln('</object>');
	document.writeln('</div>');
}

function fWriteTransportationIndustryNoFlash() {
	document.writeln('<div class="flashContainer">');
	document.writeln('<img src="img/industries_transportation_no_flash.jpg" height="195" width="870" alt="" border="0" />');
	document.writeln('</div>');
}

function fWriteHeavyIndustryFlash() {
	document.writeln('<div class="flashContainer">');
	document.writeln('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="870" height="195" id="hms_home" align="middle" />');
	document.writeln('<param name="allowScriptAccess" value="sameDomain" />');
	document.writeln('<param name="Movie" value="flash/industries_heavy_industry_01.swf?cacheBuster=' + randTime + '" />');
	document.writeln('<param name="quality" value="high" />');
	document.writeln('<param name="wmode" value="transparent" />');
	document.writeln('<param name="bgcolor" value="#ffffff">');
	document.writeln('<embed src="flash/industries_heavy_industry_01.swf?cacheBuster=' + randTime + '" wmode="transparent" bgcolor="#ffffff" quality="high" width="870" height="195" name="hms_home" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.writeln('</object>');
	document.writeln('</div>');
}

function fWriteHeavyIndustryNoFlash() {
	document.writeln('<div class="flashContainer">');
	document.writeln('<img src="img/industries_heavy_no_flash.jpg" height="195" width="870" alt="" border="0" />');
	document.writeln('</div>');
}

function fWriteFieldIndustryFlash() {
	document.writeln('<div class="flashContainer">');
	document.writeln('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="870" height="195" id="hms_home" align="middle" />');
	document.writeln('<param name="allowScriptAccess" value="sameDomain" />');
	document.writeln('<param name="Movie" value="flash/industries_field_service_01.swf?cacheBuster=' + randTime + '" />');
	document.writeln('<param name="quality" value="high" />');
	document.writeln('<param name="wmode" value="transparent" />');
	document.writeln('<param name="bgcolor" value="#ffffff">');
	document.writeln('<embed src="flash/industries_field_service_01.swf?cacheBuster=' + randTime + '" wmode="transparent" bgcolor="#ffffff" quality="high" width="870" height="195" name="hms_home" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.writeln('</object>');
	document.writeln('</div>');
}

function fWriteFieldIndustryNoFlash() {
	document.writeln('<div class="flashContainer">');
	document.writeln('<img src="img/industries_heavy_no_flash.jpg" height="195" width="870" alt="" border="0" />');
	document.writeln('</div>');
}

function fWritec12Flash() {
	document.writeln('<div class="flashContainer">');
	fWriteFlash("flash/c12_product_viewer.swf", "drs_c12", 692, 350);
	document.writeln('</div>');
}

function fWritec12NoFlash() {
	document.writeln('<div class="flashContainer">');
	document.writeln('<img src="img/c12_noflash.jpg" height="350" width="692" alt="" border="0" />');
	document.writeln('</div>');
}

function fWriteSplashFlash(strFlash,idFlash,widthFlash,heightFlash) {
	document.writeln('<div class="splashFlash">');
	fWriteFlash("/flash/splash/"+strFlash, idFlash,widthFlash, heightFlash);
	document.writeln('</div>');
}

function fWriteSplashNoFlash(strImg,strHeight,strWidth,strAlt) {
	document.writeln('<div class="splashFlash">');
	document.writeln('<img src="/img/splash/'+strImg+'" height="'+strHeight+'" width="'+strWidth+'" alt="'+strAlt+'" border="0" />');
	document.writeln('</div>');
}

function fWritex10Flash() {
	document.writeln('<div class="flashContainer">');
	fWriteFlash("flash/X10_product_viewer.swf", "drs_x10", 692, 350);
	document.writeln('</div>');
}

function fWritex10NoFlash() {
	document.writeln('<div class="flashContainer">');
	fWriteNoFlash("img/x10_noflash.jpg", 691, 351, "");
	document.writeln('</div>');
}

function fWriteX10GxFlash() {
	document.writeln('<div class="flashContainer">');
	//fWriteFlash("flash/X10gx_product_viewer.swf", "drs_x10gx", 692, 350);
	fWriteFlash("flash/360viewer_DRS_x10gx_10-14-10_SPECS.swf", "drs_x10gx", 692, 350);
	document.writeln('</div>');
}

function fWriteX10GxNoFlash() {
	document.writeln('<div class="flashContainer">');
	fWriteNoFlash("img/x10Gx_noflash.jpg", 692, 351, "");
	document.writeln('</div>');
}

function fWriteX7Flash() {
	document.writeln('<div class="flashContainer">');
	//fWriteFlash("flash/X10gx_product_viewer.swf", "drs_x10gx", 692, 350);
	fWriteFlash("flash/360viewer_DRS_x7_10-21-10_SPECS_v2.swf", "drs_x7", 692, 350);
	document.writeln('</div>');
}

function fWriteX7NoFlash() {
	document.writeln('<div class="flashContainer">');
	fWriteNoFlash("img/x7_noflash.jpg", 692, 351, "");
	document.writeln('</div>');
}

function fWriteX10mgFlash() {
	document.writeln('<div class="flashContainer">');
	fWriteFlash("flash/X10mg_product_viewer.swf", "drs_x10_mg", 692, 350);	
	document.writeln('</div>');
}

function fWriteX10mgNoFlash() {
	document.writeln('<div class="flashContainer">');
	fWriteNoFlash("img/X10mg_product_viewer.jpg", 690, 350, "");
	document.writeln('</div>');
}

/*
	Update the link text on the next/previous video link on the home page.
	@param oLink the link object for the next/previous video link on the home page
*/
function fUpdateHomeVidNextPrevLink(oLink) {
	if(oLink == null || oLink == undefined) {
		oLink = document.getElementById("lnkNextPrevHomeVid");
	}
	var strLinkText = "Video siguiente &raquo;";
	if(intHomeVidIndex == intHomePageVideos - 1) {
		strLinkText = "&laquo; Video anterior";
	}
//alert("intHomeVidIndex = " + intHomeVidIndex + "\nstrLinkText = " + strLinkText + "\n");
	oLink.innerHTML = strLinkText;
}

function fPopMapFlash() {
	window.open (""+strPageRoot+"flash_map.html","map_flash","location=0,status=0,scrollbars=0,width=800,height=475");
	return false;
}

function fPopTestVideo() {
	window.open ("flash/DRS_vidbox_rtmp.php","map_flash","location=0,status=0,scrollbars=0,width=400,height=400");
}

function fPopVideo(strType) {
	window.open ("race_flash/drs.php?type="+strType,"race_flash","location=0,status=0,scrollbars=0,width=480,height=290");
}

function fPopHomeVideo(anIndex) {
	var intIndex = anIndex;
	if(anIndex == undefined || anIndex == null) {
		intIndex = intHomeVidIndex;
	}
//alert("intIndex = " + intIndex + "\n");
	window.open ("fieldreport/flash/DRS_vidbox_rtmp.php?index=" + intIndex, "home_flash", "location=0,status=0,scrollbars=0,width=400,height=400");
}

function fHideDropdown(strID) {
//console.log("strID = " + strID + "\n");
	oTimer = setTimeout('fHideDiv(\"' + strID + '\"); fHideSubmenu();', intDelay);
	return false;
}

function fHideSubmenu(strID) {
	if(strID == undefined || strID == null) {
		strID = strCurrentSubmenu;
	}
	if(strID != undefined && strID != "") {
		oSubTimer = setTimeout('fHideThatFreakinSubmenuAlready("' + strID + '");', intDelay);
	}
	return false;
}

function fHideThatFreakinSubmenuAlready(anID) {
	fHide(anID);
	strCurrentSubmenu = "";
	fDeactivateMainLink();
}

function fDeactivateMainLink() {
	if(oActiveLink != null) {
//alert("oActiveLink.className = " + oActiveLink.className + "\n");
		oActiveLink.className = strDefaultClass;
//alert("oActiveLink.className = " + oActiveLink.className + "\n");
		oActiveLink = null;
	}
}

function fHideDiv(strID) {
	var oDiv = document.getElementById(strID);
	//oDiv.style.display = "none";
	oDiv.style.visibility = "hidden";
	if(boolHideForms && (strID == "divClaims" || strID == "divPrograms")) {
		document.getElementById("Select1").style.visibility = "visible";
		document.getElementById("Select2").style.visibility = "visible";
	}
	clearTimeout(oTimer);
}

function fHideMenusNoDHTML(strCurrentMenu){
	if(strCurrentMenu != "") {
			fHideDiv(strCurrentMenu);
		}
	}

function fShowDropdown(strID) {
	if(strCurrentMenu != "") {
		fHideDiv(strCurrentMenu);
	}
	if(strCurrentSubmenu != "") {
		fHide(strCurrentSubmenu);
		strCurrentSubmenu = "";
	}
	if(boolHideForms && (strID == "divClaims" || strID == "divPrograms")) {
		document.getElementById("Select1").style.visibility = "hidden";
		document.getElementById("Select2").style.visibility = "hidden";
	}
	strCurrentMenu = strID;
	var oDiv = document.getElementById(strID);
	oDiv.style.visibility = "visible";
	//oDiv.style.display = "block";
	if(oTimer != null) {
		clearTimeout(oTimer);
	}
	return false;
}

/*
 * Display a submenu adjacent to one of the items in the main menu.  Also style the link that toggled the submenu to indicate that it is currently "active".
 * @param strID the ID of the div containing the submenu
 * @param aToggler the object that toggled the display of this link.
 */
function fShowSubmenu(strID, aToggler) {
	fDeactivateMainLink();
	if(strCurrentSubmenu != "") {
		fHide(strCurrentSubmenu);
	}
	strCurrentSubmenu = strID;
	fShow(strID);
	if(oSubTimer != null) {
		clearTimeout(oSubTimer);
	}
	if(aToggler != undefined && aToggler != null) {
//alert("aToggler.id = " + aToggler.id + "\naToggler.className = " + aToggler.className + "\n");
		aToggler.className += strActiveClass;
		oActiveLink = aToggler;
	}
	return false;
}

//	Main dropdown vars
var oTimer = null;
var oSubTimer = null;
var strCurrentMenu = "";
var strCurrentSubmenu = "";
var boolHideForms = false;
var intDelay = 1000;
var oActiveLink = null;
var strActiveClass = " active";
var strDefaultClass = "cssDropDown";

function fShowModal(strID) {
	var oDiv = document.getElementById(strID);
	oDiv.style.visibility = "visible";
	oDiv.style.display = "block";
}

function fHideModal(strID) {
	var oDiv = document.getElementById(strID);
	oDiv.style.visibility = "hidden";
	oDiv.style.display = "none";
}

function fShow(strDiv) {
	document.getElementById(strDiv).style.visibility = "visible";
	document.getElementById(strDiv).style.display = "block";
}

function fHide(strDiv) {
	document.getElementById(strDiv).style.visibility = "hidden";
	document.getElementById(strDiv).style.display = "none";
}

function fVisibilityShowSubMenu (strDiv) {
	document.getElementById(strDiv).style.visibility = "visible";
}

function fVisibilityHideSubMenu (strDiv) {
	document.getElementById(strDiv).style.visibility = "hidden";
}

function fToggleDiv(strDiv) {
 var objDiv = document.getElementById(strDiv);
 if(objDiv.style.visibility == "hidden") {
	 objDiv.style.visibility = "visible";
	 objDiv.style.display = "block";
	 document.getElementById(strDiv + "plus").src = "img/img_minus.gif";
 } else {
	 objDiv.style.visibility = "hidden";
	 objDiv.style.display = "none";
	 document.getElementById(strDiv + "plus").src = "img/img_plus.gif";
 }
}

/*
	Expand or collapse all expandable/collapsable nodes.
	@param oLinkSource the link object that triggerred this function call
*/
function fExpandCollapseAll(oLinkSource) {
//alert("boolAllCollapsed = " + boolAllCollapsed + "\n");
	var strID;
	var boolVisible;
	var strLinkText;
	var arrIds = new Array();
	
	//	Expand or collapse all items that should be expanded or collapsed.
	$(".expandableCollapsable").each(function() {
		boolVisible = $(this).css("visibility") == "visible";
		if((boolAllCollapsed && !boolVisible) || (!boolAllCollapsed && boolVisible)) {
			strID = $(this).attr("id");
			fToggleDiv(strID);
		}
	});
	
	boolAllCollapsed = !boolAllCollapsed;
	
	if(boolAllCollapsed) {	//	Items were all just collapsed.
		strLinkText = "Ampliar";
	} else {	//	Items were all just expanded.
		strLinkText = "Colapsar";
	}
	strLinkText += " todos &raquo;";
	oLinkSource.innerHTML = strLinkText;
	
	return false;
}

function fToggleDivRWS(strDiv) {
 var objDiv = document.getElementById(strDiv);
 if(objDiv.style.visibility == "hidden") {
	 objDiv.style.visibility = "visible";
	 objDiv.style.display = "block";
	 document.getElementById(strDiv + "plus").src = "img/h_click_collapse.gif";
 } else {
	 objDiv.style.visibility = "hidden";
	 objDiv.style.display = "none";
	 document.getElementById(strDiv + "plus").src = "img/h_click_expand.gif";
 }
}

function fVerifyInput(strID, strText) {
	var oInput = document.getElementById(strID);
	if(oInput.value == "") {
		oInput.style.background = "#ffcccc";
		return strText;
	} else {
		oInput.style.background = "";
		return "";
	}
}

function fVerifySelect(strID, strText) {
	var oElement = document.getElementById(strID);
	if(oElement.selectedIndex == 0) {
		oElement.style.background = "#ffcccc";
		oElement.focus();
		return strText;
	} else {
		oElement.style.background = "#ffffff";
	}
	return "";
}

function fEmailTextbox(strTxtBox) {
	if (document.getElementById(strTxtBox).value == "enter your email address") {
		document.getElementById(strTxtBox).value = "";
	}
}

function fVerifyChk (strID, strText) {
	var oChk = document.getElementById(strID);
		if(oChk.checked) {
			return "";
		}
	return strText + "\n";
}

function popUp(strURL,strW,strH)
{
//	alert("HERE");
	day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width='+strW+',height='+strH);");
eval("page" + id + ".moveTo(0,0);");

}


var newwindow = ''
function popitup(url) {
if (newwindow.location && !newwindow.closed) {
    newwindow.location.href = url;
    newwindow.focus(); }
else {
    newwindow=window.open(url,'htmlname','width=404,height=316,resizable=1');}
}

function tidy() {
if (newwindow.location && !newwindow.closed) {
   newwindow.close(); }
}

/*
	Return a random integer from a starting integer to an ending integer, inclusive.
	@param aMinimum the minimum value
	@param aMaximum the maximum value
*/
function fGetRandomInteger(aMinimum, aMaximum) {
	return Math.floor(Math.random() * aMaximum + aMinimum);
}

/*
	Embed an SWF, utilizing a cachebuster to prevent it from getting cached.
	@param aPath the path and filename of the Flash
	@param anID an ID to assign to the HTML object/embed tags
	@param aWidth the width of the Flash
	@param aHeight the height of the Flash
	@param strFlashvars the Flashvars
	@param anAlignment where to align the flash
	@param aQuality the quality, defaults to "high"
	@param aWMode the wmode, defaults to "transparent"
	@param aBgColor the background color, defaults to "ffffff"
*/
function fWriteFlash(aPath, anID, aWidth, aHeight, strFlashvars, anAlignment, aQuality, aWMode, aBgColor) {
	var strFlash = fGetFlash(aPath, anID, aWidth, aHeight, strFlashvars, anAlignment, aQuality, aWMode, aBgColor);
	document.writeln(strFlash);
}

function fWriteNoFlash(anImgPath, aWidth, aHeight, anAlt) {
	document.writeln(fGetNoFlash(anImgPath, aWidth, aHeight, anAlt));
}

