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 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)  {                      
               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 = $('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.
  }
}


