	//Gets the browser specific XmlHttpRequest Object
	function getXmlHttpRequestObject() {
		if (window.XMLHttpRequest) {
			return new XMLHttpRequest();
		} else if(window.ActiveXObject) {
			return new ActiveXObject("Microsoft.XMLHTTP");
		} else {
			document.getElementById('p_status').innerHTML = 'Status: Cound not create XmlHttpRequest Object.  Consider upgrading your browser.';
		}
	}

	//Sends the request and calls handler when Response received
	function sendRequest(req, url, handler, param) {
		if (req.readyState == 4 || req.readyState == 0) {
			req.open("POST", url, true);
			req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			req.onreadystatechange = handler;
			req.send(param);
		}
		return req;
	}
	
	//Sends the request using a form and calls handler when Response received
	function submitForm(req, handler, frm) {
		var boundary = generateBoundary();
		if (req.readyState == 4 || req.readyState == 0) {
			req.open("POST", frm.action, true);
			req.setRequestHeader("Content-Type", "multipart/form-data; boundary=" + boundary);
			req.onreadystatechange = handler;
			var data = binaryMessage(frm, boundary);
			req.sendAsBinary(data);
		}
		return req;
	}
	
	// Creates a random boundry for binary Message //
	function generateBoundary() {
		return "TECHNOLABS---------------------------------" + (new Date()).getTime();
	}
	
	// Creates a binary Message using a form
	function binaryMessage(frm, boundary) {
		var elements = frm.getElements();
		var CRLF = "\r\n";
		var parts = [];
		elements.forEach(function(element, index, all) {
			var part = "";
			var type = "TEXT";
			if (element.nodeName.toUpperCase() === "INPUT") {
				type = element.getAttribute("type").toUpperCase();
			}
			if (type === "FILE" && element.files.length > 0) {
				var fieldName = element.name;
				var fileName = element.files[0].fileName;
				/*
				 * Content-Disposition header contains name of the field
				 * used to upload the file and also the name of the file as
				 * it was on the user's computer.
				 */
				part += 'Content-Disposition: form-data; ';
				part += 'name="' + fieldName + '"; ';
				part += 'filename="'+ fileName + '"' + CRLF;
				/*
				 * Content-Type header contains the mime-type of the file
				 * to send. Although we could build a map of mime-types
				 * that match certain file extensions, we'll take the easy
				 * approach and send a general binary header:
				 * application/octet-stream
				 */
				part += "Content-Type: application/octet-stream";
				part += CRLF + CRLF; // marks end of the headers part
				/*
				 * File contents read as binary data, obviously
				 */
				part += element.files[0].getAsBinary() + CRLF;
			} else {
				/*
				 * In case of non-files fields, Content-Disposition
				 * contains only the name of the field holding the data.
				 */
				part += 'Content-Disposition: form-data; ';
				part += 'name="' + element.name + '"' + CRLF + CRLF;
				/*
				 * Field value
				 */
				part += element.value + CRLF;
			}
			parts.push(part);
		});
		var request = "--" + boundary + CRLF;
		request+= parts.join("--" + boundary + CRLF);
		request+= "--" + boundary + "--" + CRLF;
		return request;
	}

	// Creates a parameter string with the given fields and values
	function paramString(fields, values) {
		var param = "";
		for(var i = 0; i < fields.length; i++) {
			param += fields[i] + "=" + values[i] + "&";
		}
		return param;
	}
	
	// Get screen width
	function getScreenWidth() {
		var x = 0;
        if (self.innerHeight) {
                x = self.innerWidth;
        } else if (document.documentElement && document.documentElement.clientHeight) {
                x = document.documentElement.clientWidth;
        } else if (document.body) {
                x = document.body.clientWidth;
        }
        return x;
	}
	
	function getScreenHeight() {
		var y = 0;
        if (self.innerHeight) {
                y = self.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) {
                y = document.documentElement.clientHeight;
        } else if (document.body) {
                y = document.body.clientHeight;
        }
        return y;
	}
	
	function getScrollX() {
	    var x = 0;
	    if( typeof( window.pageYOffset ) == 'number' ) {
	        // Netscape
	        x = window.pageXOffset;
	    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
	        // DOM
	        x = document.body.scrollLeft;
	    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
	        // IE6 standards compliant mode
	        x = document.documentElement.scrollLeft;
	    }
	    return x;
	}
	
	function getScrollY() {
	    var y = 0;
	    if( typeof( window.pageYOffset ) == 'number' ) {
	        // Netscape
	        y = window.pageYOffset;
	    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
	        // DOM
	        y = document.body.scrollTop;
	    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
	        // IE6 standards compliant mode
	        y = document.documentElement.scrollTop;
	    }
	    return y;
	}
	
	function grayOut(vis, boxId, options, extra) {
		// Pass true to gray out screen, false to ungray
		// options are optional.  This is a JSON object with the following (optional) properties
		// opacity:0-100         // Lower number = less grayout higher = more of a blackout
		// zindex: #             // HTML elements with a higher zindex appear on top of the gray out
		// bgcolor: (#xxxxxx)    // Standard RGB Hex color code
		// grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
		// Because options is JSON opacity/zindex/bgcolor are all optional and can appear
		// in any order.  Pass only the properties you need to set.
		var options = options || {};
		var zindex = options.zindex || 50;
		var opacity = options.opacity || 70;
		var opaque = (opacity / 100);
		var bgcolor = options.bgcolor || '#000000';
		var scrollX = getScrollX();
		var scrollY = getScrollY();
//		alert(scrollX + ", " + scrollY);
		
		var dark=document.getElementById('darkenScreenObject');
		if (!dark) {
			// The dark layer doesn't exist, it's never been created.  So we'll
			// create it here and apply some basic styles.
			// If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
			var tbody = document.getElementsByTagName("body")[0];
			var tnode = document.createElement('div');           // Create the layer.
			tnode.style.position='absolute';                 // Position absolutely
			tnode.style.top='0px';                           // In the top
			tnode.style.left='0px';                          // Left corner of the page
			tnode.style.overflow='hidden';                   // Try to avoid making scroll bars
			tnode.style.display='none';                      // Start out Hidden
			tnode.id='darkenScreenObject';                   // Name it so we can find it later
			tbody.appendChild(tnode);                            // Add it to the web page
			dark=document.getElementById('darkenScreenObject');  // Get the object.
		}		
			var msgnode = document.getElementById(boxId);           // Create the box layer.
			msgnode.style.position='absolute';                 // Position absolutely
			msgnode.style.top=  (screen.height)/3+'px';                           // In the top
			msgnode.style.left= (screen.width)/3+'px';                          // Left corner of the page
			msgnode.style.overflow='hidden';                   // Try to avoid making scroll bars
			msgnode.style.display='none';                      // Start out Hidden
//			msgnode.id='box';                   				// Name it so we can find it later
//			tbody.appendChild(msgnode);                            // Add it to the grey screen
		
		if (vis) {
			// Calculate the page width and height
			if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
				var pageWidth = document.body.scrollWidth+'px';
				var pageHeight = document.body.scrollHeight+'px';
			} else if( document.body.offsetWidth ) {
				var pageWidth = document.body.offsetWidth+'px';
				var pageHeight = document.body.offsetHeight+'px';
			} else {
				var pageWidth='100%';
				var pageHeight='100%';
			}
			//set the shader to cover the entire page and make it visible.
			dark.style.opacity=opaque;
			dark.style.MozOpacity=opaque;
			dark.style.filter='alpha(opacity='+opacity+')';
			dark.style.zIndex=zindex;
			dark.style.backgroundColor=bgcolor;
			dark.style.width= pageWidth;
			dark.style.height= pageHeight;
			dark.style.display='block';
			if(extra == 'Y')
				document.body.style.overflow =  'hidden';

			document.getElementById(boxId).style.zIndex = zindex+10;
//			document.getElementById(boxId).style.border = "#000 solid 1px";
//			document.getElementById(boxId).style.width = "300px";
//			document.getElementById(boxId).style.height = "100px";
			document.getElementById(boxId).style.display = "block";
//			document.getElementById(boxId).style.textAlign = "center";
			document.getElementById(boxId).onclick = function() //attach a event handler to hide both div
			{
				dark.style.display="none";
				document.getElementById(boxId).style.display = "none";
			}
//			document.getElementById(boxId).style.backgroundColor="#FFF";
//			document.getElementById(boxId).innerHTML = "This is a box. Click me to exit effect.";
		} else {
			dark.style.display='none';
		}
	}
	
	// get Element Position
	function getElementPosition(obj) {
		var curleft = curtop = 0;
		if (obj.offsetParent) {
			curleft = obj.offsetLeft;
			curtop = obj.offsetTop;
			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
			}
		}
		return [curleft,curtop];
    }
	
	function enableDisable(enId, val) {
		for(var i = 0; i < enId.length; i++) {
			var enInp = document.getElementById(enId[i]);
			enInp.removeAttribute('disabled');
			if(val) {
				var disAttr = document.createAttribute("disabled");
				disAttr.nodeValue = "true";
				enInp.setAttributeNode(disAttr);
			}
		}
	}

