// qnsoft.js
if(typeof qnsoft == "undefined")
{
    var qnsoft = {};
}

$.extend(
    qnsoft,
    {
        registNamespace : function() 
        {        
            var a=arguments, o=null, i, j, d;            
            for (i=0; i<a.length; i=i+1) 
            {
                d=a[i].split(".");
               if(d[0] == "qnsoft" )
               {
                    o= qnsoft ;
                    j= 1;
               } 
               else
               {
                    o= window ;
                    j=0;
               }
                
                for (j; j<d.length; j=j+1) 
                {                    
                    o[d[j]]=o[d[j]] || {};
                    o=o[d[j]];
                }
            }

            return o;        
        }
    }
);

$.extend(
    qnsoft,
    {
        token:null, 
       noUtcTime : false ,
       queue : null ,       
       quotes : {
	        '\b': '\\b',
	        '\t': '\\t',
	        '\n': '\\n',
	        '\f': '\\f',
	        '\r': '\\r',
	        '"' : '\\"',
	        '\\': '\\\\'
        }, 	    
       toJSON: function(o) 
       {	
	        if(o == null) {
		        return "null";
	        }
	        var v = [];
	        var i;
	        var c = o.constructor;
	        if(c == Number) 
	        {
		        return isFinite(o) ? o.toString() : qnsoft.toJSON(null);
	        } 
	        else if(c == Boolean) 
	        {
		        return o.toString();
	        } 
	        else if(c == String) 
	        {
		        if (/["\\\x00-\x1f]/.test(o)) 
		        {
			        o = o.replace(/([\x00-\x1f\\"])/g, function(a, b) 
			        {
				        var c = qnsoft.quotes[b];
				        if (c) 
				        {
					        return c;
				        }
				        c = b.charCodeAt();
				        return '\\u00' +
					        Math.floor(c / 16).toString(16) +
					        (c % 16).toString(16);
			        });
                }
		        return '"' + o + '"';
	        } 
	        else if (c == Array) 
	        {
		        for(i=0; i<o.length; i++) 
		        {
			        v.push(qnsoft.toJSON(o[i]));
		        }
		        return "[" + v.join(",") + "]";
	        } 
	        else if (c == Date) 
	        {
		        var d = {};
		        d.__type = "System.DateTime";
		        if(qnsoft.noUtcTime == true) 
		        {
			        d.Year = o.getFullYear();
			        d.Month = o.getMonth() +1;
			        d.Day = o.getDate();
			        d.Hour = o.getHours();
			        d.Minute = o.getMinutes();
			        d.Second = o.getSeconds();
			        d.Millisecond = o.getMilliseconds();
		        } 
		        else 
		        {
			        d.Year = o.getUTCFullYear();
			        d.Month = o.getUTCMonth() +1;
			        d.Day = o.getUTCDate();
			        d.Hour = o.getUTCHours();
			        d.Minute = o.getUTCMinutes();
			        d.Second = o.getUTQneconds();
			        d.Millisecond = o.getUTCMilliseconds();
		        }
		        return qnsoft.toJSON(d);
	        }
	        if(typeof o.toJSON == "function") 
	        {
		        return o.toJSON();
	        }
	        if(typeof o == "object") 
	        {
		        for(var attr in o) 
		        {
			        if(typeof o[attr] != "function") 
			        {
				        v.push('"' + attr + '":' + qnsoft.toJSON(o[attr]));
			        }
		        }
		        if(v.length>0) 
		        {
			        return "{" + v.join(",") + "}";
		        }
		        return "{}";		
	        }
	        return o.toString();
        },
        dispose: function() {
	        if(qnsoft.queue != null) 
	        {
		        qnsoft.queue.dispose();
	        }
        }
     
    }
);   



/*****^*****^*****^*****^*****^*****^*****^*****^*****^*****^*****
 ** 
 ** ��Ҫ�����������б��в���ѡ�� do by lqs
 ** 
 *****^*****^*****^*****^*****^*****^*****^*****^*****^*****^*****/
//$.fn.AddOption = function(text,value,selected,index){
//    option = new Option(text,value);         
//   if (selected) {
//        option.selected = true; 
//   }    
//	this.options.add(option,index);
//}
/*****^*****^*****^*****^*****^*****^*****^*****^*****^*****^*****
 ** 
 **Jquery�Ĵ��������б�Ĳ�� do by cjb
 ** 
 *****^*****^*****^*****^*****^*****^*****^*****^*****^*****^*****/
$.fn.extend({
   addoption : function(text,value){
      this[0].options.add(new Option(text,value));
   } ,
   addoptionselected : function(text,value,selected,index){
       option = new Option(text,value);         
       if (selected) {
            option.selected = true; 
       }    
      this[0].options.add(option,index);
   } ,
   removeoption : function(index){
      this[0].options.remove(index);
   } ,
   itemoption : function(index){
      return	 this[0].options.item(index);
   } ,
   selectedoption: function(){
      return this[0].options[this[0] .selectedIndex];
   }
}
);
 /*****^*****^*****^*****^*****^*****^*****^*****^*****^*****^*****
 ** 
 **��� do by cjb
 ** 
 *****^*****^*****^*****^*****^*****^*****^*****^*****^*****^*****/
$.fn.extend({
breakword:function(len)   
{
   if($.browser.msie)
   {
      this.css("word-wrap", "break-word" );
      this.css("word-break", "break-all" );
   }
   else
   { 
     this.each(function(i) {
	  var strContent=this.innerHTML , strTemp="";
      while(strContent.length>len){
         strTemp+=strContent.substr(0,len)+"\r\n";
         strContent=strContent.substr(len,strContent.length);
      }
      strTemp+="\r\n"+strContent;
      this.innerHTML=strTemp;
      });
   }
}
}); 
/*****^*****^*****^*****^*****^*****^*****^*****^*****^*****^*****
 ** 
 ** ��Ҫ���ڲ���cookie  DO BY LQS:
 ** 
 *****^*****^*****^*****^*****^*****^*****^*****^*****^*****^*****/
/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', {expires: 7, path: '/', domain: 'jquery.com', secure: true});
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */ 
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTQntring)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTQntring(); // use expires attribute, max-age is not supported by IE
        }
        var path = options.path ? '; path=' + options.path : '';
        var domain = options.domain ? '; domain=' + options.domain : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
}; 
