﻿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.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
        }
        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;
    }
};

$(document).ready(function() {
	if($.browser.msie && $.browser.version=="6.0"){
		return;
	};
	var isshow = 'height: 18px;';
	var txt = '最大化';
	if($.cookie('tag')==null || $.cookie('tag')=='0') {isshow = '';var txt = '最小化';}
	
	var strHtml = '<style>a.feedback{display:block;padding:8px;margin:5px;background:#FFF;text-decoration:none;color:#000;}a.feedback:hover {background-color: #449DFC;color:#FFF;}</style>'+
	'<div id="feedback" style="border-top:1px #FFF solid;border-left:1px #FFF solid;position: fixed;right: 0;bottom: 0;filter: Alpha(opacity=90);-moz-opacity:.9;opacity:0.9;background:#233A42;width:250px;'+isshow+'padding:5px 15px; overflow:hidden;"><div style="margin:0 0 15px;height:20px;padding: 0 0 0 5px;border-bottom:1px #FFF solid;"><b style="float:left;color:#FFF">联系方式</b><i style="color: white;float:right; cursor: pointer;">'+txt+'</i></div>'+
	'<a href="javascript:;" class="feedback" style="line-height:20px;">免费400电话：400-002-0035 <br/>Email： lf114@126.com<br/>地 址：廊坊市新华路89号、新华广场商务大厦3楼</a>'+
	'<a href="http://www.shanghao.cc/shchina.htm" style="width: 80px; margin-top: 10px; text-align: center; padding: 5px 0; float: right;" class="feedback">更详细信息</a></div>';

  $('body>div:last').before(strHtml);
  
  $("#feedback>div>i").click(function(){
  	if($(this).html() == "最小化") {
  		$("#feedback").css("height","18px");
  		$(this).html("最大化");
  		$.cookie('tag', '1',{'expires':30});
  		
  	}else{
  		$("#feedback").css("height","auto");
  		$(this).html("最小化");
  		$.cookie('tag', '0',{'expires':30});
  	}
  	
  });
});
