var fixedAdNum = 0;
var ns = navigator.appName == "Netscape";

function ad_fixed(imgPosition,offsetY,imgSrc,imgWidth,imgHeight,imgURL,imgTitle,linkTarget) {
	this.position = imgPosition;												//图象位置 1:左上 2:右上 3:左下 4:右下
	this.offsetY = offsetY;														//Y向偏移量
	this.src = imgSrc;															//图片文件SRC
	this.url = imgURL;															//图片链接URL
	this.width = imgWidth;														//图片宽度
	this.height = imgHeight;													//图片高度
	this.title = imgTitle;														//图片标题TITLE
	this.index = ++fixedAdNum;													//图片序号INDEX
	this.target = linkTarget;													//链接目标Target
	this.is_swf = this.src.replace(/^(\S+\.)(\w+)$/,"$2") == "swf";				//是否swf格式

	switch (this.position) {
		case 1:
			this.left = 5;
			this.top = 5 + this.offsetY;
			break;
		case 2:
			this.left = ns ? pageXOffset + window.innerWidth - this.width - 25:document.body.scrollLeft + document.body.offsetWidth - this.width - 25;
			this.top = 5 + this.offsetY;
			break;
		case 3:
			this.left = 5;
			this.top = ns ? pageYOffset + window.innerHeight - this.height - 10 + this.offsetY:document.body.scrollTop + document.body.offsetHeight - this.height - 10 + this.offsetY;
			break;
		case 4:
			this.left = ns ? pageXOffset + window.innerWidth - this.width - 25:document.body.scrollLeft + document.body.offsetWidth - this.width - 25;
			this.top = ns ? pageYOffset + window.innerHeight - this.height - 10:document.body.scrollTop + document.body.offsetHeight - this.height - 10 + this.offsetY;
			break;
	}

	document.writeln('<div id="fixed_' + this.index + '" name="fixed_' + this.index + '" style="position: absolute;width:80;top:' + this.top + ';left:' + this.left + ';visibility: visible;z-index: 1">');
	if (this.is_swf) {
		if (this.url != "") {
			document.writeln('<a href="' + this.url + '" target="' + this.target + '"><img src="/images/transparent.gif" style="position:absolute;" WIDTH="' + this.width + '" HEIGHT="' + this.height + '" border="0" alt="' + this.title + '" /></a>');
		}
		document.writeln('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" WIDTH="' + this.width + '" HEIGHT="' + this.height + '">');
		document.writeln('<PARAM NAME="movie" VALUE="' + this.src + '" />');
		document.writeln('<PARAM NAME="quality" VALUE="high" />');
		document.writeln('<PARAM NAME="wmode" VALUE="transparent" />');
		document.writeln('<EMBED src="' + this.src + '" quality="high" WIDTH="' + this.width + '" HEIGHT="' + this.height + '" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>');
		document.writeln('</OBJECT>');
	} else {
		if (this.url != "") {
			document.writeln('<a href="' + this.url + '" target="' + this.target + '"><img src="/images/transparent.gif" style="position:absolute;" WIDTH="' + this.width + '" HEIGHT="' + this.height + '" border="0" alt="' + this.title + '" /><img src="' + this.src + '" border="0" width="' + this.width + '" height="' + this.height + '" alt="' + this.title + '" /></a>');
		} else {
			document.writeln('<img src="' + this.src + '" border="0" width="' + this.width + '" height="' + this.height + '" alt="' + this.title + '" />');
		}
	}
	//document.writeln('<div align="right" style="cursor: hand;" onclick="this.parentElement.style.display = \'none\';">关闭</div>');
	document.writeln('</div>');
}

ad_fixed.prototype.move = fixed_ad_move;
ad_fixed.prototype.hide = fixed_ad_hide;

function fixed_ad_move() {
	var x = document.getElementsByName("fixed_" + this.index);
	switch(this.position) {
		case 1:
			x[0].style.left = ns ? pageXOffset + 5 + "px":document.body.scrollLeft + 5 + "px";
			x[0].style.top = ns ? pageYOffset + 5 + this.offsetY + "px":document.body.scrollTop + 5 + this.offsetY + "px";
			break;
		case 2:
			x[0].style.left = ns ? pageXOffset + window.innerWidth - this.width - 25 + "px":document.body.scrollLeft + document.body.offsetWidth - this.width - 25 + "px";
			x[0].style.top = ns ? pageYOffset + 5 + this.offsetY + "px":document.body.scrollTop + 5 + this.offsetY + "px";
			break;
		case 3:
			x[0].style.left = ns ? pageXOffset + 5 + "px":document.body.scrollLeft + 5 + "px";
			x[0].style.top = ns ? pageYOffset + window.innerHeight - this.height - 10 + this.offsetY + "px":document.body.scrollTop + document.body.offsetHeight - this.height - 10 + this.offsetY + "px";
			break;
		case 4:
			x[0].style.left = ns ? pageXOffset + window.innerWidth - this.width - 25 + "px":document.body.scrollLeft + document.body.offsetWidth - this.width - 25 + "px";
			x[0].style.top = ns ? pageYOffset + window.innerHeight - this.height - 10 + this.offsetY + "px":document.body.scrollTop + document.body.offsetHeight - this.height - 10 + this.offsetY + "px";
			break;
	}
}

function fixed_ad_hide() {
	var x = document.getElementsByName("fixed_" + this.index);
	x[0].style.display = "none";
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {
		if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
			document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage;
		}
	} else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) {
		location.reload();
	}
}
MM_reloadPage(true);

//var img_1 = new ad_fixed(1,80,"*.swf",80,200,"http://linkurl/","AltText","_blank");
//setInterval("img_1.move()",50);
