﻿// JScript File
// Prevents event bubble up or any usage after this is called. 
// e - event object 
function stopEvent(e) 
{ 
   if (!e) 
     if (window.event) 
        e = window.event; 
     else 
        return; 
   if (e.cancelBubble != null) 
      e.cancelBubble = true; 
   if (e.stopPropagation) 
      e.stopPropagation(); 
   if (e.preventDefault) 
      e.preventDefault(); 
   if (window.event) 
      e.returnValue = false; 
   if (e.cancel != null) 
      e.cancel = true; 
}

function validateTextLength(textboxClientID, textboxName,maxlen)
{
    if (document.getElementById(textboxClientID).value.length > maxlen)
    {
        alert(textboxName + ' text in may not exceed ' + parseInt(maxlen) + ' characters.');
        return false;
    }
    else
        return true;
}

/*function doPrint()
{
	//Popup a blank window, have it's script copy the content
	//of the underlying "opener" html and re-style.
	var path = location.pathname.split('/'); 
	var app = path[1];
	window.open('/' + app + '/print/print.htm','Print');
}*/

function handlePrintContent()
{
    if (parent.opener.document.getElementById('content') != null)
    {
        var val = parent.opener.document.getElementById('content').innerHTML;
        //hide print button in IE
        val = val.replace('<DIV id=printemail>','<DIV id=printemail style=display:none;>');
        val = val.replace('<div id=printemail>','<div id=printemail style=display:none;>');
        //hide print button in Firefox
        val = val.replace('<div id="printemail">','<div id="printemail" style="display:none;">');
        //hide breadcrumb in IE
        //val = val.replace('<DIV id=breadcrumbs>','<DIV id=breadcrumbs style=display:none;>');
        //val = val.replace('<div id=breadcrumbs>','<div id=breadcrumbs style=display:none;>');
         //hide breadcrumb in Firefox
        //val = val.replace('<div id="breadcrumbs">','<div id="breadcrumbs" style="display:none;">');

        document.write(val);
        //open the print dialog after 1 second
        setTimeout("window.print();", 1000);
    }
    else
    {
        //document.write('Error: The \'content\' div does not exist in the page.');
        //reload the document until the 'content' div is loaded.
        window.location.reload();
    }
}

function handlePrintFooter()
{
    if (parent.opener.document.getElementById('footer') != null)
    {
        var val = parent.opener.document.getElementById('footer').innerHTML;
        //hide Privacy and Legal links in IE
        val = val.replace('<UL id=nav_footer>','<UL id=nav_footer style=display:none;>');
        val = val.replace('<ul id=nav_footer>','<ul id=nav_footer style=display:none;>');
        //hide Privacy and Legal links in Firefox
        val = val.replace('<ul id="nav_footer">','<ul id="nav_footer" style="display:none;">');
        //alert(val);
        document.write(val);
    }
    else
    {
        //document.write('Error: The \'footer\' div does not exist in the page.');
        //reload the document until the 'footer' div is loaded.
        window.location.reload();
    }
}

function disableAnchor(tagname)
{
    for(i=0; i<document.getElementsByTagName(tagname).length; i++)
	{
		var oAnchor = document.getElementsByTagName(tagname).item(i);
		//Totally disable the anchor
		//oAnchor.removeAttribute('href');
		//The next 5 lines displays the anchor but disable it. 
		//Use "oAnchor.removeAttribute('href');" to remove the 
		//anchor totally and display it as regular text instead.
		oAnchor.setAttribute("href","#");
		oAnchor.setAttribute("onclick","javascript:return false;");
		oAnchor.textDecoration = "none";
		oAnchor.style.cssText = "CURSOR: default;"
		oAnchor.removeAttribute('target');
	}
}

function doPrintPage()
{
    document.title = parent.opener.document.title;
    disableAnchor('a');
    disableAnchor('A');
}
/* ---------------------------------------------------------
Function popupWin

DESCRIPTION: Pops open a window given user supplied params

PARAMS:
@IN: url(required), title(required empty string), features(required)
@OUT: no returns, pops up a window on caller behalf

Param Syntax:
url			= full path to file (can include querystrings)
name		= name of popup window as used by the target attribute (see following url:http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/open_0.asp)
features	= (name=value;) string value pairs seperated by semi-colons 
			for each feature to include.
			Example, to open a popup with no toolbar and width of 100, the
			features param should look like the following:
			'toolbars=no;width=100;'
			
Authors:			Revision Date:			Revision Reason:
-------------------------------------------------------------

K C				June 10, 2004			Created
K C				Aug 32, 2004			Bug fix -Edited the field "title" changed to "name"
*/
var _popupWin = null;
function popupWin(url,name,features)
{
if(''==url)		{ return; }
if(''==features){ return; }
if(''==name )	{ name = null; }
	var bContinue = false;
	var featureList = features.split(';');
		features = '';
	for(j=0;j<featureList.length;j++)
	{	if(''!=featureList[j])
		{
			//do we have a name=value?
			var featureNameVals = featureList[j].split('=');

			if(''!=featureNameVals[0]&&''!=featureNameVals[1])
			{
				features += featureList[j];
				//read ahead 1 and see if it's blank befere append ','
				if(j!=featureList.length-1 && ''!=featureList[j+1])
				{
					features+= ',';
					bContinue = true;
				}
			}
		}
	}
	//open the popup here (does not return any arguments to callers)
	//does not close the window in code, user must dismiss
	if(bContinue) {
     _popupWin =  window.open(url,name,features+',resizable=yes,scrollbars=yes');
  }
		
}

function closePopup()
{
	if(typeof(_popupWin)=='object')
	{
		_popupWin.close()
	}
}
