
// thanks for JES

function AmsExtend(a, b){
  for (var property in b) a[property] = b[property];
  return a;
};
function AmsFlash(f,w,h,options){
	var param={	id:"UIswf_"+f,quality:'high',bgcolor:'#ffffff',allowScriptAccess:'always',allowFullScreen:'true'}
	AmsExtend(param, options);

	var id='id="'+param.id+'"';
	var name = 'name="'+param.id+'"';
	var p='',e='';	

	for(i in param) 
	{
		if(i=='id')continue;
		p+='<param name="'+i+'" value="'+param[i]+'">\n';
		e+=i+'="'+param[i]+'" ';
	}
	var s='<object '+id+' width="'+w+'" height="'+h+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0">';
	s+='<param name="movie" value="'+f+'">'+ p;	
	s+='<embed '+name+' src="'+f+'" width="'+w+'" height="'+h+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" '+e+'/>';
	s+='</object>';
	if(param.containerId) {
		document.getElementById(param.containerId).innerHTML = s;
	} else {
		document.write(s);
	}
	return s;
};


// FF에서는 flash를 감싸고 있는 element의 style 속성이 바뀌면 플래시가 reload 됩니다. 천승희님과 상의 후 영화에선는 그냥 reload 되더라도 확장이 되는 방향으로 결정했습니다.
function extBannerOver() {
	try	{ document.getElementById('EXTENSIBLE_BANNER').style.overflow = 'visible'; } catch (e){}
}
function extBannerOut() {
	try	{ document.getElementById('EXTENSIBLE_BANNER').style.overflow = 'hidden'; } catch (e){}	
}



function EXTENSIBLE_BANNER_PACK(){
	if(typeof(arguments[0])=="object"){
		var options = AmsExtend({
		  secid: false,
		  iconid: false,
		  dir: "",
		  wrapper: false
		}, arguments[0] || { });
	}else{
		var options = {
		  secid: arguments[0],
		  iconid: arguments[1],
		  dir: typeof(arguments[2])=="undefined"?"":arguments[2],
		  wrapper: arguments[3]
		}
	}

	if(!options.secid)return;
			
	var rand = Math.random().toString(); 
	var ordval = rand.substring(2,rand.length);

	var extensibleHtml = '\
		<style type="text/css">\
			#EXTENSIBLE_WRAP \{position:relative;z-index:4000;height:250px;\}\
			#EXTENSIBLE_BANNER_WRAP \{\}\
			#EXTENSIBLE_BANNER \{position:relative;width:250px;height:0px;z-index:4000;overflow:hidden;\}\
			#EXTENSIBLE_BANNER object \{position:absolute;left:-35px;top:-35px;\}\
			#EXTENSIBLE_ICON \{display:none;z-index:4001;position:absolute;top:120px;left:145px;\}\
			#EXTENSIBLE_WRAP iframe \{position:absolute;top:0;left:0;z-index:4000;\}\
		</style>\
		<div id="EXTENSIBLE_WRAP">\
			<div id="EXTENSIBLE_BANNER_WRAP"><div id="EXTENSIBLE_BANNER" class="'+options.dir+'"></div><div id="EXTENSIBLE_ICON"></div></div>\
			<iframe src="http://amsv2.daum.net/ad/adview?secid='+options.secid+'" width="250" height="250" border="0" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" id="AMS_250exp" name="AMS_250exp" allowTransparency="true"></iframe>\
		</div>';

	if(options.wrapper&&document.getElementById(options.wrapper)){
		document.getElementById(options.wrapper).innerHTML = extensibleHtml;
	}else{
		document.writeln(extensibleHtml);
	}
	

	//풀스크린아이콘
	if(options.iconid) {
		document.write('<div id="TAKEOVER"><script src="http://amsv2.daum.net/ad/adview?secid='+options.iconid+'" type="text/javascript"><\/script><\/div>')
		document.getElementById("EXTENSIBLE_ICON").appendChild(document.getElementById("TAKEOVER"));
		document.getElementById("EXTENSIBLE_ICON").style.display="block";
	}
}