/*
활성화 시 html에 삽입
<SCRIPT LANGUAGE="JavaScript" src="html.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript">flashObject("board.swf", 869, 553);</SCRIPT>
*/
// easy method
function flashObject(id, url, width, height) {
	var param = new Array();	
	param["movie"]		= url;
	param["width"]		= width;
	param["height"]		= height;
	param["quality"]	= "high";
	param["id"]			= id;
	param["bgcolor"]	= "#ffff00";
	//param["loop"]		= "true";
	param["loop"]		= "false";
	param["wmode"]		= "transparent";
	//param["wmode"]		= "window";
	makeFlashObject(param);
}

// Flash Object 생성
function makeFlashObject(param) {
	var params		= new Array();
	var classID		= "D27CDB6E-AE6D-11cf-96B8-444553540000";
	var codeBase	= "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0";
	var type		= "application/x-shockwave-flash";
	var pluginsPage	= "http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash";
	var cnt = 0;

	var movie		= param["movie"] == null	? ""	: param["movie"];
	var width		= param["width"] == null	? "0"	: param["width"];
	var height		= param["height"] == null	? "0"	: param["height"];
	var id			= param["id"] == null		? ""	: param["id"];
	var quality		= param["quality"] == null	? ""	: param["quality"];
	var bgcolor		= param["bgcolor"] == null	? ""	: param["bgcolor"];//alert(bgcolor);
	var loop		= param["loop"] == null		? ""	: param["loop"];
	var wmode		= param["wmode"] == null	? ""	: param["wmode"];

	// 항목 검사
	if (movie == "") return;

	params["classID"]		= classID;
	params["codeBase"]		= codeBase;
	params["width"]			= width;
	params["height"]		= height;
	params["type"]			= type;
	params["pluginsPage"]	= pluginsPage;
	params["params"]		= new Array();
	params["name"]			= id;

	// 세부파라메터 지정
	params["params"][cnt++] = new paramValue("movie"	, movie);
	if (quality != "")	params["params"][cnt++] = new paramValue("quality"	, quality);
	if (bgcolor != "")	params["params"][cnt++] = new paramValue("bgcolor"	, bgcolor);
	if (loop != "")		params["params"][cnt++] = new paramValue("loop"		, loop);
	if (wmode != "")	params["params"][cnt++] = new paramValue("wmode"	, wmode);

	//alert(params["params"][2].name+", "+params["params"][2].value);
	params["extParam"]		= makeEmbedObject(params, false);  //alert(params["extParam"]);
	params["id"]			= id;
	params["name"]			= "";

	makeActiveXObject(params);
}

// ActiveX Objext 생성
function makeActiveXObject(param) {
	var makeString	= "";
	var classID		= param["classID"] == null	? ""	: param["classID"];
	var codeBase	= param["codeBase"] == null	? ""	: param["codeBase"];
	var width		= param["width"] == null	? "0"	: param["width"];
	var height		= param["height"] == null	? "0"	: param["height"];
	var id			= param["id"] == null		? ""	: param["id"];
	var name		= param["name"] == null		? ""	: param["name"];
	var bgcolor		= param["bgcolor"] == null	? ""	: param["bgcolor"];
	var params		= param["params"];
	var extParam	= param["extParam"] == null	? ""	: param["extParam"];
		
	if (classID == "") return;

	// object 기본정보
	
	//중앙정렬 아닐때
	makeString += "<object classid=\"clsid:" + classID + "\" width=" + width + " height=" + height;
	
	//중앙정렬일때 
	//makeString += "<object classid=\"clsid:" + classID + "\" width='100%' height='100%'";

	if (codeBase != "") {
		makeString += " codebase=\"" + codeBase + "\"";
	}

	if (id != "") {
		makeString += " id=\"" + id + "\"";
	}
	
	if (name != "") {
		makeString += " name=\"" + name + "\"";
	}
	
	makeString += ">\n";

	// 파라메터 지정
	if (params != null) {
		for (var i=0; i < params.length; i++) {
			if (params[i].value == "") continue;

			makeString += "\t<param name=\"" + params[i].name + "\" value=\"" + params[i].value + "\">\n";
		}
	}

	// 기타파라메터
	if (extParam != "") {
		makeString += "\t" + extParam;
	}

	makeString += "</object>\n";

	//document.write ("<!--",makeString,"-->");
	//alert(makeString);
	//makeString = "<table width="+ width +" height="+ height+" border='0' cellspacing='0' cellpadding='0'><tr><td><div id='flash_area'>"+ makeString +"</div></td></tr></table>";
	document.write (makeString);
	
}

// embed Object 생성
function makeEmbedObject(param, print) {
	var makeString = "";
	var type		= param["type"] == null			? ""	: param["type"];
	var pluginsPage	= param["pluginsPage"] == null	? ""	: param["pluginsPage"];
	var width		= param["width"] == null		? "0"	: param["width"];
	var height		= param["height"] == null		? "0"	: param["height"];
	var id			= param["id"] == null			? ""	: param["id"];
	var name		= param["name"] == null			? ""	: param["name"];
	var src			= param["src"] == null			? ""	: param["src"];
	var bgcolor		= param["bgcolor"] == null	? ""	: param["bgcolor"];
	var params		= param["params"];

	makeString += "<embed width=" + width + " height=" + height;

	if (type != "") {
		makeString += " type=\"" + type + "\"";
	}

	if (pluginsPage != "") {
		makeString += " pluginsPath=\"" + pluginsPage + "\"";
	}

	if (id != "") {
		makeString += " id=\"" + id + "\"";
	}
	
	if (name != "") {
		makeString += " name=\"" + name + "\"";
	}

	if (src != "") {
		makeString += " src=\"" + src + "\"";
	}

	// 파라메터 지정
	if (params != null) {
		for (var i=0; i < params.length; i++) {
			if (params[i].value == "") continue;

			if ((params[i].name.toLowerCase() == "movie" || params[i].name.toLowerCase() == "filename") 
				&& makeString.indexOf("src=\"") < 0) {
				makeString += " src=\"" + params[i].value + "\"";
			}
			else {
				makeString += " " + params[i].name + "=\"" + params[i].value + "\"";
			}
		}
	}

	makeString += ">\n";

	if (print) {
		document.write (makeString);
	}

	return makeString;
}
// paramValue
function paramValue(name, value) {
	this.name	= name;
	this.value	= value;
}

//open fullscreen html (ex : main.html ...)
function main_pop_full(url) {
    var intWidth = screen.availWidth - 10;
    var intHeight = screen.availHeight - 15;
  	var tempX = 0;
	var tempY = 0;
	window.open(url,"main","left="+tempX+",top="+tempY+",width="+intWidth+",height="+intHeight+",scrollbars=0");	
}

//open fix html and move center (ex : main.html ...)
/*
function main_pop_fx_c(url, width, heigh) {
	var intWidth = width;
	var intHeight = heigh;
  	var tempX = (screen.width/2)-(intWidth / 2);
	var tempY = (screen.height/2)-(intHeight / 2);
	window.open(url,"main","left="+tempX+",top="+tempY+",width="+intWidth+",height="+intHeight+",scrollbars=0");
}
*/

function main_pop_fx_c(url) {
	var intWidth = 900;
	var intHeight = 650;
  	var tempX = (screen.width/2)-(intWidth / 2);
	var tempY = (screen.height/2)-(intHeight / 2);
	window.open(url,"main","left="+tempX+",top="+tempY+",width="+intWidth+",height="+intHeight+",scrollbars=0");
}


function main_pop_fx_c2(url) {

    var height = screen.availHeight - 15;
	var width = screen.availWidth - 10;
	var intWidth = 1000
	var intHeight = 680
  	//var tempX = (screen.width/2)-(intWidth / 2);
	//var tempY = (screen.height/2)-(intHeight / 2);
	var tempX = 0;
	var tempY = 0;
	window.open(url,"main","left="+tempX+",top="+tempY+",width="+1000+",height="+680+",width=" + width + ",height=" + height + ",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=0");
	

	
//	var intWidth = 1000;
//	var intHeight = 680;
//  	var tempX = (screen.width/2)-(intWidth / 2);
//	var tempY = (screen.height/2)-(intHeight / 2);
//	window.open(url,"main","left="+tempX+",top="+tempY+",width="+intWidth+",height="+intHeight+",scrollbars=0");
}


//open fix html and move fix (ex : main.html ...)
function main_pop_fx(url, width, heigh, left, top) {
	var intWidth = width;
	var intHeight = heigh;
  	var tempX = left;
	var tempY = top;
	window.open(url,"main","left="+tempX+",top="+tempY+",width="+intWidth+",height="+intHeight+",scrollbars=0");
}


//event popup object
function popupValue(name, url, width, height, left, top) {
	this.name	= name;
	this.url	= url;
	this.width	= width;
	this.height	= height;	
	this.left 	= left;
	this.top 	= top;
}

//open event html (ex : popup.html ...)
function event_pop(param) {
	var param = param;
	var pop = new Array(); 
	var temp = new Array(); 
	var temp2 = new Array(); 
	var left = 10;
	var top = 10;	
	
	//param = "popup.html,300,300|popup2.html,300,300|popup.html,300,300|popup2.html,300,300";
	temp = param.split("|");
	//alert(temp.length);
	for (var i=0; i<temp.length; i++)
	{
		temp2 = temp[i].split(",");

		if(i!=0) {
			left = parseInt(left) + parseInt(prv) + parseInt("10");
		}
		pop[i] = new popupValue("popup_"+i, temp2[0], temp2[1], temp2[2], left, top);
		prv = temp2[1];
		
		//document.write(temp2[0], temp2[1], temp2[2]);
	}
	
	for (var i=0; i<pop.length; i++)
	{ //alert(pop[i].left);
		event_pop_real(pop[i].url, pop[i].name, pop[i].width, pop[i].height, pop[i].left, pop[i].top);
	}
	
	
	//pop[count++] = new popupValue("popup_"+count, );
	//url, width, height
}

//open event html (ex : popup.html ...)
function event_pop_real(url, name, width, heigh, left, top) { alert("event_pop_real");
	var intWidth = width;
	var intHeight = heigh;
  	var tempX = left;
	var tempY = top;
	window.open(url,name,"left="+tempX+",top="+tempY+",width="+intWidth+",height="+intHeight+",scrollbars=0");
}

function event_end () {
	var end = "200801221700";
	var now = new Date(); 	
	year=now.getYear();
	month=(now.getMonth()+1);
	date=now.getDate();	
	hour=now.getHours();
	minutes=now.getMinutes();
	if(month < 10)
		month = "0"+month;
	var current = year.toString() + month.toString() + date.toString() + hour.toString() + minutes.toString();
	alert(current);	
	var cnt=1;
	if (parseInt(current)>parseInt(end)) {
		if (cnt=1) {
			alert("end!!"); //flash에서 이부분에 exit나 mod=no를 넣어 시간이 지나면 데이터가 디비에 안싸이도록 한다. php로 변환 필요
			cnt++;
		}
	}
}

function change_flash_wh ( id, width, height ) {
	document.getElementById(id).width = width;
	document.getElementById(id).height = height;
	document.getElementById(id).style.verticalAlign = "middle";
}

function open_popup(url) {
	//url = "map.html";
	name = "_blank";
	var intWidth = 612;
	var intHeight = 792;
	var tempX = 10;
	var tempY = 10;
	window.open(url,name,"left="+tempX+",top="+tempY+",width="+intWidth+",height="+intHeight+",scrollbars=0");

}


function copyData(text) {alert("copyData");
 window.clipboardData.setData('Text', text);
 alert("클립보드에 복사되었습니다.\n\n붙여넣기( Ctrl+v )를 이용하시면 됩니다.");
}

function flashlogin() { //alert("flashlogin");
	
	var win = window.open("/kalmain/etcLogin.aspx?returnUrl=/kalmain/site/uzbek/admin/login_check.asp&channel=MUC_site", "REQUEST","width=650, height=430, scrollbars=yes, resize=no, left=" + (screen.availwidth-348)/2 + ",top=" + (screen.availheight-297)/2);
}

function flashlogin_layer() { //alert("flashlogin_layer");
	document.getElementById('loginFrame').src = "/kalmain/etcLogin.aspx?returnUrl=/kalmain/site/uzbek/admin/login_check.asp&channel=MUC_site";
	document.getElementById('loginArea').style.display = "block";
	//var win = window.open("http://kr.koreanair.com/kalmain/etcLogin.aspx?returnUrl=/kalmain/site/munich/admin/login_check.asp&channel=MUC_site", "REQUEST","width=650, height=430, scrollbars=no, resize=no, left=" + (screen.availwidth-348)/2 + ",top=" + (screen.availheight-297)/2);
}

function remove_layer() {
	document.getElementById('loginArea').style.display = "none";
}

function init() {
	document.getElementById('loginFrame').src = "about:blank";
}

function FNchkLogIn(UserID){//alert("FNchkLogIn"+UserID);
  document.all["bottom"].setVariable("user_id", UserID);
  //remove_layer();
 }

function FNchkLogIn2(UserID){//alert("FNchkLogIn2"+UserID);
  document.all["download"].setVariable("user_id", UserID);
 }
 
function main_flash() {
	document.write(document.all["txt1"].value);
}


function regis_pop() {
 
 var win = window.open("http://kr.koreanair.com/kalmain/frm_intro.aspx?mode=111", "REQUEST1","");
}

function dp_flash(id){
  document.write(id.innerHTML);
}