if (document.getElementById)
{ 
document.write('<style type="text/css">\n');
document.write('.submenu{display: none;}\n');
document.write('.menuitem{display: block;}\n');
document.write('.menuitem2{display: none;}\n');
document.write('</style>\n');
}

function checkAjax() {
	var AJAX = null;                                 // Initialize the AJAX variable.
	if (window.XMLHttpRequest) {                     // Are we working with mozilla?
	  AJAX=new XMLHttpRequest();                    // Yes -- this is mozilla.
	} else {                                         // Not Mozilla, must be IE
	  AJAX=new ActiveXObject("Microsoft.XMLHTTP");  // Initialize with active X
	}                                                // End setup Ajax.
	if (AJAX==null) {                                // If we couldn't initialize Ajax...
	  return false;                                 // Return false 
	}                                                // End check if AJAX=null
	delete AJAX;                                     // Delete the object since we don't need it anymore
	return true;                                     // Return True, we can do AJAX.
}  

function showTSC(e, strText)
{
	if (!e) var e = window.event;
	if (document.all) 
		var tooltip=document.all.tooltip;
	else
		var tooltip=document.getElementById("tooltip");
	
	tooltip.style.width = "auto";
	tooltip.innerHTML = strText;
	tooltip.style.top = e.clientY + document.documentElement.scrollTop + "px";
	tooltip.style.left = e.clientX + 10 + "px";
	
	if (tooltip.style.display=="none")
	{
		tooltip.style.display = "block";
	}
}

function hideTSC()
{
	if (document.all) 
		var tooltip=document.all.tooltip;
	else
		var tooltip=document.getElementById("tooltip");
	tooltip.style.display = "none";	
}


function showLandfillServices(siteID,type,canada) {
	var popupWin = window.open('/facilities/landfill_services.asp?id='+siteID+'&type='+type+'&canada='+canada,'LandfillServices','width=625,height=300,resizable=yes,scrollbars=yes,toolbar=no');
	popupWin.focus();
}

function showLandfillHolidays(siteID,type,canada,state) {
	var popupWin = window.open('/facilities/holidays.asp?id='+siteID+'&type='+type+'&canada='+canada+'&state='+state,'LandfillHolidays','width=625,height=300,resizable=yes,scrollbars=yes,toolbar=no');
	popupWin.focus();
}
function showLandfillHours(siteID,type,canada,state) {
	var popupWin = window.open('/facilities/hours.asp?id='+siteID+'&type='+type+'&canada='+canada+'&state='+state,'LandfillHours','width=625,height=300,resizable=yes,scrollbars=yes,toolbar=no');
	popupWin.focus();
}
function showLandfillPermits(siteID,type,canada) {
	var popupWin = window.open('/facilities/landfill_permits.asp?id='+siteID+'&type='+type+'&canada='+canada,'LandfillPermits','width=625,height=300,resizable=yes,scrollbars=yes,toolbar=no');
	popupWin.focus();
}

/**********************/
// displayPopup parameters / usage
// callingelement: STRING; HTML-defined ID of the originator element. This element will have it's
//							opacity set to 100 if the cancel button is clicked.
// image: STRING; defines which icon is displayed in the alert window
//					Pre-defined options:
//										alert
//										info
//										error
//					You can pass a URL to any image to use a custom icon.
//					Blank string tells the function to not show an image.
// headertext: STRING; defines the text shown in the green header
//						if this and the image string are blank, the green header bar is not displayed.
// contenttext: STRING; defines the text shown in the alert's body.
// canceltext: STRING - optional; The text displayed on the cancel button. If omitted, the cancel button is not displayed
// submittext: STRING - optional; The text displayed on the submit button. If omitted, the submit button is not displayed.
// submitfunction: Javascript Function Name - optional; The Javascript function to call when the submit button is clicked.
//														NOTE: Do not put the parenthesis after the function name
//														MyFunction is correct, MyFunction() is not correct.
//
//														To Pass an argument when clicking the Submit button:
//														function() {theFunction(argument,list); $('alertbox').style.display='none';}
function displayPopup(callingelement,image,headertext,contenttext,canceltext,submittext,submitfunction) {
	//If this width is changed, you MUST change it in the CSS as well.
	var boxWidth = 400;
	
	document.getElementById('callingelement').value = callingelement

	//Grab all of the elements
	var alertbox = document.getElementById('alertbox');
	var header = document.getElementById('abheader');
	var content = document.getElementById('abcontent');
	var btn_cancel = document.getElementById('abbtn_cancel');
	var btn_submit = document.getElementById('abbtn_submit');


	//Set the header text
	if (headertext.length > 0 || image.length > 0) {
		header.style.display = 'block';
		
		if (image.length > 0) {
			var imageURL;
			switch (image) {
				case 'alert':
					imageURL = 'https://static.wmdisposal.com/images/displaypopup/alert.gif';
					break;
				case 'info':
					imageURL = 'https://static.wmdisposal.com/images/displaypopup/info.gif';
					break;
				case 'error':
					imageURL = 'https://static.wmdisposal.com/images/displaypopup/error.gif';
					break;
				default:
					imageURL = image;
					break;
			}
			var imagecontent = '<img src="' + imageURL + '" style="padding-right: 5px;" />';
		}
		
		header.innerHTML = imagecontent + headertext;
	} else {
		header.style.display = 'none';
	}
	//Set the content text
	content.innerHTML = contenttext;

	//Set the cancel button text/display
	if (canceltext.length > 0) {
		btn_cancel.value = canceltext;
		btn_cancel.style.display = 'inline';
	} else {
		btn_cancel.style.display = 'none';
	}
	
	//Set the submit button text/display
	if (submittext != undefined) {
		if (submittext.length > 0) {
			btn_submit.value = submittext;
			btn_submit.onclick = submitfunction;
			btn_submit.style.display = 'inline';
		} else {
			btn_submit.style.display = 'none';
		}
	} else {
		btn_submit.style.display = 'none';
	}


	//Set the x/y position
	var scrollTop = getScrollY();
	alertbox.style.top = (scrollTop + 200) + 'px';
	alertbox.style.left = ((document.body.clientWidth / 2) - (boxWidth / 2)) + 'px';

	//Display the alert box
	alertbox.style.display = "block";
}

function getScrollY(){
	if (navigator.appName == "Microsoft Internet Explorer"){      
		if(!document.documentElement.scrollTop)
			return document.body.scrollTop;
		return document.documentElement.scrollTop;
 	} else {
		return window.pageYOffset;
	}
}
