/* Rollover
Requires:
	object id to equal the base name of the image
	over state of image ends with _over
	images are gifs
*/

function roll(obj, over)
{
	if (!obj)
		return
	
	if (over)
		src = '/Templates/media/images/' + obj.id + '_over.gif'
	else
		src = '/Templates/media/images/' + obj.id + '.gif'
	
	obj.src = src;
}

var menu_timer = null
var menu = null
var menu_body = null
var menu_open_color = null
var menu_close_color = null

function menu_open(obj, open_color, close_color)
{
	menu_hold()
	menu_close()

	menu_open_color = open_color
	menu_close_color = close_color

	menu = obj
	menu_body = document.getElementById(obj.id + '_body')
	
	menu.style.backgroundColor = menu_open_color
	menu_body.style.display = 'block'
}

function menu_close()
{
	if (!menu && !menu_body)
		return 

	menu.style.backgroundColor = menu_close_color
	menu_body.style.display = 'none'
	
	menu = null
	menu_body = null
}

function menu_start_close()
{
	menu_timer = window.setTimeout(menu_close, 25)
}

function menu_hold()
{
	if (menu_timer)
	{
		window.clearTimeout(menu_timer)
		menu_timer = null
	}
}
var min=8;
var max=18;
function increaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
   var li = document.getElementsByTagName('li');
        
   for(i=0;i<li.length;i++) {
      if(li[i].style.fontSize) {
         var s = parseInt(li[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s += 1;
      }
      li[i].style.fontSize = s+"px"
   } 
}
function decreaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
   var li = document.getElementsByTagName('li');
   for(i=0;i<li.length;i++) {
      if(li[i].style.fontSize) {
         var s = parseInt(li[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      li[i].style.fontSize = s+"px"
   } 
}


// Function:    removeAspNetFields
// Author:      Greg Clapp
// Date:        04/07/2009
// Summary:     Spins through the form elements collection and removes any elements
//              that start with a double underscore "__" which indicates an ASP .NET
//              field, such as used to maintain ViewState. These fields are not needed
//              when submitting to a 3rd party site or non-.NET form processor. Used
//              by 3rd party form processor user control.
function removeAspNetFields() {
    var form = document.forms[0]; var i = form.elements.length; var remove = '';
    for (var j=0; j<i; j++) { var name = form.elements[j].name; if (name.substr(0,2) == "__") { remove += (name + ',') } }
    var arrRemove = remove.split(",");
    for (var k=0; k<arrRemove.length; k++) { if (arrRemove[k] != "") { form.elements[arrRemove[k]].parentNode.removeChild(form.elements[arrRemove[k]]); } }
}







// AjaxControlToolkit ModalPopupExtender onunload flicker fix ///////////////////////////
// This bit of script attempts to set style display=none on modal popup extender
// popup panels, so they don't flicker. To use it, the host page must include
// javascript that populates the modalPopups array with the names of all the popup
// panels in the page. Use the push function to *add* items to the array, so that
// multiple controls can implement this independently. 
//
//        <script type="text/javascript"> 
//            modalPopups.push('mpeLogin');
//        </script>    
//

// instantiate global array
var modalPopups = [''];

function pageLoad(sender, args)
{
    AddHiddenEventToPopups(modalPopups);
}

function AddHiddenEventToPopups(modalPopups)
{
    //step through the popups
    for (var i=0; i < modalPopups.length; i++)
    {
        //find the current popup
        var popUp = $find(modalPopups[i]);

        //check it exists so the script won't fail
        if (popUp)
        {
            //Add the function below as the event
            popUp.add_hidden(HidePopupPanel);
        }
    }
}

function HidePopupPanel(source, args)
{
    //find the panel associated with the extender
    objPanel = document.getElementById(source._PopupControlID);

    //check the panel exists
    if (objPanel)
    {
        //set the display attribute, so it remains hidden on postback
        objPanel.style.display= 'none';
    }
}

// END AjaxControlToolkit ModalPopupExtender onunload flicker fix //////////////////////

