// this function toggles the display of a collapsable list
// used by products/index.jsp and similar pages
function toggle(image,list) { 
	var listElementStyle=document.getElementById(list).style; 
	if (listElementStyle.display=="none") { 
		listElementStyle.display="block"; 
		document.getElementById(image).src="/images/products/arrow_open.gif"; 
		document.getElementById(image).alt="Close list"; 
	} else { 
		listElementStyle.display="none"; 
		document.getElementById(image).src="/images/products/arrow_closed.gif"; 
		document.getElementById(image).alt="Open list";
	} 
}

// show/hide the email address label within the textbox
function showEmailLabel(visible) {
	var txtEmail = document.getElementById("txtEmail");
	if (visible) {
		if (txtEmail.value == "") {
			txtEmail.value = "E-mail Address";
			txtEmail.className = "sign-in-label";
		}
	}
	else {
		if (txtEmail.value == "E-mail Address") {
				txtEmail.value = "";
				txtEmail.className = "sign-in";
		}
	}
}

// show/hide the password label within the textbox
function showPasswordLabel(visible) {
	var password = document.getElementById("password");
	var txtPassword = document.getElementById("txtPassword");
	if (visible) {
		if (password.value == "") {
			password.style.display = "none";
			txtPassword.style.display = "inline";
			txtPassword.value = "Password";
			txtPassword.className = "sign-in-label";
		}
	}
	else {
		password.style.display = "inline";
		txtPassword.style.display = "none";
		password.value = "";
		password.className = "sign-in";
		password.focus();
	}
}

function doLogin () {
	var txtEmail = document.getElementById("txtEmail");
	if (txtEmail.value == "E-mail Address")
		txtEmail.value = "";
	document.signin.submit();
}

// display the odometer
function displayOdometer() {
	if (DetectFlashVer(8, 0, 0)) {
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="230" height="32" id="odometer" align="middle">');
		document.write('<param name="allowScriptAccess" value="sameDomain" />');
		document.write('<param name="movie" value="/odometer.swf" />');
		document.write('<param name="quality" value="high" />');
		document.write('<param name="menu" value="false" />');
		document.write('<param name="bgcolor" value="#ffffff" />');
		document.write('<param name="wmode" value="transparent" />');
		document.write('<param name="flashvars" value="loadTxt=/servlet/odometer"> ');
		document.write('<embed 	src="/odometer.swf" ');
		document.write('		quality="high" ');
		document.write('		bgcolor="#ffffff" ');
		document.write('		wmode="transparent" ');
		document.write('		width="230" ');
		document.write('		height="32" ');
		document.write('		name="odometer" ');
		document.write('		menu="false" ');
		document.write('		align="middle" ');
		document.write('		allowScriptAccess="sameDomain" ');
		document.write('		flashvars="loadTxt=/servlet/odometer"');
		document.write('		type="application/x-shockwave-flash" ');
		document.write('		pluginspage="http://www.macromedia.com/go/getflashplayer" />');
		document.write('</object>');
	} else{
		//document.writeln("<img src=\"/images/home/homepage_main.gif\" alt=\"Aplia - an interactive learning solution that increases student effort and engagement\" border=\"0\" width=\"950\" height=\"215\" />");
	}
}

var FlashOld = "<img src=\"/images/company/PaulVideoStatic.jpg\" width=\"685\" height=\"320\" alt=\"Paul Romer on Aplia Video\"><br /><br />" +
"<span class=\"errorhdr\">Flash Player 9 or later is required to view this video.<br />Please upgrade to the current version of the Flash Player.<\/span><br /><br /><a href=\"javascript:popup('http://www.macromedia.com/go/getflashplayer/')\"><img src=\"/images/support/get_flashplayer.gif\" width=\"88\" height=\"31\" border=\"0\" alt=\"Get Flash Player\"></a><br /><br />";

var FlashAuto = "<img src=\"/images/company/PaulVideoStatic.jpg\" width=\"685\" height=\"320\" alt=\"Paul Romer on Aplia Video\"><br /><br />" +
"<span class=\"errorhdr\">Flash Player 9 or later is required to view this video.<br />Please upgrade to the current version of the Flash Player.<\/span><br /><br />";

// display Paul's video
function displayPaulVideo() {
	if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {
		alert("This page requires AC_RunActiveContent.js.");
	} else {
		// Major version of Flash required
		var requiredMajorVersion = 8;
		// Minor version of Flash required
		var requiredMinorVersion = 0;
		// Revision of Flash required
		var requiredRevision = 0;
	
		var versionStr = "";
		var MMredirectURL = window.location;
		var hasProductInstall = DetectFlashVer(6, 0, 65);
		var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
		
		if ( hasProductInstall && !hasReqestedVersion ) {
			//Flash express install is only supported on firefox  and IE on windows.			   
			if (win && firefox || win && ie) {
				document.write(FlashAuto);
				 
				 // MMdoctitle is the stored document.title value used by the installation process to close the window that started the process
				// This is necessary in order to close browser windows that are still utilizing the older version of the player after installation has completed
				// DO NOT MODIFY THE FOLLOWING FOUR LINES
				// Location visited after installation is complete if installation is required
				var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
				document.title = document.title.slice(0, 47) + " - Flash Player Installation";
				var MMdoctitle = document.title;
		
				AC_FL_RunContent(
					"src", "flashInstall",
					"FlashVars", 'MMredirectURL='+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
					"width", "215",
					"height", "138",
					"align", "middle",
					"id", "flashInstall",
					"quality", "high",
					"bgcolor", "#FFFFFF",
					"name", "flashInstall",
					"allowScriptAccess","sameDomain",
					"type", "application/x-shockwave-flash",
					"pluginspage", "https://www.adobe.com/go/getflashplayer"
				);
			} else {
				 document.write(FlashOld);
			}
		} else if (hasReqestedVersion) {
			// embed the flash movie
			AC_FL_RunContent(
				'codebase', 'https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
				'width', '685',
				'height', '320',
				'src', 'PaulVideo',
				"FlashVars", "MMredirectURL="+MMredirectURL+"&ImagePath=/images/company/bandwidthCheck.jpg",
				'quality', 'high',
				'pluginspage', 'https://www.macromedia.com/go/getflashplayer',
				'align', 'middle',
				'play', 'true',
				'loop', 'true',
				'scale', 'showall',
				'wmode', 'transparent',
				'devicefont', 'false',
				'id', 'PaulVideo',
				'bgcolor', '#ffffff',
				'name', 'PaulVideo',
				'menu', 'false',
				'allowScriptAccess','sameDomain',
				'allowFullScreen','false',
				'movie', 'PaulVideo',
				'salign', ''
			); //end AC code
		} else {  
			// flash is too old or we can't detect the plugin
			document.write(FlashOld);
		}
	}
}

var FlashOldGIN = "<span class=\"errorhdr\">Flash Player 9 or later is required to view this video.<br />Please upgrade to the current version of the Flash Player.<\/span><br /><br /><a href=\"javascript:popup('http://www.macromedia.com/go/getflashplayer/')\"><img src=\"/images/support/get_flashplayer.gif\" width=\"88\" height=\"31\" border=\"0\" alt=\"Get Flash Player\"></a><br /><br />";
FlashOldGIN += "<img src=\"/images/company/GINVideoStatic.jpg\" width=\"665\" height=\"543\" alt=\"Paul Romer on Aplia Video\"><br /><br />";

var FlashAutoGIN = "<span class=\"errorhdr\">Flash Player 9 or later is required to view this video.<br />Please upgrade to the current version of the Flash Player.<\/span><br /><br />";
FlashAutoGIN += "<img src=\"/images/company/GINVideoStatic.jpg\" width=\"665\" height=\"543\" alt=\"Paul Romer on Aplia Video\"><br /><br />";

// display GIN video
function displayGINVideo() {
	if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {
		alert("This page requires AC_RunActiveContent.js.");
	} else {
		var requiredMajorVersion = 8; // Major version of Flash required
		var requiredMinorVersion = 0; // Minor version of Flash required
		var requiredRevision = 0; // Revision of Flash required
		var versionStr = "";
		var MMredirectURL = window.location;
		var hasProductInstall = DetectFlashVer(6, 0, 65);
		var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
		
		if (hasProductInstall && !hasReqestedVersion) {
			//Flash express install is only supported on firefox  and IE on windows.
			if(win && firefox || win && ie){
				var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
				document.write(FlashAutoGIN);
				document.title = document.title.slice(0, 47) + " - Flash Player Installation";
				var MMdoctitle = document.title;
				
				AC_FL_RunContent(
					"src", "flashInstall",
					"FlashVars", 'MMredirectURL='+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
					"width", "215",
					"height", "138",
					"align", "middle",
					"id", "flashInstall",
					"quality", "high",
					"bgcolor", "#FFFFFF",
					"name", "flashInstall",
					"allowScriptAccess","sameDomain",
					"type", "application/x-shockwave-flash",
					"pluginspage", "https://www.adobe.com/go/getflashplayer"
				);
			} else {
				document.write(FlashOldGIN);
			}
		} else if (hasReqestedVersion) {
			// embed the flash movie
			AC_FL_RunContent(
				'codebase', 'https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
				'width', '100%',
				'height', '543',
				'src', 'GINVideo',
				"FlashVars", "MMredirectURL="+MMredirectURL+"&ImagePath=/images/company/bandwidthCheck.jpg",
				'quality', 'high',
				'pluginspage', 'https://www.macromedia.com/go/getflashplayer',
				'align', 'middle',
				'play', 'true',
				'loop', 'true',
				'scale', 'showall',
				'wmode', 'transparent',
				'devicefont', 'false',
				'id', 'GINVideo',
				'bgcolor', '#ffffff',
				'name', 'GINVideo',
				'menu', 'false',
				'allowScriptAccess','sameDomain',
				'allowFullScreen','false',
				'movie', 'GINVideo',
				'salign', ''
			);
		} else {
			document.write(FlashOldGIN);
		}
	}
}

function popup(content) {
	var h = screen.height;
	var w = screen.width;
	h = h * .7;
	w = w * .7;
	var loc = "toolbar=0,menubar=0,location=0,status=0,scrollbars=0,resizable=1,width=" + w + ",height=" + h;
	window.open(content,'Information',loc);
}

function popupApliaText(i, c, m, s) {
	if (s == null)
		s = "";
	
	var theURL = "/servlet/apliatext?i=" + i + "&c=" + c + "&m=" + m + "&s=" + s;
	if (ielang != null && wnd != null && !wnd.closed) {
    	wnd.close();
  	}
	
	var wndName = window.location.hostname;
	wndName = "atext_" + wndName.substring(0, wndName.indexOf("."));
	
	var h = screen.height * .8;
	var w = 765;
	var loc = "toolbar=1,menubar=1,location=0,status=0,scrollbars=1,resizable=1,width=" + w + ",height=" + h;
	wnd = window.open(theURL, wndName, loc);
	if (wnd != null) {
		wnd.focus();
    }
}

function displayVideoHighlight(path) {
	if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {
		alert("This page requires AC_RunActiveContent.js.");
	} else {
		// Major version of Flash required
		var requiredMajorVersion = 8;
		// Minor version of Flash required
		var requiredMinorVersion = 0;
		// Revision of Flash required
		var requiredRevision = 0;
	
		var versionStr = "";
		var MMredirectURL = window.location;
		var hasProductInstall = DetectFlashVer(6, 0, 65);
		var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
		
		if ( hasProductInstall && !hasReqestedVersion ) {
			// don't do anything
		} else if (hasReqestedVersion) {
			// embed the flash movie
			AC_FL_RunContent(
				"codebase", "https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0",
				"width", "300",
				"height", "220",
				"src", path + "video_highlight",
				"FlashVars", "MMredirectURL="+MMredirectURL+"&ImagePath=/images/company/bandwidthCheck.jpg",
				"quality", "high",
				"pluginspage", "https://www.macromedia.com/go/getflashplayer",
				"align", "middle",
				"play", "true",
				"loop", "true",
				"scale", "showall",
				"wmode", "window",
				"devicefont", "false",
				"id", "video_highlight",
				"bgcolor", "#ffffff",
				"name", path + "video_highlight",
				"menu", "false",
				"allowScriptAccess","sameDomain",
				"allowFullScreen","false",
				"movie", path + "video_highlight",
				"salign", ""
			); //end AC code
		} else {  
			// don't do anything
		}
	}
}

function displayImageHighlight(path) {
	if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {
		alert("This page requires AC_RunActiveContent.js.");
	} else {
		// Major version of Flash required
		var requiredMajorVersion = 8;
		// Minor version of Flash required
		var requiredMinorVersion = 0;
		// Revision of Flash required
		var requiredRevision = 0;
	
		var versionStr = "";
		var MMredirectURL = window.location;
		var hasProductInstall = DetectFlashVer(6, 0, 65);
		var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
		
		if ( hasProductInstall && !hasReqestedVersion ) {
			// don't do anything
		} else if (hasReqestedVersion) {
			// embed the flash movie
			AC_FL_RunContent(
				"codebase", "https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0",
				"width", "300",
				"height", "220",
				"src", path + "image_highlight",
				"FlashVars", "MMredirectURL="+MMredirectURL+"&ImagePath=/images/company/bandwidthCheck.jpg",
				"quality", "high",
				"pluginspage", "https://www.macromedia.com/go/getflashplayer",
				"align", "middle",
				"play", "true",
				"loop", "true",
				"scale", "showall",
				"wmode", "window",
				"devicefont", "false",
				"id", "image_highlight",
				"bgcolor", "#ffffff",
				"name", path + "image_highlight",
				"menu", "false",
				"allowScriptAccess","sameDomain",
				"allowFullScreen","false",
				"movie", path + "image_highlight",
				"salign", ""
			); //end AC code
		} else {  
			// don't do anything
		}
	}
}

function displayIntroHighlight() {
	if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {
		alert("This page requires AC_RunActiveContent.js.");
	} else {
		// Major version of Flash required
		var requiredMajorVersion = 8;
		// Minor version of Flash required
		var requiredMinorVersion = 0;
		// Revision of Flash required
		var requiredRevision = 0;
	
		var versionStr = "";
		var MMredirectURL = window.location;
		var hasProductInstall = DetectFlashVer(6, 0, 65);
		var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
		
		if ( hasProductInstall && !hasReqestedVersion ) {
			// don't do anything
		} else if (hasReqestedVersion) {
			// embed the flash movie
			AC_FL_RunContent(
				"codebase", "https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0",
				"width", "100%",
				"height", "100%",
				"src", "intro",
				"FlashVars", "MMredirectURL="+MMredirectURL+"&ImagePath=/images/company/bandwidthCheck.jpg",
				"quality", "high",
				"pluginspage", "https://www.macromedia.com/go/getflashplayer",
				"align", "middle",
				"play", "true",
				"loop", "true",
				"scale", "showall",
				"wmode", "transparent",
				"devicefont", "false",
				"id", "intro",
				"bgcolor", "#ffffff",
				"name", "intro",
				"menu", "false",
				"allowScriptAccess","sameDomain",
				"allowFullScreen","false",
				"movie", "intro",
				"salign", ""
			); //end AC code
		} else {  
			// don't do anything
		}
	}
}

function getIEVersion() {
	//Returns the version of Internet Explorer or a -1
	//(indicating the use of another browser).
	var rv = -1; // Return value assumes failure.
	if (navigator.appName == 'Microsoft Internet Explorer') {
	 var ua = navigator.userAgent;
	 var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
	 if (re.exec(ua) != null)
	   rv = parseFloat( RegExp.$1 );
	}
	return rv;
}

function ah(index) {
	if (index == 1) {
		YAHOO.util.Dom.setStyle("m1", "font-weight", "bold");
		YAHOO.util.Dom.setStyle("m2", "font-weight", "normal");
		YAHOO.util.Dom.setStyle("m3", "font-weight", "normal");
		YAHOO.util.Dom.removeClass("testimonials", "m-hide");
		YAHOO.util.Dom.addClass("testimonials", "m-show");
		YAHOO.util.Dom.removeClass("current-users", "m-show");
		YAHOO.util.Dom.addClass("current-users", "m-hide");
		YAHOO.util.Dom.removeClass("featured-news", "m-show");
		YAHOO.util.Dom.addClass("featured-news", "m-hide");
	}
	if (index == 2) {
		YAHOO.util.Dom.setStyle("m1", "font-weight", "normal");
		YAHOO.util.Dom.setStyle("m2", "font-weight", "bold");
		YAHOO.util.Dom.setStyle("m3", "font-weight", "normal");
		YAHOO.util.Dom.removeClass("testimonials", "m-show");
		YAHOO.util.Dom.addClass("testimonials", "m-hide");
		YAHOO.util.Dom.removeClass("current-users", "m-hide");
		YAHOO.util.Dom.addClass("current-users", "m-show");
		YAHOO.util.Dom.removeClass("featured-news", "m-show");
		YAHOO.util.Dom.addClass("featured-news", "m-hide");
	}
	if (index == 3) {
		YAHOO.util.Dom.setStyle("m1", "font-weight", "normal");
		YAHOO.util.Dom.setStyle("m2", "font-weight", "normal");
		YAHOO.util.Dom.setStyle("m3", "font-weight", "bold");
		YAHOO.util.Dom.removeClass("testimonials", "m-show");
		YAHOO.util.Dom.addClass("testimonials", "m-hide");
		YAHOO.util.Dom.removeClass("current-users", "m-show");
		YAHOO.util.Dom.addClass("current-users", "m-hide");
		YAHOO.util.Dom.removeClass("featured-news", "m-hide");
		YAHOO.util.Dom.addClass("featured-news", "m-show");
	}
}