﻿//=============================================================================
//
// Copyright (c) 2007 RuanYu
//
// FileName     :core.js
//
// Description  :global configuration file
//
// Author       :RuanYu
//
// Date         :2007-05-29
//
//=============================================================================

Type.registerNamespace('RuanYu');

RuanYu.version = "1.0.0.1";

RuanYu.publishDate = "2007-02-24";

RuanYu.corporation = "Yoshow";

RuanYu.author = "ruanyu83@gmail.com";

RuanYu.hostName = "http://localhost/instance/";

if(typeof(Sys) == 'undefined')
{    
    throw("The microsoft ajax 1.0 is required.");
}


//===========================================================================
//
// RuanYu.Cookies | update: 2007.07.10
//
//===========================================================================

RuanYu.Cookies = function(){}

RuanYu.Cookies.prototype.add_cookie = function(name,value,expire,path)
{
    document.cookie = name+"="+escape(value) + ((!expire)?"":("; expires="+expire.toGMTString()))+"; path="+((!path)?"/":path);
}

RuanYu.Cookies.prototype.remove_cookie = function(name,path)
{
    if(RuanYu.Cookies.get_cookie(name))
    {
        document.cookie=name+"="+"; path="+((!path)?"/":path)+"; expires=" + new Date(0).toGMTString();
    }
}

RuanYu.Cookies.prototype.get_cookie = function(name)
{
    var value = "";
    var search = name + "=";
    
    if(document.cookie.length>0)
    {
        var offset=document.cookie.indexOf(search);
        
        if(offset!=-1){
            
            offset+=search.length;
            
            var end = document.cookie.indexOf(";",offset);
            
            if( end == -1 ) 
                end = document.cookie.length;
            
            value = unescape(document.cookie.substring(offset,end));
       }
    }
    
    return value;
}