
function getPageXY()
{
	var w = (document.body.scrollWidth > document.body.offsetWidth)?document.body.scrollWidth:document.body.offsetWidth;
	var h = (document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;
	return {"width": w, "height":h};
}

function getElementPosition(elemId)
{
	var elem = document.getElementById(elemId);
	if(elem==null) return;
	
	var w = elem.offsetWidth;
	var h = elem.offsetHeight;
	
	var l = 0;
	var t = 0;
	
	while (elem)
	{
	  l += elem.offsetLeft;
	  t += elem.offsetTop;
	  elem = elem.offsetParent;
	}

	return {"left":l, "top":t, "width": w, "height":h};
}
function mousePageXY(e)
{
	var x = 0, y = 0;
	if (!e) e = window.event;
	if (e.pageX || e.pageY)
	{
		x = e.pageX;
		y = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
		y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
	}
	return {"x":x, "y":y};
}

function checkkeyb(e, vform)
{
	var keynum;
	if(window.event) keynum = window.event.keyCode;		// IE
	else if(e.which) keynum = e.which;		// Netscape/Firefox/Opera
	//if(keynum==13) xsubmit(vform);
}

function xhide(popup_name)
{
	$("#"+popup_name).slideToggle('fast');
}

function centerwindow_old(winid)
{
	var bIE = (String(typeof(document.all)) != "undefined");
	if(bIE) { 	x=document.body.offsetWidth; y=document.body.offsetHeight; }
	else { x = window.innerWidth; y = window.innerHeight; }
	$(winid).css("left", x/2 - ($(winid).width())/2);
	$(winid).css("top", y/2 - ($(winid).height())/2);
}

function centerwindow(winid)
{
	var h=document.body.clientHeight;
	var w=document.body.clientWidth;
	$(winid).css("left", w/2 - ($(winid).width())/2);
	$(winid).css("top", 100);
	//$(winid).css("top", h/2 - ($(winid).height())/2);
}

function xsubmit(vform, vparams)
{
	formdata = $("form#"+vform+" :input").serialize();
	
	$("#loading").show();
	$.ajax({ type: "POST", dataType: "script", url: "/inc/form.php?form="+vform+"&"+vparams, data: formdata, 
		complete: function() 
		{
			$("#loading").hide();
		}
	});
}

function xscript(vform, vparams)
{
	formdata = $("form#"+vform+" :input").serialize();
	
	$("#loading").show();
	$.ajax({ type: "POST", dataType: "script", url: "/inc/form.php?form="+vform+"&"+vparams, data: formdata, 
		complete: function() 
		{
			$("#loading").hide();
		}
	});
}

function mailtoggle(_id, inbox)
{
	$("#p"+_id).slideToggle();
	if(inbox)
	{
		$("#h"+_id+" > td > p").removeClass("unreaded");
	}
}

function toggle(_element)
{
	$(_element).slideToggle();
}

function remove(_id)
{
	$(_id).remove();
}

function movereplybox(id, parent)
{
	$("#commentarea").val("");
	$("#commentform input[name='parent']").val(parent);
	$("#commentform").insertAfter("#"+id);
	$("#commentform").show();
}		
