//'*******************************************************************************
//'Function:      GetNewPage
//'Parameters:
//'Return:
//'Description:   automatically loads page from a dropdown SELECT list
//'*******************************************************************************

function getNewPage(form) {
	var f = form.urlList;
	var selectedUrl = f.options[f.selectedIndex].value;
	return location.href = selectedUrl;
}

//'*******************************************************************************
//'Function:      PreloadImages
//'Parameters:
//'Return:
//'Description:   preload images that are used for mouseovers
//'*******************************************************************************

function PreloadImages()
{
   if (document.images)
   {
     menu1_off = new Image();
     menu1_off.src = "/images/homeButton1.jpg";
	 menu1_on = new Image();
	 menu1_on.src = "/images/homeButton1_ON.jpg";
	 menu1_active = new Image();
	 menu1_active.src = "/images/homeButton1_ON.jpg";

	 menu2_off = new Image();
	 menu2_off.src = "/images/homeButton2.jpg";
	 menu2_on = new Image();
	 menu2_on.src = "/images/homeButton2_ON.jpg";
	 menu2_active = new Image();
	 menu2_active.src = "/images/homeButton2_ON.jpg"; 	 
   }
}
// call this function as soon as its loaded
PreloadImages();

//'*******************************************************************************
//'Function:      hideFlash, showFlash
//'Parameters:    
//'Return:
//'Description:   THESE FUNCTIONS HIDE AND UNHIDE THE FLASH FOR MODAL POPUP, OR OTHER
//					ELEMENTS WHERE FLASH LAYER OVERLAPS AND INTERFERES
//'*******************************************************************************

function hideFlash(divToHide){
	//hide flash
	flashbox = document.getElementById(divToHide);
	flashbox.style.visibility = "hidden";
}

function showFlash(divToHide){
	//hide flash
	flashbox = document.getElementById(divToHide);
	flashbox.style.visibility = "visible";
}


//'*******************************************************************************
//'Function:      TurnOn
//'Parameters:    strName,strCurrentSection,strMenu
//'Return:
//'Description:   function to turn on mouseover effect for navigation elements
//'*******************************************************************************

function TurnOn(strName)
{
   if (document.images)
   {
      onImage = eval(strName + "_on.src");
      document[strName].src = onImage;
   }
}

//'*******************************************************************************
//'Function:      TurnOff
//'Parameters:    strName,strCurrentSection,strMenu
//'Return:
//'Description:   function to turn off mouseover effect for navigation elements
//'*******************************************************************************

function TurnOff(strName,strCurrentSection,strMenu)
{
   if (document.images)
   {
      if (strCurrentSection != strMenu)
      {
         offImage = eval(strName + "_off.src");
         document[strName].src = offImage;
      }
      else
      {
         activeImage = eval(strName + "_active.src");
         document[strName].src = activeImage;
      }
   }
}

//'*******************************************************************************
//'Function:      LaunchExternal
//'Parameters:    strURL
//'Return:
//'Description:   function to launch a new window set to a specific size
//
//'Parameters:    strURL,strName,intMenubar,intToolbar,intLocation,
//'               intDirectories,intStatus,intScrollbars,intResizable,
//'               intWidth,intHeight
//'*******************************************************************************

function LaunchExternal(strURL,width,height)
{
   if(width==null)
   {
   width=750;
   }
   
   if(height==null)
   {
   height=525;
   }
   NewWindow(strURL,'',0,0,0,0,1,1,1,width,height);
}

//'*******************************************************************************
//'Function:      NewWindow
//'Parameters:    strURL,strName,intMenubar,intToolbar,intLocation,
//'               intDirectories,intStatus,intScrollbars,intResizable,
//'               intWidth,intHeight
//'Return:
//'Description:   function to launch a new window set to specific parameters
//'*******************************************************************************

function NewWindow(strURL,strName,intMenubar,intToolbar,intLocation,intDirectories,intStatus,intScrollbars,intResizable,intWidth,intHeight)
{
   var objNewWindow;
   if (strURL == '' && strName == 'print')
   {  
		strURL = window.location + "&Print=True";
   }
   
   if (strURL == '' && strName == 'print2')
   {  
		strURL = window.location + "?Print=True";
   }
   var strParameters
   strParameters = 'menubar=' + intMenubar;
   strParameters += ',toolbar=' + intToolbar;
   strParameters += ',location=' + intLocation;
   strParameters += ',directories=' + intDirectories;
   strParameters += ',status=' + intStatus;
   strParameters += ',scrollbars=' + intScrollbars;
   strParameters += ',resizable=' + intResizable;
   strParameters += ',width=' + intWidth;
   strParameters += ',height=' + intHeight;
   strParameters += ',screenX=' + 10;
   strParameters += ',screenY=' + 10;
   strParameters += ',left=' + 10;
   strParameters += ',top=' + 10;
   objNewWindow = window.open(strURL,strName,strParameters);
   objNewWindow.focus();
}

//'*******************************************************************************
//'Function:      MultilineCount
//'Return:
//'Description:   function to count chars for textbox in multiline mode
//'*******************************************************************************

function MultilineCount(text,long,msg) 

{
	var maxlength = new Number(long); // Change number to your max length.
	var alertMsg= new String(alertMsg);
	
	if (msg == null) // if alertMsg wasn't passed in use generic msg
	{
		alertMsg = "Maximum length";
	}
	else
	{
		alertMsg = msg;
	}

	if (text.value.length > maxlength){

		text.value = text.value.substring(0,maxlength);
		alert(" " + alertMsg + " [" + long + "]");
	}
}

//'*******************************************************************************
//'Function:      Reset .NET Maintainscrollbackposition flag
//'Description:   if maintainscrollback is set to true but you'd like to override for certain functions
// register the line below on that function:
//
// Page.ClientScript.RegisterStartupScript(Page.Clien tScript.GetType(), Page.ClientID, "resetDotNetScrollPosition();", true);
//
//'*******************************************************************************

function resetDotNetScrollPosition()
{
	var scrollX = document.getElementById('__SCROLLPOSITIONX');
	var scrollY = document.getElementById('__SCROLLPOSITIONY');

	if(scrollX != null && scrollY != null)
	{
	scrollX.value = 0;
	scrollY.value = 0;
	}
}

//'*******************************************************************************
//'Function:      POPUP HTML BOXES
//'Description:   
//
//'*******************************************************************************

   function ShowPopup(hoverItem)
    {
    hp = document.getElementById(hoverItem);

    // Set popup to visible
    hp.style.visibility = "Visible";
    }

    function HidePopup(hoverItem)
    {
    hp = document.getElementById(hoverItem);
    hp.style.visibility = "Hidden";
    }


//'*******************************************************************************
//'Function:      DISABLE/ENABLE ALL CONTROLS ON PAGE - FOR AJAX CALLS
//'Return:
//'Description:   function for various behaviors of the rad editor
//'*******************************************************************************

                function DisableControls()
                {
                    for (var i=0; i<document.forms[0].elements.length; i++)
                    {            
                        var obj = document.forms[0].elements[i];
                        obj.disabled = true;
                    }
                }
                function EnableControls()
                {
                    for (var i=0; i<document.forms[0].elements.length; i++)
                    {        
                        var obj = document.forms[0].elements[i];
                        obj.disabled = false;
                    }
                }