

function Ping()
{
	var request;
	// var query = new QueryParam();
	// query.add2("action", "ping");
	// N.B. When refreshing the page, request with GET method won't be 
	// to the server, the return is from the local cache !!!
	// request = GetURL("CheckUser.asp", query.params); 
	var currTime = new Date();
	request = PostURL("CheckUser.asp?action=ping", currTime.getTime());
	
	if (request.readyState == 4) 
	{ // Complete
		if (request.status == 200) { // OK response
			if (request.responseText == "True")
			{
				return true;
			}
			else
			{
				return false;
			}
		} 
		else {
			alert("¡ä¨ª?¨®: " + request.statusText);
		}
	}	
	
	return false;
}

//------------------------------------------------------
// Code for scrolling Text
//------------------------------------------------------
function initScroll(container,object){
        if (document.getElementById(container) != null){
                var contObj=document.getElementById(container);
                var obj=document.getElementById(object);
                contObj.style.visibility = "visible";
                contObj.scrlSpeed = scrlSpeed; 
                widthContainer = contObj.offsetWidth;
                obj.style.left=parseInt(widthContainer)+"px";
                widthObject=obj.offsetWidth;
                interval=setInterval("objScroll('"+ container +"','"+ object +"',"+ widthContainer +")",20);
                contObj.onmouseover = function(){
                        contObj.scrlSpeed=0;
                }
                contObj.onmouseout = function(){
                        contObj.scrlSpeed=scrlSpeed;
                }        
        }
}

function objScroll(container,object,widthContainer){
        var contObj=document.getElementById(container);
        var obj=document.getElementById(object);
        widthObject=obj.offsetWidth;
        if (parseInt(obj.style.left)>(widthObject*(-1))){
                obj.style.left=parseInt(obj.style.left)-contObj.scrlSpeed+"px";
        } else {
                obj.style.left=parseInt(widthContainer)+"px";
        }
} 


//------------------------------------------------------------------------------------
// 
//------------------------------------------------------------------------------------
function Cookie(cookiename, cookievalue, cookieduration){
	this.name 		= cookiename;
	this.value 		= cookievalue;
	this.duration	= cookieduration;
	this.exp 		= new Date();
	this.newDate 	= this.exp.getTime() + (this.duration * 24 * 60 * 60 * 1000);
	this.exp.setTime(this.newDate);
	
	this.start 		= document.cookie.indexOf( this.name + "=" );
	this.len 		= this.start + this.name.length + 1;
	this.end 		= document.cookie.indexOf(";",this.len);
}

Cookie.prototype = {

	getCookie : function(){
		if ((!this.start) && (this.name != document.cookie.substring( 0, this.name.length ))) {
			return null;
		}
		if ( this.start == -1 ) return null;
		
		if (this.end == -1) this.end = document.cookie.length;
		return unescape(document.cookie.substring(this.len,this.end));	
	},
	
	setCookie : function(){
		document.cookie = this.name + "=" + this.value + "; expires=" + this.exp.toGMTString();
	},
	
	delCookie : function () {
		document.cookie = this.name + "=" + this.value + "; expires=expires=Thu, 01-Jan-1970 00:00:01 GMT";
	}

};


function closeWindow()
{
    if(document.all)
	    window.opener=null;
    else
	    window.open('','_parent','');

	window.close();
}

function trimString(str)
{
	return str.replace(/(^\s*)|(\s*$)/g, ""); 
}


function gotoFrontpage() 
{
	document.URL = "../index.asp";
	
}


// Add data field to specified form object
// that will be post when the form is submit
function addDataField(form, name, value)
{
	var newInput=document.createElement('input');
	
	newInput.type = "hidden";
	newInput.name = name;
	newInput.value = value;
	
	form.appendChild(newInput);	
}

