var xmlHttp;

function GetXmlHttpObject() {
	var xmlHttp=null;
	// Firefox, Opera 8.0+, Safari
	try {xmlHttp=new XMLHttpRequest();}
	// Internet Explorer
	catch (e) {
	  try {xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
	  catch (e) {xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
	}
	return xmlHttp;
}

function isEmailAddr(Email) {
 	var result = false
 	var theStr = new String(Email)
	var index = theStr.indexOf("@");
	if (index > 0) {
		var pindex = theStr.indexOf(".",index);
		if ((pindex > index+1) && (theStr.length > pindex+1)) {result = true;}
	}
	return result;
}

function ajax_prep(x) {
	var str = x;
	str = str.replace(/#/gi, "%23");
	str = str.replace(/\+/gi, "%2B");
	str = str.replace(/\n/gi, "-BREAK-");
	str = escape(str);
	return str;
}

function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}
