//*************************************
// Static function delete input value *
//*************************************
function deleteInputValue(field,value)
{
	if (field.value == value)
	{
		field.value = '';
	}
}
	
//****************************
// Static function setCookie *
//****************************
function setCookie(name, value, path, domain, secure, expires)
{
	document.cookie= name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
}

//****************************
// Static function getCookie *
//****************************
function getCookie(name)
{	
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	
	if (begin == -1)
	{
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	}
	
	else
	{
		begin += 2;
	}
	
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
	{
		end = dc.length;
	}
	
	return unescape(dc.substring(begin + prefix.length, end));
}

//*******************************
// Static function deleteCookie *
//*******************************
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
		document.cookie = name + "=" + 
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

//*************************************
// Static function delete all cookies *
//*************************************
function deleteAllCookies(path, domain)
{
	var cookie_arr = document.cookie.split(';');
	
	// do not delete first cookie (=session id)
	for (var a=1;a<cookie_arr.length;a++)
	{
		var cookie_str	= cookie_arr[a].split('=');
		var cookie_name	= cookie_str[0];
		
		document.cookie = cookie_name + "=" + 
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

//***************************
// Static Function findPosX *
//***************************
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
	{
		curleft += obj.x;
	}
	
	return curleft;
}

//***************************
// Static Function findPosY *
//***************************
function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
	{
		curtop += obj.y;
	}
	
	return curtop;
}

//***********************************
// Static Function mouse position x *
//***********************************
function getMousePositionX(e)
{
	var posx = 0;
	
	if (!e) var e = window.event;
	if (e.pageX)
	{
		posx = e.pageX;
	}
	else if (e.clientX)
	{
		posx = e.clientX + document.body.scrollLeft;
	}
	
	return posx;
}

//***********************************
// Static Function mouse position y *
//***********************************
function getMousePositionY(e)
{
	var posy = 0;
	
	if (!e) var e = window.event;
	if (e.pageY)
	{
		posy = e.pageY;
	}
	else if (e.clientY)
	{
		posy = e.clientY + document.body.scrollTop;
	}
	
	return posy;
}

//*********************************
// Static function cancelBubbling *
//*********************************
function cancelBubbling(evt)
{	
    var e = (window.event) ? window.event : evt;
	e.cancelBubble = true;
}

//****************************
// Static function fix event *
//****************************
function fixEvent(e)
{	
	if (typeof e == 'undefined') e = window.event;
	if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
	if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;

	return e;
}

//************************************
// Static function disable selection *
//************************************
function disableSelection(e)
{	
	document.onselectstart = new Function("return false");
}

//***********************************
// Static function enable selection *
//***********************************
function enableSelection(e)
{
	document.onselectstart = new Function("return true");
}

//****************************
// Static function detectKey *
//****************************
function detectKey(e)
{
	var code;

	if (!e) var e = window.event;

	if (e.keyCode)
	{
		code = e.keyCode;
	}
	else if (e.which)
	{
		code = e.which;
	}
	
	return code;
}

//***************************************
// Static function submit form on enter *
//***************************************
function submitFormOnEnter(form_obj)
{
	var form_node	= document.getElementById(form_obj);
	
	// focus on username field
	form_node.onkeypress = function(e)
	{
		var code;

		if (!e) var e = window.event;
	
		if (e.keyCode)
		{
			code = e.keyCode;
		}
		else if (e.which)
		{
			code = e.which;
		}
		
		// submit on enter key
		if(form_node && code == 13)
		{
			form_node.submit();
		}
	}
}

//***************************************
// Static function submit form on enter *
//***************************************
function submitOnEnter(e,form_node)
{	
	
}
