//encodeURIComponent() 

function PostWebRequest( url, data, funcptr )
{
	if (window.XMLHttpRequest){		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
  	}else{										// code for IE6, IE5
 		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
	xmlhttp.onreadystatechange = funcptr;
	xmlhttp.open( "POST", url, true);
  	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", data.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send( data );
}

function ThisNsf()
{
	var url = window.location.href;
	var index = url.indexOf(".nsf" );
	return( index == -1 ? "" : url.substring(0, index+4) );
}

function SetCookie(name, value, days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function GetCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) 
			return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function DeleteCookie(name) {
	SetCookie(name,"",-1);
}

function RandomCode(){
	return( RandomXToY(1,100000000) );
}

//function to get random number upto m 
//floatVal optionally specifies number of digits 
function RandomXToY(minVal,maxVal,floatVal){
	var randVal = minVal+(Math.random()*(maxVal-minVal));
	return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
}

function Trim(stringToTrim) {
	return(stringToTrim.replace(/^\s+|\s+$/g, ""));
}

function Ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/, "");
}

function Rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/, "");
}

function IsNullOrEmpty( item ){
	return( (item == null) || (Trim(item) == "")  );
}

function ItemIsNullOrEmpty( item ){
	return( (item == null) || (Trim(item.value) == "")  );
}

function GetNodeValue( xmlDoc, Name )
{
	var NodeValue = "";
	try{
		var nodelist = xmlDoc.getElementsByTagName(Name)[0];
		var node = nodelist.childNodes[0];
		NodeValue = node.nodeValue;  
	}catch(err){
	}
	return(NodeValue);
}

function GetItemValue( FieldName ){
	var item = document.getElementById(FieldName);
	return( item == null ? "" : item.value );
}

function SetItemValue( FieldName, FieldValue ){
	var item = document.getElementById(FieldName);
	if (item != null){
		item.value = FieldValue; 
	}
}

function NoEnterKey() {
  return !(window.event && window.event.keyCode == 13); 
}




