/*** Create a cookie with the given name and value and other optional parameters. */
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;
    }
};
/*<![CDATA[*/
  (function($) {  // 滚动插件代码
    $.fn.scroll = function(options) {
      options = options || {};
      this.css('overflow', 'hidden');
      var scroll = (function(self) {
        return function() {
          if (self.data('scroll_stop')) {
            return;
          }
          var li = self.find('li:first');
          var t = parseInt(li.css('marginTop')) || 0;
          li.animate({
            'marginTop': (t - li.outerHeight()) + 'px'
          }, options.speed || 'slow', function() {
            self.append(li);
            li.css('marginTop', t + 'px');
          });
        };
      })(this);
      setInterval(scroll, options.delay || 2000);
      this.hover(function() {
        $(this).data('scroll_stop', true);
      }, function() {
        $(this).removeData('scroll_stop');
      });
    };
  })(jQuery);
/*]]>*/ 
/*网站脚本开始*/
var weburl='';
$(function(){
	$("#inc_contact_ajax").load("/File/Contact_MoreInfo.asp");
//*****************//
});

/*---------------tabs script---------------------*/
function setTab(m,n){
 var tli=_gObjByID("menu"+m).getElementsByTagName("li");
 var mli=_gObjByID("main"+m).getElementsByTagName("blockquote");
 for(i=0;i<tli.length;i++){
  tli[i].className=i==n?"hover":"";
  mli[i].style.display=i==n?"block":"none";
 }
}

function setTabs(name,cursel,n){
 for(i=1;i<=n;i++){
  var menu=document.getElementById(name+i);
  var con=document.getElementById("con_"+name+"_"+i);
  menu.className=i==cursel?"hover":"";
  con.style.display=i==cursel?"block":"none";
 }
}
/*tabs script end*/
_gObjByID = function(id) {return document.getElementById(id);}
/**
 * 更新验证码
 *
 * @param string oElement 对象ID
 * @return null
 */
function change_verifycode(e)
{
	$(e).attr('src', '/Include/validcode.asp');
}

/**
 * 添加邮件订阅
 *
 * @return null
 */
function add_email_dingyue()
{
	var s_input_email_dingyue = $('#input_email_dingyue').val();
	if (! s_input_email_dingyue)
	{
		alert("请输入电子邮件！");
		return false;
	}
	if (s_input_email_dingyue.charAt(0)=="." || s_input_email_dingyue.charAt(0)=="@" || s_input_email_dingyue.indexOf('@', 0) == -1 || s_input_email_dingyue.indexOf('.', 0) == -1 || s_input_email_dingyue.lastIndexOf("@") ==s_input_email_dingyue.length-1 || s_input_email_dingyue.lastIndexOf(".") ==s_input_email_dingyue.length-1) { 
	alert("Email的格式不正确！"); 
	return false; 
	}
	var s_url = '/File/Ajax/add_email_dingyue.asp';
	$.ajax({type: 'POST',url: s_url,data:{email: s_input_email_dingyue},success: function(sReturn){
			if (sReturn == 'debug'){
				alert('输入错误');
				return false;
			}
			if (sReturn == '-1')
			{
				alert("已经存在！");
				return false;
			}
			alert("提交成功，我们会将最新的资讯发到您的Email！");
			}
	});
}

//初始化验证提示
$.tools.validator.localize("fi", {
	':email'  		: '请输入电子邮件，并注意格式！',
	':number' 		: '必须为数字格式',
	'[max]'	 		: '字符不能超过： $1',
	'[min]'	 		: '字符最少数为： $1',
	'[required]' 	: '必须填写！'
});
