function resizeToMax(divClassName){
	var aWidthHeight;
	
	//loop threw each element with the specified class name.
	var elems = $("." + divClassName);
	var elem = elems[0];
	
	if (elem) {

//	for (x = 0; x < elems.length; x++) {
//		var elem = elems[x];

		var tot_Width = document.body.clientWidth;
		var tot_Height = document.body.clientHeight;


		//resize the object to the max allowable size based on browser type.
		if(isIE()){
		 	//IE works with just using client Width and Height so make no adjustments.
		} else {
			////Firefox needs us to strip the padding and border values.
			aWidthHeight = getNewWidthHeightOfElem(elem, tot_Width, tot_Height);
			tot_Width = aWidthHeight[0];
			tot_Height = aWidthHeight[1];
		
			//alert("w:" + tot_Width);
			//alert("h:" + tot_Height);
			
		}
		
		//adjust for parent.
		aWidthHeight = getNewWidthHeightOfElem(elem.parentNode, tot_Width, tot_Height);
		tot_Width = aWidthHeight[0];
		tot_Height = aWidthHeight[1];
		
		//var parent_offset = Position.positionedOffset(elem);
		//tot_Width = tot_Width - parent_offset[0];
		//tot_Height = tot_Height - parent_offset[1];
		
		//alert("w:" + tot_Width);
		//alert("h:" + tot_Height);
						
		if (tot_Width > 0) {
			elem.style.width = tot_Width;
		}
		if (tot_Height > 0) {
			elem.style.height = tot_Height;
		}

//	}

	}
	
		
}

function getNewWidthHeightOfElem(elem, tot_Width, tot_Height) {

	if (elem) {
		//get the style.
		var rule = getCSSRule("." + elem.className, false);			
		
		if (rule) {	
			////remove values from any external style sheets.
			//width:
			tot_Width = tot_Width - getIntFirstThenSecond(elem.style.borderLeft, rule.style.borderLeft);
			tot_Width = tot_Width - getIntFirstThenSecond(elem.style.borderRight, rule.style.borderRight);
			tot_Width = tot_Width - getIntFirstThenSecond(elem.style.paddingLeft, rule.style.paddingLeft);
			tot_Width = tot_Width - getIntFirstThenSecond(elem.style.paddingRight, rule.style.paddingRight);
			tot_Width = tot_Width - getIntFirstThenSecond(elem.style.marginLeft, rule.style.marginLeft);
			tot_Width = tot_Width - getIntFirstThenSecond(elem.style.marginRight, rule.style.marginRight);
		
			//height:
			tot_Height = tot_Height - getIntFirstThenSecond(elem.style.borderTop, rule.style.borderTop);
			tot_Height = tot_Height - getIntFirstThenSecond(elem.style.borderBottom, rule.style.borderBottom);
			tot_Height = tot_Height - getIntFirstThenSecond(elem.style.paddingTop, rule.style.paddingTop);
			tot_Height = tot_Height - getIntFirstThenSecond(elem.style.paddingBottom, rule.style.paddingBottom);
			tot_Height = tot_Height - getIntFirstThenSecond(elem.style.marginTop, rule.style.marginTop);
			tot_Height = tot_Height - getIntFirstThenSecond(elem.style.marginBottom, rule.style.marginBottom);
		
		} else {
			////remove local style values.
			
			//width:
			tot_Width = tot_Width - getInt(elem.style.borderLeft);
			tot_Width = tot_Width - getInt(elem.style.borderRight);
			tot_Width = tot_Width - getInt(elem.style.paddingLeft);
			tot_Width = tot_Width - getInt(elem.style.paddingRight);
		
			//height:
			tot_Height = tot_Height - getInt(elem.style.borderTop);
			tot_Height = tot_Height - getInt(elem.style.borderBottom);
			tot_Height = tot_Height - getInt(elem.style.paddingTop);
			tot_Height = tot_Height - getInt(elem.style.paddingBottom);
		}			
	}
	//alert("rw:" + tot_Width);
	//alert("rh:" + tot_Height);
	
	return [tot_Width, tot_Height];

}

function getIntFirstThenSecond(firstVal, secondVal) {
	var num_firstVal = getInt(firstVal);
	var num_secondVal = getInt(secondVal);
	
	if (num_firstVal == 0) {
		return num_secondVal;
	} else {
		return num_firstVal;
	}
}

function getInt(val) {
	if (isNaN(parseInt(val))) {
		return 0;
	} else {
		return parseInt(val);
	}
}

function isIE() {
	return (navigator.appVersion.match(/\bMSIE\b/));
}

function isIE6()
{
    return ($.browser.msie && $.browser.version.substr(0, 1) < 7);
}

function getCSSRule(ruleName, deleteFlag) {
   ruleName=ruleName.toLowerCase(); 
   if (document.styleSheets) {      
      for (var i=0; i<document.styleSheets.length; i++) { 
         var styleSheet=document.styleSheets[i];
         var ii=0;                              
         var cssRule=false;                      
         do {                                   
            if (styleSheet.cssRules) {          
               cssRule = styleSheet.cssRules[ii];
            } else {                             
               cssRule = styleSheet.rules[ii];    
            }   
			//alert(cssRule.selectorText.toLowerCase());                                 
            if (cssRule && cssRule.selectorText)  {                      
               if (cssRule.selectorText.toLowerCase()==ruleName) { 
                  if (deleteFlag=='delete') {    
                     if (styleSheet.cssRules) {  
                        styleSheet.deleteRule(ii);
                     } else {                     
                        styleSheet.removeRule(ii);
                     }                            
                     return true;                 
                  } else {                        
                     return cssRule;              
                  }                               
               }                                  
            }                                     
            ii++;                                 
         } while (cssRule)                        
      }                                           
   }                                              
   return false;                                  
}                                                  

function killCSSRule(ruleName) {     
  return getCSSRule(ruleName,'delete');  
}                                         

function addCSSRule(ruleName) {       
  if (document.styleSheets) {        
    if (!getCSSRule(ruleName)) {    
      if (document.styleSheets[0].addRule) {       
        document.styleSheets[0].addRule(ruleName, null,0);
      } else {                   
        document.styleSheets[0].insertRule(ruleName+' { }', 0);
      }        
    }           
  }              
  return getCSSRule(ruleName);   
} 

////scripts for positioning the footer.
function positionFooter() {
  try {
    var footer = document.getElementById('fullpageMenu');
    var content = $('.fullpageContent')[0];
    //If the footer is currently  on top of the page content take away the footer's absolute position.
    //alert(parseInt(Position.cumulativeOffset(footer)[1]) + '|' + parseInt(Position.cumulativeOffset(content)[1]) + '|' + parseInt(content.getHeight()))
	if (document.body.clientHeight > (parseInt(Position.cumulativeOffset(content)[1]) + parseInt(content.getHeight()) + 35)) {
		footer.style.bottom = '';
		footer.style.top = document.body.clientHeight - 35;
	}
	else {
		footer.style.bottom = '';
		footer.style.top = parseInt(Position.cumulativeOffset(content)[1]) + parseInt(content.getHeight()) + 30;
	}
  }
  catch (e) {
    //alert(e);
    //ignore errors, this script isn't critical.
  }
}

function closePlayer(){
	if(confirm('Are you certain you would like to close the player window?')) parent.close();
}

/*****************************************************************

	GetVars javascript class by Peter Bailey - Copyright (c) 2003
	Contact: me@peterbailey.net
	Website: http://www.peterbailey.net/site/dev/jsclasses/

	Main Features:
	-	Retrieves query-string data as an object
	-	Allows global and per-variable default values
	-	Allows data to be made global	
	-	Supports frames

	Compatibility:
	-	Tested on IE6 and Mozilla 1.1
	-	DOM compliant browsers only

	Note: This document was created with a tab-spacing of four (4)

******************************************************************/

function GetVars( def, winRef ) 
{
	var win = ( typeof winRef != 'undefined' ) ? winRef : self;
	this._def_ = def;
	var query, queries = win.location.search.substring(1).split( /[&;]/ );
	for ( var i=0; ( query = queries[i] ); i++ )
	{
		query		= query.split( /\=/ );
		query[1]	= ( typeof query[1] == 'undefined' ) ? this._def_ : unescape( query[1].replace( /\+/g, " " ) );
		if ( this.exists( query[0] ) )
		{
			if ( typeof this[query[0]] == 'string' )
			{
				this[query[0]] = [this[query[0]],query[1]];
			} else {
				this[query[0]].push( query[1] );
			}
		} else {
			this[query[0]] = ( typeof query[1] == 'undefined' ) ? def : query[1];
		}
	}
}

GetVars.prototype.assign = function( key, def )
{
	var deflt = ( typeof def == 'undefined' ) ? this._def_ : def;
	return ( !this.exists( key ) || this[key] == this._def_ ) ? deflt : this[key];
}

GetVars.prototype.exists = function( key )
{
	return ( typeof this[key] != 'undefined' );
}

GetVars.prototype.makeGlobal = function( action, prefix )
{
	prefix = ( typeof prefix == 'undefined' ) ? '' : prefix;
	for ( var i in this )
	{
		if ( typeof i != 'function' && i != '_def_' )
		{
			var gv = prefix + i;
			if ( window[gv] ) // Global already exists
			{
				switch( action )
				{
					case 0 : // Overwrite
						window[gv] = this[i];
						break;
					case 1 : // Skip
						break;
					case 2 : // Prompt
						if ( confirm( "The global variable '" + gv + "' aleady exists\nclick 'Ok' to overwrite, 'Cancel' to skip" ) )
							window[gv] = this[i];
						break;
				}
			}
			// Global doesn't already exists, assign as is
			else window[gv] = this[i];
		}
	}
}

function noop()
{

}

//Open In New Window = openINW
function openINW(url,w,h){
	if(!w) w = 450;
	if(!h) h = 350;
	if(url != ''){
		window.open(url,'SpecialInfo','top=0,left='+(screen.width-w-10)+',width='+w+',height='+h);
	}
}

//==========================================================================================
// Object: QSParameters()
// Author: JD Hendrickson
// Company: Implex.net
// Date: 08/15/2003
// Description: QSParameters takes a qualifying URL and parses out the
// Query String.  From there, it breaks out each individual parameter
// and parameter value, and then places them in an array.  This object
// also offers various methods for finding parameters with in the array
// and reading thier values.
//==========================================================================================
function QSParameters(URL){
	//Public Variables======================================================================
	
	//Private Variables ====================================================================
	var valid = false;
	var params = new Array();
	var URL = new String(URL);
	
	//Public Method Pointers ===============================================================
	this.init = init;
	this.showAll = showAll;
	this.show = show;
	this.exists = exists;
	this.getParameter = getParameter;				//Retrieve the entire parameter object.
	this.getValue = getValue;						//Retrieve only the value on the specified parameter.
	
	//Init =================================================================================
	init();
	
	//Public Methods =======================================================================
	function init(){
		if(validateURL()){
			if(hasParameters()) parseQS();
		}
		else alert('The QSParameter object requires a qualified URL string.');
	}
	
	function showAll(){
		for(i=0;i<params.length;i++){
			document.writeln('<b>Parameter Name:</b> '+params[i].name+', <b>Value:</b> '+params[i].value+'<br>');
		}
	}
	
	function show(what){
		if(!isNaN(what)){
			//Passed parameter "what" is a number
			document.writeln('<b>Parameter Name:</b> '+params[what].name+', <b>Value:</b> '+params[what].value+'<br>');
		}
		else{
			//Passed parameter "what" is not a number
			for(i=0;i<params.length;i++){
				if(params[i].name == what) document.writeln('<b>Parameter Name:</b> '+params[i].name+', <b>Value:</b> '+params[i].value+'<br>');
			}
		}
	}
	
	function exists(what){
		var exists = false;
		
		//"what" must be a string
		if(isNaN(what)){
			for(i=0;i<params.length;i++){
				if(params[i].name == what) exists = true;
			}
		}
		else alert('The exists method requires a string.  The value passed was a number.');
				
		return(exists);
	}
	
	function getParameter(what){
		var found = false;
		var index = 0;
		
		if(isNaN(what)){
			for(i=0;i<params.length;i++){
				if(params[i].name == what){
					found = true;
					index = i;
				}
			}
			if(found) return(params[index]);
			else{
				alert('The requested parameter could not be found.');
				return false;
			}
		}
		else alert('The getParameter method requires a string.  The value passed was a number.');
	}
	
	function getValue(what){
		if(isNaN(what)){
			for(i=0;i<params.length;i++){
				if(params[i].name == what) return(params[i].value);
			}	
		}
		else alert('The getValue method requires a string.  The value passed was a number.');
	}
	
	//Private Methods ======================================================================
	function validateURL(){
		if(URL.length < 1) return false;
		else return(true);
	}
	
	function hasParameters(){		
		if(URL.indexOf('?') != (-1) && URL.indexOf('=') != (-1)) return(true);
		else return false;
	}
	
	function parseQS(){
		var paramStr = new String(URL.substring(URL.indexOf('?')+1,URL.length));
		var paramName,paramValue;
		
		if(!params) alert('The parameters could not be parse due to an internal error.');
		else{
			//Parse through the string for all parameters.
			while(paramStr.indexOf('&') != (-1)){
				paramName = paramStr.substring(0,paramStr.indexOf('='));
				paramValue = paramStr.substring(paramStr.indexOf('=')+1,paramStr.indexOf('&'));
				params[params.length] = new Parameter(paramName,paramValue);
				paramStr = paramStr.substring(paramStr.indexOf('&')+1,paramStr.length);
			}
			if(paramStr != ''){
				paramName = paramStr.substring(0,paramStr.indexOf('='));
				paramValue = paramStr.substring(paramStr.indexOf('=')+1,paramStr.length);
				params[params.length] = new Parameter(paramName,paramValue);
			}
			
			//document.writeln('Finished parsing parameters.  There are '+params.length+' parameters.<br><br>');
		}
	}
}

//==========================================================================================
// Object: Parameter()
// Author: JD Hendrickson
// Company: Implex.net
// Date: 08/15/2003
// Description: This object represents a parameter.  Has 2 properties
// name and value.  Both are public.
//==========================================================================================
function Parameter(pname,pvalue){
	//Public Variables
	this.name = pname;
	this.value = pvalue;
}

/*
This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
*/
function emailCheck (emailStr) {
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
	alert("Email address seems incorrect (check @ and .'s)")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]
if (user.match(userPat)==null) {
    alert("The username doesn't seem to be valid.")
    return false
}
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("Destination IP address is invalid!")
		return false
	    }
    }
    return true
}
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("The domain name doesn't seem to be valid.")
    return false
}
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   alert("The address must end in a three-letter domain, or two letter country.")
   return false
}
if (len<2) {
   var errStr="This address is missing a hostname!"
   alert(errStr)
   return false
}
return true;
}

function getSelectedRadioValue(buttonGroup) {
   if (buttonGroup[0]) { 
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return buttonGroup[i].value
         }
      }
   } else {
      if (buttonGroup.checked) { return buttonGroup.value; } 
   }
   return "";
}

/*
	Added this javascript to this .js file to be published to the destination folder.
	This method throws an alert message if a survey doesn't get's processed and the 
	page gets displayed again for the client to try again.
*/
function getURLParameters() 
{
	var sURL = window.document.URL.toString();
	
	if (sURL.indexOf("?") > 0)
	{
		var arrParams = sURL.split("?");
			
		var arrURLParams = arrParams[1].split("&");
		
		var arrParamNames = new Array(arrURLParams.length);
		var arrParamValues = new Array(arrURLParams.length);
		
		var i = 0;
		for (i=0;i<arrURLParams.length;i++)
		{
			var sParam =  arrURLParams[i].split("=");
			arrParamNames[i] = sParam[0];
			if (sParam[1] != "")
				arrParamValues[i] = unescape(sParam[1]);
			else
				arrParamValues[i] = "No Value";
		}
		
		for (i=0;i<arrURLParams.length;i++)
		{
			if (arrParamNames[i] == 'error') {
				alert("The survey form could not be processed due to an exception. Please try again.")
				break;
			}
			//alert(arrParamNames[i]+" = "+ arrParamValues[i]);
		}

	}
}


function myunescape(str) {
    str = "" + str;
    while (true) {
        var i = str.indexOf('+');
        if (i < 0)
            break;
        str = str.substring(0, i) + '%20' +
				str.substring(i + 1, str.length);
    }
    return unescape(str);
}
