//cookie开始
jQuery.cookie = function(name, value, options) {
    if (typeof value != '5') { // 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.toUTCString)) {
            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.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        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;
    }
};
//cookie结束
//ad设置
//右下角弹窗JS代码
var j = jQuery.noConflict();
var showadbox = function(boxad11id, tipheight) {
        if(!boxad11id) boxad11id='boxad11';
        if(!tipheight) tipheight=150;

        var objclientheigth = document.getElementById(boxad11id).clientHeight;
        j('#'+boxad11id).height(objclientheigth+2);
        if(objclientheigth < tipheight) { 
                setTimeout(function(){showadbox(boxad11id, tipheight)}, 5);
        }
}

var closead11adbox = function(boxad11id) {
        if(!boxad11id) boxad11id='boxad11';
        var objclientheigth = document.getElementById(boxad11id).clientHeight;
        /*
        j('#'+boxad11id).height(objclientheigth-2);
        if(objclientheigth>1 && objclientheigth<=202) {
                setTimeout(function(){closead11adbox(boxad11id)},5);        
        }*/
        j('#'+boxad11id).height(1);
        if(objclientheigth<=1) {
                j('#'+boxad11id).hide();
        }        
}

var zoomad11InBox = function(boxad11id) {
        if(!boxad11id) boxad11id='boxad11';
        var objclientheigth = document.getElementById(boxad11id).clientHeight;
        j('#'+boxad11id).height(30);
        /*
        if(objclientheigth>=30 && objclientheigth<=202) {
                setTimeout(function(){zoomad11InBox(boxad11id)},5);        
        }*/
}

var zoomad11OutBox = function(boxad11id, tipheight) {
        if(!boxad11id) boxad11id='boxad11';
        if(!tipheight) tipheight=150;

        var objclientheigth = document.getElementById(boxad11id).clientHeight;
        j('#'+boxad11id).height(objclientheigth+2);
        if(objclientheigth < tipheight) {
                setTimeout(function(){zoomad11OutBox(boxad11id, tipheight)},5);        
        }        
}

j(function(){

        if(j.browser.msie) { //对于不同浏览弹出高度的区别IE为210,其他194
                var tipheight = 150;
        } else {
                var tipheight = 150;
        }
        if(j.cookie('hasshow') != 1) {
                j('#boxad11').show();
                showadbox('boxad11', tipheight);        
        }
        j('#closead11').click(function(){
                closead11adbox('boxad11');
                j.cookie('hasshow', 1);
        });
        j('#zoomad11').click(function(){
                if(document.getElementById('boxad11').clientHeight >= tipheight) { 
                        zoomad11InBox('boxad11');
                        j('#zoomad11').attr("title", "点击展开");
						j('#zoomad11 img').attr("src", "/ad/img/kai.jpg");
                } else {
                        zoomad11OutBox('boxad11', tipheight);
                        j('#zoomad11').attr("title", "点击收缩");
						j('#zoomad11 img').attr("src", "/ad/img/xiao.jpg");
                }
        });
        
});
//ad设置结束
