function httpQuery (url, data) {
	if (typeof data == 'undefined') {
		data = '';
	}
	var xmlhttp=false
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	   xmlhttp = false
	  }
	 }
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest()
		} catch (e) {
			xmlhttp=false
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest()
		} catch (e) {
			xmlhttp=false
		}
	}

	/*if (window.XMLHttpRequest) {
	// Mozilla/Safari
	xmlhttp=new XMLHttpRequest();
	}else if (typeof ActiveXObject != "undefined"){
	xmlhttp=new ActiveXObject
	// Internet Explorer
	("Microsoft.XMLHTTP");
	}*/

	xmlhttp.open("POST", url, true);
	xmlhttp.setRequestHeader("Content-Length", data.length);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState == 4) {
			var x
			var d = document
			if (xmlhttp.responseText != ''){
//				alert (xmlhttp.responseText);
		        var myObject = eval('('+xmlhttp.responseText+')')
				for (x in myObject) {
		        	if ('eval'==x) {
		        		eval(myObject[x]);
		        		continue;
		        	}
		        	d.getElementById(x).innerHTML = myObject[x];
		        }
			}
		}
	}
	xmlhttp.send(data);
	return true
}
function loadBlock(name, action, param)
{
	var str = location.search
	if (str.indexOf('ajax') == -1 || str.indexOf('ajax=true') != -1) {
		var val = getCookie(name);
		if (null != val) {
			document.getElementById(name).innerHTML = "<div style='padding: 20px 10px; color: Red;'>LOADING...</div>";
			httpQuery('/?ajax=true&'+action+'='+val+param);
		}
	}
}

function getExpDate(days, hours, minutes) {
    var expDate = new Date();
    if (typeof days == "number" && typeof hours == "number" &&
        typeof hours == "number") {
        expDate.setDate(expDate.getDate() + parseInt(days));
        expDate.setHours(expDate.getHours() + parseInt(hours));
        expDate.setMinutes(expDate.getMinutes() + parseInt(minutes));
        return expDate.toGMTString();
    }
}


function setCookie (name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}


function checkCookie()
{
username=getCookie('username')
if (username!=null && username!="")
  {alert('Welcome again '+username+'!')}
else
  {
  username=prompt('Please enter your name:',"")
  if (username!=null && username!="")
    {
    setCookie('username',username,365)
    }
  }
}
function httpQueryLogin(url)
{
	return httpQuery(url+'&email='+document.getElementById('email').value+'&password='+document.getElementById('password').value+'&remember='+document.getElementById('remember').checked)
}

function recoveryData (form_name)
{   str ='';
    var form = document.forms[form_name];
    for (i=0; i<form.length; i++) {
    	if (form.elements[i].type == 'checkbox' || form.elements[i].type == 'radio'){
    	   str = str+'&'+form.elements[i].name+'='+form.elements[i].checked;
    	} else {
    		 str = str+'&'+form.elements[i].name+'='+form.elements[i].value;
    	}

        }
        //alert(str)
	return str;
}

function dump(doc) {
var tmp=doc+'\n';
for (var i in doc) tmp+=i+', ';
return tmp;
}

function findPosition(node)
{
  if(node.offsetParent)
  {
    for(var posX = 0, posY = 0; node.offsetParent; node = node.offsetParent)
    {
      posX += node.offsetLeft;
      posY += node.offsetTop;
    }
	var arr = new Array();
	arr[0] = posX;
	arr[1] = posY;
	return arr;
  }
  else {
	var arr = new Array();
	arr[0] = node.x;
	arr[1] = node.y;
	return arr;
  }
}


function prompt (text, node) {
		if (typeof node == 'undefined') {
			document.getElementById('curscroll').style.visibility="hidden";
			return;
		}
		/*if ( document.getElementById('curscroll').style.visibility == "visible") {
			document.getElementById('curscroll').style.visibility="hidden";
			return;
		}*/
		else {
			document.getElementById('curscroll').style.visibility="visible";
		}
		str = findPosition(node);
		document.getElementById('curscroll').style.left=str[0]+50
		document.getElementById('curscroll').style.top=str[1]-20
		document.getElementById('curscroll').innerHTML = text;

}