﻿var IE = (document.all)? true:false ;
var NS = (document.layers)? true:false ;

/*
############## 한글 Byte 길이 체크 ###############
*/

var TOG_WORD				= '%0D';
//단문메시지에서 메시지의 길이를 체크하고 짜르는 함수
function checkShrtMsgLen(obj,sByteLen) {
	var bResult		= checkMsgLen(obj,sByteLen);
	var iCountByte	= 0;
	var sContentMsg	= '';

	if (!bResult){
		sByteLen_k = Math.floor(sByteLen / 2);
		alert(sByteLen + " Byte를 넘을수 없습니다.\n\n(한글 " + sByteLen_k + " 자, 영문 " + sByteLen + " 자)");
		sContentMsg = cutText(obj,sByteLen);
		obj.value = sContentMsg;
	}
//	iCountByte = getByteLen(obj);
//	document.frmsms.COUNTBYTE.value = iCountByte[0];
}


function checkMsgLen(obj,sByteLen) {

	var iCounts = new Array();
	iCounts = getByteLen(obj);											//변수의 길이를 구하는 함수

	if (iCounts[0] > sByteLen)
		return false;
	else
		return true;
}


function InputOnlyNum(v) {
	if (v < 48 || v > 57) {
		return false;
	}
	return true;
}


function FocusMove(len, obj1, obj2) {
	key	= event.keyCode;
	if (key != 9 && key != 16) {
		flag	= obj1.value.length;
		if (flag == len) {
			obj2.focus();
		}
	}
}


//일정 바이트 이상 되면 변수의 길이를 자르는 함수
function cutText(obj,sByteLen) {

	var sTmpMsg			= '';
	var iTmpMsgLen		= 0;
	var sOneChar		= '';
	var iCount			= 0;
	var sOneCharNext	= '';

	sTmpMsg = new String(obj.value);
	iTmpMsgLen = sTmpMsg.length;

	for (var k = 0 ;k < iTmpMsgLen ; k++) {
		sOneChar = sTmpMsg.charAt(k);
		sOneCharNext = sTmpMsg.charAt(k+1);
		if (escape(sOneChar) == TOG_WORD) {
			iCount++;
			if (iCount > sByteLen-1) {
				sTmpMsg = sTmpMsg.substring(0,k);
				break;
			}
		}
		else if (escape(sOneChar).length > 4) {
			iCount += 2;
		}
		else {
			iCount++;
		}
		if (iCount > sByteLen) {
			sTmpMsg = sTmpMsg.substring(0,k);
			break;
		}
	}
	return sTmpMsg;
}


//한글일 경우에는 2byte를 그외의 문자는 1byte로 계산하여  iCounts에 저장하여 return 해준다.
function getByteLen(obj,sMsgLng) {

	var sMsg       = obj.value;
	var sTmpMsg    = '';												//메시지를 임시로 저장하는 변수
	var sTmpMsgLen = 0;													//임시로 저장된 메시지의 길이를 저장하는 변수
	var sOneChar   = '';												//한문자를 저장하는 변수
	var iCounts    = new Array();										//총 바이트와 페이지당 바이트 수를 저장하는 배열

	iCounts[0]=0;														//총 바이트를 저장 하는 변수

	if (sMsgLng != null) {
		sTmpMsg	= new String(sMsgLng);
	}
	else
		sTmpMsg	= new String(sMsg);
	sTmpMsgLen	= sTmpMsg.length;

	for (k = 0 ;k < sTmpMsgLen ;k++) {
		sOneChar = sTmpMsg.charAt(k);
		if (escape(sOneChar) == TOG_WORD) {
			iCounts[0]++;
		}
		else if (escape(sOneChar).length > 4) {
			iCounts[0] += 2;
		}
		else  {
			iCounts[0]++;
		}
	}

	return iCounts;
}

// 주민번호 체크
function chk_jumin(Jno)
{
	J1 = Jno.substr(0,6);
	J2 = Jno.substr(6,7);
	var SUM=0;
	// 주민등록번호 1 ~ 6 자리까지의 처리
	// 주민등록번호에 숫자가 아닌 문자가 있을 때 처리
 	for(i=0;i<J1.length;i++){
        	if (J1.charAt(i) >= 0 || J1.charAt(i) <= 9) {
        		// 숫자면 값을 곱해 더한다.
			if(i == 0){
				SUM = (i+2) * J1.charAt(i);
			} else { 
				SUM = SUM +(i+2) * J1.charAt(i);
			}
		} else {
			// 숫자가 아닌 문자가 있을 때의 처리
//			alert("숫자만 입력하세요");
			return false;
		}
	}
	
	// 주민등록번호 7 ~  8 자리까지의 처리
	for(i=0;i<2;i++){
	        if (J2.charAt(i) >= 0 || J2.charAt(i) <= 9) {
	        	SUM = SUM + (i+8) * J2.charAt(i);
		}else{
			// 숫자가 아닌 문자가 있을 때의 처리
//		   	alert("숫자만 입력하세요");
       		return false;
		}
	}
	
	// 주민등록번호 9 ~ 12 자리까지의 처리
	for(i=2;i<6;i++){
	        if (J2.charAt(i) >= 0 || J2.charAt(i) <= 9) {
		   SUM = SUM + (i) * J2.charAt(i);
		}else{
			// 숫자가 아닌 문자가 있을 때의 처리
//		   	alert("숫자만 입력하세요");
       		return false;
		}
	}
	
	// 나머지 구하기
	 var checkSUM = SUM % 11;
	// 나머지가 0 이면 10 을 설정
	if(checkSUM == 0){
	   var checkCODE = 10;
	// 나머지가 1 이면 11 을 설정
	}else if(checkSUM ==1){
	   var checkCODE = 11;
	}else{
	   var checkCODE = checkSUM;
	}
	// 나머지를 11 에서 뺀다
	var check1 = 11 - checkCODE;
	if (J2.charAt(6) >= 0 || J2.charAt(6) <= 9) {
		var check2 = parseInt(J2.charAt(6))
	}else{
		// 숫자가 아닌 문자가 있을 때의 처리
//		alert("숫자만 입력하세요");
		return false;
	}
	
	if(check1 != check2){
		// 주민등록번호가 틀릴 때의 처리
//		alert("주민등록 번호를 다시 확인 하세요.");
		return false;
	}else{
		return true;
	}	  
}


//외국인 주민번호 체크 
function chk_foreigner(reg_no) {
	if (reg_no.length != 13) {
		return false;
	}

    var sum = 0;
    var odd = 0;
    
    buf = new Array(13);
    for (i = 0; i < 13; i++) buf[i] = parseInt(reg_no.charAt(i));

    odd = buf[7]*10 + buf[8];   // 앞에서 8,9번째 자리숫자
    
    if (odd%2 != 0) {		//odd가 짝수이어야 함
      return false;
    }

    if ((buf[11] != 6)&&(buf[11] != 7)&&(buf[11] != 8)&&(buf[11] != 9)) {  //12번째 숫자는 6,7,8,9 중 하나
      return false;
    }
    	
    multipliers = [2,3,4,5,6,7,8,9,2,3,4,5];
    for (i = 0, sum = 0; i < 12; i++) sum += (buf[i] *= multipliers[i]);


    sum = 11 - (sum % 11);
    
    if (sum >= 10) sum -= 10;

    sum += 2;

    if (sum >= 10) sum -= 10;

    if ( sum != buf[12]) {
      return false;
    }
    else {
        return true;
    }
}

//trim 메소드 
function trim(str) {
	var count = str.length;
	var len = count;                
	var st = 0;
		
	while ((st < len) && (str.charAt(st) <= ' ')) {
		st++;
	}
	while ((st < len) && (str.charAt(len - 1) <= ' ')) {
		len--;
	}                
	return ((st > 0) || (len < count)) ? str.substring(st, len) : str ;   
} 


// email 형식 체크
function IsEmail(str) {
  // regular expression 지원 여부 점검
	var supported = 0;
	if (window.RegExp) {
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) supported = 1;
	}
	if (!supported) return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);

	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	
	return (!r1.test(str) && r2.test(str));
}


function CtrlStatus() {
    //strStatus	= "NoAD SMB"
    strStatus	= "NoAD"
	self.status = strStatus;
	return true;
}


// Select box 에 날짜 출력
function PrintYear(d, objName, val) {
	document.write (getYearList(d, objName, val));
}


function PrintMonth(d, objName, val) {
	document.write (getMonthList(d, objName, val));
}


function PrintDay(d, objName, val) {
	document.write (getDayList(d, objName, val));
}


function getYearList(d, objName, val)
{
	val = (!val)? d.getFullYear():val;
	retVal = "<select name='" + objName + "'>";
	for (i = 2004; i <= 2020; i++) {
		if (val == i) {
			retVal += "<option value='" + i + "' selected>" + i + "년</option>";
		}
		else {
			retVal += "<option value='" + i + "'>" + i + "년</option>";
		}
	}
	retVal += "</select>";

	return retVal;
}


function getMonthList(d, objName, val)
{
	if (!val) val = d.getMonth() + 1;
	retVal = "<select name='" + objName + "'>";
	for (i = 1; i <= 12; i++) {
		tmp = "0" + i;
		tmp = tmp.substr(tmp.length - 2);
		if (val == i) {
			retVal += "<option value='" + tmp + "' selected>" + tmp + "월</option>";
		}
		else {
			retVal += "<option value='" + tmp + "'>" + tmp + "월</option>";
		}
	}
	retVal += "</select>";

	return retVal;
}

function getDayList(d, objName, val)
{
	if (!val) val = d.getDate();
	retVal = "<select name='" + objName + "'>";
	for (i = 1; i <= 31; i++) {
		tmp = "0" + i;
		tmp = tmp.substr(tmp.length - 2);
		if (val == i) {
			retVal += "<option value='" + tmp + "' selected>" + tmp + "일</option>";
		}
		else {
			retVal += "<option value='" + tmp + "'>" + tmp + "일</option>";
		}
	}
	retVal += "</select>";

	return retVal;
}

function getFullDateList(d, prefix, val, delim)
{
	if (!val)
	{
		valY = valM = valD = null;
	}
	else
	{
		if (delim)
		{
			if (val.indexOf(delim) > -1)
			{
				tmp = val.split(delim);
				valY = tmp[0];
				valM = tmp[1];
				valD = tmp[2];
			}
			else
			{
				valY = valM = valD = null;
			}
		}
		else
		{
			if (val.indexOf("-") > -1)
			{
				tmp = val.split("-");
				valY = tmp[0];
				valM = tmp[1];
				valD = tmp[2];
			}
			else
			{
				valY = val.substr(0, 4);
				valM = val.substr(4, 2);
				valD = val.substr(6, 2);
			}
		}
	}

	return getYearList(d, prefix + "Y", valY)
		+ getMonthList(d, prefix + "M", valM)
		+ getDayList(d, prefix + "D", valD);
}


function GetDateStamp(d)
{
	if (!d)
	{
		d = new Date();
	}

	yyyy = d.getFullYear();
	mm = "0" + (d.getMonth() + 1);
	dd = "0" + d.getDate();

	return yyyy.toString() + mm.substr(mm.length - 2) + dd.substr(dd.length - 2);
}


function LoadOnce(bFlag, path)
{
	try
	{
		if (!eval(bFlag))
		{
			document.write ('<SCRIPT SRC="' + path + '"></SCRIPT>');
		}
	}
	catch (ex)
	{
		document.write ('<SCRIPT SRC="' + path + '"></SCRIPT>');
	}
}


var g_eMsgBox;
var g_eMsgLine;
var g_eOldMsgBox = null;

var g_iMsgWidth = 400;
var g_iMsgHeight = 300;
function MsgBoxCtrl(msg, title, bModal, args)
{
	iNumArgs = arguments.length;
	if (iNumArgs > 0)
	{
		msg = arguments[0];
		title = arguments[1];
		bModal = (arguments[2])? true:false;

		if (bModal)
		{
			ScreenPage();
		}

		if (!g_eMsgBox)
		{
			g_eMsgBox = document.getElementById("MsgBox");

			if (!g_eMsgBox)
			{
				g_eMsgBox = document.createElement("span");
				g_eMsgBox.setAttribute("id", "MsgBox");
				document.body.appendChild(g_eMsgBox);
			}

			iLeft = (document.body.clientWidth - g_iMsgWidth)/2 + document.body.scrollLeft;
			//iTop = (document.body.clientHeight - g_iMsgHeight)/2 + document.body.scrollTop;

			g_eMsgBox.style.left = iLeft;
			//g_eMsgBox.style.top = iTop;
			//g_eMsgBox.style.top = args.y + 10;
			g_eMsgBox.style.top = document.body.scrollTop + args.y + 10;

			if (title)
			{
				eMsgTitle = document.getElementById("MsgTitle");
				if (!eMsgTitle)
				{
					eMsgTitle = document.createElement("span");
					eMsgTitle.setAttribute("id", "MsgTitle");
					eMsgTitle.style.width = "100%";
					eMsgTitle.style.left = 0;
					eMsgTitle.style.top = 0;
					g_eMsgBox.appendChild(eMsgTitle);
					eMsgTitle.innerHTML = title;
				}
				eMsgTitle.onclick = ReleaseScreen;
			}


			g_eMsgLine = document.getElementById("MsgLine");
			if (!g_eMsgLine)
			{
				g_eMsgLine = document.createElement("span");
				g_eMsgLine.setAttribute("id", "MsgLine");
				g_eMsgBox.appendChild(g_eMsgLine);
			}

			if (!bModal)
			{
				eMsgCloseBtn = document.getElementById("MsgCloseBtn");
				if (!eMsgCloseBtn)
				{
					eMsgCloseBtn = document.createElement("span");
					eMsgCloseBtn.setAttribute("id", "MsgCloseBtn");
					g_eMsgBox.appendChild(eMsgCloseBtn);
//					eMsgCloseBtn.style.borderStyle = "solid";
//					eMsgCloseBtn.style.borderColor = "black";
				}
				eMsgCloseBtn.onclick = ReleaseScreen;
				eMsgCloseBtn.innerHTML = "x";
			}

			g_eMsgBox.style.visibility = "visible";
			g_eMsgLine.innerHTML = msg;
			g_eMsgBox.style.width = g_iMsgWidth;
			g_eMsgBox.style.height = g_iMsgHeight;
		}
		else
		{
			g_eMsgBox.style.top = args.y + 10;
			if (title)
			{
				eMsgTitle.innerHTML = title;
			}
			g_eMsgLine.innerHTML = msg;
		}
	}
	else
	{
		if (g_eMsgBox)
		{
			document.body.removeChild(g_eMsgBox);
			g_eMsgBox = null;
		}
	}
}


function ScreenPage()
{
	var panel = document.getElementById("ModalPanel");
	if (!panel)
	{
		panel = document.createElement("div");
		panel.setAttribute("id", "ModalPanel");
		document.body.appendChild(panel);
	}
	
	document.body.style.overflow = "hidden";

	sW = document.body.scrollWidth;
	sH = document.body.scrollHeight;
	oW = document.body.clientWidth;
	oH = document.body.clientHeight;

	panel.style.width = (sW > oW)? sW:oW;
	panel.style.height = (sH > oH)? sH:oH;
	panel.style.display = "block";
    panel.innerHTML = "<span id='ss' class='screen'></span><!--[if lte IE 6.5]><iframe></iframe><![endif]-->";
}

function DialogControl(dlg, bShow)
{
	var cont = document.getElementById("ContainerOfDlg");
	if (bShow)
	{
		if (!cont)
		{
			cont = document.createElement("span");
			cont.setAttribute("id", "ContainerOfDlg");
			if (document.forms.length == 0)
				document.body.appendChild(cont);
			else
				document.forms[0].appendChild(cont);
		}

		w = parseInt(dlg.style.width);
		h = parseInt(dlg.style.height);
		
		iLeft = (document.body.clientWidth - w)/2 + document.body.scrollLeft;
		iTop = (document.body.clientHeight - h)/2 + document.body.scrollTop;

		cont.style.width = w + "px";
		cont.style.height = h + "px";
		cont.style.left = iLeft + "px";
		cont.style.top = iTop + "px";
		//cont.style.top = document.body.scrollTop + args.y + 10;
		
		cont.appendChild(dlg);
		dlg.show();
		
		input = dlg.getElementsBySelector("input[type='text'],select,textarea")
		if (input.length > 0)
			input[0].focus();
	}
	else
	{
		dlg.hide();
//		if (cont)
//		{
//			document.body.removeChild(cont);
//		}
	}
}

function ReleaseScreen()
{
	var panel = document.getElementById("ModalPanel");
	if (panel)
	{
		panel.style.display = "none";
		document.body.style.overflow = "visible"
		document.body.removeChild(panel);
	}

	MsgBoxCtrl();
}


function GetTimeSerial(mode)
{
	dt = new Date();

	result = "";

	if (!mode || mode == "full" || mode == "date")
	{
		result += dt.getFullYear().toString();

		tmp = "0" + (dt.getMonth() + 1);
		tmp = tmp.substr(tmp.length - 2);
		result += tmp;

		tmp = "0" + dt.getDate();
		tmp = tmp.substr(tmp.length - 2);
		result += tmp;
	}

	if (!mode || mode == "full" || mode == "time")
	{
		tmp = "0" + dt.getHours();
		tmp = tmp.substr(tmp.length - 2);
		result += tmp;

		tmp = "0" + dt.getMinutes();
		tmp = tmp.substr(tmp.length - 2);
		result += tmp;

		tmp = "0" + dt.getSeconds();
		tmp = tmp.substr(tmp.length - 2);
		result += tmp;
	}

	return result;
} // end func


function drawDataTable(obj)
{
	str = "<table width=100%>";
	for (i=0; i<obj.length; i++)
	{
		dat = obj[i];
		str += "<tr>";
		str += "<th width=110>" + dat.name + "</th>";
		if (typeof(dat.value) != "undefined")
		{
			if (dat.onclick)
			{
				str += "<td><span class='pointer blue' onclick=\"" + dat.onclick + "\">" + dat.value + "</span></td>";
			}
			else
			{
				str += "<td>" + dat.value + "</td>";
			}
		}
		str += "</tr>";
	}
	str += "</table>";

	return str;
}


function drawListTable(obj)
{
	str = "<table width=100%><tr>";
	for (i=0; i<obj.field.length; i++)
	{
		str += "<th>" + obj.field[i]; + "</th>";
	}
	str += "</tr>";

	for (i=0; i<obj.data.length; i++)
	{
		str += "<tr>";
		dat = obj.data[i];
		for (j=0; j<dat.rec.length; j++)
		{
			str += "<td>" + dat.rec[j] + "</td>";
		}
		str += "</tr>";
	}
	str += "</table>";

	return str;
}


function ProxySendRequest(callback,args,data,method,url,async,sload,user,password)
{
	proxy = "/proxy.aspx?md=" + method + "&u=" + escape(url) + "&d=" + escape(data);
	return sendRequest(callback,args,"",method,proxy,async,sload,user,password);
}

document.onmouseover = CtrlStatus;



function GetClientStates(group, callback)
{
	gid = (group || group == 0)? group:"";
	new Ajax.Request("/ws/getClientStatus.aspx", {
		parameters: "g=" + gid,
		on200: function(trans)
			{
				json = trans.responseText.evalJSON();
				callback(json);
			},
		on500: function(trans)
			{
				alert(trans.responseText);
			}
	});
}


function PrintPage()
{
	if (window.print)
	{
		window.print();
	}
}


function ChgLang(lang)
{
    if(lang == "" )
        return ;
	exp = new Date();
	exp.setTime(exp.getTime() + (1000 * 60 * 60 * 24 * 30));		// 30days
	SetCookie("ln", lang, exp, "/");
	
	window.location.reload();
}

/* @테이크 투어 */
var taketour='control';
function show_taketour(){
    document.getElementById('taketour').style.display="block";
    document.getElementById('start_container').style.height="100%";
    for(i = 0; i < document.getElementsByTagName("select").length; i++ )
        document.getElementsByTagName("select")[i].style.display = "none";
}
function close_taketour(){
    document.getElementById('taketour').style.display="none";
    document.getElementById('start_container').style.height="auto";
    for(i = 0; i < document.getElementsByTagName("select").length; i++ )
        document.getElementsByTagName("select")[i].style.display = "block";
}
function taketour_menu_set(){
    document.getElementById('taketour_control_small').style.display="none";
    document.getElementById('taketour_group_small').style.display="none";
    document.getElementById('taketour_pc_small').style.display="none";
    document.getElementById('taketour_report_small').style.display="none";
    document.getElementById('taketour_deploy_small').style.display="none";
    document.getElementById('taketour_support_small').style.display="none";
    
    document.getElementById('taketour_control_text').style.background="transparent url('/images/taketour_menu.gif') no-repeat top right";
    document.getElementById('taketour_group_text').style.background="transparent url('/images/taketour_menu.gif') no-repeat top right";
    document.getElementById('taketour_pc_text').style.background="transparent url('/images/taketour_menu.gif') no-repeat top right";
    document.getElementById('taketour_report_text').style.background="transparent url('/images/taketour_menu.gif') no-repeat top right";
    document.getElementById('taketour_deploy_text').style.background="transparent url('/images/taketour_menu.gif') no-repeat top right";
    document.getElementById('taketour_support_text').style.background="transparent url('/images/taketour_menu.gif') no-repeat top right";
    //alert(taketour);
    document.getElementById("taketour_"+taketour+"_text").style.background="#1f1f1f";
}
function taketour_menu(val){    
    taketour_menu_set();
    if(val != 'out'){
        //document.getElementById("taketour_"+val+"_small").style.display="inline";     
        if(val != taketour){document.getElementById("taketour_"+val+"_text").style.background="transparent url('/images/taketour_menu_ov.gif') no-repeat top right";}
    }
}
function taketour_change_menu(val){   
    taketour=val;   
    taketour_menu_set();    
    taketour_change_content();
}
function taketour_change_content(){
    document.getElementById('taketour_control').style.display="none";
    document.getElementById('taketour_group').style.display="none";
    document.getElementById('taketour_pc').style.display="none";
    document.getElementById('taketour_report').style.display="none";
    document.getElementById('taketour_deploy').style.display="none";
    document.getElementById('taketour_support').style.display="none";
    document.getElementById("taketour_"+taketour).style.display="block";
}
/* //테이크 투어 */

function IsLogin()
{
	return (GetCookie(".NOADAUTH"))? true:false;
}

var NoadUser = {
	Id: null,
	Index: 0,
	IsLogin: function() {
		return (NoadUser.Index)? true:false;
	}
};

function ChangeSiteLanguage(o)
{
	if (o.options[o.selectedIndex].value == "EN-us")	    
	    window.open("http://www.noad365.com","noad365","","");
}



///////////////Flash Player ///////////////////////////////////////////////////
function PrintFlash(s,d,w,h,t,f,l){
    var keys = new Array();
    var values = new Array();
    if(f != null && f.length > 0){keys.push("nfreq");values.push(f);}
    for(var i = 0; l != null && i < l.length; i++){
        var clkid = i + 1;
        keys.push(clkid);values.push(encode(l[i]));
    }
    return mf81(s,d,w,h,t,keys,values);
}

function mf81(s,d,w,h,t,k,v){
    var flashvars = "";
    if(k != null && v != null && k.length > 0 && k.length == v.length){
        for(var i = 0; i < k.length; i++){
            if(i > 0){ flashvars += "&"; }
            flashvars += k[i] + "=" + v[i];
        }
    }

    var code = "";
    code  = "<object type=\"application/x-shockwave-flash\" ";
    code +=         "classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" ";
    code +=         "codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" ";
    code +=         "width=\""+w+"\" height=\""+h+"\" id=\""+d+"\">";
    code += "<param name=\"movie\" value=\""+s+"\" />";
    code += "<param name=\"quality\" value=\"high\" />";
    //code += "<param name=\"bgcolor\" value=\"#ffffff\" />";
    code += "<param name=\"wmode\" value=\""+t+"\" />";
    code += "<param name=\"menu\" value=\"false\" />";
    code += "<param name=\"allowScriptAccess\" value=\"always\" />";
    code += "<param name=\"swliveconnect\" value=\"true\" />";

    if(flashvars.length > 0){
        code += "<param name=\"FlashVars\" value=\""+flashvars+"\" />";
    }

    code += "<embed src=\""+s+"\" quality=\"high\" "
    //code +=        "bgcolor=\"#ffffff\" "
    code +=        "wmode=\""+t+"\" "
    code +=        "menu=\"false\" width=\""+w+"\" height=\""+h+"\" "
    code +=        "type=\"application/x-shockwave-flash\" "

    if(flashvars.length > 0){
        code +=    "FlashVars=\""+flashvars+"\" ";
    }

    code +=        "pluginspage=\"http://www.macromedia.com/go/getflashplayer\"> "
    code += "</embed>"
    code += "</object>"

    return documentwrite(code);
}

// write document contents
function documentwrite(src){ document.write(src); }

/////////////////////////////////////////////////////////////////////////////////