


function copyFormValue(source, dest){
	var sourceEl = document.getElementById(source);
	var destEl = document.getElementById(dest);
	destEl.value = sourceEl.value;
}


document.getElementsByClassName = function (needle)
{
  var         my_array = document.getElementsByTagName("*");
  var         retvalue = new Array();
  var        i;
  var        j;

  for (i = 0, j = 0; i < my_array.length; i++)
  {
    var c = " " + my_array[i].className + " ";
    if (c.indexOf(" " + needle + " ") != -1)
      retvalue[j++] = my_array[i];
  }
  return retvalue;
}
function addEvent(obj, evType, fn)
{
	if (obj.addEventListener)
	{
		obj.addEventListener(evType, fn, true);
		return true;
	} 
	else if (obj.attachEvent)
	{
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} 
	else 
	{
		return false;
	}
}
function HelpHover()
{
	this._mousePosX = 0;
	this._mousePosY = 0;
	this._hoverItem = null;
	this._hoverContents = null;
}

HelpHover.prototype.init = function()
{
	var hh = this;
	var helpItems = document.getElementsByClassName('hasHelp');
	for (var i=0; i<helpItems.length; i++)
	{
		helpItems[i].onmousemove = function(e)
		{
			if (!e) var e = window.event;
			if (e.pageX || e.pageY)
			{
				hh.mousePosX = e.pageX;
				hh.mousePosY = e.pageY;
			}
			else if (e.clientX || e.clientY)
			{
				hh.mousePosX = e.clientX + document.documentElement.scrollLeft;
				hh.mousePosY = e.clientY + document.documentElement.scrollTop;
			}
			hh._hoverItem = this;
			hh._hoverContents = document.getElementById(this.id+'Help');
			hh.move();
		}
		helpItems[i].onmouseout = function (e)
		{
			hh.out();
		}
	}
}

HelpHover.prototype.out = function()
{
	this._hoverContents.style.top = -10000+'px';
	this._hoverContents.style.left = -10000+'px';
	this._hoverItem = null;
	this._hoverContents = null;
}

HelpHover.prototype.move = function()
{
	this._hoverContents.style.top = this.mousePosY+10+'px';
	this._hoverContents.style.left = this.mousePosX-0+'px';
	//alert(this._hoverContents.style.width);
	//this._hoverContents.style.left = this.mousePosX-this._hoverContents.style.width+'px';
}

addEvent(window, 'load', function()
{
	var hh = new HelpHover();
	hh.init();
});


//=====================================================================
function ajaxCall(FURL)	{
//=====================================================================

	var status;
	
	if (browserName() == "MacIE")
		return "";
	else if (window.XMLHttpRequest)
		ajaxReq = new XMLHttpRequest();
	else if (window.ActiveXObject)
		ajaxReq = new ActiveXObject("Microsoft.XMLHTTP");
	else
		return "";
	if (FURL.indexOf("?") == -1)
		submitURL = FURL + "?r=" + Math.random();
	else
	    submitURL = FURL + "&r=" + Math.random();
	//alert(submitURL);
	ajaxReq.open("GET",submitURL,false);
	ajaxReq.send(null);
	
	status = ajaxReq.responseText.substring(ajaxReq.responseText.indexOf("<orderStatus>")+13, 					ajaxReq.responseText.indexOf("</orderStatus>"));
	switch (status)
	{
		case "NO RECORD":
			alert("A record was not found for the values provided.\nYour changes have NOT been processed.\n\nPlease try again.  Thank you.");
			return "";
			break;
		case "BAD VALUE":
			alert("An incorrect value was passed to this function.\nYour changes have NOT been processed.\n\nPlease try again.  Thank you.");
			return "";
			break;
		default:
			return ajaxReq.responseText;
			break;
	}
}

//=====================================================================
function shimObject(windowName) {
//=====================================================================
	var DivRef = document.getElementById(windowName);
	
	// Insert IFrame shim underneath DHTML window to hide drop down menus in IE
	var IfrRef = document.getElementById('DivShim');
	if(IfrRef!=null)
	{
		IfrRef.style.width = DivRef.offsetWidth;
	    IfrRef.style.height = DivRef.offsetHeight;
		alert("top:" + DivRef.style.top + " left:" + DivRef.style.left);
		var top = parseInt(DivRef.style.top)-152*2+'px';
		alert(top);
	    IfrRef.style.top = top;
	    IfrRef.style.left = DivRef.style.left;
	    IfrRef.style.zIndex = DivRef.style.zIndex + 1;
	    IfrRef.style.display = "block";
    }
}

//=====================================================================
function browserName()
//=====================================================================	
{
	browserAgent = navigator.userAgent;
	var patternFirefox = /firefox/i;
	var patternNetscape = /netscape/i;
	var patternOpera = /opera/i;
	var patternSafari = /safari/i;
	var patternIE = /msie/i;
	var patternMac = /mac/i;
	
	if (patternFirefox.test(browserAgent))
		return "Firefox";
	else if (patternNetscape.test(browserAgent))
		return "Netscape";
	else if (patternOpera.test(browserAgent))
		return "Opera";
	else if (patternSafari.test(browserAgent))
		return "Safari";
	else if (patternIE.test(browserAgent) && patternMac.test(browserAgent))
		return "MacIE";
	else if (patternIE.test(browserAgent))
		return "IE";
	else
		return "Other";
}

function setBackgroundColor(elementID,color){
	if(browserName() !=  "IE"){
		return document.getElementById(elementID).style.backgroundColor  = color ;
	}
	else{
		return document.getElementById(elementID).backgroundColor  = color;
	}
}

function setColor(elementID,color){
	if(browserName() !=  "IE"){
		return document.getElementById(elementID).style.color = color ;
	}
	else{
		return document.getElementById(elementID).color = color;
	}
}



function openWindow(path, width, height){
	window.open(path,"Link","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=" + width + ",height=" + height + ",left=40,top=50");
}




function openWindowToclearApplicationVariables(path) {


	window.open(path,"Link","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=200,height=200,left=40,top=50")

}



