<!--
//-------------------------------------=================================JQUERY Documnet=================---------------
$(function(){
	$(document).pngFix();
	$('#menuWrap > ul > li > a > img').each(function(i){
		if (Tools.lastFolderName == $(this).parent().attr('href').replace(/\W/g, '').toLowerCase())
			$(this).attr('src', $(this).attr('src') + '.gif');
		//if (i == 2) $('#proMenuWrap > dl > dt:eq(0)').find('div').addClass('proStrong').parent().next().show();
	});
	var sltSubMenu = function(i) {
		$('#subMenu > ul > li > a').eq(i).addClass('sltSubMenu');
		$('.title span').html('&gt; ' + $('#subMenu > ul > li > a').eq(i).text());
	}
	if (Tools.lastFileName.length == 0) {
	    if (window.location.href.indexOf('news') != -1)
	        sltSubMenu(1);
	    else
		    sltSubMenu(0);
	}
	else {
		switch(parseInt(Tools.getParameter('type'))) {
			case 2:
				sltSubMenu(2);
				break;
			case 3:
				sltSubMenu(3);
				break;
			case 4:
				sltSubMenu(0);
				break;
			case 5:
				sltSubMenu(0);
				break;
			case 6:
				sltSubMenu(1);
				break;
			case 7:
				sltSubMenu(2);
				break;
			case 9:
				sltSubMenu(4);
				break;
			case 10:
				sltSubMenu(5);
				break;
			case 11:
				sltSubMenu(6);
				break;
			case 12:
				sltSubMenu(1);
				break;
			default:
				$('#subMenu > ul > li > a').each(function(i){
					if (Tools.lastFileName.replace(/index.+/g, '') == $(this).attr('href').replace(/.+\//, '').toLowerCase()) {
						$(this).addClass('sltSubMenu');
						$('.title span').html('&gt; ' + $(this).text());
					}
				});
				break;
		}
	}
	$('#proMenuWrap > dl > dt > div:odd, .news:even, .supportList:even, .listPro:even').css('background-color', '#f4f4f4');
	$('.proList dd ul').each(function(){
		//$(this).children('li:even').css('background-color', '#f4f4f4');
		$(this).children('li').each(function(i){
			if ((i % 4 == 0) || ((i - 1) % 4 == 0)) $(this).css('background-color', '#f4f4f4');
		});
	});
	$('#detailed dd ul').each(function(){
		$(this).children('li:even').css('background-color', '#f3f3f3');
	});
	$('.proListAll > li').each(function(i){
		if ((i % 4 == 0) || ((i - 1) % 4 == 0)) $(this).css('background-color', '#f4f4f4');
	});
	Tools.switchDiv('#proContent > dt > ul > li', 'sltProContent', '#proContent > dd > div');
	var siteProSearch = function() {
		$('form').submit(function(){return false;});
		if ($('#searchKeywords').val().length == 0) {
			alert('请输入搜索关键字');
			$('#searchKeywords').focus();
			return false;
		}
		else {
		    var _path = '/products/';
		    if ($('#btnSearch').length) {
			    window.location.href = _path + 'list.aspx?searchType='+ $('#sltProType').val() +'&keywords='+ encodeURI($('#searchKeywords').val());
		    }
		    if ($('#iSearch').length) {
			    window.location.href = '../other/search.aspx?searchType='+ $('#sltProType').val() +'&keywords='+ encodeURI($('#searchKeywords').val());
		    }
		    if ($('#btnSupport').length) {
			    window.location.href = '../support/?type=5&keywords='+ encodeURI($('#searchKeywords').val());
		    }
		    if ($('#btnSupportFaq').length) {
			    window.location.href = '../support/faq.aspx?type=6&keywords='+ encodeURI($('#searchKeywords').val());
		    }
		    if ($('#newsSupport').length) {
			    _path = '../news/index.aspx?';
			    if (window.location.href.indexOf('list.aspx') != -1) _path = '../news/list.aspx?type=' + Tools.getParameter('type') + "&";
			    window.location.href = _path + 'keywords='+ encodeURI($('#searchKeywords').val());
		    }
		}
	};
	document.onkeyup = function(e){
		if (e == null) keycode = event.keyCode;// ie
		else keycode = e.which;// mozilla
		if (keycode == 13 && $('#searchKeywords').length) siteProSearch();// submit
	};
	if ($('#sltProType').length) {
		$('#btnSearch').click(siteProSearch);
		$('#iSearch').click(siteProSearch);
	}
	$('#btnSupport').click(siteProSearch);
	$('#btnSupportFaq').click(siteProSearch);
	$('#newsSupport').click(siteProSearch);
	if (window.location.href.indexOf('products/') != -1 && $('#formulaStyle').length) {
		var lastViewed = [];
		var _proName = $('#proName > dt').text();
		if ($.cookie('lastViewed')) lastViewed = $.cookie('lastViewed').split('|');
		if (lastViewed.length == 0 || $.cookie('lastViewed').indexOf(_proName) == -1) {//产品名不相同
			if (lastViewed.length >= 6) lastViewed.shift();
			lastViewed.push(_proName + '}{' + window.location.href);
			$.cookie('lastViewed', lastViewed.join('|'), {path: '/'});
		}
//		$.cookie('lastViewed', null, {path: '/'});
		var _lastViewed = [];
		for (var i = lastViewed.length - 1;i >= 0;i--) {
			var _temp = lastViewed[i].split('}{');
			_lastViewed.push('<li><a href="'+ _temp[1] +'">'+ _temp[0] +'</a></li>');
		}
		$('.lastViewed:eq(0) > dd > ul').append(_lastViewed.join(''));
	}
	if ($('#proContent').length) {
		$('#proContent > dd > div').each(function(i){
			//if (i > 0 && $(this).html().length == 0) $(this).html('抱歉，暂时没有资料提供，如有问题，请咨询。');
			if ($(this).html().length == 0) $(this).html('抱歉，暂时没有相关资料，如有问题，请来电垂询。');
		});
	}
	if ($('#formulaStyle').text().length > 0)
		$('#formulaStyle').html($('#formulaStyle').text().replace(/([a-zA-z])(\d+)/g, '$1<sub>$2</sub>'));
	if (Tools.lastFolderName == 'index' || Tools.lastFolderName == 'news')
		$('.news > dt > a:lt(3)').append(' <img src=\"../images/new.gif\" />');
	if (Tools.getParameter('searchType').length > 0 && Tools.getParameter('keywords').length > 0) {
		$('#sltProType').val(Tools.getParameter('searchType'));
		$('#searchKeywords').val(decodeURI(Tools.getParameter('keywords')));
	}
});
//-------------------------------------=================================JQUERY Documnet=================---------------
var Tools = {
	isUndefined : function(variable) {
		return typeof variable == 'undefined' ? true : false;
	},
	lastFolderName : window.location.href.toLowerCase().replace(/.+\/(\w+)\/[^\/]*$/, '$1'),
	lastFileName : window.location.href.toLowerCase().replace(/.+\//g, ''),
	isArray : function(o) {
		return Object.prototype.toString.call(o) === '[object Array]';   
	},
	arraySearch : function(ary, x) {
		if (ary.length == 0) return -1;
		for (var i = 0; i < ary.length; i++)
			if (x == ary[i]) return i;
		return -1;
	},
	strlen : function(str) {
		return (is_ie && str.indexOf('\n') != -1) ? str.replace(/\r?\n/g, '_').length : str.length;
	},
	getExt : function(path) {
		return path.lastIndexOf('.') == -1 ? '' : path.substr(path.lastIndexOf('.') + 1, path.length).toLowerCase();
	},
	getEBI : function(obj) {
		return document.getElementById(obj);
	},
	$ : function(obj) {
		return document.getElementById(obj);
	},
	getParameter : function(param) {
		var query = window.location.search;
		var iLen = param.length;
		var iStart = query.indexOf(param);
		if (iStart == -1)  return '';
		iStart += iLen + 1;
		var iEnd = query.indexOf('&', iStart);
		if (iEnd == -1) return query.substring(iStart);
		return query.substring(iStart, iEnd);
	},
	switchDiv : function(li, sltClass, switchObj) {
		$(li).each(function(i) {
			$(this).click(function() {
				$(this).addClass(sltClass).siblings().removeClass(sltClass);
				$(switchObj).eq(i).show().siblings(switchObj).hide();
			});
		});
	}
};
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;
    }
};
//-->
