//This file made 04/22/02 to combine generic sitewide js functions into one includes file.

//This is path-stripping code for the Flash NavBar location.href
thisPath = location.href;
function ecStripPathExtention(path) {
	srcStr = path;
	
	if (path.lastIndexOf('/') > 0) {
		srcStr = srcStr.substring(0, srcStr.length - 1);
	}
	
	strArray = srcStr.split('/');

	if (strArray.length > 0) {
		str = strArray[strArray.length - 1];
		strArray2 = str.split('.');
		str = strArray2[0];	
	} else {
		str = strArray[strArray.length];
		strArray2 = str.split('.');
		str = strArray2[0];	
	}
	
	return str;
}		



<!--
//generic code for launching new windows
function openNewWindow(URLtoOpen, windowName, windowFeatures) {
    newWindow=window.open(URLtoOpen, windowName, windowFeatures); 
}
// -->

<!--
//code for trapping the history on IE 5.5 & higher for Flash Navbar 'Back' button
function trapBack( ){
	if (navigator.appName == "Microsoft Internet Explorer") {

		var brVer = navigator.userAgent;

		var brVerId = brVer.indexOf('MSIE');

	   	var brNum = brVer.substr( ( brVerId + 5 ), 3);

	   	if( brNum >= 5.5 ){
	   		history.back( );
	   	}

	}
}
//-->


<!--
// 7/13/00, Downloaded from the web, coded by Yehuda Shiran. 
// 7/14/00 JPX: Modified for eCOW.

var da = (document.all) ? 1 : 0;
var pr = (window.print) ? 1 : 0;
var mac = (navigator.userAgent.indexOf("Mac") != -1); 

function printPage() {
  if (pr) { // NS4, IE5
  	stripHeaderAndFooterForPrinting();
    window.print();
  } else if (da && !mac) { // IE4 (Windows)
	stripHeaderAndFooterForPrinting();
    vbPrintPage();
  } else { // other browsers
    alert("Sorry, your browser doesn't support this feature. \nPlease use Print... command on your browser File menu \nor Print button on your browser toolbar.");
  }
  return false;
}

function stripHeaderAndFooterForPrinting() {
	//document.getElementById('centerAligned').innerHTML="&nbsp;";
}

if (da && !pr && !mac) with (document) {
  writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
  writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
  writeln('Sub window_onunload');
  writeln('  On Error Resume Next');
  writeln('  Set WB = nothing');
  writeln('End Sub');
  writeln('Sub vbPrintPage');
  writeln('  OLECMDID_PRINT = 6');
  writeln('  OLECMDEXECOPT_DONTPROMPTUSER = 2');
  writeln('  OLECMDEXECOPT_PROMPTUSER = 1');
  writeln('  On Error Resume Next');
  writeln('  WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
  writeln('End Sub');
  writeln('<' + '/SCRIPT>');
}

// 12/20/05 KGB: Added the common Macromedia rollover image functions, so we don't
//		have to include them all over the place -->
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function embedFlashMovie(filePathName, myWidth, myHeight, myBGColor) {
	// 12/1/06 KGB: Updated to remove the loop="false" attribute of the embed element.
	//		This was causing the Story Players not to run on Mac Safari, Netscape and Firefox.
	// 7/17/06 KGB: If hasRightFlashVersion is set to -99, then the calling page doesn't have the
	//	new Flash detection code yet. We did this for backwards-compatibility.
    if (myBGColor == null){ myBGColor = "#ffffff"; }
	if (hasRightFlashVersion == -99 || hasRightFlashVersion) {
		var oeTags = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
		+ ' width="'+myWidth+'" height="'+myHeight+'" bgcolor="'+myBGColor+'"'
		+ ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
		+ '<param name="movie" value="'+filePathName+'" />'
		+ '<param name="quality" value="high" />'
		+ '<embed src="'+filePathName+'"' 
		+ ' bgcolor="'+myBGColor+'"'
		+ ' width="'+myWidth+'" height="'+myHeight+'"'
		+ ' name="movie"'
		+ ' align="middle"'
		+ ' play="true"'
		+ ' quality="high"'
		+ ' allowscriptaccess="sameDomain"'
		+ ' type="application/x-shockwave-flash"'
		+ ' pluginspage="http://www.macromedia.com/go/getflashplayer">'
		+ '</embed>'
		+ '</object>';
		document.write(oeTags);   // embed the flash movie
	} else 
		document.write(alternateContent);  // insert non-flash content
}

// These 3 variables were moved from MM_Flash_Detect.js  7/10/06
// The version of Flash the user's machine has installed.
var flashVer;

// flag which is set to true or false depending on if we have the right version of flash
var hasRightFlashVersion = -99; 	// Set to -99 so we can tell that we haven't yet checked!
var hasRightDirectorVersion = false; 

// The alternate content message if the user doesn't have the appropriate Flash Plugin installed:
var alternateContent = '<TABLE cellpadding=4 border=1><TR><TD><font face="Arial, Helvetica, sans-serif" size="2" color="#BB0000">The HighlightsKids site requires the Adobe Flash Player. Speak with your parents about installing the Flash Player.</font></TD></TR></TABLE>';

// The alternate content message if the user doesn't have the appropriate SW Director Plugin installed:
var alternateDirectorContent = '<TABLE cellpadding=4 border=1><TR><TD><font face="Arial, Helvetica, sans-serif" size="2" color="#BB0000">The HighlightsKids site requires the Adobe Shockwave Director Player. Speak with your parents about installing the Shockwave Director Player.</font></TD></TR></TABLE>';


// Based on the web
function getQueryStringValue(name)
{
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var tmpURL = window.location.href;
  var results = regex.exec( tmpURL );
  if( results == null )
    return "";
  else
    return decodeURI(results[1]);
}


// Validate the Eail Submission Form
function checkHFCemailSubmissionForm(f) {

	if (f.name != undefined) {
		f.name.value = f.name.value.replace(/^\s*(\b.*\b|)\s*$/, "$1");
		if (f.name.value == "" || f.name.value == "0") {
			alert(emailSubmitNameEmpty);
			f.name.focus();
			return false;
		}
	}
	
	if (f.age != undefined) {
		f.age.value = f.age.value.replace(/^\s*(\b.*\b|)\s*$/, "$1");
		if (f.age.value == "" || f.age.value == "0") {
			alert(emailSubmitAgeEmpty);
			f.age.focus();
			return false;
		}
	}
	
	if (f.email != undefined) {
		f.email.value = f.email.value.replace(/^\s*(\b.*\b|)\s*$/, "$1");
		if (!ecValidateEmailNoMsg (f.email.value)) {
			alert(emailSubmitEmailInvalid);
			f.email.focus();
			return false;
		}
	}
	if (f.emailConfirm != undefined) {
		f.emailConfirm.value = f.emailConfirm.value.replace(/^\s*(\b.*\b|)\s*$/, "$1");
		if (f.emailConfirm.value != f.email.value) {
			alert(emailSubmitEmailsDontMatch);
			f.emailConfirm.focus();
			return false;
		}
	}

	if (f.state != undefined) {
		if (f.state.value == "") {
			alert(emailSubmitStateEmpty);
			f.state.focus();
			return false;
		}
	}

	if (f.comment != undefined) {
		f.comment.value = f.comment.value.replace(/^\s*(\b.*\b|)\s*$/, "$1");
		if (f.comment.value == "" || f.comment.value == "0") {
			alert(emailSubmitCommentEmpty);
			f.comment.focus();
			return false;
		} else if (f.comment.value.length >= 4000) {
			alert(emailSubmitCommentTooLong);
			f.comment.focus();
			return false;
		}
	}
	

	// Done checking. Dynamically assign other parameters.
	f.subject.value = emailSubmitSubject; 
	f.thanksPage.value = emailSubmitThanksPage; 
	f.returnPage.value = emailSubmitReturnPage; 
	f.emailErrorPage.value = emailSubmitEmailErrorPage; 

	// All done
	return true;
	
}

// -->
