if(!document.getElementById)
{
	if(document.all)
	{
		accessObj = function()
		{
			if(typeof document.all[arguments[0]]!="undefined")
				return document.all[arguments[0]];
			else
				return null;
		}
	}
	else if(document.layers)
	{
		accessObj = function()
		{
			if(typeof document[arguments[0]]!="undefined")
				return document[arguments[0]];
			else
				return null;
		}
	}
}
else
{
	accessObj = function()
	{
		return document.getElementById(arguments[0]);
	}
}

function show_div(div_name)
{
	var obj = accessObj(div_name);
	obj.style.visibility = "visible";
}

function hide_div(div_name)
{
	var obj = accessObj(div_name);
	obj.style.visibility = "hidden";
}

function openDiv(name)
{
	var obj = accessObj(name);
	if (!isNull(obj))
		obj.style.display = "block";
}

function closeDiv(name)
{
	var obj = accessObj(name);
	if (!isNull(obj))
		obj.style.display = "none";
}

function isNull(val)
{
	return(val==null);
}

function get_screen_pos(obj)
{
	var curheight = obj.offsetHeight
	var curleft = curtop = 0;
	if (obj.offsetParent)
	{
		do
		{
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
		while (obj = obj.offsetParent);
	}
	return [curleft,curtop,curheight];
}

function set_screen_pos(obj, x, y)
{
	if (!isNull(obj))
	{
		obj.style.left = x+"px";
		obj.style.top = y+"px";
	}
}

function jumpto(url, confirmStr)
{
	if (!confirmStr)
	{
		window.location = url;
	}
	else
	{
		var userinput = confirm(confirmStr);
		if(userinput)
		{
			window.location = url;
		}
	}
}

function get_window_size()
{	
	var myWidth, myHeight;
	if (self.innerHeight)
	{
		// all except Explorer
		if(document.documentElement.clientWidth)
		{
			myWidth = document.documentElement.clientWidth; 
			myHeight = document.documentElement.clientHeight; 
		}
		else
		{
			myWidth = self.innerWidth;
			myHeight = self.innerHeight;
		}	
		myWidth = self.innerWidth;
		myHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		// Explorer 6 Strict Mode
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		// other Explorers
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	//alert("w: "+myWidth+", h:"+myHeight);
	return Array(myWidth, myHeight);
}

function set_window_size(width, height)
{
	window.resizeTo(width, height);
}

function dummy()
{
	if (self.innerHeight)
	{	
		// all except Explorer
	   window.innerHeight = height;
	    window.innerWidth = width;
		window.resizeTo(width, height);
		// alert("win resize #1"
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{	
		// Explorer 6 Strict Mode
	    window.resizeTo(width+10,height+10);
		alert("win resize #2");
	}
	else if (document.body)
	{ // other Explorers
	    window.resizeTo(width+10,height+10);
		alert("win resize #3");
	}
}

function set_content(div, data)
{
	var obj = accessObj(div);
	obj.innerHTML = data;
}

function setStr(var_name, var_value)
{
	eval(var_name+"='"+var_value+"';");
}

var ma = false;
function open_members_area_window(url)
{
	if (ma != false)
		ma.close();
	ma = window.open(url, "membersarea", "toolbar=no,location=no,status=0,scrollbars=0,directories=0,width=810,height=560,resizable=no");
	ma.focus();
}

function preloader()
{
    buttonImage = new Image();
    buttonImage.src = "../images/site/members-area/button_header_active.jpg"
    
    helpImage = new Image();
    helpImage.src = "../images/site/members-area/button_help.gif";
}

function open_window(url, name, width, height)
{
	window.open(url, name, "toolbar=no,location=no,status=0,scrollbars=0,directories=0,width="+width+",height="+height+",resizable=no");
}

function set_style_class(item, style_class)
{
	var obj = accessObj(item);
	obj.className = style_class;
	/*alert("wank you very much");
	document.getElementById(item).setAttribute("class", style_class);*/
}

function check_log_win(url, check_url)
{
	open_members_area_window(url);
	var xmlHttpReq = false;
	var self = this;
	var refresh_url = url;
	// var callback = callback_div;
	self.xmlHttpReq = (typeof(XMLHttpRequest) != "undefined") ? new XMLHttpRequest() : new ActiveXObject("Msxml2.XMLHTTP");
	self.xmlHttpReq.open('POST', check_url, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function()
	{
		if (self.xmlHttpReq.readyState == 4)
		{
			temp = self.xmlHttpReq.responseText.split("|");
			if(temp[1] == "yes")
			{
				ma.location = refresh_url;
				var obj = accessObj("logFrmHolder");
				obj.innerHTML = temp[2];
			}
			else
			{
				ma.close();
			}
		}
	}
	var frm = accessObj("logfrm");
	var vars = "un="+frm.un.value+"&pw="+frm.pw.value;
	self.xmlHttpReq.send(vars);
}

function submitenter(myfield,e,url,check_url)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;

	if (keycode == 13)
	{
		//myfield.form.submit();
		check_log_win(url, check_url);
		return false;
	}
	else
		return true;
}
