//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 GetWebRequest( url, 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("GET", url, true);	
	xmlhttp.send(null);
}

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) {
	var expires = "";
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		expires = "; expires="+date.toGMTString();
	}
	document.cookie = name+"="+ encodeURIComponent(value) + expires+"; path=/";
}

function GetCookie(cookie_name) {
  	var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
  	if ( results ){
    	return ( decodeURIComponent( results[2] ) );
 	}else{
    	return null;
 	}
}

/*    
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); 
}

function ValidateEmail(email){  
	var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
 	return email.match(re)  
} 

function SetItemDisplayStyle(Name, Display){  
	var item1 = document.getElementById(Name);
	if (item1 != null){
		item1.style.display = Display; 
	}
}

function GoToPage(Url){
	window.location.href=Url;
}

function VerifyHostName(){	
	if ( location.hostname.substr(0, 21).toLowerCase() != "www.justfordomino.com"){
			location.replace( location.href.replace( location.hostname, "www.justfordomino.com" ) );
	}
}

function VerifyHostName2(){	
	location.replace( location.href.replace( location.hostname, "www.justfornotes.com" ) );
}

