
var helpOn;
bHelpOn=0;
var mailpagewin;
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}



function sureremove(listid)
{
	return confirm("Are you sure you want to remove listing #" + listid + " from EquipNet's MarketPlace?");
}

function MyEquipNetQuikNav()
{
	window.location.href = document.forms.frmnav.nav.options[document.forms.frmnav.nav.selectedIndex].value;
	return false;
}


function openinlinewindow(s)
{
   var inlinewin=dhtmlwindow.open("broadcastbox", "inline", s, "Conditions", "width=375px,height=240px,left=350px,top=350px,resize=1,scrolling=0")
}

function openinlinewindowkeys(s,hdg)
{
   var inlinewin=dhtmlwindow.open("broadcastbox", "inline", s, hdg, "width=375px,height=240px,left=350px,top=350px,resize=1,scrolling=1")
}

function openinlinewindowEmailList(sAjaxPage)
{
	mailpagewin=dhtmlwindow.open("emailpage", "ajax", sAjaxPage, "Email to a friend", "width=375px,height=300px,left=350px,top=130px;resize=1,scrolling=1");
}

function ToOffer(pid, bidid)
{
	window.location = '/bid/reply_to_offer.asp?bidid=' + bidid + '&pid=' + pid + '&from=myequipnet'
}

function opensmallwindow(page, sContent, height, width) {
if (height == '')
 	height = 300
if (width=='')
	width = 525
	
var sOpts = "resizable=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,height=" + height + ",width=" + width

var OpenWin = window.open(page, "smWindow", sOpts);
if (OpenWin != null) {
 	if (sContent != '') {
 		OpenWin.document.write(sContent)
		OpenWin.document.close()
	}	
	OpenWin.focus()
 }
 
}

function newPage(pageno)
{
	document.forms.frmlist.page.value = pageno;
	document.forms.frmlist.submit();
}

function newPage2(pageno)
{
	document.forms.frmlist.page2.value = pageno;
	document.forms.frmlist.submit();
}

function newPage3(pageno)
{
	document.forms.frmlist3.page.value = pageno;
	document.forms.frmlist3.submit();
}

function newSortOrder(so)
{
	document.forms.frmlist.sort.value = so;
	// set pageno to 1
	document.forms.frmlist.page.value = 1;
	document.forms.frmlist.submit();
}
function newSortOrder2(so)
{
	document.forms.frmlist2.sort2.value = so;
	// set pageno to 1
	document.forms.frmlist2.page.value = 1;
	document.forms.frmlist2.submit();
}

function newSpecSortOrder(so)
{
	document.forms.frmlist.specsort.value = so;
	document.forms.frmlist.page.value = 1;
	document.forms.frmlist.submit();
}

function newWatchList(listid)
{
	document.forms.frmlist.watchlistid.value = listid;
	document.forms.frmlist.submit();
}

function toExcel()
{
	document.forms.frmlist.excel.value = 'y';
	document.forms.frmlist.submit();
}

function updatelistnumall(x)
{
	var index = 0;
	// remove from listnumall
	var front = getFront(document.forms.frmlist.listnumall.value, x);
	var end = getEnd(document.forms.frmlist.listnumall.value, x);
	if (front != null && end != null) {
			document.forms.frmlist.listnumall.value = front + end;
	}
	// if begins with , remove it
	if (document.forms.frmlist.listnumall.value.charAt(0) == ',')
		document.forms.frmlist.listnumall.value = document.forms.frmlist.listnumall.value.substring(1,200);
	

	// if only 1 listnum no index
	if (document.forms.frmlist.listnum.length == 1)
	{
		if (document.forms.frmlist.listnum.checked)
		{
			if (document.forms.frmlist.listnumall.value == '')
				document.forms.frmlist.listnumall.value = x; 
			else
				document.forms.frmlist.listnumall.value = document.forms.frmlist.listnumall.value + ',' + x; 
		}
	}
	else
	{	
		// set index
		for (var i = 0; i < document.forms.frmlist.listnum.length; i++)
		{
			if (document.forms.frmlist.listnum[i].value == x)
			{
				index = i;
				break;
			}
		}
		
		if (document.forms.frmlist.listnum[index].checked)
		{
			// add it now
			if (document.forms.frmlist.listnumall.value == '')
				document.forms.frmlist.listnumall.value = x; 
			else
				document.forms.frmlist.listnumall.value = document.forms.frmlist.listnumall.value + ',' + x; 
		}	
	}		
}

function getFront(mainStr, searchStr)
{
   	foundOffset = mainStr.indexOf(',' + searchStr);
	if (foundOffset == -1) 
	{
		foundOffset = mainStr.indexOf(searchStr);
		if (foundOffset == -1) {
			return null;
		}
	}		
	return mainStr.substring(0, foundOffset);
}


function getEnd(mainStr, searchStr)
{
	foundOffset = mainStr.indexOf(searchStr);
	if (foundOffset == -1) {
		return null;
	}	
	return mainStr.substring(foundOffset+searchStr.length,mainStr.length);
}


function loadpage(page)
{
	window.location = page;
	return false;
}

function emailThisPage(spage)
{
	var newWindow = window.open(spage,"email","status,scrollbars,height=500,width=520");
	newWindow.focus();
}



function newManuf()
{
	document.forms.frmpost2.newmanuf.value = '1';
	document.forms.frmpost2.submit();
	
}

var iFormCanGo;
// 1 = ok to go
iFormCanGo = 1;
	
function disableFormSubmit()
{
	iFormCanGo = 0;
}
function okToSubmit()
{
	if(iFormCanGo == 1)
		{
			//disableFormSubmit()
			return(true);
		}	
	else
		{
			return(false);
		}
}

	
function chkShowZip(form, prevval)
{
  if ((document.forms.frmadvsrch.CountryID[document.forms.frmadvsrch.CountryID.selectedIndex].value == 'USA') || (prevval == 'USA'))
  	{
	disableFormSubmit();
	form.submit();
	}
}
function updateregionname(choice)
{
	document.forms.frmadvsrch.regionname.value = choice[choice.selectedIndex].text;
}
function updatemfgname(choice)
{
	document.forms.frmadvsrch.mfgname.value = choice[choice.selectedIndex].text;
}


function validate(theForm)
{
	var bFnd = false; 
	var bNoFnd = false; 
	if(theForm.dbid.value=="")
	{
		alert("Please enter an offer amount.");
		theForm.dbid.focus();
		return(false);
	}
 
	 var checkOk="1234567890.";
	 var checkStr=theForm.dbid.value;
	 var allValid=true;
	 if(checkStr.length==1)
	 {
		 if(checkStr.charAt(0)=="0")
		 {
		   alert("The offer amount cannot be 0");
		   theForm.dbid.value="";
		   theForm.dbid.focus();
		   return(false);
		 }
		 
 		 if(checkStr.charAt(0)==".")
		 {
		   alert("The offer amount cannot be just a period.");
		   theForm.dbid.value="";
		   theForm.dbid.focus();
		   return(false);
		 }
	 }
	 
	 for(i=0;i<checkStr.length;i++)
	 {
	 	ch=checkStr.charAt(i);
		if(ch=='.')
			if( bFnd)
			{
			   alert("The offer amount cannot contain more than one decimal point.");
			   theForm.dbid.value="";
			   theForm.dbid.focus();
			   return(false);
			}
			else
				bFnd = true; 
	}
	

	if(allValid)
	{
		 for(i=0;i<checkStr.length;i++)
		 {
		 	ch=checkStr.charAt(i);
			for(j=0;j<checkOk.length;j++)
				if(ch==checkOk.charAt(j))
				{
					if('.'!=checkOk.charAt(j))
						bNoFnd = true; 
					break;
				}	
					
			if(j==checkOk.length)
			{
				allValid=false;
				break;
			}
		}
	}

	if(allValid && !bNoFnd)
	{
		alert("Enter numbers in the offer amount field");
		theForm.dbid.value="";
		theForm.dbid.focus();
		return(false);
	}



	if(!allValid)
	{
		alert("Enter only numbers in the offer amount field");
		theForm.dbid.value="";
		theForm.dbid.focus();
		return(false);
	}

}

function doReset()
{
	return true;
}

function goBack()
{
	history.back();
}

function toggleVisibility(me){
var me1 = document.getElementById('helptext');
var me2 = document.getElementById('helptext2');
		me = document.getElementById(me);
		if (me.style.visibility=="hidden"){
			me1.style.visibility="hidden";
			me2.style.visibility="hidden";
			me.style.visibility="visible";
			}
		else {
			me1.style.visibility="hidden";
			me2.style.visibility="hidden";
			me.style.visibility="hidden";
			}
}

function toggleSearchLeftNav(id) {
	var count = 0;
	var eclass = 'className';
		
	identity=document.getElementById(id);
		
	// thi is the more link
	plusid=document.getElementById('plus'+id);
	
	if (identity != null)
		if (identity.getAttribute("className") == null)
			eclass = 'class';
		else
			eclass = 'className';
	
		
	while (identity != null)
	{
	
    
		if (identity.getAttribute(eclass) == "noshow_leftnav") {
			identity.setAttribute("class", "show_leftnav"); 
			identity.setAttribute("className", "show_leftnav"); 
			//identity.style.backgroundColor="#ffffff";
		}
		else if (identity.getAttribute(eclass) == "show_leftnav") {
			identity.setAttribute("class", "noshow_leftnav"); 
			identity.setAttribute("className", "noshow_leftnav"); 
			//identity.style.backgroundColor="#ffffff";
		}
	
		if (count == 0)
			if (plusid.innerHTML == "less ...")
				plusid.innerHTML = "more ...";
			else
				plusid.innerHTML = "less ...";
				
		count = count + 1;
		identity=document.getElementById(id+count);
		
	}

}

function toggleChangeShow(id) {
	var count = 0;
	var eclass = 'className';
	
	identity=document.getElementById(id);
		
	// get the plus td id
	plusid=document.getElementById('plus'+id);
	if (identity != null)
		if (identity.getAttribute("className") == null)
			eclass = 'class';
		else
			eclass = 'className';
			
	while (identity != null)
	{
		if (count == 0)
		{
		    if (identity.style.backgroundColor=="#cccccc" || identity.style.backgroundColor=="rgb(204, 204, 204)")
				if (identity.getAttribute(eclass) == "rptline") {
				  identity.style.backgroundColor="#ffffff";
				  plusid.innerHTML = "+";
				}  
				else {
				    identity.style.backgroundColor="#D7E7FF";
					plusid.innerHTML = "+";
				}
			else {
					identity.style.backgroundColor="#cccccc";
					plusid.innerHTML = "-";
			}
		}
		if (identity.getAttribute(eclass) == "noshow_rptline" && count > 0) {
			identity.setAttribute("class", "rptline"); 
			identity.setAttribute("className", "rptline"); 
			identity.style.backgroundColor="#cccccc";
		}
		else if (identity.getAttribute(eclass) == "noshow_rptline-ltblue" && count > 0) {
			identity.setAttribute("class", "rptline-ltblue"); 
			identity.setAttribute("className", "rptline-ltblue"); 
			identity.style.backgroundColor="#cccccc";
		}	
		else if (identity.getAttribute(eclass) == "rptline" && count > 0) {
			identity.setAttribute("class", "noshow_rptline"); 
			identity.setAttribute("className", "noshow_rptline"); 
			identity.style.backgroundColor="#ffffff";
		}	
		else if (identity.getAttribute(eclass) == "rptline-ltblue" && count > 0) {
			identity.setAttribute("class", "noshow_rptline-ltblue"); 
			identity.setAttribute("className", "noshow_rptline-ltblue"); 
			identity.style.backgroundColor="#D7E7FF";
		}		
		count = count + 1;
		identity=document.getElementById(id+count);
	}
}

function toggleexpand()
{
	document.forms.frmlist.toggleexpand.value = 1;
	document.forms.frmlist.submit();
}

function viewSalesAgreementMaster(listid)
{

	opensmallwindow("/bid/viewSalesAgreementMaster.asp?listid="+listid, "", 500, 600)
	return (false);
}
function viewSalesAgreementMasterFac(facilityid)
{

	opensmallwindow("/bid/viewSalesAgreementMaster.asp?facilityid="+facilityid, "", 500, 600)
	return (false);
}
function viewSalesAgreementMasterComp(companyid)
{

	opensmallwindow("/bid/viewSalesAgreementMaster.asp?companyid="+companyid, "", 500, 600)
	return (false);
}



function clear_this(box, stext)
{
		  if (box.value == stext)
					 box.value = "";
} 


function listSubmit(sdest)
{
	var newwin = window.open(sdest, "MyListingsDetail","menubar,status,scrollbars,resizable,height=650,width=780");
	newwin.focus();
}

// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================

/* 
AnchorPosition.js
Author: Matt Kruse
Last modified: 10/11/02

DESCRIPTION: These functions find the position of an <A> tag in a document,
so other elements can be positioned relative to it.

COMPATABILITY: Netscape 4.x,6.x,Mozilla, IE 5.x,6.x on Windows. Some small
positioning errors - usually with Window positioning - occur on the 
Macintosh platform.

FUNCTIONS:
getAnchorPosition(anchorname)
  Returns an Object() having .x and .y properties of the pixel coordinates
  of the upper-left corner of the anchor. Position is relative to the PAGE.

getAnchorWindowPosition(anchorname)
  Returns an Object() having .x and .y properties of the pixel coordinates
  of the upper-left corner of the anchor, relative to the WHOLE SCREEN.

NOTES:

1) For popping up separate browser windows, use getAnchorWindowPosition. 
   Otherwise, use getAnchorPosition

2) Your anchor tag MUST contain both NAME and ID attributes which are the 
   same. For example:
   <A NAME="test" ID="test"> </A>

3) There must be at least a space between <A> </A> for IE5.5 to see the 
   anchor tag correctly. Do not do <A></A> with no space.
*/ 

// getAnchorPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the page.
function getAnchorPosition(anchorname) {
	// This function will return an Object with x and y properties
	var useWindow=false;
	var coordinates=new Object();
	var x=0,y=0;
	// Browser capability sniffing
	var use_gebi=false, use_css=false, use_layers=false;
	if (document.getElementById) { use_gebi=true; }
	else if (document.all) { use_css=true; }
	else if (document.layers) { use_layers=true; }
	// Logic to find position
 	if (use_gebi && document.all) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_gebi) {
		var o=document.getElementById(anchorname);
		x=AnchorPosition_getPageOffsetLeft(o);
		y=AnchorPosition_getPageOffsetTop(o);
		}
 	else if (use_css) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_layers) {
		var found=0;
		for (var i=0; i<document.anchors.length; i++) {
			if (document.anchors[i].name==anchorname) { found=1; break; }
			}
		if (found==0) {
			coordinates.x=0; coordinates.y=0; return coordinates;
			}
		x=document.anchors[i].x;
		y=document.anchors[i].y;
		}
	else {
		coordinates.x=0; coordinates.y=0; return coordinates;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
	}

// getAnchorWindowPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the window
function getAnchorWindowPosition(anchorname) {
	var coordinates=getAnchorPosition(anchorname);
	var x=0;
	var y=0;
	if (document.getElementById) {
		if (isNaN(window.screenX)) {
			x=coordinates.x-document.body.scrollLeft+window.screenLeft;
			y=coordinates.y-document.body.scrollTop+window.screenTop;
			}
		else {
			x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
			y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
			}
		}
	else if (document.all) {
		x=coordinates.x-document.body.scrollLeft+window.screenLeft;
		y=coordinates.y-document.body.scrollTop+window.screenTop;
		}
	else if (document.layers) {
		x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
		y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
	}

// Functions for IE to get position of an object
function AnchorPosition_getPageOffsetLeft (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
	}
function AnchorPosition_getWindowOffsetLeft (el) {
	return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
	}	
function AnchorPosition_getPageOffsetTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;
	}
function AnchorPosition_getWindowOffsetTop (el) {
	return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
	}

function viewcentralizedNotes_lead(leadid)
{
	opensmallwindow("/equipnet/centralized_notes_display.asp?leadid="+leadid, "", 500, 600)
	return (false);
}

////////////////////////////////////////////////////////////////////////

var enableCache = true;
var jsCache = new Array();

var dynamicContent_ajaxObjects = new Array();

function ajax_showContent(divId,ajaxIndex,url)
{
	document.getElementById(divId).innerHTML = dynamicContent_ajaxObjects[ajaxIndex].response;
	if(enableCache){
		jsCache[url] = 	dynamicContent_ajaxObjects[ajaxIndex].response;
	}
	dynamicContent_ajaxObjects[ajaxIndex] = false;
}

function ajax_loadContent(divId,url)
{
	if(enableCache && jsCache[url]){
		document.getElementById(divId).innerHTML = jsCache[url];
		return;
	}

	
	var ajaxIndex = dynamicContent_ajaxObjects.length;
	document.getElementById(divId).innerHTML = '';
	dynamicContent_ajaxObjects[ajaxIndex] = new sack();
	
	if(url.indexOf('?')>=0){
		dynamicContent_ajaxObjects[ajaxIndex].method='GET';
		var string = url.substring(url.indexOf('?'));
		url = url.replace(string,'');
		string = string.replace('?','');
		var items = string.split(/&/g);
		for(var no=0;no<items.length;no++){
			var tokens = items[no].split('=');
			if(tokens.length==2){
				dynamicContent_ajaxObjects[ajaxIndex].setVar(tokens[0],tokens[1]);
			}	
		}	
		url = url.replace(string,'');
	}
	
	dynamicContent_ajaxObjects[ajaxIndex].requestFile = url;	// Specifying which file to get
	dynamicContent_ajaxObjects[ajaxIndex].onCompletion = function(){ ajax_showContent(divId,ajaxIndex,url); };	// Specify function that will be executed after file has been found
	dynamicContent_ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function	
	
	
}

/* Custom variables */

/* Offset position of tooltip */
var x_offset_tooltip = 5;
var y_offset_tooltip = 0;

/* Don't change anything below here */


var ajax_tooltipObj = false;
var ajax_tooltipObj_iframe = false;

var ajax_tooltip_MSIE = false;
if(navigator.userAgent.indexOf('MSIE')>=0)ajax_tooltip_MSIE=true;


function ajax_showTooltip(externalFile,inputObj)
{
	if(!ajax_tooltipObj)	/* Tooltip div not created yet ? */
	{
		ajax_tooltipObj = document.createElement('DIV');
		ajax_tooltipObj.style.position = 'absolute';
		ajax_tooltipObj.id = 'ajax_tooltipObj';
		ajax_tooltipObj.onmouseout = ajax_hideTooltip;
		document.body.appendChild(ajax_tooltipObj);
		
		var leftDiv = document.createElement('DIV');	/* Create arrow div */
		leftDiv.className='ajax_tooltip_arrow';
		leftDiv.id = 'ajax_tooltip_arrow';
		ajax_tooltipObj.appendChild(leftDiv);
		
		var contentDiv = document.createElement('DIV'); /* Create tooltip content div */
		contentDiv.className = 'ajax_tooltip_content';
		ajax_tooltipObj.appendChild(contentDiv);
		contentDiv.id = 'ajax_tooltip_content';
		
		if(ajax_tooltip_MSIE){	/* Create iframe object for MSIE in order to make the tooltip cover select boxes */
			ajax_tooltipObj_iframe = document.createElement('<IFRAME frameborder="0">');
			ajax_tooltipObj_iframe.style.position = 'absolute';
			ajax_tooltipObj_iframe.border='0';
			ajax_tooltipObj_iframe.frameborder=0;
			ajax_tooltipObj_iframe.style.backgroundColor='#FFF';
			ajax_tooltipObj_iframe.src = 'about:blank';
			contentDiv.appendChild(ajax_tooltipObj_iframe);
			ajax_tooltipObj_iframe.style.left = '0px';
			ajax_tooltipObj_iframe.style.top = '0px';
		}

			
	}
	// Find position of tooltip
	ajax_tooltipObj.style.display='block';
	ajax_loadContent('ajax_tooltip_content',externalFile);
	if(ajax_tooltip_MSIE){
		ajax_tooltipObj_iframe.style.width = ajax_tooltipObj.clientWidth + 'px';
		ajax_tooltipObj_iframe.style.height = ajax_tooltipObj.clientHeight + 'px';
	}

	ajax_positionTooltip(inputObj);
}

function ajax_positionTooltip(inputObj)
{
	var leftPos = (ajaxTooltip_getLeftPos(inputObj) + inputObj.offsetWidth);
	var topPos = ajaxTooltip_getTopPos(inputObj);
	
	/*
	var rightedge=ajax_tooltip_MSIE? document.body.clientWidth-leftPos : window.innerWidth-leftPos
	var bottomedge=ajax_tooltip_MSIE? document.body.clientHeight-topPos : window.innerHeight-topPos
	*/
	var tooltipWidth = document.getElementById('ajax_tooltip_content').offsetWidth +  document.getElementById('ajax_tooltip_arrow').offsetWidth; 
	// Dropping this reposition for now because of flickering
	//var offset = tooltipWidth - rightedge; 
	//if(offset>0)leftPos = Math.max(0,leftPos - offset - 5);
	
	ajax_tooltipObj.style.left = leftPos + 'px';
	ajax_tooltipObj.style.top = topPos + 'px';	
	
	
}


function ajax_hideTooltip()
{
	
	 setTimeout("HideOpenMenus()",2000);
}

function HideOpenMenus()
{
		ajax_tooltipObj.style.display='none';	  
}

function ajaxTooltip_getTopPos(inputObj)
{		
  var returnValue = inputObj.offsetTop;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetTop;
  }
  return returnValue;
}

function ajaxTooltip_getLeftPos(inputObj)
{
  var returnValue = inputObj.offsetLeft;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetLeft;
  }
  return returnValue;
}

function sack(file){
	this.AjaxFailedAlert = "Your browser does not support the enhanced functionality of this website, and therefore you will have an experience that differs from the intended one.\n";
	this.requestFile = file;
	this.method = "POST";
	this.URLString = "";
	this.encodeURIString = true;
	this.execute = false;

	this.onLoading = function() { };
	this.onLoaded = function() { };
	this.onInteractive = function() { };
	this.onCompletion = function() { };

	this.createAJAX = function() {
		try {
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (err) {
				this.xmlhttp = null;
			}
		}
		if(!this.xmlhttp && typeof XMLHttpRequest != "undefined")
			this.xmlhttp = new XMLHttpRequest();
		if (!this.xmlhttp){
			this.failed = true; 
		}
	};
	
	this.setVar = function(name, value){
		if (this.URLString.length < 3){
			this.URLString = name + "=" + value;
		} else {
			this.URLString += "&" + name + "=" + value;
		}
	}
	
	this.encVar = function(name, value){
		var varString = encodeURIComponent(name) + "=" + encodeURIComponent(value);
	return varString;
	}
	
	this.encodeURLString = function(string){
		varArray = string.split('&');
		for (i = 0; i < varArray.length; i++){
			urlVars = varArray[i].split('=');
			if (urlVars[0].indexOf('amp;') != -1){
				urlVars[0] = urlVars[0].substring(4);
			}
			varArray[i] = this.encVar(urlVars[0],urlVars[1]);
		}
	return varArray.join('&');
	}
	
	this.runResponse = function(){
		eval(this.response);
	}
	
	this.runAJAX = function(urlstring){
		this.responseStatus = new Array(2);
		if(this.failed && this.AjaxFailedAlert){ 
			alert(this.AjaxFailedAlert); 
		} else {
			if (urlstring){ 
				if (this.URLString.length){
					this.URLString = this.URLString + "&" + urlstring; 
				} else {
					this.URLString = urlstring; 
				}
			}
			if (this.encodeURIString){
				var timeval = new Date().getTime(); 
				this.URLString = this.encodeURLString(this.URLString);
				this.setVar("rndval", timeval);
			}
			if (this.element) { this.elementObj = document.getElementById(this.element); }
			if (this.xmlhttp) {
				var self = this;
				if (this.method == "GET") {
					var totalurlstring = this.requestFile + "?" + this.URLString;
					this.xmlhttp.open(this.method, totalurlstring, true);
				} else {
					this.xmlhttp.open(this.method, this.requestFile, true);
				}
				if (this.method == "POST"){
  					try {
						this.xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded')  
					} catch (e) {}
				}

				this.xmlhttp.send(this.URLString);
				this.xmlhttp.onreadystatechange = function() {
					switch (self.xmlhttp.readyState){
						case 1:
							self.onLoading();
						break;
						case 2:
							self.onLoaded();
						break;
						case 3:
							self.onInteractive();
						break;
						case 4:
							self.response = self.xmlhttp.responseText;
							self.responseXML = self.xmlhttp.responseXML;
							self.responseStatus[0] = self.xmlhttp.status;
							self.responseStatus[1] = self.xmlhttp.statusText;
							self.onCompletion();
							if(self.execute){ self.runResponse(); }
							if (self.elementObj) {
								var elemNodeName = self.elementObj.nodeName;
								elemNodeName.toLowerCase();
								if (elemNodeName == "input" || elemNodeName == "select" || elemNodeName == "option" || elemNodeName == "textarea"){
									self.elementObj.value = self.response;
								} else {
									self.elementObj.innerHTML = self.response;
								}
							}
							self.URLString = "";
						break;
					}
				};
			}
		}
	};
this.createAJAX();
}





function extractNumber(obj, decimalPlaces, allowNegative) {
    var temp = obj.value;

    // avoid changing things if already formatted correctly
    var reg0Str = '[0-9]*';
    if (decimalPlaces > 0) {
        reg0Str += '\\.?[0-9]{0,' + decimalPlaces + '}';
    } else if (decimalPlaces < 0) {
        reg0Str += '\\.?[0-9]*';
    }
    reg0Str = allowNegative ? '^-?' + reg0Str : '^' + reg0Str;
    reg0Str = reg0Str + '$';
    var reg0 = new RegExp(reg0Str);
    if (reg0.test(temp)) return true;

    // first replace all non numbers
    var reg1Str = '[^0-9' + (decimalPlaces != 0 ? '.' : '') + (allowNegative ? '-' : '') + ']';
    var reg1 = new RegExp(reg1Str, 'g');
    temp = temp.replace(reg1, '');

    if (allowNegative) {
        // replace extra negative
        var hasNegative = temp.length > 0 && temp.charAt(0) == '-';
        var reg2 = /-/g;
        temp = temp.replace(reg2, '');
        if (hasNegative) temp = '-' + temp;
    }

    if (decimalPlaces != 0) {
        var reg3 = /\./g;
        var reg3Array = reg3.exec(temp);
        if (reg3Array != null) {
            // keep only first occurrence of .
            //  and the number of places specified by decimalPlaces or the entire string if decimalPlaces < 0
            var reg3Right = temp.substring(reg3Array.index + reg3Array[0].length);
            reg3Right = reg3Right.replace(reg3, '');
            reg3Right = decimalPlaces > 0 ? reg3Right.substring(0, decimalPlaces) : reg3Right;
            temp = temp.substring(0, reg3Array.index) + '.' + reg3Right;
        }
    }

    obj.value = temp;
}
function blockNonNumbers(obj, e, allowDecimal, allowNegative) {
    var key;
    var isCtrl = false;
    var keychar;
    var reg;

    if (window.event) {
        key = e.keyCode;
        isCtrl = window.event.ctrlKey
    }
    else if (e.which) {
        key = e.which;
        isCtrl = e.ctrlKey;
    }

    if (isNaN(key)) return true;

    keychar = String.fromCharCode(key);

    // check for backspace or delete, or if Ctrl was pressed
    if (key == 8 || isCtrl) {
        return true;
    }

    reg = /\d/;
    var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
    var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;

    return isFirstN || isFirstD || reg.test(keychar);
}