//////////////////////////////////////////////////////////////////
//	Proloads all graphics needed for the page
//
//	Currently included in:	index.html
//////////////////////////////////////////////////////////////////

function preloadPage(){
	Number_0.src = "IMAGES2/Clock/Number-0.gif";	
	Number_1.src = "IMAGES2/Clock/Number-1.gif";
	Number_2.src = "IMAGES2/Clock/Number-2.gif";
	Number_3.src = "IMAGES2/Clock/Number-3.gif";
	Number_4.src = "IMAGES2/Clock/Number-4.gif";
	Number_5.src = "IMAGES2/Clock/Number-5.gif";
	Number_6.src = "IMAGES2/Clock/Number-6.gif";
	Number_7.src = "IMAGES2/Clock/Number-7.gif";
	Number_8.src = "IMAGES2/Clock/Number-8.gif";
	Number_9.src = "IMAGES2/Clock/Number-9.gif";
	Blank.src = "IMAGES2/Clock/Blank.gif";
	Letter_A.src = "IMAGES2/Clock/Letter-A.gif";
	Letter_B.src = "IMAGES2/Clock/Letter-B.gif";
	Letter_C.src = "IMAGES2/Clock/Letter-C.gif";
	Letter_D.src = "IMAGES2/Clock/Letter-D.gif";
	Letter_E.src = "IMAGES2/Clock/Letter-E.gif";
	Letter_F.src = "IMAGES2/Clock/Letter-F.gif";
	Letter_G.src = "IMAGES2/Clock/Letter-G.gif";
	Letter_J.src = "IMAGES2/Clock/Letter-J.gif";
	Letter_L.src = "IMAGES2/Clock/Letter-L.gif";
	Letter_M.src = "IMAGES2/Clock/Letter-M.gif";
	Letter_N.src = "IMAGES2/Clock/Letter-N.gif";
	Letter_O.src = "IMAGES2/Clock/Letter-O.gif";
	Letter_P.src = "IMAGES2/Clock/Letter-P.gif";
	Letter_R.src = "IMAGES2/Clock/Letter-R.gif";
	Letter_S.src = "IMAGES2/Clock/Letter-S.gif";
	Letter_T.src = "IMAGES2/Clock/Letter-T.gif";
	Letter_U.src = "IMAGES2/Clock/Letter-U.gif";
	Letter_V.src = "IMAGES2/Clock/Letter-V.gif";
	Letter_Y.src = "IMAGES2/Clock/Letter-Y.gif";
	MainImg.src = "IMAGES2/Main-Image.gif";
	for (i = 0; i < p; i++){
		preLoad[i] = new Image();
		preLoad[i].src = Pic[i];
	}
}



//////////////////////////////////////////////////////////////////
//	Formats the time for the digital display
//
//	Currently included in:	index.html
//////////////////////////////////////////////////////////////////

function formatTime(hour, minute, second, year, month, day) {
	if (!document.images)
		return;
	if (hour <= 9){
		document.images.hour1.src = Number_0.src;
		document.images.hour2.src = eval("Number_"+hour+".src");
	}
	else{
		document.images.hour1.src = eval("Number_"+Math.floor(hour/10)+".src");
		document.images.hour2.src = eval("Number_"+(hour%10)+".src");
	}
	if (minute <= 9){
		document.images.minute1.src = Number_0.src;
		document.images.minute2.src = eval("Number_"+minute+".src");
	}
	else{
		document.images.minute1.src = eval("Number_"+Math.floor(minute/10)+".src");
		document.images.minute2.src = eval("Number_"+(minute%10)+".src");
	}
	if (second <= 9){
		document.images.second1.src = Number_0.src;
		document.images.second2.src = eval("Number_"+second+".src");
	}
	else{
		document.images.second1.src = eval("Number_"+Math.floor(second/10)+".src");
		document.images.second2.src = eval("Number_"+(second%10)+".src");
	}
	if (year%2000 <= 9){
		document.images.year1.src = Number_0.src;
		document.images.year2.src = eval("Number_"+(year%2000)+".src");
	}
	else {
		document.images.year1.src = eval("Number_"+Math.floor((year%2000)/10)+".src");
		document.images.year2.src = eval("Number_"+((year%2000)%10)+".src");
	}
	if (month == 0){
		document.images.month1.src = Letter_J.src;
		document.images.month2.src = Letter_A.src;
		document.images.month3.src = Letter_N.src;
	}
	if (month == 1){
		document.images.month1.src = Letter_F.src;
		document.images.month2.src = Letter_E.src;
		document.images.month3.src = Letter_B.src;
	}
	if (month == 2){
		document.images.month1.src = Letter_M.src;
		document.images.month2.src = Letter_A.src;
		document.images.month3.src = Letter_R.src;
	}
	if (month == 3){
		document.images.month1.src = Letter_A.src;
		document.images.month2.src = Letter_P.src;
		document.images.month3.src = Letter_R.src;
	}
	if (month == 4){
		document.images.month1.src = Letter_M.src;
		document.images.month2.src = Letter_A.src;
		document.images.month3.src = Letter_Y.src;
	}
	if (month == 5){
		document.images.month1.src = Letter_J.src;
		document.images.month2.src = Letter_U.src;
		document.images.month3.src = Letter_N.src;
	}
	if (month == 6){
		document.images.month1.src = Letter_J.src;
		document.images.month2.src = Letter_U.src;
		document.images.month3.src = Letter_L.src;
	}
	if (month == 7){
		document.images.month1.src = Letter_A.src;
		document.images.month2.src = Letter_U.src;
		document.images.month3.src = Letter_G.src;
	}
	if (month == 8){
		document.images.month1.src = Letter_S.src;
		document.images.month2.src = Letter_E.src;
		document.images.month3.src = Letter_P.src;
	}
	if (month == 9){
		document.images.month1.src = Letter_O.src;
		document.images.month2.src = Letter_C.src;
		document.images.month3.src = Letter_T.src;
	}
	if (month == 10){
		document.images.month1.src = Letter_N.src;
		document.images.month2.src = Letter_O.src;
		document.images.month3.src = Letter_V.src;
	}
	if (month == 11){
		document.images.month1.src = Letter_D.src;
		document.images.month2.src = Letter_E.src;
		document.images.month3.src = Letter_C.src;
	}
	if (day <= 9){
		document.images.day1.src = Number_0.src;
		document.images.day2.src = eval("Number_"+day+".src");
	}
	else{
		document.images.day1.src = eval("Number_"+Math.floor(day/10)+".src");
		document.images.day2.src = eval("Number_"+(day%10)+".src");
	}
	document.images.tz1.src = Letter_G.src;
	document.images.tz2.src = Letter_M.src;
	document.images.tz3.src = Letter_T.src;
}



//////////////////////////////////////////////////////////////////
//	Gets the time for the digital display
//
//	Currently included in:	index.html
//////////////////////////////////////////////////////////////////

function getTime(){
	if (!document.images)
		return;
	var Time = new Date();
	var hour = Time.getUTCHours();
	var minute = Time.getUTCMinutes();
	var second = Time.getUTCSeconds();
	var year = Time.getUTCFullYear();
	var month = Time.getUTCMonth();
	var day = Time.getUTCDate();
	formatTime(hour, minute, second, year, month, day);
	setTimeout("getTime()", 1000);
}



//////////////////////////////////////////////////////////////////
//	Runs the slide show
//
//	Currently included in:	index.html
//////////////////////////////////////////////////////////////////

function runSlideShow(){
	if (document.all){
		document.images.SlideShow.style.filter="blendTrans(duration=3)";
		document.images.SlideShow.filters.blendTrans.Apply();
	}
	document.images.SlideShow.src = preLoad[j].src;
	if (document.all){
		document.images.SlideShow.filters.blendTrans.Play();
	}
	j = j + 1;
	if (j > (p - 1)) j = 0;
	t = setTimeout('runSlideShow()', slideShowSpeed);
}



//////////////////////////////////////////////////////////////////
//	Preloads the glows for the CETA navpanal
//
//	Currently included in:	downloads-ceta.html
//							products-ceta.html
//							support-ceta.html
//							ceta-benefits.html
//							ceta-usage.html
//							ceta-pricing.html
//							ceta-screenshots.html
//							ceta-download.html
//							ceta-download-demo.html
//							ceta-download-factsheet.html
//							ceta-download-userguide.html
//							ceta-submitted.html
//////////////////////////////////////////////////////////////////

function preloadCETANavPanal() {
	CNP1 = new Image();
	CNP1.src = "IMAGES2/CETA-NavPanal-What-Glow.gif";
	CNP2 = new Image();
	CNP2.src = "IMAGES2/CETA-NavPanal-Benefits-Glow.gif";
	CNP3 = new Image();
	CNP3.src = "IMAGES2/CETA-NavPanal-Usage-Glow.gif";
	CNP4 = new Image();
	CNP4.src = "IMAGES2/CETA-NavPanal-Pricing-Glow.gif";
	CNP5 = new Image();
	CNP5.src = "IMAGES2/CETA-NavPanal-Screen-Glow.gif";
	CNP6 = new Image();
	CNP6.src = "IMAGES2/CETA-NavPanal-Downloads-Glow.gif";
	CNP7 = new Image();
	CNP7.src = "IMAGES2/CETA-NavPanal-Support-Glow.gif";
}



//////////////////////////////////////////////////////////////////
//	Preloads the glows for the TrilogyEC navpanal
//
//	Currently included in:	downloads-trilogyec.html
//							products-trilogyec.html
//							support-trilogyec.html
//							trilogyec-miser.html
//							trilogyec-usb.html
//							trilogyec-spanish.html
//							trilogyec-screenshots.html
//							trilogyec-reviews.html
//							trilogyec-download.html
//							trilogyec-download-pro.html
//							trilogyec-download-spansih.html
//							trilogyec-download-quickstart.html
//							trilogyec-download-factsheet.html
//							trilogyec-download-usb.html
//							trilogyec-submitted.html
//////////////////////////////////////////////////////////////////

function preloadTrilogyECNavPanal() {
	ECNP1 = new Image();
	ECNP1.src = "IMAGES2/TrilogyEC-NavPanal-What-Glow.gif";
	ECNP2 = new Image();
	ECNP2.src = "IMAGES2/TrilogyEC-NavPanal-Miser-Glow.gif";
	ECNP3 = new Image();
	ECNP3.src = "IMAGES2/TrilogyEC-NavPanal-Spanish-Glow.gif";
	ECNP4 = new Image();
	ECNP4.src = "IMAGES2/TrilogyEC-NavPanal-Screen-Glow.gif";
	ECNP5 = new Image();
	ECNP5.src = "IMAGES2/TrilogyEC-NavPanal-Reviews-Glow.gif";
	ECNP6 = new Image();
	ECNP6.src = "IMAGES2/TrilogyEC-NavPanal-Downloads-Glow.gif";
	ECNP7 = new Image();
	ECNP7.src = "IMAGES2/TrilogyEC-NavPanal-Support-Glow.gif";
}



//////////////////////////////////////////////////////////////////
//	Preloads the glows for the Products navpanal
//
//	Currently included in:	products.html
//////////////////////////////////////////////////////////////////

function preloadProductsNavPanal() {
	PNP1 = new Image();
	PNP1.src = "IMAGES2/TrilogyEC-NavPanal-What-Glow.gif";
	PNP2 = new Image();
	PNP2.src = "IMAGES2/CETA-NavPanal-What-Glow.gif";
}


//////////////////////////////////////////////////////////////////
//	Preloads the glows for the Services navpanal
//
//	Currently included in:	services.html
//////////////////////////////////////////////////////////////////

function preloadServicesNavPanal() {
	PNP1 = new Image();
	PNP1.src = "IMAGES2/SVCS-NavPanal-Overview-Glow.gif";
	PNP2 = new Image();
	PNP2.src = "IMAGES2/SVCS-NavPanal-Arch-Glow.gif";
	PNP3 = new Image();
	PNP3.src = "IMAGES2/SVCS-NavPanal-HC-Glow.gif";
	PNP4 = new Image();
	PNP4.src = "IMAGES2/SVCS-NavPanal-EP-Glow.gif";
	PNP5 = new Image();
	PNP5.src = "IMAGES2/SVCS-NavPanal-OCS-Glow.gif";
	PNP6 = new Image();
	PNP6.src = "IMAGES2/SVCS-NavPanal-Framework-Glow.gif";
}


//////////////////////////////////////////////////////////////////
//	Preloads the glows for the DriveSight navpanal
//
//	Currently included in:	products-drivesight.html
//////////////////////////////////////////////////////////////////

function preloadDriveSightNavPanal() {
	DSP1 = new Image();
	DSP1.src = "IMAGES2/DriveSight-NavPanal-Spt-Glow.gif";
	DSP2 = new Image();
	DSP2.src = "IMAGES2/DriveSight-NavPanal-What-Glow.gif";
	DSP3 = new Image();
	DSP3.src = "IMAGES2/DriveSight-NavPanal-SS-Glow.gif";
}


//////////////////////////////////////////////////////////////////
//	Preloads the glows for the About navpanal
//
//	Currently included in:	about.html
//////////////////////////////////////////////////////////////////

function preloadAboutNavPanal() {
	PNP1 = new Image();
	PNP1.src = "IMAGES2/About-NavPanal-About-Glow.gif";
	PNP2 = new Image();
	PNP2.src = "IMAGES2/About-NavPanal-Corp-Glow.gif";
        PNP3 = new Image();
	PNP3.src = "IMAGES2/About-NavPanal-Partners-Glow.gif";
        PNP4 = new Image();
	PNP4.src = "IMAGES2/About-NavPanal-Contact-Glow.gif";
}



//////////////////////////////////////////////////////////////////
//	Preloads the glows for the Downloads navpanal
//
//	Currently included in:	downloads.html
//////////////////////////////////////////////////////////////////
function preloadDownloadsNavPanal() {
	DNP1 = new Image();
	DNP1.src = "IMAGES2/TrilogyEC-NavPanal-What-Glow.gif";
	DNP2 = new Image();
	DNP2.src = "IMAGES2/CETA-NavPanal-What-Glow.gif";
}



//////////////////////////////////////////////////////////////////
//	Preloads the glows for the Support navpanal
//
//	Currently included in:	support.html
//////////////////////////////////////////////////////////////////

function preloadSupportNavPanal() {
	SNP1 = new Image();
	SNP1.src = "IMAGES2/Support-NavPanal-TrilogyEC-Glow.gif";
	SNP2 = new Image();
	SNP2.src = "IMAGES2/Support-NavPanal-CETA-Glow.gif";
	SNP3 = new Image();
	SNP3.src = "IMAGES2/Support-NavPanal-Forum-Glow.gif";
	SNP4 = new Image();
	SNP4.src = "IMAGES2/Support-NavPanal-Website-Glow.gif";
}



//////////////////////////////////////////////////////////////////
//	Switches the screenshots on user clicks and
//		displays the current caption
//
//	Currently included in:	ceta-screenshots.html
//							trilogyec-screenshots.html
//////////////////////////////////////////////////////////////////

function makeBig(thumb) {
	var pathname = thumb;
	var pathname2 = document.getElementById('fullsize').src;
	document.getElementById('fullsize').src = pathname2.substring(0,pathname2.length-5)+pathname.substring(5)+".jpg";
	document.getElementById('caption').innerHTML = document.getElementById('caption'+pathname.substring(5)).innerHTML;
}



//////////////////////////////////////////////////////////////////
//	Preloads the screenshots for CETA
//
//	Currently included in:	ceta-screenshots.html
//////////////////////////////////////////////////////////////////

function preloadCETAScreenshots() {
	CETASS1 = new Image();
	CETASS1.src = "IMAGES2/CETA-Screenshot-1.jpg";
	CETASS2 = new Image();
	CETASS2.src = "IMAGES2/CETA-Screenshot-2.jpg";
	CETASS3 = new Image();
	CETASS3.src = "IMAGES2/CETA-Screenshot-3.jpg";
	CETASS4 = new Image();
	CETASS4.src = "IMAGES2/CETA-Screenshot-4.jpg";
	CETASS5 = new Image();
	CETASS5.src = "IMAGES2/CETA-Screenshot-5.jpg";
}



//////////////////////////////////////////////////////////////////
//	Preloads the screenshots for TrilogyEC
//
//	Currently included in:	trilogyec-screenshots.html
//////////////////////////////////////////////////////////////////

function preloadTrilogyECScreenshots() {
	ECSS1 = new Image();
	ECSS1.src = "IMAGES2/TrilogyEC-Screenshot-1.jpg";
	ECSS2 = new Image();
	ECSS2.src = "IMAGES2/TrilogyEC-Screenshot-2.jpg";
	ECSS3 = new Image();
	ECSS3.src = "IMAGES2/TrilogyEC-Screenshot-3.jpg";
	ECSS4 = new Image();
	ECSS4.src = "IMAGES2/TrilogyEC-Screenshot-4.jpg";
	ECSS5 = new Image();
	ECSS5.src = "IMAGES2/TrilogyEC-Screenshot-5.jpg";
	ECSS6 = new Image();
	ECSS6.src = "IMAGES2/TrilogyEC-Screenshot-6.jpg";
	ECSS7 = new Image();
	ECSS7.src = "IMAGES2/TrilogyEC-Screenshot-7.jpg";
	ECSS8 = new Image();
	ECSS8.src = "IMAGES2/TrilogyEC-Screenshot-8.jpg";
}



//////////////////////////////////////////////////////////////////
//	Preloads the effects for the XP style download button
//
//	Currently included in:	trilogyec-download-pro.html
//							trilogyec-download-spansih.html
//							trilogyec-download-quickstart.html
//							trilogyec-download-factsheet.html
//							trilogyec-download-usb.html
//							ceta-download-demo.html
//							ceta-download-factsheet.html
//							ceta-download-userguide.html
//////////////////////////////////////////////////////////////////

function preloadDownloadButton() {
	B1 = new Image();
	B1.src = "IMAGES2/DownloadButton-Down.gif";
	B2 = new Image();
	B2.src = "IMAGES2/DownloadButton-Over.gif";
}



//////////////////////////////////////////////////////////////////
//	Action images for the XP style donwload button
//	
//	Currently included in:	ceta-download-demo.html
//							ceta-download-factsheet.html
//							ceta-download-userguide.html
//							trilogyec-download-factsheet.html
//							trilogyec-download-pro.html
//							trilogyec-download-quickstart.html
//							trilogyec-download-spanish.html
//							trilogyec-download-usb.html
//////////////////////////////////////////////////////////////////

function buttonDown(button){
	document.getElementById(button).src="http://www.trilogysolutions.com/IMAGES2/DownloadButton-Down.gif";
}
function buttonUp(button){
	document.getElementById(button).src="http://www.trilogysolutions.com/IMAGES2/DownloadButton-Up.gif";
}
function buttonOver(button){
	document.getElementById(button).src="http://www.trilogysolutions.com/IMAGES2/DownloadButton-Over.gif";
}



//////////////////////////////////////////////////////////////////
//	Changes the validity of a form
//
//	Currently included in:	support-trilogyec.html
//							support-ceta.html
//							support-web.html
//////////////////////////////////////////////////////////////////

function checkForm() {
	var email=document.formmail.Email.value;
	var message=document.formmail.Message.value;
	var messageMaxLength = 10000;
	var messageCurrentLength = message.length;
	if (email == '') {
		alert('The "Your E-Mail Address" field must be filled out.');
		return false;
	}
	else if (message == '') {
		alert('The "Your Message" field must be filled out.');
		return false;
	}
	else if (!checkEmail(email)) {
		alert('The E-Mail address you supplied is not valid.\n\nE-Mail addresses must be in the standard form, i.e. "User@TrilogySolutions.com"');
		return false;
	}
	else if (messageCurrentLength >= messageMaxLength) {
		alert('The "Message" field can not contain more than ' + messageMaxLength + ' characters.\n\nYou are currently at ' + messageCurrentLength + ' characters');
		return false;
	}
}



//////////////////////////////////////////////////////////////////
//	Changes the validity of a form
//
//	Currently included in:	ncam-schedule-demo.html
//////////////////////////////////////////////////////////////////

function checkForm2() {
	var email=document.formmail.Email.value;
	var message=document.formmail.Message.value;
	var name=document.formmail.Name.value;
	var organization=document.formmail.Organization.value;
	var version=document.formmail.Version.value;
	var demo=document.formmail.Demo.value;
	var month=document.formmail.Month.value;
	var day=document.formmail.Day.value;
	var year=document.formmail.Year.value;
	var time=document.formmail.Time.value;
	var zone=document.formmail.Zone.value;
	var messageMaxLength = 10000;
	var messageCurrentLength = message.length;
	if (email == '') {
		alert('The "Your E-Mail Address" field must be filled out.');
		return false;
	}
	else if (name == '') {
		alert('The "Your Name" field must be filled out.');
		return false;
	}
	else if (organization == '') {
		alert('The "Organization" field must be filled out.');
		return false;
	}
	else if (version == '') {
		alert('You must choose a version.');
		return false;
	}
	else if (demo == '') {
		alert('You must choose what type of demo you want.');
		return false;
	}
	else if (month == '') {
		alert('You must choose a month');
		return false;
	}
	else if (day == '') {
		alert('You must choose a day');
		return false;
	}
	else if (year == '') {
		alert('You must choose a year');
		return false;
	}
	else if (time == '') {
		alert('You must choose a time');
		return false;
	}
	else if (zone == '') {
		alert('You must choose a time zone');
		return false;
	}
	else if (!checkEmail(email)) {
		alert('The E-Mail address you supplied is not valid.\n\nE-Mail addresses must be in the standard form, i.e. "User@TrilogySolutions.com"');
		return false;
	}
	else if (messageCurrentLength >= messageMaxLength) {
		alert('The "Message" field can not contain more than ' + messageMaxLength + ' characters.\n\nYou are currently at ' + messageCurrentLength + ' characters');
		return false;
	}
}



//////////////////////////////////////////////////////////////////
//	Changes the validity of an email address
//
//	Currently included in:	support-trilogyec.html
//							support-ceta.html
//							support-web.html
//////////////////////////////////////////////////////////////////

function checkEmail(email) {
	var valid = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	if (!email.match(valid)) {
		return false;
	}
	else {
		return true;
	}
}



//////////////////////////////////////////////////////////////////
//	Detects the verison of flash installed on the users machine 
//
//	Currently included in:	products-trilogyec.html
//////////////////////////////////////////////////////////////////

function getFlashVersion() {
	var latestFlashVersion = 8;
	flashVersion_DONTKNOW = -1;
	var agent = navigator.userAgent.toLowerCase(); 
	if (agent.indexOf("mozilla/3") != -1 && agent.indexOf("msie") == -1) {
		flashVersion = 0;
	}
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		var flashPlugin = navigator.plugins['Shockwave Flash'];
		if (typeof flashPlugin == 'object') { 
			for (var i = latestFlashVersion; i >= 3; i--) {
				if (flashPlugin.description.indexOf(i + '.') != -1) {
					flashVersion = i;
					break;
				}
			}
		}
	}
	else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
		var doc = '<scr' + 'ipt language="VBScript"\> \n';
		doc += 'On Error Resume Next \n';
		doc += 'Dim obFlash \n';
		doc += 'For i = ' + latestFlashVersion + ' To 3 Step -1 \n';
		doc += '   Set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash." & i) \n';
		doc += '   If IsObject(obFlash) Then \n';
		doc += '      flashVersion = i \n';
		doc += '      Exit For \n';
		doc += '   End If \n';
		doc += 'Next \n';
		doc += '</scr' + 'ipt\> \n';
		document.write(doc);
	}
	else if (agent.indexOf("webtv/2.5") != -1) flashVersion = 3;
	else if (agent.indexOf("webtv") != -1) flashVersion = 2;
	else {
		flashVersion = flashVersion_DONTKNOW;
	}
	return flashVersion;
}



//////////////////////////////////////////////////////////////////
//	Changes the status bar on IE
//
//	Currently included in:	trilogyec-faq.html
//////////////////////////////////////////////////////////////////

function showStatus(msg) {
	window.status = msg;
	return true;
}