(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);
					var url = obj.attr('url');
					jQuery.ajax({
						url: url,
						type: "GET",
						dataType: "html",
						complete: function(res, status){
							if ( status == "success" || status == "notmodified" ) {
								//解决ie6浏览器下not found问题
								var resText = res.responseText.toLowerCase().indexOf("404 not found");
								obj.html( resText >= 0 ? "": res.responseText );
								//回调
								obj.each( function () {
									loadComplete(id, obj);
									fn_disposePicPNG(obj);
								}, [res.responseText, status, res] );
							}
						}
					});
					/*
					$(this).load($(this).attr('url'), function () {
						loadComplete(id, obj);
						fn_disposePicPNG(obj);
					});
					*/
				}
			}
		});

		// 解决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;
				}
			});
		}

		//计数器
		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()});
		}
	});
	window.loadComplete = function () {
	};

})(jQuery);
