/***********************************************************************
 *                                                                     *
 * Copyright (C) 2003-2008 iWebGate Technology Ltd & Charlie Gargett   *
 * Author: Charlie Gargett                                             *
 *                                                                     *
 ***********************************************************************
 *                                                                     *
 * LICENCE  AGREEMENT:  YOU MAY  NOT  USE,  COPY,  MODIFY, DISASSEMBLE *
 * DECOMPILE, REVERSE ENGINEER,  OR TRANSFER THE SOFTWARE OR ANY COPY, *
 * MODIFICATION,  MERGED  PORTION,  IN  WHOLE  OR IN PART,  EXCEPT  AS *
 * EXPRESSLY  PROVIDED   FOR  IN  THIS  AGREEMENT OR IN THE FULL END   *
 * USER LICENCE AGREEMENT ACCOMPANYING THIS LICENCE AGREEMENT. IF  YOU *
 * TRANSFER POSSESSION OF  ANY COPY,  MODIFICATION  OR  MERGED PORTION *
 * OF  THE SOFWARE  TO ANOTHER PARTY,  YOUR  LICENCE IS  AUTOMATICALLY *
 * TERMINATED.                                                         *
 *                                                                     *
 * This software  product and related  source code is  licenced by the *
 * owner and copyright holder,  iWebGate Technology Ltd, Perth Western *
 * Australia 6000, AUSTRALIA.                                          *
 *                                                                     *
 * All intellectual property rights  in this software product and user *
 * documentation are owned by  iWebGate Technology Ltd,  PERTH Western *
 * Australia  6000,   AUSTRALIA,   and  are  protected  by  applicable *
 * Australian Copyright laws and international treaty provisions.  The *
 * owner retains all rights not expressly granted.                     *
 *                                                                     *
 * YOU MUST  READ AND  AGREE  TO THE  LICENCE  DOCUMENTS  ACCOMPANYING *
 * THIS  SOFTWARE  PRODUCT  PRIOR  TO  INSTALLING  OR  UTILISING  THIS *
 * SOFTWARE IN ANY WAY.                                                *
 *                                                                     *
 * As a special exception  to the above  Licence Agreement, javascript *
 * source code  exposed by  this software product  through direct HTML *
 * embedding,  in-direct linking through reference to  external source * 
 * files or  by any  other means  of exposure of  javascript  routines * 
 * made by this software product may  be used for the explicit purpose *
 * of research into the development of similar routines but may not be *
 * copied,  modified,  disassembled, decompiled,  reverse  engineered, *
 * transfered as  is or as a copy,  modification,  merged portion,  in *
 * whole  or  in  part,  except  as  expressly  provided  for in  this *
 * agreement.                                                          *
 *                                                                     *
 ***********************************************************************/

function getCookie(name) {
    var result = null
    var myCookie = " "+document.cookie+";"
    var search = " "+name+"="
    var start = myCookie.indexOf(search)
    var end = null

    if(start != -1) {
        start += search.length
        end = myCookie.indexOf(";", start)
        result = unescape(myCookie.substring(start, end))
    }
    return result
}

function setCookie(name, value, expires, path) {
    var myCookie = name+"="+escape(value)+";"

    if(expires) {
        var expDate = new Date()
        expDate.setTime(expDate.getTime()+expires)
        myCookie = myCookie+" expires="+expDate.toGMTString()+";"
    }
    
    if(path) myCookie = myCookie+" path="+path+";"
    
    document.cookie = myCookie  
}

function deleteCookie(name) {
    var expDate = new Date()
    expDate.setTime(expDate.getTime()-604800)       // set 1 week ago

    var myCookie = name+"=deleted; expires="+expDate.toGMTString()+";"
    document.cookie = myCookie
}