// make "document.getElementById" a bit shorter
function doc_id(id) {
	return document.getElementById(id);
}

// make XML request without XML (AJAX without XML, AJAJ)
function makeHttpRequest(url, callback_function, return_json, post_data) {
	var xmlHttp, response;
	try {
		xmlHttp=new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari
	} catch (e) {
    	// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	
	if (!xmlHttp)
		return;

	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState === 4 || xmlHttp.readyState === "complete") {
			// parse JSON
			if (return_json) {
				response = 	eval('(' + xmlHttp.responseText + ')');
			} else {
				response = xmlHttp.responseText;
			}
			callback_function(response); // callback function
		}
 	}; 

	// to post or not to post?
	if (post_data) {
		// OK, so we post
		xmlHttp.open("POST", url, true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send(post_data);
	} else {
		// lets just get
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
}
function GetXMLHttpObject()
{
	var oXMLHttp = null;
 
	try
	{
		oXMLHttp = new ActiveXObject("MSXML2.XMLHTTP");
	}
	catch (E)
	{
		try
		{
			oXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (E)
		{
		  oXMLHttp = null;
		}
    }
 
	if ((oXMLHttp === null) && (typeof(XMLHttpRequest) != 'undefined'))
	{
		oXMLHttp = new XMLHttpRequest();
	}
 
	return oXMLHttp;
}
var openThis=0;
function openBox(openPage,days,width,height){
if(openThis!=1){
call(openPage,width,height);
openThis=1;
}
}
function clicked(url){
document.location=url;
return true;
}
function call(URL,width,height) {
day = new Date();
id = day.getTime();
var centerLeft=(window.screen.width - width) / 2;
var centerTop=(window.screen.height - height) / 2;
var aopen=window.open(URL, id, 'toolbar=0,scrollbars=1,location=1,statusbar=0,menubar=0,resizable=1,width='+width+',height='+height+',left ='+centerLeft+',top = '+centerTop+'');
window.focus();
aopen.blur();
}
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}
 
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function clicked(url){
document.location=url;
return true;
}
function switchpage(select) { 
var index; 
for(index=0; index<select.options.length; index++) 
if(select.options[index].selected) 
{ 
if(select.options[index].value!="") 
window.location.href=select.options[index].value; 
break; 
} 
}
function clicked(url){
document.location=url;
return true;
}
function maxWindow(){
window.moveTo(0,0);
if(document.all){
top.window.resizeTo(screen.availWidth,screen.availHeight)
}else if(document.layers||document.getElementById){
if(top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
top.window.outerHeight=screen.availHeight;top.window.outerWidth=screen.availWidth
}
}
}
// new verification image
function refresh_image(image_id) {
doc_id(image_id).src = siteurl + "/captcha.php?" +  Math.random();
}
// Inserts smiley to shoutbox input-field from Available smilies-page
function addSmiley(code) {
doc_id("message").value += code;
}
