(function ($) {
	$(function () {
		//var loadingDivs = $('div', '#dindex');
		var loadingDivs = $("div[@id*=dindex]");
		var date = new Date();
		var str = "" + date.getYear()
				+ date.getMonth()
				+ date.getDate()
				+ date.getHours();
		loadingDivs.each(function () {
			if($(this).find('div[@id*=dindex]').length == 0){
				var id = $(this).attr('id');
				if ($(this).attr('url')) {
					var obj = $(this);
					$(this).load($(this).attr('url'), function () {
						loadComplete(id, obj);
						fn_disposePicPNG(obj);
					});
				}
			}
		});

		//google Analytics
		try {
			var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
			$.ajax({
				type: "GET",
				url: gaJsHost + "google-analytics.com/ga.js",
				dataType: "script",
				success: function () {
					try {
						var pageTracker = _gat._getTracker("UA-7313659-1");
						pageTracker._trackPageview();
					} catch(err) {}
				}
			});
		} catch(err) {}

		// 解决ie6图片显示问题
		function fn_disposePicPNG(obj) {
			$("img", obj).each(function () {
				var imgName = $(this).attr("src").toUpperCase();
				if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
					var imgID = (this.id)? "id='" + this.id + "' ": "";
					var imgClass = (this.className) ? "class='" + this.className + "' " : "";
					var imgTitle = (this.title) ? "title='" + this.title + "' " : "title='" + this.alt + "' ";
					var imgStyle = "display:inline-block;" + this.style.cssText;
					if (this.align == "left") imgStyle = "float:left;" + imgStyle;
					if (this.align == "right") imgStyle = "float:right;" + imgStyle;
					if (this.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
					var strNewHTML = "<span " + imgID + imgClass + imgTitle
						+ " style=\"" + "width:" + this.width + "px; height:" + this.height + "px;" + imgStyle + ";"  
						+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"  
						+ "(src=\'" + this.src + "\', sizingMethod='image');\"></span>" 
					this.outerHTML = strNewHTML;
				}
			});
		}
		fn_disposePicPNG(document.body);
		//计数器
		if (typeof(siteId) != 'undefined' && typeof(webSiteUrl) != 'undefined')
		{
			var counterUrl = "http://" + document.domain +'/html/cms/count.bc?method=addCatalogArticleClickCount';
			if (typeof(siteId) != 'undefined') {
				counterUrl += "&columnId=" + siteId;
			}
			if (typeof(counterType) != 'undefined' && typeof(articleId) != 'undefined') {
				counterUrl += "&articleId=" + articleId;
			}
			$.get(counterUrl, {time: +new Date()},function(count){
				try{
					count = parseInt(count);
					if(!isNaN(count)) {
						if($('#s_index_1'))
						{
							$('#s_index_1').html(count);
						}
					}
				}catch(e)
				{
				}
			});
		}
	});

	window.loadComplete = function (id, obj, time) {
		if (id.indexOf('dindex_2_2') >= 0 && typeof(listPage) != 'undefined') {
			$('#dindex_2_2').height('auto');
			time = time || 1500;
			window.setTimeout(function () {
				var rightH = $('#dindex_2_2').height();
				if (!isNaN(parseInt($('#dindex_2_1').height())) && !isNaN(rightH)) {
					if (parseInt(rightH) > parseInt($('#dindex_2_1').height())) {
						window.leftHeight = parseInt($('#dindex_2_1').height());
						$('#dindex_2_1').height(rightH);
					} else {
						$('#dindex_2_2').height($('#dindex_2_1').height());
					}
				}
			}, time);
		}
	};

	
})(jQuery);