/*
 * function : define flash tag and write
 * @info    : ActivX IE modify
 * @param fID(Flash ID), fURL(Flash URL), w(width), h(height)
 *        wmode(wmode value[null,0 - non select mode, 1 - select mode])
 *        bgClr(background color[null - no value, value - set value])
 *        lstate(loop value[null,0 - not define loop, 2 - loop false])
 *        rtnV(return type[null,0 - null, 1 - string])
 */
function drawFlash(fID, fURL, w, h, wmode, bgClr, lstate, rtnV) {
	var tmpStr = "";
	tmpStr += "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='" + w + "' height='" + h + "' id='" + fID + "' name='" + fID + "' align='middle' type='application/x-shockwave-flash'>";
	tmpStr += "<param name='allowScriptAccess' value='always' />";
	tmpStr += "<param name='movie' value='" + fURL + "' />";
	tmpStr += "<param name='quality' value='high' />";
	tmpStr += "<param name='menu' value='false' />";

	if (lstate == 2) tmpStr += "<param name='loop' value='false' />";
	if (wmode == 1) tmpStr += "<param name='wmode' value='transparent' />";
	if (wmode == 2) tmpStr += "<param name='wmode' value='opaque' />";
	if (bgClr != null && bgClr != "undefined") tmpStr += "<param name='bgcolor' value='" + bgClr + "' />";

	tmpStr += "<embed src='" + fURL + "' quality='high' ";
	if (lstate == 2) tmpStr += "loop='false' ";
	if (wmode == 1) tmpStr += "wmode='transparent' ";
	if (wmode == 2) tmpStr += "wmode='opaque' ";
	if (bgClr != null && bgClr != "undefined") tmpStr += "bgcolor='" + bgClr + "' ";

	tmpStr += "width='" + w + "' height='" + h + "' name='" + fID + "' menu='false' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'  />";
	tmpStr += "</object>";

	if (rtnV && rtnV == 1) { // return string
		return tmpStr;
	} else {
		document.write(tmpStr);
	}
}

/* function : check null */
function isNull(tObj) {
	if (tObj == null || tObj == "undefined") return true;
	return false;
}

/* function : add onload function */
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof(window.onload) != "function") {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}


/*
 * function : define popup window
 * @param url(page url), wname(popup name), w(width), h(height)
 *        ptype(popup type), t(top position), l(left position)
 */
function popWin(url,wname,w,h,ptype,t,l){
	var popupWin;
	var popOpt = "width="+w+",height="+h+"";
	if (!isNull(t)) popOpt += ",top="+t;
	if (!isNull(l)) popOpt += ",left="+l;
	if(ptype == 0){
		popOpt += ",scrollbars=no";
	}
	if(ptype == 1){
		popOpt += ",scrollbars=yes";
	}
	if(ptype == 2){
		popOpt += ",scrollbars=yes,resizable=yes";
	}
	if(ptype == 3){
		popOpt += ",scrollbars=no,resizable=yes";
	}
	popupWin = window.open(url,wname,popOpt);
	popupWin.focus();
}


/*
 * function : define popup close
 */
function popClose() {
	try {
		if (window.opener != null && window.opener.closed) window.opener = self;
	} catch (e) {
		window.opener = self;
	}
	self.close();
}


/*
 * function : define mouse over action to tab
 * @param ipfix(tab id prefix), idx(tab id), snum(state number)
 *        tnum(total tab number), dpfix(tab detail layer prefix)
 */
function overTab(ipfix, idx, snum, tnum, dpfix) {
	var tmpTab, tmpDiv, tmpImg;
	if (ipfix && (idx == null) && tnum) return;
	for (var i = snum; i < snum+tnum; i++) {
		tmpTab = document.getElementById(ipfix+i);
		tmpDiv = document.getElementById(dpfix+i);
		tmpImg = tmpTab.getAttribute("src");
		if (!tmpImg) continue;
		tmpImg = tmpImg.substring(0,tmpImg.length-5);
		if (i == idx) {
			if (tmpTab) tmpTab.setAttribute("src",tmpImg+"o.gif");
			if (tmpDiv) tmpDiv.style.display = "block";
		} else {
			if (tmpTab) tmpTab.setAttribute("src",tmpImg+"x.gif");
			if (tmpDiv) tmpDiv.style.display = "none";
		}
	}
}

