//<!--
/*
    client library
    Author: Louis Daoust
*/

function UTGotoURL(szURL,szFrameName) 
{
    document.UTReturnValue = false;

    if( szFrameName && parent.frames[szFrameName] )
        parent.frames[szFrameName].location=szURL;
    else
        parent.location=szURL;
}

/*
    Open the current email client with specified TO: email address and optional subject and body
*/
function OpenSendMail(Address,Subject,Body)
{
    var myURL = "mailto:" + escape(Address);
    
    if( Subject )
        myURL += "?subject=" + escape(Subject);
    
    if( Body )
        myURL += "&body=" + escape(Body); 

    window.location = myURL; 

    return true;
}

// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
function CLSetCookieFull(name, value, expires, path, domain, secure) 
{
    var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");

    //parent.document.cookie = curCookie;
    document.cookie = curCookie;
}

function CLSetCookie(name, value, expiredays) 
{
    var ExpireDate = null;
    
    if( expiredays )
    {
        ExpireDate = new Date ();

        ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
    }

    CLSetCookieFull(name,value,ExpireDate,null,null,null);
}

// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function CLGetCookie(name) 
{
    // First we check if there is a cookie stored at all.
    // Otherwise the length of document.cookie would be zero.

    //if (parent.document.cookie.length > 0) 
    if (document.cookie.length > 0) 
    { 
        // Second we check if the cookies name is stored in the
        // "document.cookie"-object for the page.

        // Since more than just one cookie can be set on a
        // single page it is possible that our cookie
        // is not present, even though the "document.cookie"-object
        // is not just an empty text.
        // If our cookiename is not present the value -1 is stored
        // in the variable called "begin".

        //begin = parent.document.cookie.indexOf(name+"="); 
        begin = document.cookie.indexOf(name+"="); 
        if (begin != -1)   // Note: != means "is not equal to"
        { 

        // Our cookie was set. 
        // The value stored in the cookie is returned from the function.

            begin += name.length+1; 
            //end = parent.document.cookie.indexOf(";", begin);
            end = document.cookie.indexOf(";", begin);
            if (end == -1) 
                //end = parent.document.cookie.length;
                end = document.cookie.length;

            //return unescape(parent.document.cookie.substring(begin, end));
            return unescape(document.cookie.substring(begin, end));
        } 
    }

    // Our cookie was not set. 
    // The value "null" is returned from the function.

    return null;  
}

function CLDelCookie(name) 
{
    // The function simply checks if the cookie is set.
    // If so the expiredate is set to Jan. 1st 1970.

    if( CLGetCookie(name) ) 
        document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function OpenSimpleWindow(theURL,winName,features)
{
    window.open(theURL,winName,features);
}
//-->
