/***********************************************************************
 * @filename            : inc/common.js
 * @author              : Ken Wang
 * @description         : javascript
 * @created             : 2008-07-12
 * @modified            : 2008-07-15
 * @requires            : none
 ***********************************************************************/

/***** Detect Browser Capabilities *****/
var isDom = (document.getElementById) ? true:false;

/***** Generic Functions *****/
/* string manipulation */
function trim( String ) 
{
    if ( String == null )
    {
        return (false);
    }
    return String.replace( /(^\s+)|(\s+$)/g,"" );
}

/* Emulate CGI Vars */
var cgi = new Object();
    cgi.http_host = location.host;
    cgi.http_user_agent = navigator.userAgent;
    cgi.http_cookie = document.cookie;
    cgi.https = (location.protocol == 'https:\/\/') ? 'on' : 'off';
    cgi.path_info = (location.pathname.indexOf('?') != -1) ? location.pathname.substring(0, location.pathname.indexOf('?')) : location.pathname;
    cgi.query_string = (location.search) ? ((location.search.indexOf('#') != -1) ? location.search.substring(1, location.search.indexOf('#')) : location.search.substring(1)) : '';
    cgi.script_name = cgi.path_info;
    cgi.http_referer = document.referrer;

function logAccess( s_type, s_item )
{
    var logImg = new Image();
    var t = (typeof(s_type)=='string' && s_type=='c') ? 'c':'p';
    var i = (typeof(s_item)=='string' && s_item!='' ) ? s_item : cgi.script_name;
    var r = new Date();
    logImg.src = './counter.php?t='+t+'&i='+encodeURIComponent(i)+'&r='+encodeURIComponent( r.getTime() );
}

logAccess( 'p' );
