﻿
/*  www.CIMAMotor.com  第九届中国国际摩托车博览会 CIMA 2010											WangXing 2010-08-17 09:30:20
================================================================================================================================= */

var j$ = jQuery.noConflict();  // 为避免与其它框架冲突，jQuery工厂函数设置为 j$()


// - DOM加载完成后执行的内容 j$(document).ready - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
j$(function(){

	//j$('html').addClass(getBrowser_UF());
	//j$('.debug').html(j$('html').attr('class'));

	/* 主菜单项目的等宽调整 */
	if(window.navigator.userAgent.indexOf("MSIE 6.0")<1){
		EqWidth(j$(".s1"),100); EqWidth(j$(".s2"),100); EqWidth(j$(".s3")); EqWidth(j$(".s4"));
		//EqWidth(j$(".ss1"),100);
		//EqWidth(j$(".sss1"));
	} else {
		EqWidth(j$(".s1"),100); EqWidth(j$(".s2"),100); EqWidth(j$(".s3")); EqWidth(j$(".s4"));
		//EqWidth(j$(".ss1"),100);
		//EqWidth(j$(".sss1"));
	}

	/* 新闻列表样式交替 */
	ExStyle2(".Ex2 li");

	/* 去除虚框 */
	j$("a,:radio,:checkbox").focus(function(){ this.blur(); });

});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //






/* 等宽调整(Min为可选宽度最小值)
-------------------------------------------------------------------------------------------------------------------------------- */
function EqWidth(Item,Min){
	var Widest = 0;
	Item.each(function(){
		currentWidth = j$(this).width();
		if(currentWidth > Widest){ Widest = currentWidth; }
	});
	if(typeof(Min)!="undefined"){
		if(Widest < Min){ Widest = Min; }
	}
	Item.width(Widest);
}


/* 样式交替(奇/偶) + 悬停加效
-------------------------------------------------------------------------------------------------------------------------------- */
function ExStyle2(obj){
	j$(obj+":odd").addClass("odd");
	//j$(obj+":even").addClass("even"); // 由于偶数项设计为默认白底样式，所以此行可省略。
    j$(obj).hover(
		function(){j$(this).addClass("hover");}, // mouseover
		function(){j$(this).removeClass("hover");} // mouseout
	);
}


/* 用户浏览器判断
-------------------------------------------------------------------------------------------------------------------------------- */
function getBrowser_UA(){
	var Sys = {}; var ua = navigator.userAgent.toLowerCase();

	// 特征判断 [2010-07-21]
//	window.ActiveXObject ? Sys.ie = ua.match(/msie ([\d.]+)/)[1] :
//	document.getBoxObjectFor ? Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1] :
//	window.MessageEvent && !document.getBoxObjectFor ? Sys.chrome = ua.match(/chrome\/([\d.]+)/)[1] :
//	window.opera ? Sys.opera = ua.match(/opera.([\d.]+)/)[1] :
//	window.openDatabase ? Sys.safari = ua.match(/version\/([\d.]+)/)[1] : 0;

	// userAgent判断
	var s;
	(s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
	(s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
	(s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
	(s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
	(s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;

	if (Sys.ie) return 'ie'+Sys.ie.split('.')[0];				//IE
	if (Sys.firefox) return 'ff';								//Firefox
	//if (Sys.chrome) return 'ch'+Sys.chrome.split('.')[0];		//Chrome
	//if (Sys.opera) return 'op'+Sys.opera.split('.')[0];		//Opera
	//if (Sys.safari) return 'sa'+Sys.safari.split('.')[0];		//Safari

};

// 更详尽和可能更准确的特征判断 未测
// 来源:http://blog.csdn.net/satans18/archive/2010/04/19/5502129.aspx [2010.04.18]
function getBrowser_UF(){
	var isIE = !','.split(/,/).length,
	isIE6 = isIE && !window.XMLHttpRequest,
	isIE8 = !!window.XDomainRequest,
	isIE9 = isIE && !!+'\v1',	// alt: !!-[1,]
	isIE7 = isIE && !isIE6 && !isIE8 && !isIE9,
	isFF = !!document.getBoxObjectFor || 'mozInnerScreenX' in window,	// gecko
		/* Firefox 重大里程碑版本的特征判断  不建议纳入 除非需要区别这些版本的差异 */
		//isFF36 = 'mozInnerScreenX' in window,	// alt: !!document.body.mozMatchesSelector
		//isFF35 = !!Object.getPrototypeOf,
		//isFF2 = !!window.globalStorage,
		//isFF3 = isFF2 && !!win.MessageEvent,	// alt: 'reduce' in Array
		//isFF15 = 'some' in Array,
	isOP = !!window.opera && !!window.opera.toString().indexOf('Opera'),
	isOP9 = /^function \(/.test([].sort),
	isWK = !!window.devicePixelRatio,	// web-kit
	isSF = /a/.__proto__ == '//',	// safari
	isCR = /s/.test(/a/.toString);	// chrome

	return isIE6?'ie ie6':isIE8?'ie ie8':isIE9?'ie ie9':isIE7?'ie ie7':isFF?'ff':
		//isFF36?'ff ff36':isFF35?'ff ff35':isFF2?'ff ff2':isFF3?'ff ff3':isFF15?'ff ff15':
		isOP?'op':isOP9?'op op9':isWK?'wk':isSF?'wk sa':isCR?'wk cr':0;
}



