// JavaScript files for PCTS website framework - 20080523 v. 1

// declare a global object to act as a primary namespace
var pctsFramework = {};

// also declare an object for a primary namespace
var pcts = {};

// also declare a page namespace
var page = {};

// --- namespace properties -------
pctsFramework.clientHeight = 3000;
pctsFramework.clientWidth = '';
pctsFramework.readyState = '';
pctsFramework.browserPath = '';
pctsFramework.browserParent = '';
pctsFramework.browserVersion = '';
pctsFramework.browser = '';
pctsFramework.currentPage = null;
pctsFramework.selectedGallerySequence = '';
pctsFramework.selectedGallerySource = '';
pctsFramework.selectedGalleryWidth = '';
pctsFramework.selectedGalleryHeight = '';
pctsFramework.selectedGalleryCaption = '';
pctsFramework.imageString = '';
pctsFramework.balloonTimer = '';
pctsFramework.balloonShown = false;
pctsFramework.balloonIn = false;
pctsFramework.safari = false;
pctsFramework.maskShown = false;
pctsFramework.discoveredBrowser = '';
pctsFramework.alertTitle = '';
pctsFramework.alertBody = '';
pctsFramework.resourceSecure = false;
pctsFramework.showSource = '';
pctsFramework.currentYear = '';
pctsFramework.pastYear = '';
pctsFramework.nextYear = '';
pctsFramework.pendingMediaID = '';
pctsFramework.pendingMediaType = '';
pctsFramework.pendingMediaCaption = '';
pctsFramework.webAccessor = '';
pctsFramework.orphanMode = true;
pctsFramework.pngFix = false;
pctsFramework.shareLink = '';
pctsFramework.pageTitle = '';
pctsFramework.sitePrefix = 'www';
pctsFramework.platform = '';
pctsFramework.version = '';
pctsFramework.mobileDevice = '';
pctsFramework.mobileDeviceProfile = '';
pctsFramework.mobileDeviceTemplate = '';
pctsFramework.transactionState = '';
pctsFramework.currentIP = '';
pctsFramework.registeredUser = '';
pctsFramework.browseCapMajorVersion = '';
pctsFramework.inCMS = '0';


// --- static page elements for consumption by script -------
pctsFramework.bigSpinnerPart1 = "<div style=\"position:relative; width:100%\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td id=\"pctsSpinnerCell\" height=\"";
pctsFramework.bigSpinnerPart2 = "\" align=\"center\" valign=\"middle\"><div class=\"inPlaceSpinner_bg\" style=\"height:53px; width:53px\"><table width=\"53\" height=\"53\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td align=\"center\" valign=\"middle\"><img src=\"../images/loading_anim.gif\" width=\"32\" height=\"32\" /></td></tr></table></div></td></tr></table></div>";
pctsFramework.balloonSpinner = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td align=\"center\" valign=\"middle\" ><img src=\"../images/balloonSpinner.gif\" /></td></tr></table>";

// --- namespace functions -------

pctsFramework.popAlert = function(theAlert) {
	// display an alert
	alert(theAlert);
}

pctsFramework.getClientHeight = function() {
	return document.documentElement.clientHeight;
}
	
pctsFramework.getClientWidth = function() {
	return document.documentElement.offsetWidth;
}

pctsFramework.setBasicClientData = function() {
	// get and retain basic information about the client
	
	// first, get the height
	pctsFramework.clientHeight = pctsFramework.getClientHeight();

	// now get the width
	pctsFramework.clientWidth = pctsFramework.getClientWidth();
	
	if (pctsFramework.browser == 'IE' && pctsFramework.browserVersion < 7) {
		pctsFramework.pngFix = true;
	}
	
}

pctsFramework.handleMobileDevices = function(deviceString) {
	// handle mobile devices if a valid mobile device profile is found

	// test to see if the connecting client is a mobile device
	if (pctsFramework.mobileDeviceProfileActive == 'true') {
		// handle the mobile platform as its profile is active
		var theLocationString = "http://mobile.pcts.com/" + deviceString + "/";
		window.location = theLocationString;
		
	}
}

pctsFramework.getContent = function(theContentSource, theTarget, showSpinner) {
	// ajax some content asynchronously, and return that content to a target
	// container after return

	// first, set up a request object.  We have to do this so it degrades gracefully for IE6
	if (window.XMLHttpRequest) {
		// this is IE7, safari, etc.

		var xmlhttp =  new XMLHttpRequest();

	} else {
		// this is probably IE6, so see if we can instantiate an activeX obejct
		if (window.ActiveXObject) {

     		try { var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.6.0") } catch(e) {}
  			try { var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.3.0") } catch(e) {}
  			try { var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch(e) {}
  			try { var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch(e) {}
		
			// var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');

  		}
	}

	// inject a loading indicator into the target object
	if (showSpinner != false) {
		// we do not show the spinner in IE6 because it will cause a crash
		// interacts with Ajax activeX object
		if (pctsFramework.browserVersion != '6.0') {
			pctsFramework.injectSpinner(theTarget);
		}

	}
	
	// wire up the callBack handler
	xmlhttp.onreadystatechange = function() {  
  		if(xmlhttp.readyState == 4)  
		var theReturn = xmlhttp.responseText;

		// alert(theReturn);

		// populate it only if it is not 'undefined'

		if (theReturn != undefined) {
			theTarget.innerHTML = theReturn;

		} else {
			// alert(theReturn);

		}
		
	};  

    // send the ajax request after the desired data
	xmlhttp.open('GET', theContentSource, true);
	xmlhttp.send(null);
}

pctsFramework.getData = function(theContentSource) {
	// ajax some data asynchronously, and return that data for evaluation

	// first, set up a request object.  We have to do this so it degrades gracefully for IE6
	if (window.XMLHttpRequest) {
		// this is IE7, safari, etc.
		var xmlhttp =  new XMLHttpRequest();

	} else {
		// this is probably IE6, so see if we can instantiate an activeX obejct
		if (window.ActiveXObject) {
     		try { var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.6.0") } catch(e) {}
			try { var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.3.0") } catch(e) {}
			try { var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch(e) {}
			try { var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch(e) {}
		
			// var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');

  		}
	}
	
	// wire up the callBack handler
	xmlhttp.onreadystatechange = function() {  
  		if(xmlhttp.readyState == 4) {   
			var theReturn = xmlhttp.responseText;
			// alert(theReturn);

			eval(theReturn);
			// eval(theReturn);	
		}
	};  

    // send the ajax request after the desired data
	xmlhttp.open('GET', theContentSource, true);
	xmlhttp.send(null);
}

pctsFramework.blindGetDate = function(theContentSource) {
	// ajax some data asynchronously, and return that data for evaluation

	// first, set up a request object.  We have to do this so it degrades gracefully for IE6
	if (window.XMLHttpRequest) {
		// this is IE7, safari, etc.
		var xmlhttp =  new XMLHttpRequest();

	} else {
		// this is probably IE6, so see if we can instantiate an activeX obejct
		if (window.ActiveXObject) {
     		try { var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.6.0") } catch(e) {}
  			try { var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.3.0") } catch(e) {}
  			try { var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch(e) {}
  			try { var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch(e) {}
		
			// var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');

  		}
	}
	
	// wire up the callBack handler
	xmlhttp.onreadystatechange = function() {  
  		if(xmlhttp.readyState == 4) {   
			var theReturn = xmlhttp.responseText;
			// alert(theReturn);

			// eval(theReturn);
			// eval(theReturn);	
		}
	};  

    // send the ajax request after the desired data
	xmlhttp.open('GET', theContentSource, true);
	xmlhttp.send(null);
}

pctsFramework.insertData = function(theContentSource) {
	// ajax some data asynchronously, and return that data for evaluation

	// first, set up a request object.  We have to do this so it degrades gracefully for IE6
	if (window.XMLHttpRequest) {
		// this is IE7, safari, etc.
		var xmlhttp =  new XMLHttpRequest();

	} else {
		// this is probably IE6, so see if we can instantiate an activeX obejct
		if (window.ActiveXObject) {
     		try { var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.6.0") } catch(e) {}
  			try { var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.3.0") } catch(e) {}
  			try { var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch(e) {}
  			try { var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch(e) {}
		
			// var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');

  		}
	}
	
	// wire up the callBack handler
	xmlhttp.onreadystatechange = function() {  
  		if(xmlhttp.readyState == 4) {   
			var theReturn = xmlhttp.responseText;

			eval(theReturn);

		}
	};  

    // send the ajax request after the desired data
	xmlhttp.open('GET', theContentSource, true);
	xmlhttp.send(null);
}

pctsFramework.getContentPlusData = function(theContentSource, theTarget, showSpinner) {
	// ajax some content asynchronously along with a data packet.  Return content to a target
	// container after return AND process data.

	// first, set up a request object.  We have to do this so it degrades gracefully for IE6
	if (window.XMLHttpRequest) {
		// this is IE7, safari, etc.

		var xmlhttp =  new XMLHttpRequest();

	} else {
		// this is probably IE6, so see if we can instantiate an activeX obejct
		if (window.ActiveXObject) {

     		try { var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.6.0") } catch(e) {}
  			try { var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.3.0") } catch(e) {}
  			try { var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch(e) {}
  			try { var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch(e) {}
		
			// var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');

  		}
	}

	// inject a loading indicator into the target object
	if (showSpinner != false) {
		// we do not show the spinner in IE6 because it will cause a crash
		// interacts with Ajax activeX object
		if (pctsFramework.browserVersion != '6.0') {
			pctsFramework.injectSpinner(theTarget);
		}

	}
	
	// wire up the callBack handler
	xmlhttp.onreadystatechange = function() {  
  		if(xmlhttp.readyState == 4)  
		var theReturn = xmlhttp.responseText;

		// populate the target only if it is not 'undefined'
		if (theReturn != undefined) {
			
			// break the return into parts.  The first part will be the script block returned, the second will be the content
			var theParts = theReturn.split('#content');
			var theData = theParts[0];
			
			// evaluate the returned data packet
			// and populate the innerHTML
			
			try {
				theTarget.innerHTML = theParts[1];
				
				eval(theData);
				
			} catch(err) {
				
			}

		} else {
			// alert(theReturn);

		}
		
	};  

    // send the ajax request after the desired data
	xmlhttp.open('GET', theContentSource, true);
	xmlhttp.send(null);
}

pctsFramework.postData = function(theTarget, params) {
	// post data to a DB accessor
	// alert('in post function');
	
	// first, set up a request object.  We have to do this so it degrades gracefully for IE6
	if (window.XMLHttpRequest) {
		// this is IE7, safari, etc.

		pctsFramework.httpRequest = new XMLHttpRequest();

	} else {
		// this is probably IE6, so see if we can instantiate an activeX obejct
		if (window.ActiveXObject) {

     		pctsFramework.httpRequest = new ActiveXObject('Microsoft.XMLHTTP');

  		}
	}
	
	pctsFramework.httpRequest.open("POST", theTarget, true);
	
	// alert('opened request channel');
	
	//Send the proper header information along with the request
	pctsFramework.httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	pctsFramework.httpRequest.setRequestHeader("Content-length", params.length);
	pctsFramework.httpRequest.setRequestHeader("Connection", "close");
	
	// alert('set headers');
	
	// wire up the callBack handler
	pctsFramework.httpRequest.onreadystatechange = pctsFramework.handlePostReadyState;
	
	// alert('configured callback');
	
	// send the params
	pctsFramework.httpRequest.send(params);
	
}

pctsFramework.handlePostReadyState = function() {
	//
	if(pctsFramework.httpRequest.readyState == 4) {  
	
		if (pctsFramework.httpRequest.status == 200) {
			var theReturn = pctsFramework.httpRequest.responseText;
			eval(theReturn);
			
		} else {
			var theReturn = pctsFramework.httpRequest.responseText;
			// alert(theReturn);
		}
	}	
}


pctsFramework.randomNumber = function() {
	// creae a random number to be used in accessors so as to prevent IE
	// from caching them.

	var theNumber = Math.floor(Math.random()*700000000);
	return theNumber;

}

pctsFramework.injectSpinner = function(theTarget) {
	// inject a spinner into an object that has been set to receive 
	// some content through an asynchronous ajax call.
	
	if(theTarget) {
		// first determine the height and width of the object being
		// replaced so as to determine what spinner to use
		var theHeight = theTarget.offsetHeight;
		var theWidth = theTarget.offsetWidth;
	
		// determine what spinner to use - small or large
		if (theHeight > 53 || theWidth > 53) {
			// inject the big spinner
			var theSpinner = pctsFramework.bigSpinnerPart1 + theHeight + pctsFramework.bigSpinnerPart2;
			theTarget.innerHTML = theSpinner;
	
		} else {
			// inject the small spinner
			var theSpinner = pctsFramework.bigSpinnerPart1 + theHeight + pctsFramework.bigSpinnerPart2;
			theTarget.innerHTML = theSpinner;
		}
	}
	
}

pctsFramework.setElementHeights = function() {
	// set the heights of certain page elements
	// document.getElementById('pctsWebMainContent').style.height = pctsFramework.clientHeight + 'px';
	pctsFramework.resizeMask();
}

pctsFramework.performLoadOperations = function() {
	// perform certain load operations that are desired
	
	// detect the browser type and route internal pages accordingly
	var opera = window.opera;
	if (window.attachEvent) {
		// this may be IE or Opera
		if (!window.opera) {
			pctsFramework.browserPath = 'ie';

			// determine the specific IE version.  If it is 8, we could use "other" browser mode,
			// assuming IE fixes all their CSS oversights.  For now we stick with IE.
			var theVersion = pctsFramework.getInternetExplorerVersion();
			if (theVersion == 8) {
				pctsFramework.browserPath = 'ie';
			}
		} else {
			// this is not IE
			pctsFramework.browserPath = 'other';
		}

	} else {
		// this is not IE
		pctsFramework.browserPath = 'other';

	}
	
	//attach jquery events
	var theElementId = '#regionSelector';
   	jQuery(theElementId).mouseleave(function() { pctsFramework.hideRegionSelector(); });

}

pctsFramework.fadeOut = function(theId, theStart, theEnd, theTime) {
	// fade an object in from one specified opacity to another
	// set the speed of fade
	var theSpeed = Math.round(theTime / 100);
	var theTimer = 0;

	for(i = theStart; i >= theEnd; i--) {
		setTimeout("pctsFramework.setOpacity(" + i + ",'" + theId + "')",(theTimer * theSpeed));
		theTimer++;
	}
}

pctsFramework.fadeIn = function(theId, theStart, theEnd, theTime) {
	// fade an object in from one specified opacity to another
	// set the speed of fade
	var theSpeed = Math.round(theTime / 100);
	var theTimer = 0;

	for(i = theStart; i <= theEnd; i++) {
		pcts.fadeTimer = setTimeout("pctsFramework.setOpacity(" + i + ",'" + theId + "')",(theTimer * theSpeed));
		theTimer++;
	}
}

pctsFramework.setOpacity = function(theOpacity, theId) {
	// this is a cross-browser capable method for setting the opacity of an object
	try {
		var theObject = document.getElementById(theId).style; 
	
		// safari
		theObject.opacity = (theOpacity / 100);
	
		// mozilla
		theObject.MozOpacity = (theOpacity / 100);
	
		// IE
		theObject.filter = "alpha(opacity=" + theOpacity + ")";
	
	} catch(err) {
		// if we wind up here, it is likely the object was not found
		
	}
}

pctsFramework.showSpinner = function() {
	// show the pcts spinner
	var theTop = pcts.clientHeight / 2 - 35 + 'px';
	var theLeft = pcts.clientWidth / 2 - 35 + 'px';

	document.getElementById('pctsSpinner').style.top = theTop;
	document.getElementById('pctsSpinner').style.left = theLeft;

}

pctsFramework.hideSpinner = function() {
	// hide the pcts spinner
	document.getElementById('pctsSpinner').style.top = '-100px';
	document.getElementById('pctsSpinner').style.left = '-100px';

}

pctsFramework.setReadyStateInterval = function() {
	// set up a ready state interval that will keep firing until the document has completely loaded
	// check every 100MS
	pcts.readyState = setInterval("pcts.readyMonitor()", 100);
}

pctsFramework.readyMonitor = function() {
	// check to see if the page has fully loaded / rendered in IE
	// in mozilla, onload doesn't fire until the DOM is loaded.
	var theState = document.readyState;

	if (pctsFramework.browserPath == 'ie') {
		if (theState == "complete") {
			// clear the readystate interval
			clearInterval(pcts.readyState);
	
			// do some other IE related thing here
			
			//attach jquery events
			var theElementId = '#regionSelector';
   	 		// $(theElementId).mouseenter(function() { pctsFramework.areaMouseEventIn(this); });
    		jQuery(theElementId).mouseleave(function() { pctsFramework.hideRegionSelector(); });
			
		}
	} else {
		clearInterval(pcts.readyState);
		//attach jquery events
		var theElementId = '#regionSelector';
   	 	// $(theElementId).mouseenter(function() { pctsFramework.areaMouseEventIn(this); });
    	jQuery(theElementId).mouseleave(function() { pctsFramework.hideRegionSelector(); });
			
	}
}

pctsFramework.showMainBody = function() {
	// show the main body after it has been sized.
	// document.getElementById('pctsWebMainContentContainer').style.visibility = 'visible';
	// document.getElementById('pctsWebMainContent').style.visibility = 'visible';
}

pctsFramework.GetElementLeft = function(eElement) {
	// determine the true left coordinate of an element
	
    // initialize var to store calculations
	var nLeftPos = eElement.offsetLeft;          
    
	// identify first offset parent element
	var eParElement = eElement.offsetParent;     
	
	// now move up through element hierarchy and calculate the left offset
    while (eParElement != null)
    {                                            
        nLeftPos += eParElement.offsetLeft;      
        eParElement = eParElement.offsetParent; 
		
    }
	
	// return the offset calculated
    return nLeftPos;                             
}

pctsFramework.GetElementTop = function(eElement) {
	// determine the true top coordinate of an element
	
    // initialize var to store calculations
	var nTopPos = eElement.offsetTop;            
    
	// identify first offset parent element
	var eParElement = eElement.offsetParent;
	
	// now move up through element hierarchy and calculate the top offset
    while (eParElement != null)
    {                                            
        nTopPos += eParElement.offsetTop;        
        eParElement = eParElement.offsetParent;  
		
    }
	
	// return the offset calculated
    return nTopPos;                              
}

pctsFramework.getInternetExplorerVersion = function()
// 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;

}

pctsFramework.showMask = function() {
	// show the mask
	
	// first set the size of the mask
	document.getElementById('maskLayer').style.display = "block"
	pctsFramework.setOpacity(0, 'maskLayer');
	
	// once again safari is weird, so we have to get the document height differently for it
	if(pctsFramework.browser == "Safari" || pctsFramework.chromeFrame == 'true') {
		var theHeight = document.body.scrollHeight + 30;
		//alert('theHeight');
	} else {
		var theHeight = document.documentElement.scrollHeight;
		
	}
	
	// get the scrollHeight of the window
	document.getElementById('maskLayer').style.height = theHeight + 'px';
	// document.getElementById('maskLayer').style.width = (pctsFramework.clientWidth - 20) + 'px';

	// show the mask
	document.getElementById('maskLayer').style.visibility = "visible"
	// pctsFramework.fadeIn('maskLayer', 0, 52, 700);
	
	// fade it in
	$('#maskLayer').fadeTo("slow", 0.61);

}

pctsFramework.showMaskIE = function() {
	// show the mask
	
	// first set the size of the mask
	document.getElementById('maskLayer').style.display = "block";
	
	document.getElementById('maskLayer').style.height = document.body.scrollHeight + 'px';
	// document.getElementById('maskLayer').style.width = (pctsFramework.clientWidth - 20) + 'px';

	// show the mask
	document.getElementById('maskLayer').style.visibility = "visible"
	pctsFramework.fadeIn('maskLayer', 0, 61, 520);

}

pctsFramework.resizeMask = function() {
	// resize the mask
	
	// first set the size of the mask
	document.getElementById('maskLayer').style.display = "block"
	document.getElementById('maskLayer').style.height = document.body.scrollHeight + 'px';
	
	// alert(pctsFramework.clientHeight);
	// alert(document.body.scrollHeight);
		  
	// document.getElementById('maskLayer').style.width = (pctsFramework.clientWidth - 20) + 'px';

	// set the display back to none if not currently visible
	if (document.getElementById('maskLayer').style.visibility != 'visible') {
		document.getElementById('maskLayer').style.display = "none";
		
	}

}

pctsFramework.hideMask = function() {
	// hide the mask
	
	// first set the size of the mask
	document.getElementById('maskLayer').style.visibility = "hidden"
	document.getElementById('maskLayer').style.display = "none"

}

pctsFramework.showWindow = function() {
	// show the window
	
	// first set the size of the mask
	document.getElementById('maskLayer').style.display = "block"
	pctsFramework.setOpacity(0, 'maskLayer');
	
	var theHeight = pctsFramework.getClientHeight();
	var theScrollHeight = document.documentElement.scrollHeight;
	
	// once again safari is weird, so we have to get the document height differently for it
	if(pctsFramework.browser == "Safari") {
		var theHeight = document.body.scrollHeight + 30;
	
	} else {
		var theHeight = document.documentElement.scrollHeight;
		
	}
	
	// set the scrollHeight of the mask
	document.getElementById('maskLayer').style.height = theHeight + 'px';

	// stupid safari hack to fix safari's insistence of bringing back the balloon always
	document.getElementById('rBalloon').style.top = "-340px";
	
	// show the mask
	document.getElementById('maskLayer').style.visibility = "visible"
	// pctsFramework.fadeIn('maskLayer', 0, 52, 700);
	
	// fade it in
	// if this is IE, we use an appropriate method, otherwise we use jquery
	if(pctsFramework.browserPath == 'ie') {
		// fade in the mask using the IE method.
		// pctsFramework.showMaskIE();
		// pctsFramework.showSlideWindow();
		$('#maskLayer').fadeTo("fast", 0.61, pctsFramework.showSlideWindow);
		
	} else {
		$('#maskLayer').fadeTo("fast", 0.61, pctsFramework.showSlideWindow);
	}
}

pctsFramework.showAlert = function(theNext) {
	// show the mask and transition to the next function in a sequence
	
	// first set the size of the mask
	document.getElementById('maskLayer').style.display = "block"
	pctsFramework.setOpacity(0, 'maskLayer');
	
	var theHeight = pctsFramework.getClientHeight();
	var theScrollHeight = document.documentElement.scrollHeight;
	
	//alert(theHeight);
	//alert(theScrollHeight);
	//alert(document.documentElement.offsetHeight);
	//alert(document.body.offsetHeight);
	//alert(document.body.clientHeight);
	//alert(document.documentElement.clientHeight);
	//alert(document.documentElement.scrollHeight);
	
	// once again safari is weird, so we have to get the document height differently for it
	if(pctsFramework.browser == "Safari") {
		var theHeight = document.body.scrollHeight + 30;
	
	} else {
		var theHeight = document.documentElement.scrollHeight;
		
	}
	
	// set the scrollHeight of the mask
	document.getElementById('maskLayer').style.height = theHeight + 'px';
	
	// show the mask
	document.getElementById('maskLayer').style.visibility = "visible"
	// pctsFramework.fadeIn('maskLayer', 0, 52, 700);
	
	// fade it in
	// if this is IE, we use an appropriate method, otherwise we use jquery
	if(pctsFramework.browserPath == 'ie') {
		// fade in the mask using the IE method.
		// pctsFramework.showMaskIE();
		// pctsFramework.showAlertWindow();
		$('#maskLayer').fadeTo("fast", 0.61, pctsFramework.showAlertWindow);
		
	} else {
		$('#maskLayer').fadeTo("fast", 0.61, pctsFramework.showAlertWindow);
	}

}

pctsFramework.showSlideWindow = function() {
	
	// make the slide have display
	document.getElementById('imageContainer').style.display = 'block';
	
	// get the scrollTop - we have to use a creapy hack to do it
	if(pctsFramework.browser == "Safari") {
		var theScroll = document.body.scrollTop;
		
	} else {
		
		var theScroll = document.documentElement.scrollTop;
	}
	
	// now determin its size
	var theHeight = document.getElementById('imageContainer').offsetHeight;
	var theWidth = document.getElementById('imageContainer').offsetWidth;

	// now set the top and left appropriately
	var theMidY = Math.round(pctsFramework.clientHeight / 2);
	var theMidX = Math.round(pctsFramework.clientWidth / 2);
	
	var theLeft = theMidX - (theHeight / 2);
	var theTop = theMidY - (theWidth / 2);
	
	document.getElementById('imageContainer').style.left = theLeft + 'px';
	document.getElementById('imageContainer').style.top = theTop + theScroll + 'px';
	
	// make the slide visible
	document.getElementById('imageContainer').style.visibility = 'visible';
	
	// inject the spinner
	// pctsFramework.injectSpinner(document.getElementById('imageContainerBody'));
	
	// inject the image
	pctsFramework.injectImage();
	
}

pctsFramework.showMediaWindow = function(contentHeight, contentWidth, mediaID, mediaType, mediaCaption, captionMode) {
	
	// before we do aything, we stop the rotator from advancing while the movie plays.
	// restart the rotator
	if (pcts.rotatorStarted == true) {
		pcts.stopRotator();
	}
	
	// show the mask, based on browser type
	if(pctsFramework.browserPath == 'ie') {
		pctsFramework.showMask();
	} else {
		pctsFramework.showMask();
	}
	
	// set the pending media load ID framework property
	pctsFramework.pendingMediaId = mediaID;
	
	// set the pending media load type framework property
	pctsFramework.pendingMediaType = mediaType;
	
	// set the pending media load caption framework property
	pctsFramework.pendingMediaCaption = mediaCaption;
	
	// make the slide have display
	document.getElementById('mediaContainer').style.display = 'block';
	
	// set the caption display state
	document.getElementById('mediaContainerCaptionRow').style.display = captionMode;
	
	// now determine its size
	var theHeight = document.getElementById('mediaContainer').offsetHeight;
	var theWidth = document.getElementById('mediaContainer').offsetWidth;

	// now set the top and left appropriately
	var theMidY = Math.round(pctsFramework.clientHeight / 2);
	var theMidX = Math.round(pctsFramework.clientWidth / 2);
	
	var theLeft = theMidX - (theHeight / 2);
	var theTop = theMidY - (theWidth / 2);
	
	// get the scrollTop - we have to use a creapy hack to do it
	if(pctsFramework.browser == "Safari") {
		var theScroll = document.body.scrollTop;
		
	} else {
		
		var theScroll = document.documentElement.scrollTop;
	}
	
	document.getElementById('mediaContainer').style.left = theLeft + 'px';
	document.getElementById('mediaContainer').style.top = theTop + theScroll + 'px';
	
	// make the slide visible
	document.getElementById('mediaContainer').style.visibility = 'visible';
	
	// now animate it's size
	
	// first determine what the end size of the image window ought to be
	var finalWidth = ((contentWidth * 1) + 28);
	var finalHeight = ((contentHeight * 1) + 50);
	
	// determine where left and top should wind up
	// now set the top and left appropriately
	var theMidY = Math.round(pctsFramework.clientHeight / 2);
	var theMidX = Math.round(pctsFramework.clientWidth / 2);
	
	var theLeft = Math.round(theMidX - (finalWidth / 2)) + 'px';
	var theTop = Math.round(theMidY - (finalHeight / 2)) + theScroll + 'px';
	
	var finalWidth = finalWidth + 'px';
	var finalHeight = finalHeight + 'px';
	
	// animate the size of the imageWindow and its position
	$('#mediaContainerBody').animate({height: contentHeight}, 300 );
	$('#mediaContainerBodyFrame').animate({height: contentHeight, width: contentWidth}, 300 );
	// $('#pctsSpinnerCell').animate({height: theHeight}, 300 );
	$('#mediaContainerCaption').animate({width: finalWidth}, 300 );
	$('#mediaContainer').animate({width: finalWidth, height: finalHeight, top: theTop, left: theLeft}, 300, 'linear', pctsFramework.loadMediaWindow);

}

pctsFramework.loadMediaWindow = function() {
	// load the media window with a player for the requested media type
	
	if (pctsFramework.pendingMediaType == 'video') {
		// load the video player
		
		// first create the accessor
		var theAccessor = "../media/mediaplayer.php?id=" + pctsFramework.pendingMediaId;
		
		// add a random number so as to prevent IE from using a chached accessor return
		var theRan = pctsFramework.randomNumber();
		theAccessor = theAccessor + "&anticache=" + theRan;
		
		// set the caption
		if(document.getElementById('mediaContainerCaptionRow').style.display != 'none') {
			document.getElementById('mediaContainerCaption').innerHTML = pctsFramework.pendingMediaCaption;
		}
		
		// make the frame visible
		document.getElementById('mediaContainerBodyFrame').style.visibility = "visible";
		
		// set the source
		document.getElementById('mediaContainerBodyFrame').src = theAccessor;
		
	} else {
		// load the MP3 player
		
	}
}

pctsFramework.showAlertWindow = function() {
	
	// make the slide have display
	document.getElementById('basicAlert').style.display = 'block';
	
	// now determin its size
	var theHeight = document.getElementById('basicAlert').offsetHeight;
	var theWidth = document.getElementById('basicAlert').offsetWidth;

	// get the scrollTop - we have to use a creapy hack to do it
	if(pctsFramework.browser == "Safari") {
		var theScroll = document.body.scrollTop;
		
	} else {
		
		var theScroll = document.documentElement.scrollTop;
	}
	
	// now set the top and left appropriately
	var theMidY = Math.round(pctsFramework.clientHeight / 2);
	var theMidX = Math.round(pctsFramework.clientWidth / 2);
	
	var theLeft = theMidX - (theWidth / 2);
	var theTop = theMidY - (theHeight / 2);
	
	document.getElementById('basicAlert').style.left = theLeft + 'px';
	document.getElementById('basicAlert').style.top = theTop + theScroll + 'px';
	
	// set content
	document.getElementById('basicAlertTitleBlock').innerHTML = pctsFramework.alertTitle;
	document.getElementById('alertBody').innerHTML = pctsFramework.alertBody;
	
	// make the alert visible
	document.getElementById('basicAlert').style.visibility = 'visible';
	
	// set the ok button action for the window
	document.getElementById('alertPos').onclick = function() { pctsFramework.hideAlertWindow(); };
	
	
}

pctsFramework.showWebWindow = function(contentHeight, contentWidth, theAccessor) {
	
	// show the mask, based on browser type
	if(pctsFramework.browserPath == 'ie') {
		pctsFramework.showMask();
	} else {
		pctsFramework.showMask();
	}
	
	// execute a fix PNG call if not already done.
	if (pctsFramework.pngFix) {
		// call the PNG fix routines
		// pngfix();
		pctsFramework.pngFix = false;
	} 
	
	// make the container have display
	document.getElementById('webContainer').style.display = 'block';
	
	// set the webwinow accessor directive
	pctsFramework.webAccessor = theAccessor;
	
	// now determin its size
	var theHeight = document.getElementById('webContainer').offsetHeight;
	var theWidth = document.getElementById('webContainer').offsetWidth;

	// get the scrollTop - we have to use a creapy hack to do it
	if(pctsFramework.browser == "Safari" || pctsFramework.chromeFrame == 'true') {
		var theScroll = document.body.scrollTop;
		
	} else {
		
		var theScroll = document.documentElement.scrollTop;
	}
	
	// now set the top and left appropriately
	var theMidY = Math.round(pctsFramework.clientHeight / 2);
	var theMidX = Math.round(pctsFramework.clientWidth / 2);
	
	var theLeft = theMidX - (theHeight / 2);
	var theTop = theMidY - (theWidth / 2);
	
	document.getElementById('webContainer').style.left = theLeft + 'px';
	document.getElementById('webContainer').style.top = theTop + theScroll + 'px';
	
	// make the slide visible
	document.getElementById('webContainer').style.visibility = 'visible';
	
	// now animate it's size
	
	// first determine what the end size of the image window ought to be
	var finalWidth = ((contentWidth * 1) + 28);
	var finalHeight = ((contentHeight * 1) + 50);
	
	// determine where left and top should wind up
	// now set the top and left appropriately
	var theMidY = Math.round(pctsFramework.clientHeight / 2);
	var theMidX = Math.round(pctsFramework.clientWidth / 2);
	
	var theLeft = Math.round(theMidX - (finalWidth / 2)) + 'px';
	var theTop = Math.round(theMidY - (finalHeight / 2)) + theScroll + 'px';
	
	var finalWidth = finalWidth + 'px';
	var finalHeight = finalHeight + 'px';
	
	// animate the size of the imageWindow and its position
	$('#webContainerBody').animate({height: contentHeight}, 300 );
	$('#webContainer').animate({width: finalWidth, height: finalHeight, top: theTop, left: theLeft}, 300, 'linear', pctsFramework.loadWebWindow);

}

pctsFramework.loadWebWindow = function() {
	// load the web window with content specified by the webAccessor framework directive
	
	// first get a random number so as to prevent IE from using a cached accessor return
	var theRan = pctsFramework.randomNumber();
		
	// Create an accessor string
	var theAccessor = pctsFramework.webAccessor + "?anticache=" + theRan;
	
	// set the target
	var theTarget = document.getElementById('webContainerBody');
	
	pctsFramework.getContent(theAccessor, theTarget, true);
	
}

pctsFramework.doPrivacy = function() {
	// display the privacy policy
	
	pctsFramework.showWebWindow(300, 430, "../accessors/getPrivacyPolicy.php");
	
}

pctsFramework.doSiteMap = function() {
	// display the privacy policy
	
	pctsFramework.showWebWindow(430, 210, "../accessors/getLeftNav.php");
	
}

pctsFramework.injectImage = function() {
	// inject the image source into the slide window, and animate it
	
	// if the selected image source is null, use the default image
	if (pctsFramework.selectedGallerySource == "") {
		var theSrc = "noimage.jpg";
		var theHeight = "331";
		var theWidth = "480";
		
	} else {
		var theSrc = pctsFramework.selectedGallerySource;
		var theHeight = pctsFramework.selectedGalleryHeight;
		var theWidth = pctsFramework.selectedGalleryWidth;
		// alert(pctsFramework.selectedGallerySource);
	}
	
	// get the scrollTop - we have to use a creapy hack to do it
	if(pctsFramework.browser == "Safari") {
		var theScroll = document.body.scrollTop;
		
	} else {
		
		var theScroll = document.documentElement.scrollTop;
	}
	
	// determine what the end size of the image window ought to be
	var finalWidth = ((theWidth * 1) + 28);
	var finalHeight = ((theHeight * 1) + 50);
	
	// determine where left and top should wind up
	// now set the top and left appropriately
	var theMidY = Math.round(pctsFramework.clientHeight / 2);
	var theMidX = Math.round(pctsFramework.clientWidth / 2);
	
	var theLeft = Math.round(theMidX - (finalWidth / 2)) + 'px';
	var theTop = Math.round(theMidY - (finalHeight / 2) + theScroll) + 'px';
	
	var finalWidth = finalWidth + 'px';
	var finalHeight = finalHeight + 'px';
	
	// build up a src string to handle the image
	var theImageString = "<table width=\"100%\"><tr><td><img id=\"bigSlideImage\" src=\"../images/gallery/" + theSrc + "\"" + " width=\"" + theWidth + "\"" + " height=\"" + theHeight + "\"" + " style=\"visibility:hidden\" /></td></tr></table>";
	
	pctsFramework.imageString = theImageString;
	
	// animate the size of the imageWindow and its position
	$('#imageContainerBody').animate({height: theHeight}, 300 );
	// $('#pctsSpinnerCell').animate({height: theHeight}, 300 );
	$('#imageContainerCaption').animate({width: finalWidth}, 300 );
	$('#imageContainer').animate({width: finalWidth, height: finalHeight, top: theTop, left: theLeft}, 300, 'linear', pctsFramework.fadeAppearSlideImage);

}

pctsFramework.fadeAppearSlideImage = function() {
	// appear the slide image after the animation of the window is complete
	
	// first force sizing to fix a weird safari bug
	if (pctsFramework.selectedGallerySource == "") {
		var theHeight = "331";
		var theWidth = "480";
		
	} else {
		var theHeight = pctsFramework.selectedGalleryHeight;
		var theWidth = pctsFramework.selectedGalleryWidth;
		// alert(pctsFramework.selectedGallerySource);
	}
	
	// size the elements
	document.getElementById('imageContainerBody').style.width = theWidth + 'px';
	document.getElementById('imageContainerCaption').style.width = theWidth + 'px';
	
	// push the image into the container
	document.getElementById('imageContainerBody').innerHTML = pctsFramework.imageString;
	
	// make the image have zero opacity
	pctsFramework.setOpacity(0, 'bigSlideImage');
	
	// set the image visible
	document.getElementById('bigSlideImage').style.visibility = 'visible';
	
	// now show the image
	$('#bigSlideImage').fadeTo("fast", 1.0, pctsFramework.showSlideCaption);
}

pctsFramework.showSlideCaption = function() {
	// show the slide caption
	if (pctsFramework.selectedGallerySource == "") {
		var theHeight = "331";
		var theWidth = "480";
		
	} else {
		var theHeight = pctsFramework.selectedGalleryHeight;
		var theWidth = pctsFramework.selectedGalleryWidth;
	}

	document.getElementById('imageContainerCaption').innerHTML = pctsFramework.selectedGalleryCaption;

}

pctsFramework.hideSlideWindow = function() {
	// hide the slide window
	
	// first hide the window
	// document.getElementById('imageContainer').style.visibility = 'hidden';
	
	// dump its contents
	document.getElementById('imageContainerBody').innerHTML = '';
	document.getElementById('imageContainerCaption').innerHTML = '';
	
	// reset to original size
	document.getElementById('imageContainer').style.width = "151px";
	document.getElementById('imageContainerBody').style.height = "79px";
	document.getElementById('imageContainer').style.height = "151px";
	
	// cancel window display
	document.getElementById('imageContainer').style.display = 'none';

	// now the mask
	document.getElementById('maskLayer').style.visibility = 'hidden';
	document.getElementById('maskLayer').style.display = 'none';
	
}

pctsFramework.hideMediaWindow = function() {
	// hide the media window
	
	// dump its contents
	document.getElementById('mediaContainerBodyFrame').src = '';
	document.getElementById('mediaContainerBodyFrame').style.visibility = 'hidden';
	document.getElementById('mediaContainerCaption').innerHTML = '';
	
	// reset to original size
	document.getElementById('mediaContainer').style.width = "151px";
	document.getElementById('mediaContainerBody').style.height = "79px";
	document.getElementById('mediaContainer').style.height = "151px";
	
	// cancel window display
	document.getElementById('mediaContainer').style.display = 'none';

	// now the mask
	document.getElementById('maskLayer').style.visibility = 'hidden';
	document.getElementById('maskLayer').style.display = 'none';
	
	// restart the rotator
	if (pcts.rotatorStarted == true) {
		pcts.startRotator();
	}
	
}

pctsFramework.hideWebWindow = function() {
	// hide the web content window
	
	// dump its contents
	document.getElementById('webContainerBody').innerHTML = '';
	
	// reset to original size
	document.getElementById('webContainer').style.width = "151px";
	document.getElementById('webContainerBody').style.height = "79px";
	document.getElementById('webContainer').style.height = "151px";
	
	// cancel window display
	document.getElementById('webContainer').style.display = 'none';

	// now the mask
	document.getElementById('maskLayer').style.visibility = 'hidden';
	document.getElementById('maskLayer').style.display = 'none';
	
}

pctsFramework.showSlideThumbCaptionBalloon = function(theCaption, theTop, theLeft) {
	// show the slide caption balloon for a given slide
	pctsFramework.balloonShown = true;
	
	// set the balloon display
	document.getElementById('rBalloon').style.display = 'block';
	
	// set the body with the caption
	document.getElementById('balloonBody').innerHTML = theCaption;
	
	// now determine the offsetHeight of the balloon
	var theOHeight = document.getElementById('rBalloon').offsetHeight;
	var theOHeight = theOHeight - 34;
	
	// get the scroll position of the window
	if (pctsFramework.browser == 'IE') {
		var theScroll = document.documentElement.scrollTop;
	} else {
		// stupid firefox hack
		if (navigator.userAgent.indexOf("Firefox")!=-1) {
			// we have to do this because firefox is so freakish and doesn't do anything even
			// remotely standard for iframe content
			var theScroll = document.documentElement.scrollTop;
		} else {
			var theScroll = document.body.scrollTop;
		}
		
	}
	
	// set the top and left with offsets
	var theDesiredTop = theTop - theOHeight;
	
	document.getElementById('rBalloon').style.top = (theDesiredTop) + 'px';
	document.getElementById('rBalloon').style.left = (theLeft + 43) + 'px';
	
	// set the opacity of the constituents
	if (pctsFramework.browserPath != 'ie') {
		pctsFramework.setOpacity(0, 'rBalloon');
		pctsFramework.setOpacity(0, 'balloonBodyRow');
	}
	
	// set visibility for the components
	document.getElementById('rBalloon').style.visibility = 'visible';
	document.getElementById('balloonBody').style.visibility = 'visible';
	document.getElementById('balloonBodyRow').style.visibility = 'visible';
	
	
	// show the balloon
	if (pctsFramework.browserPath != 'ie') {
		$('#rBalloon').fadeTo("fast", 1.0);
		$('#rBalloonBody').fadeTo("fast", 1.0);
		$('#balloonBodyRow').fadeTo("fast", 1.0, pctsFramework.setCaption);
	}
	
	pctsFramework.selectedGalleryCaption = theCaption;
	
}

pctsFramework.setCaption = function() {
	// set the body with the caption
	document.getElementById('balloonBody').innerHTML = pctsFramework.selectedGalleryCaption;
}

pctsFramework.hideSlideThumbCaptionBalloon = function() {
	// show the slide caption balloon for a given slide
	
	try {
		if(pctsFramework.balloonIn != true) {
			pctsFramework.balloonShown = false;
		
			// set the body with the caption
			document.getElementById('balloonBody').innerHTML = '';
			
			document.getElementById('balloonBody').visibility = 'hidden';
		
			// set the balloon display
			document.getElementById('rBalloon').style.display = 'none';
		}
	
	} catch(err) {
		
	}
	
}

pctsFramework.balloonOver = function() {
	// make sure the balloon stays shown

	pctsFramework.balloonIn = true;
	// document.getElementById('rBalloon').style.display = 'block';
	pctsFramework.setCaption();
}


pctsFramework.balloonOut = function() {
	pctsFramework.balloonIn = false;
	
	// firefox hack
	// because firefox events don't fire when traversing from the child of a parent,
	// we manually force an event.
	if (navigator.userAgent.indexOf("Firefox")!=-1) {
		document.getElementById('rBalloon').style.display = 'none';
	}
}

pctsFramework.handleAlertButtonOut = function(theId, theClass) {
	// handle mouse out events from an alert button
	
	// split apart to get the base class name
	var theParts = theClass.split('Moused');
	var theClassName = theParts[0];
	
	// apply the className
	document.getElementById(theId).className = theClassName;
	
}

pctsFramework.handleAlertButtonOver = function(theId, theClass) {
	// handle mouse out events from an alert button
	
	// set the class name
	var theClassName = theClass + 'Moused';
	
	// apply the className
	document.getElementById(theId).className = theClassName;
	
}

pctsFramework.handleWindowButtonOut = function(theId, theClass) {
	// handle mouse out events from an alert button
	
	// split apart to get the base class name
	var theParts = theClass.split('Moused');
	var theClassName = theParts[0];
	
	// apply the className
	document.getElementById(theId).className = theClassName;
	
}

pctsFramework.handleWindowButtonOver = function(theId, theClass) {
	// handle mouse out events from an alert button
	
	// set the class name
	var theClassName = theClass + 'Moused';
	
	// apply the className
	document.getElementById(theId).className = theClassName;
	
}

pctsFramework.hideAlertWindow = function() {
	// hide the basic entry window.
	
	// cancel window display
	document.getElementById('basicAlert').style.display = 'none';

	// now the mask
	document.getElementById('maskLayer').style.visibility = 'hidden';
	document.getElementById('maskLayer').style.display = 'none';
	
}

pctsFramework.hideBasicWindow = function() {
	// hide the basic entry window.
	
	// reset field errors, if any
	pctsFramework.clearErrorStates();
								
	// cancel window display
	document.getElementById('basicWindow').style.display = 'none';

	// now the mask
	document.getElementById('maskLayer').style.visibility = 'hidden';
	document.getElementById('maskLayer').style.display = 'none';
	
	
}

pctsFramework.presentExternal = function(theSource, theState) {
	// present a feature resource in an external window
	
	if (theState != 'secure') {
		if(pctsFramework.browserPath == 'ie') {
			var theSourceString = "../resources/" + theSource;
			
		} else {
			var theSourceString = "../resources/" + theSource;
			
		}
		
		var myWin = window.open(theSourceString,'PCTS_Resource');
	
	} else {
		// it can only be accessed after registration, so check to see if
		// registration has occurred
		if(pctsFramework.resourceSecure) {
			var theSourceString = "../resources/" + theSource;
			window.open(theSourceString,'PCTS_Resource');
		
		} else {
			// a secure state does not exist, which means that during this session, the user
			// has not registered for content
			pctsFramework.doRegister(theSource);
			
		}
		
	}
	
}

pctsFramework.presentExternalUnsecured = function(theSource) {
	// present a feature resource in an external window
	if(pctsFramework.browserPath == 'ie') {
		var theSourceString = theSource;
		
	} else {
		var theSourceString = theSource;
		
	}
	
	var myWin = window.open(theSourceString,'PCTS_external');
	
}


pctsFramework.doRegister = function(theSource) {
	// present a registration dialogue so a user can register for resource content.
	
	// Process by showing the mask and then transitioning to the next function in a sequence
	
	// first set the size of the mask
	document.getElementById('maskLayer').style.display = "block"
	pctsFramework.setOpacity(0, 'maskLayer');
	
	var theHeight = pctsFramework.getClientHeight();
	var theScrollHeight = document.documentElement.scrollHeight;
	
	// once again safari is weird, so we have to get the document height differently for it
	if(pctsFramework.browser == "Safari") {
		var theHeight = document.body.scrollHeight + 30;
	
	} else {
		var theHeight = document.documentElement.scrollHeight;
		
	}
	
	// set the scrollHeight of the mask
	document.getElementById('maskLayer').style.height = theHeight + 'px';
	
	// show the mask
	document.getElementById('maskLayer').style.visibility = "visible"
	
	// indicate the source to be shown
	pctsFramework.showSource = theSource;
	
	// set the display values
	pctsFramework.alertTitle = "Registration Required...";
	pctsFramework.alertBody = "This resource requires registration.  To register, please complete the form below, then select 'Ok'.";
	
	// fade it in
	// if this is IE, we use an appropriate method, otherwise we use jquery
	if(pctsFramework.browserPath == 'ie') {
		// fade in the mask using the IE method.
		// pctsFramework.showMaskIE();
		// pctsFramework.showRegisterWindow();
		$('#maskLayer').fadeTo("fast", 0.61, pctsFramework.showRegisterWindow);
		
	} else {
		$('#maskLayer').fadeTo("fast", 0.61, pctsFramework.showRegisterWindow);
	}
}

pctsFramework.showRegisterWindow = function() {
	// show the registration window so the user can be prompted to register to gain access to resources.
	
	// give the window display
	document.getElementById('basicWindow').style.display = 'block';
	
	// get the scrollTop - we have to use a creapy hack to do it
	if(pctsFramework.browser == "Safari") {
		var theScroll = document.body.scrollTop;
		
	} else {
		
		var theScroll = document.documentElement.scrollTop;
	}
	
	// now determin its size
	var theHeight = document.getElementById('basicWindow').offsetHeight;
	var theWidth = document.getElementById('basicWindow').offsetWidth;

	// now set the top and left appropriately
	var theMidY = Math.round(pctsFramework.clientHeight / 2);
	var theMidX = Math.round(pctsFramework.clientWidth / 2);
	
	var theLeft = theMidX - (theWidth / 2);
	var theTop = theMidY - (theHeight / 2);
	
	document.getElementById('basicWindow').style.left = theLeft + 'px';
	document.getElementById('basicWindow').style.top = theTop + theScroll + 'px';
	
	// set content
	document.getElementById('basicWindowTitleBlock').innerHTML = pctsFramework.alertTitle;
	document.getElementById('windowBody').innerHTML = pctsFramework.alertBody;
	
	// make the alert visible
	document.getElementById('basicWindow').style.visibility = 'visible';
	
	// set the ok and cancel button action for the window
	document.getElementById('windowNeg').onclick = function() { pctsFramework.hideBasicWindow(); };
	document.getElementById('windowPos').onclick = function() { pctsFramework.validateRegistrationForm(); };
	
	
}

pctsFramework.processRegistrationForm = function() {
	// process the registration form for resources and perform actions as required
	// to set a secure state
	//alert('starting form registration');
	// first collect all of the data to be submitted, and then submit it
	
	// now dispense with the window, set a secure state, etc.
	pctsFramework.setSecureMode();
	
	// open the selected document
	if(pctsFramework.browserPath == 'ie') {
		var theSourceString = "../resources/" + pctsFramework.showSource;
			
	} else {
		var theSourceString = "../resources/" + pctsFramework.showSource;
			
	}
	
	// submit the form data
	pctsFramework.submitContactForm(true);
	// alert('submitted form registration');
	// alert(theSouceString);
	// open the resource the user was trying to access
	var myWin = window.open(theSourceString,'PCTS_Resource');
			
	// record the resource being obtained
	var theAccessor = "../accessors/insertResourceRetrieval.php?source=" + theSourceString + "&ip=" + pctsFramework.currentIP + "&user=" + pctsFramework.registeredUser + "&type=asset";
	
	// add a random number so as to prevent IE from using a chached accessor return
	var theRan = pctsFramework.randomNumber();
	theAccessor = theAccessor + "&anticache=" + theRan;
	
	pctsFramework.getData(theAccessor);
	
}

pctsFramework.submitContactForm = function(regMode) {
	// send the information in the cotact or registration form to the server
	
	// package up the values from the form
	// first, fields
	var name = document.getElementById('fullname').value;
	// var lname = document.getElementById('lname').value;
	var email = document.getElementById('email').value;
	var phone = document.getElementById('phone').value;
	var theCompany = document.getElementById('companyField').value;
	var title = document.getElementById('title').value;
	var department = document.getElementById('department').value;
	var city = document.getElementById('city').value;
	
	try {
		var zip = document.getElementById('zip').value;
		
	} catch(err) {
		var zip = '';
		
	}
	
	// try {
		// var depOtherField = document.getElementById('depOtherField').value;
		
	// } catch(err) {
		// var depOtherField = '';
		
	// }
	
	// var comment = document.getElementById('comment').value;
	// comment = comment.replace(/\n/g,"<br/>").replace(/\r/g,"");
	
	// next, checkboxes
	// var pulse = document.getElementById('pulse').checked;
	// var trackPatients = document.getElementById('trackPatients').checked;
	// var trackEquipment = document.getElementById('trackEquipment').checked;
	// var depEmergency = document.getElementById('depEmergency').checked;
	// var depPeriop = document.getElementById('depPeriop').checked;
	// var depOutpatient = document.getElementById('depOutpatient').checked;
	// var depCC = document.getElementById('depCC').checked;
	// var depEnterprise = document.getElementById('depEnterprise').checked;
	// var depOther = document.getElementById('depOther').checked;
	
	// finally, select elements
	// var theIndex = document.getElementById('suffix').selectedIndex;
	// var theControl = document.getElementById('suffix');
	// var theText = theControl[theIndex].text;
	// var credential = theText;
	
	theIndex = document.getElementById('country').selectedIndex;
	theControl = document.getElementById('country');
	theText = theControl[theIndex].text;
	var country = theText;
	
	try {
		theIndex = document.getElementById('state').selectedIndex;
		theControl = document.getElementById('state');
		theText = theControl[theIndex].text;
		var state = theText;
		
	} catch(err) {
		
		var state = '';
	}
	
	// now that all values are collected, package a post statement
	var params = "name=" + name;
	// params = params + "&lname=" + lname;
	params = params + "&email=" + email;
	params = params + "&phone=" + phone;
	params = params + "&company=" + theCompany;
	params = params + "&title=" + title;
	params = params + "&department=" + department;
	params = params + "&city=" + city;
	params = params + "&zip=" + zip;
	// params = params + "&depOtherField=" + depOtherField;
	// params = params + "&comment=" + comment;
	// params = params + "&pulse=" + pulse;
	// params = params + "&trackPatients=" + trackPatients;
	// params = params + "&trackEquipment=" + trackEquipment;
	// params = params + "&depEmergency=" + depEmergency;
	// params = params + "&depPeriop=" + depPeriop;
	// params = params + "&depOutpatient=" + depOutpatient;
	// params = params + "&depCC=" + depCC;
	// params = params + "&depEnterprise=" + depEnterprise;
	// params = params + "&depOther=" + depOther;
	// params = params + "&credential=" + credential;
	params = params + "&country=" + country;
	params = params + "&state=" + state
	params = params + "&registration=" + regMode;
	
	// now set an accessor to post the data
	var theAccessor = "../accessors/insertNewContact.php?region=1";
	
	// add a random number so as to prevent IE from using a chached accessor return
	var theRan = pctsFramework.randomNumber();
	theAccessor = theAccessor + "&anticache=" + theRan;
	
	pctsFramework.postData(theAccessor, params);
	
	// reset the form
	pctsFramework.clearErrorStates(); 
	document.getElementById('registerNow').reset();
	
	// send a note to PCTS employees that a registration was made
	var theAccessor = "../mail/production/contentRequest.php?email=" + email + "&name=" + name + "&phone=" + phone + "&company=" + theCompany + "&title=" + title + "&dept=" + department + "&city=" + city + "&state=" + state + "&country=" + country + "&zip=" + zip + "&registration=true" + "&resource=" + pctsFramework.showSource;
	
	// add a random number so as to prevent IE from using a chached accessor return
	var theRan = pctsFramework.randomNumber();
	theAccessor = theAccessor + "&anticache=" + theRan;
	
	pctsFramework.getData(theAccessor);
	
}

pctsFramework.setSecureMode = function() {
	// after submitting registration information, set the secure mode to true and then
	// dismiss the registration window.
	
	pctsFramework.resourceSecure = true;
	
	// hide the resource registration form
	pctsFramework.hideBasicWindow();
	
	// make the icons all free access
	pctsFramework.transitionSecureIcons();
	
}

pctsFramework.validateRegistrationForm = function() {
	// validate the contact form before submission
	var valid = true;
	
	var theValue = document.getElementById('fullname').value;
	if(theValue == '') {
		valid = false;
		pctsFramework.setFieldError('fullname');
	}
	
	var theValue = document.getElementById('companyField').value;
	if(theValue == '') {
		valid = false;
		pctsFramework.setFieldError('companyField');
	}
	
	var theValue = document.getElementById('email').value;
	if(theValue == '') {
		valid = false;
		pctsFramework.setFieldError('email');
	}
	
	var theValue = document.getElementById('email').value;
	var theErr = theValue.search('@');
	if(theErr == -1) {
		valid = false;
		pctsFramework.setFieldError('email');
	}
	
	// if it is valid, process submit, otherwise alert
	if(valid) {
		
		// submit the form
		pctsFramework.processRegistrationForm();
		
		
	} else {
		// set the registration form error icon
		document.getElementById('bwIcon').className = 'exclIcn';
		
		// set the intro text
		var theString = "You did not complete, or entered incorrect values for, one or more required fields. Please try again.";
		document.getElementById('windowBody').innerHTML = theString;
	
	}
	
}

pctsFramework.setFieldError = function(theId) {
	// set a field to an error state
	var theWidth = document.getElementById(theId).style.width;
	var theParts = theWidth.split('px');
	var wNum = theParts[0] * 1;
	
	// set the width to - 21px for error style offset
	if (document.getElementById(theId).className != "cInsetFormFieldErr") {
		document.getElementById(theId).style.width = (wNum - 21) + 'px';
	}
	
	// set the style
	document.getElementById(theId).className = "cInsetFormFieldErr";
	
}

pctsFramework.clearErrorStates = function() {
	// clear the error states for the contact form
	
	// set the styles
	document.getElementById('fullname').className = "cInsetFormField";
	document.getElementById('email').className = "cInsetFormField";
	document.getElementById('companyField').className = "cInsetFormField";
	
	// set the widths
	document.getElementById('fullname').style.width = "174px";
	document.getElementById('email').style.width = "174px";
	document.getElementById('companyField').style.width = "174px";
	
	// set the registration form error icon
	document.getElementById('bwIcon').className = 'infoIcnLarge';
		
	// set the intro text
	var theString = "This resource requires registration.  To register, please complete the form below, then select 'Ok'.";
	document.getElementById('windowBody').innerHTML = theString;
	
}

pctsFramework.handleCountrySelect = function(theValue) {
	// handle selection of a country in the country selector
	var theIndex = document.getElementById('country').selectedIndex;
	var theControl = document.getElementById('country');
	var theText = theControl[theIndex].text;
	
	if(theValue == 'US') {
		// the US has been selected so we need to load the US state list
		
		// get a random number so as to prevent IE from using a cached accessor return
		var theRan = pctsFramework.randomNumber();
		
		// Create an accessor
		var theAccessor = "accessors/getStates.php?anticache=" + theRan;
		
		// set the target
		var theTarget = document.getElementById('stateContainer');
	
		pctsFramework.getContent(theAccessor, theTarget, false);
		
		// set the state label
		document.getElementById('stateLabelContainer').innerHTML = "State";
		
		// set the code label
		document.getElementById('codeLabelContainer').innerHTML = "Zip Code";
	}
	
	if(theValue == 'CA') {
		// Canada has been selected so we need to load the Canada province list
		
		// get a random number so as to prevent IE from using a cached accessor return
		var theRan = pctsFramework.randomNumber();
		
		// Create an accessor
		var theAccessor = "accessors/getProvinces.php?anticache=" + theRan;
		
		// set the target
		var theTarget = document.getElementById('stateContainer');
	
		pctsFramework.getContent(theAccessor, theTarget, false);
		
		// set the label
		document.getElementById('stateLabelContainer').innerHTML = "Province";
		
		// set the code label
		document.getElementById('codeLabelContainer').innerHTML = "Postal Code";
		
	}
	
	if(theValue != 'CA' && theValue != 'US') {
		// neither has been selected, so we need to remove both the state selector and the label
		
		// hide the state / province label
		document.getElementById('stateLabelContainer').innerHTML = "";
		
		// hide the state / province label
		document.getElementById('stateContainer').innerHTML = "";
		
		// set the code label
		document.getElementById('codeLabelContainer').innerHTML = "Postal Code";
		
	}	
	
}

pctsFramework.loadMaintenance = function() {
	// transition to the maintenance page because an attempt to navigate to a sub has detected that the site is currently in 
	// maintenance mode.
	window.location = "../maintenanceMode.php";
	
}

pctsFramework.resumeNormal = function() {
	// transition to the normal page because an attempt to refresh the maintenance page has determined that the site is no longer in 
	// maintenance mode.
	window.location = "../index.php";
	
}

pctsFramework.goToURL = function(theURL, theID) {
	// navigate to a specified URL
	document.getElementById('pctsWebMainContent').src = theURL + "?frameworkState=" + pctsFramework.orphanMode;
	
	// chop the ID up
	var theIDParts = theID.split('_');
	var theID = theIDParts[0];
	
	if (theID != 'undefined') {
		// set the clicked ID
		pctsFramework.currentPage = theID;
	} else {
		pctsFramework.currentPage = null;
	}

	// hide any balloons that are lingering
	pctsFramework.hideSlideThumbCaptionBalloon();
	
}

pctsFramework.handleNavlistExpando = function(theId, theClass) {
	// handle clicks to a nav list expando

	// first determine what the child container is
	var theParts = theId.split('_');
	var thePrimaryID = theParts[0];
	var theTarget = thePrimaryID + '_childContainer';

	if(theClass != 'navListNoChild_icn') {
		if (theClass == "navListMinus_icn") {
		// it is expanded, so we collapse it
		document.getElementById(theId).className = "navListPlus_icn";
		document.getElementById(theTarget).style.display = 'none';

		} else {
			// it is collapsed so we expand it
			document.getElementById(theId).className = "navListMinus_icn";
			document.getElementById(theTarget).style.display = 'block';
	
		}
	}
}

pctsFramework.handleNavlistChildExpando = function(theId, theClass) {
	// handle clicks to a nav list expando

	// first determine what the child container is
	var theParts = theId.split('_');
	var thePrimaryID = theParts[0];
	var theTarget = thePrimaryID + '_childContainer';

	if(theClass != 'navListNoChild_icn') {
		if (theClass == "navListMinus_icn") {
			// it is expanded, so we collapse it
			document.getElementById(theId).className = "navListPlus_icn";
			document.getElementById(theTarget).style.display = 'none';

		} else {
			// it is collapsed so we expand it
			document.getElementById(theId).className = "navListMinus_icn";
			document.getElementById(theTarget).style.display = 'block';
			// pctsFramework.getLevelThreeItems(thePrimaryID);
		}
	}
}

pctsFramework.goHome = function() {
	// navigate to the home page, as appropriate, depending on the browser
	if (pctsFramework.browserPath == 'ie') {
		// direct to ie main
		window.location = "../index.php";

	} else {
		// direct to other main
		window.location = "../index.php";

	}
	
	// hide any balloons that are lingering
	pctsFramework.hideSlideThumbCaptionBalloon();

}

pctsFramework.shareThisPage = function(shareType) {
	// share the page by invoking the correct social media URL and site.
	
	switch(shareType) {
		
		case 'digg':
			//do something
			var theURL = "http://digg.com/submit?phase=2&url=" + escape(pctsFramework.shareLink) + "&title=" + escape(pctsFramework.pageTitle);
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'facebook':
			//do something http://del.icio.us/post?url=http%3A%2F%2Fsharethis.com%2F&title=ShareThis
			var theURL = "http://www.facebook.com/share.php?u=" + escape(pctsFramework.shareLink);
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'delicious':
			//do something http://del.icio.us/post?url=http%3A%2F%2Fsharethis.com%2F&title=ShareThis
			var theURL = "http://del.icio.us/post?url=" + escape(pctsFramework.shareLink) + "&title=" + escape(pctsFramework.pageTitle);
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'google':
			//do something http://www.google.com/bookmarks/mark?op=edit&bkmk=http%3A%2F%2Fsharethis.com%2F&title=ShareThis
			var theURL = "http://www.google.com/bookmarks/mark?op=edit&bkmk=" + escape(pctsFramework.shareLink) + "&title=" + escape(pctsFramework.pageTitle);
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'myspace':
			//do something http://www.myspace.com/Modules/PostTo/Pages/?l=3&u=http%3A%2F%2Fsharethis.com%2F&t=ShareThis&c=
			var theURL = "http://www.myspace.com/Modules/PostTo/Pages/?l=3&u=" + escape(pctsFramework.shareLink) + "&t=" + escape(pctsFramework.pageTitle) + "&c=";
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'live':
			//do something https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&url=http%3A%2F%2Fsharethis.com%2F&title=ShareThis&top=1
			var theURL = "https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&url=" + escape(pctsFramework.shareLink) + "&title=" + escape(pctsFramework.pageTitle) + "&top=1";
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'buzz':
			//do something http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fsharethis.com%2F&submitHeadline=ShareThis
			var theURL = "http://buzz.yahoo.com/submit/?submitUrl=" + escape(pctsFramework.shareLink) + "&submitHeadline=" + escape(pctsFramework.pageTitle);
			var myWin = window.open(theURL,'PCTS_external');
			break;
		
		case 'stumble':
			//do something http://www.stumbleupon.com/submit?url=http%3A%2F%2Fsharethis.com%2F&title=ShareThis
			var theURL = "http://www.stumbleupon.com/submit?url=" + escape(pctsFramework.shareLink) + "&title=" + escape(pctsFramework.pageTitle);
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'twitter':
			//do something http://twitter.com/home?status=http%3A%2F%2Fwww.addthis.com%2F
			var theURL = "http://twitter.com/home?status=" + escape(pctsFramework.shareLink);
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'myaol':
			//do something 
			var theURL = "http://favorites.my.aol.com/ffclient/webroot/0.4.5/src/html/addBookmarkDialog.html?url=" + escape(pctsFramework.shareLink) + "&title=" + escape(pctsFramework.pageTitle) + "&favelet=true";
			var myWin = window.open(theURL,'PCTS_external');
			break;
		
		case 'ask':
			//do something http://myjeeves.ask.com/mysearch/BookmarkIt?v=1.2&t=webpages&url=http%3A%2F%2Fwww.addthis.com%2F&title=AddThis+-+Social+Bookmark+%26+Feed+Button+Builder
			var theURL = "http://myjeeves.ask.com/mysearch/BookmarkIt?v=1.2&t=webpages&url=" + escape(pctsFramework.shareLink) + "&title=" + escape(pctsFramework.pageTitle);
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'thisnext':
			//do something http://www.thisnext.com/pick/new/submit/url/?url=http%3A%2F%2Fwww.addthis.com%2F
			var theURL = "http://www.thisnext.com/pick/new/submit/url/?url=" + escape(pctsFramework.shareLink);
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'reddit':
			//do something http://reddit.com/submit?url=http%3A%2F%2Fsharethis.com%2F&title=ShareThis
			var theURL = "http://reddit.com/submit?url=" + escape(pctsFramework.shareLink) + "&title=" + escape(pctsFramework.pageTitle);
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'faves':
			//do something http://faves.com/Authoring.aspx?u=http%3A%2F%2Fwww.addthis.com%2F&t=AddThis+-+Social+Bookmark+%26+Feed+Button+Builder
			var theURL = "http://faves.com/Authoring.aspx?u=" + escape(pctsFramework.shareLink) + "&t=" + escape(pctsFramework.pageTitle);
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'mixx':
			//do something http://www.mixx.com/submit?page_url=http%3A%2F%2Fsharethis.com%2F
			var theURL = "http://www.mixx.com/submit?page_url=" + escape(pctsFramework.shareLink);
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'newsvine':
			//do something http://www.newsvine.com/_tools/seed&save?popoff=0&u=http%3A%2F%2Fsharethis.com%2F&h=ShareThis
			var theURL = "http://www.newsvine.com/_tools/seed&save?popoff=0&u=" + escape(pctsFramework.shareLink) + "&h=" + escape(pctsFramework.pageTitle);
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'blinklist':
			//do something http://blinklist.com/index.php?Action=Blink/addblink.php&Url=http%3A%2F%2Fsharethis.com%2F&Title=ShareThis
			var theURL = "http://blinklist.com/index.php?Action=Blink/addblink.php&Url=" + escape(pctsFramework.shareLink) + "&Title=" + escape(pctsFramework.pageTitle);
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'current':
			//do something http://current.com/clipper.htm?url=http%3A%2F%2Fsharethis.com%2F&title=ShareThis&src=st
			var theURL = "http://current.com/clipper.htm?url=" + escape(pctsFramework.shareLink) + "&title=" + escape(pctsFramework.pageTitle) + "&src=st";
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'diigo':
			//do something http://secure.diigo.com/post?url=http%3A%2F%2Fsharethis.com%2F&title=ShareThis
			var theURL = "http://secure.diigo.com/post?url=" + escape(pctsFramework.shareLink) + "&title=" + escape(pctsFramework.pageTitle);
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'friendfeed':
			//do something http://friendfeed.com/share?url=http%3A%2F%2Fsharethis.com%2F&title=ShareThis
			var theURL = "http://friendfeed.com/share?url=" + escape(pctsFramework.shareLink) + "&title=" + escape(pctsFramework.pageTitle);
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'furl':
			//do something http://furl.net/storeIt.jsp?u=http%3A%2F%2Fsharethis.com%2F&t=ShareThis
			var theURL = "http://furl.net/storeIt.jsp?u=" + escape(pctsFramework.shareLink) + "&t=" + escape(pctsFramework.pageTitle);
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'linkedin':
			//do something http://www.linkedin.com/shareArticle?mini=true&url=http%3A%2F%2Fsharethis.com%2F&title=ShareThis&summary=&source=
			var theURL = "http://www.linkedin.com/shareArticle?mini=true&url=" + escape(pctsFramework.shareLink) + "&title=" + escape(pctsFramework.pageTitle) + "&summary=&source=";
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'propeller':
			//do something http://www.propeller.com/submit/?U=http%3A%2F%2Fsharethis.com%2F&T=ShareThis
			var theURL = "http://www.propeller.com/submit/?U=" + escape(pctsFramework.shareLink) + "&T=" + escape(pctsFramework.pageTitle);
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'slashdot':
			//do something http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fsharethis.com%2F&title=ShareThis
			var theURL = "http://slashdot.org/bookmark.pl?url=" + escape(pctsFramework.shareLink) + "&title=" + escape(pctsFramework.pageTitle);
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'technorati':
			//do something http://www.technorati.com/faves?add=http%3A%2F%2Fsharethis.com%2F
			var theURL = "http://www.technorati.com/faves?add=" + escape(pctsFramework.shareLink);
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'xango':
			//do something http://www.xanga.com/private/editorx.aspx?t=ShareThis&u=http%3A%2F%2Fsharethis.com%2F&s=
			var theURL = "http://www.xanga.com/private/editorx.aspx?t=" + escape(pctsFramework.pageTitle) + "&u=" + escape(pctsFramework.shareLink) + "&s=";
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
		case 'yahoo':
			//do something http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&u=http%3A%2F%2Fsharethis.com%2F&t=ShareThis
			var theURL = "http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&u=" + escape(pctsFramework.shareLink) + "&t=" + escape(pctsFramework.pageTitle);
			var myWin = window.open(theURL,'PCTS_external');
			break;
			
	}
	
}

pctsFramework.shareByEmail = function() {
	// share a page via email
	
	// first get a random number so as to prevent IE from using a cached accessor return
	var theRan = pctsFramework.randomNumber();
		
	// Create an accessor string
	var theAccessor = "../accessors/shareViaEmail.php?anticache=" + theRan;
	
	// set the target
	var theTarget = document.getElementById('webContainerBody');
	
	// alert(theAccessor);
	pctsFramework.getContent(theAccessor, theTarget, true);
	
}

pctsFramework.cancelEmailShare = function() {
	// cancel the share by email screen and return to the normal share screen.
	
	// first get a random number so as to prevent IE from using a cached accessor return
	var theRan = pctsFramework.randomNumber();
		
	// Create an accessor string
	var theAccessor = "../accessors/getSharePane.php?anticache=" + theRan;
	
	// set the target
	var theTarget = document.getElementById('webContainerBody');
	
	// alert(theAccessor);
	pctsFramework.getContent(theAccessor, theTarget, true);
	
}

pctsFramework.verifyEmailShare = function() {
	// verify that the email share form is completed.
	var valid = true;
	
	var theValue = document.getElementById('senderName').value;
	if(theValue == '') {
		valid = false;
		pctsFramework.setFieldError('senderName');
	}
	
	
	var theValue = document.getElementById('senderEmail').value;
	if(theValue == '') {
		valid = false;
		pctsFramework.setFieldError('senderEmail');
	}
	
	var theValue = document.getElementById('senderEmail').value;
	var theErr = theValue.search('@');
	if(theErr == -1) {
		valid = false;
		pctsFramework.setFieldError('senderEmail');
	}
	
	var theValue = document.getElementById('destEmail').value;
	if(theValue == '') {
		valid = false;
		pctsFramework.setFieldError('destEmail');
	}
	
	var theValue = document.getElementById('destEmail').value;
	var theErr = theValue.search('@');
	if(theErr == -1) {
		valid = false;
		pctsFramework.setFieldError('destEmail');
	}
	
	// if it is valid, process submit, otherwise alert
	if(valid) {
		
		// submit the form
		pctsFramework.processShareForm();
		
		
	} else {
		// set the registration form error icon
		document.getElementById('shareBWIcon').className = 'exclIcn';
		
		// set the intro text
		var theString = "You did not complete, or entered incorrect values for, one or more required fields. Please try again.";
		document.getElementById('shareWindowBody').innerHTML = theString;
	
	}
}

pctsFramework.processShareForm = function() {
	// process the share form for submission to the email processor
	var senderEmail = document.getElementById('senderEmail').value;
	var senderName = document.getElementById('senderName').value;
	var destEmail = document.getElementById('destEmail').value;
	var friendName = document.getElementById('friendName').value;
	var shareComment = document.getElementById('shareComment').value;
	
	// send a note to the desired recipient inviting them to link to the page
	var theAccessor = "../mail/production/invitationRequest.php?senderEmail=" + senderEmail + "&destEmail=" + destEmail + "&senderName=" + senderName + "&friendName=" + friendName + "&shareComment=" + escape(shareComment) + "&shareURL=" + escape(pctsFramework.shareLink);
	
	// add a random number so as to prevent IE from using a chached accessor return
	var theRan = pctsFramework.randomNumber();
	theAccessor = theAccessor + "&anticache=" + theRan;
	
	// alert(theAccessor);
	
	pctsFramework.getData(theAccessor);	
	
}

pctsFramework.presentEventUnsecured = function(theSource) {
	// present a feature resource in an external window
	if(pctsFramework.browserPath == 'ie') {
		var theSourceString = theSource;
		
	} else {
		var theSourceString = theSource;
		
	}
	
	// record the resource being obtained
	var theAccessor = "../accessors/insertResourceRetrieval.php?source=" + theSourceString + "&ip=" + pctsFramework.currentIP + "&user=" + pctsFramework.registeredUser + "&type=event";
	
	// add a random number so as to prevent IE from using a chached accessor return
	var theRan = pctsFramework.randomNumber();
	theAccessor = theAccessor + "&anticache=" + theRan;
	
	pctsFramework.getData(theAccessor);
		
	var myWin = window.open(theSourceString,'PCTS_external');
	
}

pctsFramework.presentLectureUnsecured = function(theSource) {
	// present a feature resource in an external window
	if(pctsFramework.browserPath == 'ie') {
		var theSourceString = theSource;
		
	} else {
		var theSourceString = theSource;
		
	}
	
	// record the resource being obtained
	var theAccessor = "../accessors/insertResourceRetrieval.php?source=" + theSourceString + "&ip=" + pctsFramework.currentIP + "&user=" + pctsFramework.registeredUser + "&type=lecture";
	
	// add a random number so as to prevent IE from using a chached accessor return
	var theRan = pctsFramework.randomNumber();
	theAccessor = theAccessor + "&anticache=" + theRan;
	
	pctsFramework.getData(theAccessor);
		
	var myWin = window.open(theSourceString,'PCTS_external');
	
}

pctsFramework.showRegionSelector = function(theObject) {
	// show the region selector
	
	var state = document.getElementById('regionSelector').style.display;
	
	if (state == 'none') {
		// give the selector display
		document.getElementById('regionSelector').style.display = 'block';
		
		// now determine some basic information
		var sWidth = document.getElementById('regionSelector').offsetWidth;
		var sourcePosTop = pctsFramework.GetElementTop(theObject);
		var sourcePosLeft = pctsFramework.GetElementLeft(theObject);
		
		// now position and show the selector
		document.getElementById('regionSelector').style.left = (sourcePosLeft - 12) + 'px';
		document.getElementById('regionSelector').style.top = (sourcePosTop + 16) + 'px';
		
		// now show it
		document.getElementById('regionSelector').style.visibility = 'visible';
		
	} else {
		pctsFramework.hideRegionSelector();
		
	}
	
}

pctsFramework.setCookie = function(c_name, value, expiredays) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

pctsFramework.doRegionSelect = function(regionId) {
	// set region based on a user behavior
	var theParts = regionId.split('_');
	var theToken = theParts[1];
	
	// get the region string
	var regionName = document.getElementById(regionId).innerHTML;
	
	// construct a region string
	var theCurrentLocation = window.location.href;
	
	var theParts = theCurrentLocation.split('http://www.pcts.com/');
	var theLeaf = theParts[1];
	
	if (theLeaf != '') {
		var regionString = 'http://www.pcts.com/?region=' + theToken + '&directLoad=' + theLeaf;
		
	} else {
		var theRan = pctsFramework.randomNumber();
		var regionString = 'http://www.pcts.com/?region=' + theToken;
		
	}
	
	// set the location
	// we do this differently if we are on the mainpage.
	var mp = pctsFramework.mainPage;
	
	if(mp) {
		// window.location.reload(true);
		window.location.href = 'http://www.pcts.com/?region=' + theToken;
		// window.location.href = window.location.href;
		
	} else {
		// window.location.reload(true);
		window.location.href = regionString;
	
	}
	
	pctsFramework.hideRegionSelector();
	
	
}

pctsFramework.hideRegionSelector = function() {
	// hide the region selector
	document.getElementById('regionSelector').style.visibility = 'hidden';
	document.getElementById('regionSelector').style.display = 'none';
	
}

// --- page namespace functions -------
page.goToURL = function(theURL, theID, theLevel) {
	// navigate to a specified URL
	document.getElementById('pctsWebMainContent').src = theURL + "?frameworkState=" + pctsFramework.orphanMode;
	
	// chop the ID up
	var theIDParts = theID.split('_');
	var theID = theIDParts[0];
	
	if (theLevel == '1') {
		theID = 'undefined';
	}
	
	if (theID != 'undefined') {
		// set the clicked ID
		pctsFramework.currentPage = theID;
	} else {
		pctsFramework.currentPage = null;
	}

	// hide any balloons that are lingering
	pctsFramework.hideSlideThumbCaptionBalloon();
	
}

page.noAction = function() {
	// perform no nav action
	// hack to fix navigation madness inflicted by nav marketing structure changes
	
}

page.goToSub = function() {
	// perform no nav action
	// hack to fix navigation madness inflicted by nav marketing structure changes
	
}

// --- attached events -------

// we attach inside an if statement because IE handles event listeners differently from other browsers.

if (window.attachEvent) {
	// attached events for IE
	window.attachEvent("onload", pctsFramework.setBasicClientData);
	window.attachEvent("onload", pctsFramework.setElementHeights);
	window.attachEvent("onload", pctsFramework.showMainBody);
	window.attachEvent("onload", pctsFramework.performLoadOperations);
	window.attachEvent("onresize", pctsFramework.setBasicClientData);
	window.attachEvent("onresize", pctsFramework.setElementHeights);
} else {
	// attached events for other browsers
	window.addEventListener('load', pctsFramework.setBasicClientData, false);
	window.addEventListener('load', pctsFramework.setElementHeights, false);
	window.addEventListener('load', pctsFramework.showMainBody, false);
	window.addEventListener('load', pctsFramework.performLoadOperations, false);
	window.addEventListener('resize', pctsFramework.setBasicClientData, false);
	window.addEventListener('resize', pctsFramework.setElementHeights, false);

}