
/* 汉字 */

var FadInitTop = 18;
function FadGetCurrentLeft(pos, width) {
	var docwidth = 960; var space = 15;
	//FadDebug(document.documentElement.offsetWidth);
	//return left - width - space;
	var totalwidth = document.documentElement.offsetWidth ? document.documentElement.offsetWidth : document.body.offsetWidth;

	var left = 0;
	if (pos == "left") {
		left = (totalwidth - docwidth) / 2 - space - width;
	} else {
		left = (totalwidth - docwidth) / 2 + space + docwidth;
	}
	return left;
}

function FadDebug(text) {
	var d = document.getElementById("faddebug");
	d.style.cssText = "display:block; left:0px; top:0px;";
	if (d) { d.innerHTML = text; }
}

function FadSetPosition(obj, pos, top, width, height) {
	if (obj) {
		var left = FadGetCurrentLeft(pos, width);
		left -= 7;
		//FadDebug(obj.style.cssText);
		if (obj.style.cssText.length >= 12 && obj.style.cssText.length <= 16) {
		} else {
			//left=0;
			var scrollTop = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
			var top = parseInt(FadInitTop + scrollTop + top);
			//
			obj.style.cssText = "position:absolute;left:" + left + "px;top:" + top + "px; width:" + width + "px;height:" + (height + 21) + "px;overflow:hidden;";
			//FadDebug(obj.style.cssText);
		}
	}
}

function FadShow(pos, top, width, height, html, href) {
	var topcontainer = document.getElementById("fad" + pos);
	if (!topcontainer) {
		if (document.body) {
			//alert(document.body.appendChild);
			topcontainer = document.createElement("span");
			document.body.appendChild(topcontainer);
			topcontainer.id = "fad" + pos;
			topcontainer.style.cssText = "display:block;";
			//alert(topcontainer.outerHTML);
		}
	}
	if (!topcontainer) {
		throw new Exception("Can't create container.");
		return;
	}
	var container = document.getElementById("fad" + pos + "_" + top);
	if (!container) {
		container = document.createElement("div");
		topcontainer.appendChild(container);
		container.id = "fad" + pos + "_" + top;
	}
	if (container) {

		FadSetPosition(container, pos, top, width, height);
		//var left=FadGetCurrentLeft(pos, width);
		//container.style.cssText="position:absolute;left:"+left+"px;top:"+FadInitTop+"px; width:"+width+"px;height:"+(height+21)+"px;overflow:hidden;";
		/*var link=document.createElement("a");
		container.appendChild(link);
		link.href=href;*/
		/*var image=document.createElement("img");
		link.appendChild(image);
		image.src=src;
		image.border=0;*/
		var contentblock = document.createElement("span");
		container.appendChild(contentblock);
		contentblock.style.cssText = "display:block;clear:both;width:" + width + ";height:" + height + ";"; //background:url(images/talkbk.gif) no-repeat left top;
		contentblock.innerHTML = html;

		var closespan = document.createElement("span");
		container.appendChild(closespan);
		closespan.style.cssText = "clear:both;display:block; margin-top:2px; text-align:center;";
		var closetxt = document.createElement("span");
		closespan.appendChild(closetxt);
		closetxt.style.cssText = "cursor:pointer;font-size:10px;color:#999999;";
		closetxt.innerHTML = "Close";
		closetxt.onclick = function () {
			container.style.cssText = "display:none;";
		}
		// resize
		var originalResizeHandler = window.onresize;
		window.onresize = function () {
			if (originalResizeHandler) {
				originalResizeHandler();
			}
			FadSetPosition(container, pos, top, width, height);
		}
		// scroll
		var originalScrollHandler = window.onscroll;
		window.onscroll = function () {
			if (originalScrollHandler) {
				originalScrollHandler();
			}
			FadSetPosition(container, pos, top, width, height);
		}
	}
}


/* for comm100_ */
function comm100_OpenChatWindow() {
	window.open("http://chatserver.comm100.cn/ChatWindow.aspx?siteId=80003605&planId=124&visitType=1&byHref=1", "comm100", "width=480,height=540,left=100,top=100,scrollbars=yes");
}

/* FadShow(pos, top, width, height, src, href) */

//FadShow("left", 0, 100,300,"images/090101_notify.png","#");
//FadShow("right", 0, 90, 300, "http://xlphoto.com.cn/TempImages/notify_09_51hol.gif", "http://xlphoto.com.cn/page.2009_51notify.aspx");
var __fadinitfunc = function () {
	return;
	var html = '<div><div style="z-index:99;position:absolute;visibility:hidden;"><a href="http://www.comm100.cn">客服技术支持</a></div><a href="http://chatserver.comm100.cn/ChatWindow.aspx?siteId=80003605&planId=124&visitType=1&byHref=1" target="_blank"><img id="comm100_EmailImage" src="http://chatserver.comm100.cn/BBS.aspx?siteId=80003605&planId=124" border="0px" alt="Live Chat" /></a><div style="z-index:99;visibility:hidden;"><span style="font-size:10px; font-family:Arial, Helvetica, sans-serif;"><a href="http://www.comm100.cn/livechat/" style="text-decoration:none;color:#000000;" target="_blank"><b>在线客服系统</b></a>由<a href="http://www.comm100.cn" style="text-decoration:none;color:#009999;" target="_blank">Comm100</a>提供</span></div></div>';
	FadShow("right", 140, 99, 150, html, "");
};
if (window.onload) {
	var originalOnLoadHandler = window.onload;
	window.onload = function () {
		originalOnLoadHandler();
		__fadinitfunc();
	};
} else {
	window.onload = function () {
		__fadinitfunc();
	};
}



