/* finalsiteCf fs_global.js

****** Requires scriptaculous *******

-- Version History --

1.0 - Merged global.js and javascript.js


-- Functions --

fsBtn('btn_name','state','alt_onSrc') or fsBtn('btn_name','state','otherBtn_name,other/btn/src.jpg');
-- state: on/off (on is default)

*/

/*
TODO

- Menu direction does not work with animated menus
- Change style from "visibility:hidden" to "display:none" on dropdowns for use with animated scriptaculous menus, then remove the style swithing code from preLoad
- fsBtn on text link assumes menu exists. Move menu checking to showSubs().
- edit flash code to allow for variable alternate HTML output (add writeFlash from old flash.js)

 */

document.write('<script type="text/javascript" src="javascript/flash_headers.js"></script>');

// these items can be redefined in global_vars.js
var menu_pause = 250;
var anim_menus = 0;
var menu_speed = .25;
var use_overview_pages = 0;
var use_select_btn = 0;
var section_subs = 0;
var linkBackMsg = "&lt; back to page list";
var menu_dir;
var otherBtns = new Array();
var otherImages = new Array();
function loadJS(){}


// Browser & Platform Check
var isIE = (document.all) ? true : false;
var isNS4 = (document.layers) ? true : false;
var isNS6 = (document.getElementById && !isIE) ? true : false;
var isSafari = (navigator.userAgent.indexOf("Safari") >= 0) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

var isMAC = (navigator.appVersion.toLowerCase().indexOf("mac") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;

//button variables
var sectionId = "";
var sectionBtn = "";
var thisMenu = "";
var xBtn = "";
var xBtnImg = "";
var wait;
var fsLinks = new Array();
var buttons = new Array();


//onLoad functions
addOnloadEvent(preLoad);

// Use this to add a function to the onload event
function addOnloadEvent(fnc){
  if ( typeof window.addEventListener != "undefined" )
    window.addEventListener( "load", fnc, false );
  else if ( typeof window.attachEvent != "undefined" ) {
    window.attachEvent( "onload", fnc );
  }
  else {
    if ( window.onload != null ) {
      var oldOnload = window.onload;
      window.onload = function ( e ) {
        oldOnload( e );
        window[fnc]();
      };
    }
    else
      window.onload = fnc;
  }
}

// Button Object Constructor
function btnObj(btnName,menuName,pageId,offSrc,onSrc,selectSrc) {
	this.btnName = btnName;
	if( menuName.indexOf("|") != -1 ){
		this.menuName = menuName.split("|")[0];
		this.menuDirection = menuName.split("|")[1];
	}else{
		this.menuName = menuName;
	}
	this.pageId = pageId;
	this.offSrc = offSrc;
	this.onSrc = onSrc;
	this.selectSrc = selectSrc;
}


function preLoad(){
	
	colorLink();
	loadJS();
	setStyle();
	linkBack();
	
	//------------------------ Create fsLinks buttons -----------------//

	//get all <a> tags
	fsLinks = document.getElementsByTagName('a');
	
	
	//test for fsbtn class and add button events
	for(i=0;i<fsLinks.length;i++){
		if( fsLinks[i].className.toLowerCase() == 'fsbtn' ){
			//get page id from href
			var search_str = fsLinks[i].search.split('&');
			for(j=0;j<search_str.length;j++){
				if(search_str[j].split('=')[0] == '?p'){
					fsLinks[i].pid = search_str[j].split('=')[1]; //add a pid attribute to <a> tag and assign id value
				}else{
					//this is for links other than "page.cfm"
					fsLinks[i].pid = "btn"+i; //add a generic id
				}
			}
			
			//create menu reference
			fsLinks[i].menu = "dhtmlmenu_"+fsLinks[i].pid;
			
			// change style from "visibility:hidden" to "display:none"
			// for use with animated scriptaculous menus
			if( anim_menus && document.getElementById(fsLinks[i].menu)){
				document.getElementById(fsLinks[i].menu).style.display = "none";
				document.getElementById(fsLinks[i].menu).style.visibility = "visible";
			}

			//check if there is anything in the <a> tag besides text
			if(fsLinks[i].childNodes[0].tagName){ 
				fsLinks[i].childNodes[0].id = "dhtmlbtn_"+fsLinks[i].pid; //add ID to the image			
				fsLinks[i].childNodes[0].onSrc = fsLinks[i].childNodes[0].src.replace(/\.(gif|jpg)/,"_on.$1"); //create onSrc and add to image
				
				if(use_select_btn){
					fsLinks[i].childNodes[0].selectSrc = fsLinks[i].childNodes[0].src.replace(/\.(gif|jpg)/,"_select.$1"); //create selectSrc and add to image
				}else{
					fsLinks[i].childNodes[0].selectSrc = fsLinks[i].childNodes[0].src.replace(/\.(gif|jpg)/,"_on.$1"); //create selectSrc and add to image
				}
				buttons[fsLinks[i].childNodes[0].id] = new btnObj(fsLinks[i].childNodes[0].id,fsLinks[i].menu,fsLinks[i].pid,fsLinks[i].childNodes[0].src,fsLinks[i].childNodes[0].onSrc,fsLinks[i].childNodes[0].selectSrc);
				
				fsLinks[i].onmouseover = function (){ fsBtn(this.childNodes[0].id); }
				fsLinks[i].onmouseout = function (){ fsBtn(this.childNodes[0].id,'off'); }

			}else{
				fsLinks[i].id = "dhtmlbtn_"+fsLinks[i].pid; //add ID to the a tag
				buttons[fsLinks[i].id] = new btnObj(fsLinks[i].id,fsLinks[i].menu,fsLinks[i].pid,'','');
				fsLinks[i].onmouseover = function (){ showSubs(this.id); this.className = "fsBtn_on"; }
				fsLinks[i].onmouseout = function (){ mnuOut(this.id); }
			}
		
			if(use_overview_pages && document.getElementById(fsLinks[i].menu)){ fsLinks[i].href = document.getElementById(fsLinks[i].menu).getElementsByTagName('a')[0].href; }
		
			//turn on section button here
			for(n=0;n<pagearray.length;n++){
				if( fsLinks[i].pid == pagearray[n] ){
					fsLinks[i].className = "fsBtn_on";
					sectionId = fsLinks[i].pid;
					sectionBtn = fsLinks[i].id;
				}
			}
		
		
		}//end fsBtn check
		
		//Auto generate ql_btn code
		if( fsLinks[i].className.toLowerCase() == 'qlbtn' ){
			
			// change style from "visibility:hidden" to "display:none"
			// for use with animated scriptaculous menus
			if( anim_menus && document.getElementById('ql_menu')){
				document.getElementById('ql_menu').style.display = "none";
				document.getElementById('ql_menu').style.visibility = "visible";
			}
			
			if(fsLinks[i].childNodes[0].tagName){ 
				fsLinks[i].childNodes[0].id = "ql_btn"; //add ID to the image			
				fsLinks[i].childNodes[0].onSrc = fsLinks[i].childNodes[0].src.replace(/\.(gif|jpg)/,"_on.$1"); //create onSrc and add to image
				buttons['ql_btn'] = new btnObj('ql_btn','ql_menu','0',fsLinks[i].childNodes[0].src,fsLinks[i].childNodes[0].onSrc);			
				fsLinks[i].onmouseover = function (){ fsBtn('ql_btn'); }
				fsLinks[i].onmouseout = function (){ fsBtn('ql_btn','off'); }
			}else{
				fsLinks[i].id = "ql_btn"; //add ID to the a tag
				buttons['ql_btn'] = new btnObj('ql_btn','ql_menu','0','','');
				fsLinks[i].onmouseover = function (){ showSubs('ql_btn'); }
				fsLinks[i].onmouseout = function (){ mnuOut('ql_btn'); }
				
				document.getElementById('ql_menu').onmouseover = function(){ clearTimeout(wait); }
				document.getElementById('ql_menu').onmouseout = function(){ mnuOut('ql_btn','ql_menu'); }
		
				
			}
		}
	}//end loop through fsLinks
	
	//add otherBtns
	if(otherBtns.length>0){
		for(i=0;i<otherBtns.length;i++){
			btnAttrs = otherBtns[i].split(',');
			buttons[btnAttrs[0]] = new btnObj(btnAttrs[0],btnAttrs[1],btnAttrs[2],btnAttrs[3],btnAttrs[4]);
		}
	}

	//preLoad loops through the buttons array and pre-loads all of the onSrc's
	//Also defines sectionID & sectionBtn & turns on section button

	if(document.images){
		var myImages = new Array();
		var i=0;
		for (this.btnName in buttons) {
			if (buttons[this.btnName].onSrc){
				myImages[i] = new Image();
				myImages[i].src = buttons[this.btnName].onSrc;
				i++;
				var n = 0;
				for (n in pagearray) { // loop through pagearray to match pageid
					if (pagearray[n] == buttons[this.btnName].pageId) {
						if(use_select_btn){
							document.images[this.btnName].src = buttons[this.btnName].selectSrc;
						}else{
							document.images[this.btnName].src = buttons[this.btnName].onSrc;
						}
						sectionId = buttons[this.btnName].pageId;
						sectionBtn = buttons[this.btnName].btnName;
					}
					n++;
				}
			}
		}
	
	if(otherImages){
		var oi = new Array();
		for(i=0; i < otherImages.length; i++){
			oi[i] = new Image(); oi[i].src = otherImages[i];
		}
	}
	
	}

} //end preLoad


function fsBtn(btn,state,alt_onSrc){
	if(alt_onSrc){
		if(alt_onSrc.indexOf(",") != -1){ //check if there is a comma list with btn_name and src
			ob = alt_onSrc.split(",");
			xBtn = ob[0];
			xBtnImg = ob[1];
			swapImage(btn);
		}else{
			// if there is just an alt src then only that button will be changed
				// this function may no longer be needed but is included for backwards compatiblity
			document.images[btn].src = alt_onSrc;
		}
	}else if(state == "off"){
		imgRestore(btn);
	}else{ swapImage(btn); }
}

function swapImage(btn){
	//swapImage creates a roll-over effect from onSrc when passed the name of the button
	//Also shows sub-menus if specified
	if(buttons[btn].pageId != sectionId){ // btn src will not change if it is in the section, this preserves the selectSrc
		document.images[btn].src = buttons[btn].onSrc; //Turn button on
	}
	
	//check btnID against sectionId and section_menu variable before turning on sub menus
	if( buttons[btn].menuName && document.getElementById(buttons[btn].menuName) ){
	//Turn on menus if section sub option is on or the button pageId does not equal the sectionId
		showSubs(btn);
	}else if( (thisMenu.length>0) && (thisMenu != buttons[btn].btnName) ){
		clearSubs(thisMenu);
	}
	
	if(xBtn){ document.images[xBtn].src = xBtnImg; }
	
} //end swapImage

function imgRestore(btn){
	// turns button off unless it is the section button or has a menu
	if(buttons[btn].menuName && document.getElementById(buttons[btn].menuName)){
		mnuOut(btn);
	}else if(buttons[btn].pageId != sectionId){
		document.images[btn].src = buttons[btn].offSrc;
		if(xBtn){ document.images[xBtn].src = buttons[xBtn].offSrc; }
	}
}


//Sub Menu Functions
function showSubs(btn){
	if((thisMenu.length>0) && (thisMenu != buttons[btn].btnName)){ //turn off any current menus unless we are still on the same button
		clearSubs(thisMenu);
	}
	// set offsets based on browser			 
	
	var mDir = (buttons[btn].menuDirection) ? buttons[btn].menuDirection : menu_dir;
	
	var mName = document.getElementById(buttons[btn].menuName);
	var bName = document.getElementById(buttons[btn].btnName);
	
	if(section_subs == 1 || (buttons[btn].pageId != sectionId)){ //Test for section subs option and section ID

		mName.style.left = findPosX(bName) + "px";

		if( mDir == "up" ){ mName.style.top = (findPosY(bName) - mName.scrollHeight) + "px";
		}else if( mDir == "center" ){ mName.style.top = (findPosY(bName) - (mName.scrollHeight / 2) + (bName.scrollHeight/2)) + "px";
		}else{ mName.style.top = (findPosY(bName) + bName.scrollHeight) + "px"; }

		if(anim_menus){
			if(thisMenu != buttons[btn].btnName){
				new Effect.BlindDown(buttons[btn].menuName,{ duration:menu_speed, queue: {position:'end', scope: btn} });
			}
		}else{
			mName.style.visibility = 'visible';
		}	

		thisMenu = buttons[btn].btnName; //add menu to close later
	}
	
	clearTimeout(wait);
} //end showSubs


function mnuOut(btn){
	wait = setTimeout("clearSubs('"+ btn +"')", menu_pause);
}

function clearSubs(btn) { //clears open menu
	if(buttons[btn].menuName){
		if(anim_menus){
			new Effect.BlindUp(buttons[btn].menuName,{ duration:menu_speed,afterFinish:function(){btnOff(btn)}, queue: {position:'end', scope: btn} });
		}else{
			document.getElementById(buttons[btn].menuName).style.visibility='hidden';
			btnOff(btn);
		}
		thisMenu="";
	}else{
		btnOff(btn);
	}
	if(document.getElementById(btn).className=="fsBtn_on" && buttons[btn].pageId != sectionId){ document.getElementById(btn).className="fsBtn"; }
}

function btnOff(btn){
	if(buttons[btn].pageId != sectionId && buttons[btn].offSrc){
			document.images[btn].src = buttons[btn].offSrc; //turn button back off
			}else if(buttons[btn].selectSrc){
				document.images[btn].src = buttons[btn].selectSrc;
			}
	if(xBtn){ document.images[xBtn].src = buttons[xBtn].offSrc; }
}


//Automatically find x,y positions of objects
function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }
//end Sub Menus

// ----------------------------------------------


function swapStyle(title) {
	document.getElementById('contentdiv').className = title;
	createCookie("cfstyle", title);
}

function setStyle() {
	var style = readCookie("cfstyle");
	if (style != null && document.getElementById('contentdiv')) { swapStyle(style);}
}


// ----------------------------------------------
// Cookie functions
// ----------------------------------------------

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = ";expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+";path=/;";
}

// ----------------------------------------------

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

//Colorize parent links in banner navigation module
function colorLink(){
	var links = new Array();
	
	if( document.getElementById('leftbanner') ){
		links = document.getElementById('leftbanner').getElementsByTagName('a');	
		for(i=0;i < links.length;i++){
			for(j=2; j<pagearray.length;j++){
				rExp = new RegExp( "p=" + pagearray[j] + "$" , "i" );
				if( links[i].href.search(rExp) > 0 ){ 
					links[i].className = 'nav_history';
				}
			}
		}		
	}
}

function linkBack(){
	if(document.location.href.indexOf('pback')>=0){ 
		pb = document.location.href.split('pback=')[1].split('&')[0];

		if(pb > 0){
			bLink = '<a href="page.cfm?p=' + pb + '" class="link_back">'+ linkBackMsg +'</a>';
		}else{
			bLink = '<a href="#" onclick="history.back();" class="link_back">'+ linkBackMsg +'</a>';
		}

		document.getElementById('contentdiv').innerHTML = document.getElementById('contentdiv').innerHTML + bLink;
	}
}

/*
	fsRedirect accepts a desitination URL to redirect the browser to and,
	optionally, a warn message which will produce a confirmation dialog
*/
function fsRedirect(l,warn){
	if(!parent.topframe){
		if(warn){
			if(confirm(warn)){document.location.replace(l);}else{return false;}
		}else{
			document.location.replace(l);
		}
	}
}

/*---------------------------
 Start of javascript.js code
*/

 

if (typeof(pathprefix) != "string"){
	var pathprefix = '';	
}

function valuevalidation(entered, min, max, alertbox, datatype)
	{
		// Value Validation by Henrik Petersen / NetKontoret
		// Explained at www.echoecho.com/jsforms.htm
		// Please do not remove this line and the two lines above.
		with (entered)
		{
		checkvalue=parseFloat(value);
		if (datatype)
		{smalldatatype=datatype.toLowerCase();
		if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value)};
		}
		if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue)
		{if (alertbox!="") {alert(alertbox);} return false;}
		else {return true;}
		}
	}

function popUp(url,w,h){
	var properties = 'toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width='+w+',height='+h+'';
	mypopup = window.open(url,'name', properties);
	if (mypopup == undefined) {alert('It appears that your browser has popup blocking enabled.\nPlease modify this setting to allow for full functionality.');}
	else {mypopup.focus();}
}

// Init pop-up height vars
var addHeight = 0;
var baseHeight = 490;
var testHeight = false;
function popMedia(thevar) {
	
	var mh_url = pathprefix + "cf_media2/popheight.cfm";
	
	synRequest(mh_url);
	mediaAction(thevar);
	
}

// perform actual window open
function mediaAction (thevar){
	var popHeight = baseHeight + (addHeight/1);
	
	if ( ((thevar.indexOf('grp=') != -1) || (thevar.indexOf('cat=') != -1) || (thevar.indexOf('chnl=') != -1) || (thevar.indexOf('obj='))) != -1 && thevar != '' ) {
		
		/* Replaced by new media 
		theurl = pathprefix + 'cf_media/index.cfm?' + thevar;
		var properties = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550';
		*/
		if ((thevar.indexOf('grp='))  != -1 && thevar != '') {
			thevar = thevar.replace('grp','g');
			
			var properties = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=580,height='+popHeight;
			theurl = pathprefix + 'cf_media2/index.cfm?' + thevar;
		} else {
			
			// Launch Full Player
			var properties = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=830,height='+popHeight;
			theurl = pathprefix + 'cf_media2/index.cfm?' + thevar;
		}
	} else {
		if ((thevar.indexOf('g='))  != -1 && thevar != '') {
			var properties = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=580,height='+popHeight;
			theurl = pathprefix + 'cf_media2/index.cfm?' + thevar;
		} else {
			var properties = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=830,height='+popHeight;
			theurl = pathprefix + 'cf_media2/index.cfm?' + thevar;
		}
		
	}
	mymedia = window.open(theurl,'popupmedia', properties);
	mymedia.focus();
}

// Callback for getting the media header height
function mediaHeight(rq,thevar) {
	addHeight = rq.responseText;
	testHeight = true;
	
}

function synRequest(url){
	
	if(window.XMLHttpRequest) {
		// Gecko (Firefox, Moz), KHTML (Konqueror, Safari), Opera, Internet Explorer 7
		var req = new XMLHttpRequest(); 
	} else if(window.ActiveXObject) {  
		var req = new ActiveXObject("Microsoft.XMLHTTP"); // Internet Explorer 4,5,5.5,6
	} 
	
	req.open('GET', url, false); 
	req.send(null);
	if(req.status == 200){
		addHeight = req.responseText;
	} else {
		// Fail to default of 80
		addHeight = 80;
	}
 	
}

// Request
	function request(url,method,qs,callback,cbparam){
		var myRequest = null;
		var ready  = false;
	
		try {
			if(window.XMLHttpRequest) {
				
				// Gecko (Firefox, Moz), KHTML (Konqueror, Safari), Opera, Internet Explorer 7
				myRequest = new XMLHttpRequest(); 
			} else if(window.ActiveXObject) {  
				myRequest = new ActiveXObject("Microsoft.XMLHTTP"); // Internet Explorer 4,5,5.5,6
			} 
		} catch(e) {
			return false;
		}
		
		ready = false;
		method = method.toUpperCase();
	
		try {
			if((method=="GET") || (method=="HEAD"))
			{
				myRequest.open(method, url+qs, true);
			}
			else if(method=="POST")
			{
				myRequest.open(method, url, true);
				myRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			}
			myRequest.onreadystatechange = function(){
				if(myRequest.readyState==4 && !ready) {
					ready = true;
					callback(myRequest,cbparam);
				} else {
				return false;
				}
			}
			myRequest.send(qs);
		}
		catch(e) {
			return false;
		}
		return true;
	}
	

//moved flash version variables to the top of file

function writeJS(player,grp,wide,high,auto,rand,loop_tog,time,aspect){
	 
	if(player == 'slideshow'){
		var playerType = 'slideshow_small';	
        var defaultHeight = 225;
        var defaultWidth = 300;
		
	}
	else if(player == 'mp3'){
		var playerType = 'mp3_small';
        var defaultHeight = 80;
        var defaultWidth = 300;
		aspect = (defaultWidth/defaultHeight); // force landscape view
	}
	else if(player == 'video'){
		var playerType = 'video_small';
        var defaultHeight = 225;
        var defaultWidth = 300;
	}
	
	if(grp != null){var mediaPath = grp;}
	if(auto != null){var autoplay = auto;}
	if(rand != null){var ran = rand;}
	if(time != null){var timer = time;}

    if((wide != null)&&(high != null)){
		var width = wide;
		var height = high;
	}
    else if((wide != null)&&(high == null)){
		var width = wide;
		
		// (defaultHeight/defaultWidth) or (defaultWidth/defaultHeight)
		var height = Math.round(width * aspect); 
		
		// force mp3 height to be static - (height < 80)&&
        if((player == 'mp3')){
			height = 80;
         }
	}
	else if((wide == null)&&(high != null)){
		var height = high;
		
		// (defaultWidth/defaultHeight) or (defaultHeight/defaultWidth)
		var width = Math.round(height * aspect);
		
	}
    else if((wide == null)&&(high == null)){
		var width = defaultWidth;
		var height = defaultHeight;
	}

	var filename = "cf_media2/players/"+playerType+".swf";

        var alternateContent = '<div id="tooolds"><p>We have detected that your version of flash is too old.</p><p>This Media Gallery requires Flash 8 or higher</p><p align="center"><a href="http://www.adobe.com/go/getflashplayer" target="_blank"><img src="cf_media2/images/get_flash_player.gif" alt="Get the Flash Player" border="0" /></a></p></div>';

	var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	
	// +' <param name="bgcolor" value="#000000" />'
	if(hasRightVersion) {  // if we've detected an acceptable version
    	var oeTags = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
   		+ 'width="'+width+'" height="'+height+'"'
    	+ 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" id="mm_movie'+grp+'">'
	    + '<param name="movie" value="'+filename+'" />'
	    + '<param name="quality" value="high" /><param name="wmode" value="transparent" />'
                
		+ '<param name="FlashVars" value="high='+height+'&wide='+width+'&autoplay='+autoplay+'&rand='+ran+'&timer='+timer+'&grp='+grp+'" />'
    	+ '<embed src="'+filename+'" quality="high" wmode="transparent"'
    	+ 'width="'+width+'" height="'+height+'" name="mm_movie'+grp+'" align="middle"'
		+ 'FlashVars="high='+height+'&wide='+width+'&autoplay='+autoplay+'&rand='+ran+'&timer='+timer+'&grp='+grp+'" '
    	+ 'play="true"'
	    + 'loop="'+loop_tog+'"'
	    + '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
	  return oeTags;
  	} 
 	else {  // flash is too old or we can't detect the plugin
  	 	// document.write(alternateContent);  // insert non-flash content
		return alternateContent;
 	}
}


// THIS SCRIPT IS USED TO GET THE DIMENSIONS OF A DIV OR TABLE - mostly for media2
function getStyle(elem, style) {
	if(!document.getElementById){return;}
	
	var value = elem.style[style];
	
	if(!value){
		if(document.defaultView){
			value = document.defaultView.getComputedStyle(elem, "").getPropertyValue(style);
		}
        else if(elem.offsetWidth){
			//value = elem.currentStyle[style];
			value = elem.offsetWidth;	
		}
	}
	return value;
}

// Output the media html
function writeMediaJS(divID,playername,data1,mediawidth,mediaheight,auto_tog,random_tog,loop_tog,delay_num,data7){
	var theDiv=document.getElementById(divID);
	
	if(mediawidth == null){
		var currWidth = parseInt(getStyle(theDiv,"width"));
		if((currWidth==0)||(isNaN(currWidth))){currWidth = null;}
	} else {
		var currWidth = mediawidth;
	}
	
	if(mediaheight == null){
		var currHeight = parseInt(getStyle(theDiv,"height"));
		if((currHeight==0)||(isNaN(currHeight))){currHeight = null;}
	} else {
		var currHeight = mediaheight;
	}
	
	theDiv.innerHTML = writeJS(playername,data1,currWidth,currHeight,auto_tog,random_tog,loop_tog,delay_num,data7);
}

function printpage(){
	thestring = location.search.substring(1);
	var findid = thestring.indexOf('id=');
	var findp = thestring.indexOf('p=');
	if (thestring.length == 0){thestring = 'p=' + pageid}
	else if (findid == -1 && findp == -1){thestring = thestring + '&p='+pageid}
   
	for (var f = 0; f<document.forms.length; f++)
		{
		for (var i = 0; i<document.forms[f].length; i++)
			{
			if (thestring.indexOf(document.forms[f].elements[i].name) == -1 && document.forms[f].elements[i].value != "" && document.forms[f].elements[i].type != "submit" && document.forms[f].elements[i].name != "" && document.forms[f].elements[i].name.indexOf('savecontent') == -1 && document.forms[f].elements[i].name.indexOf('savetext') == -1 && document.forms[f].elements[i].name != "p" && thestring.indexOf(document.forms[f].elements[i].name) == -1  && document.forms[f].elements[i].name != "do" && document.forms[f].elements[i].name != "calid_pull" && document.forms[f].elements[i].name != "customizeit")
				{
				if (document.forms[f].elements[i].type == 'checkbox') 
					{
						if (document.forms[f].elements[i].checked == true) 
							{
								thestring = thestring + "&" + document.forms[f].elements[i].name + "=" + document.forms[f].elements[i].value;
							} 
					}
				else {
					if (document.forms[f].elements[i].value.indexOf('&') == -1)
						{thestring = thestring + "&" + document.forms[f].elements[i].name + "=" + document.forms[f].elements[i].value;}
					else
						{
							var splitValue = document.forms[f].elements[i].value.split("&");
							for(v = 0; v < splitValue.length; v++){
								if (thestring.indexOf(splitValue[v]) == -1)
									{thestring = thestring + "&" + splitValue[v]}
							}
						}
					}
				}
			}
		}

	var url = 'pageprint.cfm?'+thestring;
	var properties = 'toolbar=yes,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=650,height=600';
	printpop = window.open(url,'Print', properties);
	printpop.focus();
}

function emailpage(){
	thestring = location.search.substring(1);
	var findid = thestring.indexOf('id=');
	var findp = thestring.indexOf('p=');
	if (thestring.length == 0){thestring = 'p=' + pageid}
	else if (findid == -1 && findp == -1){thestring = thestring + '&p='+pageid}
	
	for (var f = 0; f<document.forms.length; f++)
		{
		for (var i = 0; i<document.forms[f].length; i++)
			{
			if (thestring.indexOf(document.forms[f].elements[i].name) == -1 && document.forms[f].elements[i].value != "" && document.forms[f].elements[i].type != "submit" && document.forms[f].elements[i].name != "" && document.forms[f].elements[i].name.indexOf('savecontent') == -1 && document.forms[f].elements[i].name.indexOf('savetext') == -1 && document.forms[f].elements[i].name != "p" && thestring.indexOf(document.forms[f].elements[i].name) == -1  && document.forms[f].elements[i].name != "do" && document.forms[f].elements[i].name != "calid_pull" && document.forms[f].elements[i].name != "customizeit")
				{
				if (document.forms[f].elements[i].type == 'checkbox') 
					{
						if (document.forms[f].elements[i].checked == true) 
							{
								thestring = thestring + "&" + document.forms[f].elements[i].name + "=" + document.forms[f].elements[i].value;
							} 
					}
				else {
					if (document.forms[f].elements[i].value.indexOf('&') == -1)
						{thestring = thestring + "&" + document.forms[f].elements[i].name + "=" + document.forms[f].elements[i].value;}
					else
						{
							var splitValue = document.forms[f].elements[i].value.split("&");
							for(v = 0; v < splitValue.length; v++){
								if (thestring.indexOf(splitValue[v]) == -1)
									{thestring = thestring + "&" + splitValue[v]}
							}
						}
					}
				}
			}
		}

	var url = 'pageemail.cfm?'+thestring;
	var properties = 'toolbar=yes,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=420,height=300';
	emailpop = window.open(url,'Email', properties);
	emailpop.focus();
}

var x = 1;
var y = x;

function confirmIt(){
	if (x == 1) {}
	else {return("You have not saved the latest changes made to this page. The\nchanges will be discarded if you leave before clicking 'save changes'.")}
}

function writeDate(){
var months=new Array(13);
months[1]="January";
months[2]="February";
months[3]="March";
months[4]="April";
months[5]="May";
months[6]="June";
months[7]="July";
months[8]="August";
months[9]="September";
months[10]="October";
months[11]="November";
months[12]="December";
var time=new Date();
var lmonth=months[time.getMonth() + 1];
var date=time.getDate();
var year=time.getYear();
if(year<1000){year = 1900 + year}
return(lmonth + " " + date + ", " + year);
}

function mailMe(which){
	which = unescape(which);
	window.location="mailto:"+which.replace(/\[nospam\]/,"@");
}
