
function CheckIsIE()
{
if (navigator.appName.toUpperCase() == 'MICROSOFT INTERNET EXPLORER')
    {return true;}
else
    {return false;}
}

// *******************************************************************

function PrintThisFrame(pov_frame)
{
if (CheckIsIE() == true)
    {
    pov_frame.focus();
    pov_frame.print();
    }
else
    {
    var lcv_framename = pov_frame.name;
    window.frames[lcv_framename].focus();
    window.frames[lcv_framename].print();
    }
}

// *******************************************************************

function show_flash(pcv_file,pcv_width,pcv_height,pcv_transparent)
{
   document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + pcv_width + '" height="' + pcv_height + '">\n');
   document.write('<param name="movie" value="' + pcv_file + '">\n');
   document.write('<param name="quality" value="high">\n');
    document.write('<param name="wmode" value="transparent">\n');
   document.write('<embed src="' + pcv_file + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + pcv_width + '" height="' + pcv_height + '"></embed>\n');
   document.write('</object>\n');
}

// *****************************************************************************
function FormatNumber(num,decimalNum,bolLeadingZero,bolParens,bolCommas)
/*******************************************************************************
	IN:
		NUM - the number to format
		decimalNum - the number of decimal places to format the number to
		bolLeadingZero - true / false - display a leading zero for
										numbers between -1 and 1
		bolParens - true / false - use parenthesis around negative numbers
		bolCommas - put commas as number separators.
 
	RETVAL:
		The formatted number!
 *******************************************************************************/
{ 
        if (isNaN(parseInt(num))) return "NaN";

	var tmpNum = num;
	var iSign = num < 0 ? -1 : 1;		// Get sign of number
	
	// Adjust number so only the specified number of numbers after
	// the decimal point are shown.
	tmpNum *= Math.pow(10,decimalNum);
	tmpNum = Math.round(Math.abs(tmpNum))
	tmpNum /= Math.pow(10,decimalNum);
	tmpNum *= iSign;					// Readjust for sign
	
	
	// Create a string object to do our formatting on
	var tmpNumStr = new String(tmpNum);
	
	// Pad zeros to the right so the specified number of numbers after
	// the decimal point are shown consistently.
	if (decimalNum > 0)
	{
	  //get the length of the string
	  var lnv_len = tmpNumStr.length
	  
	  // get the position of the decimal (if any)
	  var lnv_at = tmpNumStr.indexOf(".")
	  
	  // init the pad string
	  var lcv_pad = ""
	  
	  if (lnv_at > 0)
	  {
	    // it has a decimal, add zeros only
	    // indexOf is zero based, add 1
	    lnv_at ++
	    if (decimalNum > (lnv_len - lnv_at))
	        {
            for (var lnv_loop = 1; lnv_loop <= (decimalNum-(lnv_len - lnv_at)); lnv_loop++)
            {
                lcv_pad += "0";
            }
            tmpNumStr += lcv_pad;
	    }
	  }
	  else
	  {
	    // add dec and zeros 
        lcv_pad = ".";
        for (var lnv_loop = 1; lnv_loop <= decimalNum; lnv_loop++)
        {
            lcv_pad += "0";
        }
        tmpNumStr += lcv_pad;
	  }
	 
	}
	

	// See if we need to strip out the leading zero or not.
	if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
		if (num > 0)
			tmpNumStr = tmpNumStr.substring(1,tmpNumStr.length);
		else
			tmpNumStr = "-" + tmpNumStr.substring(2,tmpNumStr.length);
		
	// See if we need to put in the commas
	if (bolCommas && (num >= 1000 || num <= -1000)) {
		var iStart = tmpNumStr.indexOf(".");
		if (iStart < 0)
			iStart = tmpNumStr.length;

		iStart -= 3;
		while (iStart >= 1) {
			tmpNumStr = tmpNumStr.substring(0,iStart) + "," + tmpNumStr.substring(iStart,tmpNumStr.length)
			iStart -= 3;
		}		
	}

	// See if we need to use parenthesis
	if (bolParens && num < 0)
		tmpNumStr = "(" + tmpNumStr.substring(1,tmpNumStr.length) + ")";

	return tmpNumStr;		// Return our formatted string!
}

/*******************************************************************************/

function printPartOfPage(elementId)
{
    var printContent = document.getElementById(elementId);
    var windowUrl = 'about:blank';
    var uniqueName = new Date();
    var windowName = 'Print' + uniqueName.getTime();
    var printWindow = window.open(windowUrl, windowName, 'left=5,top=5,width=1000,height=600');
    var printHTML = '<span class="bodytext">' + document.title + ' - ' + getDateDMmmYYYY() + ' ' + getTime24hour() + '</span><hr/><br/>' + printContent.innerHTML;

    printWindow.document.write('<link href="/inc/tjinternet.css" rel="stylesheet" type="text/css">');
    printWindow.document.write(printHTML);
    pausecomp(2000);
    printWindow.document.close();
    printWindow.focus();
    printWindow.print();
    printWindow.close();
};

/*******************************************************************************/

function pausecomp(millis)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis);
} 

/*******************************************************************************/

function printPartNoHeader(elementId)
{
    var printContent = document.getElementById(elementId);
    var windowUrl = 'about:blank';
    var uniqueName = new Date();
    var windowName = 'Print' + uniqueName.getTime();
    var printWindow = window.open(windowUrl, windowName, 'left=5,top=5,width=800,height=600');
    var printHTML = printContent.innerHTML;
    
    printWindow.document.write('<link href="/inc/tjinternet.css" rel="stylesheet" type="text/css">') ;
    printWindow.document.write('<style type="text/css" media="print">') ;
    printWindow.document.write('body {margin:.05 in;}') ;
    printWindow.document.write('</style>') ;
    printWindow.document.write(printHTML);
    printWindow.document.close();
    printWindow.focus();
    printWindow.print();
    printWindow.close();
};

/*******************************************************************************/
function getDateDMMMMYYYY ()
{

/* Returns a string for the current date formatted as 1-January-2008  */

var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth();
var curr_year = d.getFullYear();
var returnString = curr_date + "-" + m_names[curr_month] + "-" + curr_year;

return returnString
};

/*******************************************************************************/
function getDateDMmmYYYY ()
{

/* Returns a string for the current date formatted as 1-January-2008  */

var m_names = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");

var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth();
var curr_year = d.getFullYear();
var returnString = curr_date + "-" + m_names[curr_month] + "-" + curr_year;

return returnString
};


/*******************************************************************************/
function getTime12hour ()
{
var a_p = "";
var d = new Date();

var curr_hour = d.getHours();

if (curr_hour < 12)
   {
   a_p = "AM";
   }
else
   {
   a_p = "PM";
   }
if (curr_hour == 0)
   {
   curr_hour = 12;
   }
if (curr_hour > 12)
   {
   curr_hour = curr_hour - 12;
   }

var curr_min = d.getMinutes();
curr_min = curr_min + "";

if (curr_min.length == 1)
   {
   curr_min = "0" + curr_min;
   }

var curr_sec = d.getSeconds();
curr_sec = curr_sec + "";

if (curr_sec.length == 1)
   {
   curr_sec = "0" + curr_sec;
   }

var returnString = curr_hour + ":" + curr_min + ":" + curr_sec + " " + a_p;
return returnString
};

/*******************************************************************************/
function getTime24hour ()
{
var d = new Date();

var curr_hour = d.getHours();

if (curr_hour == 0)
   {
   curr_hour = 12;
   }

var curr_min = d.getMinutes();

curr_min = curr_min + "";

if (curr_min.length == 1)
   {
   curr_min = "0" + curr_min;
   }

var curr_sec = d.getSeconds();
curr_sec = curr_sec + "";

if (curr_sec.length == 1)
   {
   curr_sec = "0" + curr_sec;
   }

var returnString = curr_hour + ":" + curr_min + ":" + curr_sec
return returnString
};

/*******************************************************************************/

function emailPartOfPage(objDiv, objAnchor)
{   
    alert("This option will copy the key contents of this page and start a new e-mail.  Please Right-Click in the body of the new e-mail and select Paste.");
    var rng = document.body.createTextRange();
    rng.moveToElementText(objDiv);
    rng.execCommand("Copy");
    objAnchor.click();
};

function copyPartOfPage(objDiv)
{   
    var rng = document.body.createTextRange();
    rng.moveToElementText(objDiv);
    rng.execCommand("Copy");
    var holdStatus = window.status;
    window.status = "The content area of this page has been copied to your clipboard"
    window.setTimeout("window.status = '" + holdStatus + "'",3000);
};
    
/*******************************************************************************/

function contentToXls(objDiv, objContent)
{
// Sends contents of a div tag via a hidden control to a page that formats as XLS.
// Assumes that the action property of the form passed in is pointing to a page with content type = Excel

    var Content01 = objDiv.innerHTML
 
    //Strip out all non-critical code to get as much data passed over to Excel as possible
    //Start with css classes.  account for various ways they might be coded
    //g flag = global search (all instances)
    Content01 = Content01.replace(/class='bodytext'/g, "")
    Content01 = Content01.replace(/class="bodytext"/g, "")
    Content01 = Content01.replace(/class=bodytext/g, "")

    Content01 = Content01.replace(/class=boilerplate/g, "")
    Content01 = Content01.replace(/class='boilerplate'/g, "")
    Content01 = Content01.replace(/class="boilerplate"/g, "")
	
	Content01 = Content01.replace(/class=whitespace/g, "")
    Content01 = Content01.replace(/class='whitespace'/g, "")
    Content01 = Content01.replace(/class="whitespace"/g, "")
	
	Content01 = Content01.replace(/  /g, " ")
	//disable links
	Content01 = Content01.replace(/href/g, "")

    objContent.value = escape(Content01)
}

/*******************************************************************************/

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

/*******************************************************************************/

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
} 


/*******************************************************************************/

function saveAfav(strTitle, strUrl, pRemove)
{
	var usableHeight = document.body.clientHeight
	var usableWidth = document.body.clientWidth
	var formwidth = 400;
	var formheight = 80;
	//Center the pop up form 
	var formleft = (usableWidth/2) - (formwidth/2);
	var formtop = (usableHeight/2) - (formheight/2);
	var strRemove = ""
	if(pRemove){strRemove = 'true'};
	var lov_win = window.open('/AddRemovefavorite.aspx?remove=' + strRemove + '&title=' + strTitle + '&link=' + strUrl, '_blank','top=' + formtop + ',left=' + formleft + ',toolbar=no,location=yes,resizable=no,modal=yes,width=' + formwidth + ',height=' + formheight);
}

/*******************************************************************************/
function limitText(limitField, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} 
}
