/*
*表示必须,非必须项的第一个选项选项为默认选项
url(*)						Flash地址
id(*)						对联的ID，保持唯一，建议用nad+合同号+位置的形式，如：nad5694HomeLeft
width:90/任意数字			宽度
height:450/任意数字			高度
x:left/right				水平位置
xPx:0/任意数字				水平方向上Logo左边(右边)到浏览窗口左边（右边）的像素值
yPx:110/任意数字			垂直方向上Logo顶边(底边)到浏览窗口顶边（底边）的像素值
operaShow:true/false		因为Opera目前不支持as和js通信，可以Opera下对联无法关闭，可以通过false来设置Opera下对联不显示
*/
var nadCouplet = function(url,id,options){
	if(window.screen.width<800){return;}
	if(nadIsLtIE5_5()){return;}
	if(!url){return;}else{this.url = url;}
	if(!id){return;}else{this.id = id;}
	this.options = {
		width:		90,
		height:		450,
		x:			'left',
		xPx:		0,
		yPx:		20,
		operaShow:	true
	}
	Object.nadExtend(this.options,options||{});
	if(!this.options.operaShow && nadIsOpera){return;}
	this.create();
}
nadCouplet.prototype={
	create:function(){
		var wrap = document.createElement('span');
		var _opt = this.options;
		var _x = _opt.x;
		var _id = this.id
		var id = _id + _x;
		if(_x=='left'){_id += 'right';}
		else{_id += 'left';}
		wrap.style.position = 'absolute';
		wrap.innerHTML = nadCreateSwfHtml(this.url,id,{
			width	: _opt.width,
			height	: _opt.height,
			quality	: 'high',
			wmode	: 'window'
		});
		wrap.style[_opt.x] = _opt.xPx + 'px';
		wrap.style.top = _opt.yPx + 'px';
		document.getElementById("ssid1").appendChild(wrap);
		this.ad = wrap;
		this.initScrollTop = 0;
		
		var _fscHtml ='';
		_fscHtml += '<script type="text/javascript">';
		_fscHtml += 'function '+ id +'_DoFSCommand(command,args){'
		_fscHtml += 'if (command == "quit"){'
		_fscHtml += 'document.getElementById("'+ id +'").parentNode.style.visibility = "hidden";';
		_fscHtml += 'if(document.getElementById("'+ _id +'")){document.getElementById("'+ _id +'").parentNode.style.visibility = "hidden";}';
		_fscHtml += '}}';
		_fscHtml += '<\/script>';
		if(nadIsIE){
			_fscHtml += '<script type="text/javascript" for="'+ id +'" event="FSCommand(command,args)">';
			_fscHtml += id + '_DoFSCommand(command,args)';
			_fscHtml += '<\/script>';
		}
		document.write(_fscHtml);
	}
}
/*==common function==*/
var nadUserAgent = navigator.userAgent;
var nadIsOpera = nadUserAgent.indexOf('Opera')>-1
var nadIsIE = nadUserAgent.indexOf('MSIE')>-1 && !nadIsOpera;
var nadIsLtIE5_5 = function(){
	if(nadIsIE){
		var reIE = new RegExp('MSIE (\\d+\\.\\d+);');
		reIE.test(nadUserAgent);
		var IeVersion = parseFloat(RegExp["$1"]);
		return IeVersion <5.5;
	}
}
Object.nadExtend = function(destination, source) {
  for (var property in source) {
    destination[property] = source[property];
  }
  return destination;
}
var nadCreateSwfHtml = function(url,id,options){
	var swfHtml='';
	if(!url){return;}
	_opt = options;
	if(nadIsIE){
		swfHtml += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ _opt.width +'" height="'+ _opt.height +'" id="'+ id +'">';
		swfHtml += '<param name="movie" value="'+ url +'" />';
		swfHtml += '<param name="quality" value="'+ _opt.quality +'" />';
		swfHtml += '<param name="wmode" value="opaque" />';
		swfHtml += '</object>';
	}
	else{
		swfHtml += '<embed src="'+ url +'" quality="'+ _opt.quality +'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ _opt.width +'" height="'+ _opt.height +'" wmode="opaque" id="'+ id +'" name="'+ id +'" swliveconnect="true"></embed>'
	}
	return swfHtml;
}
/*==common function==*/
 
