/*ooz
version="1.3.20"
date="2011-09-22"
ignore="false"
updateMode="absolute"
product="fxlibrary"
*/
	function sendRedirect(url) {
		var anchor = document.createElement("a");

		if (!anchor.click) {
			window.location = url;
		}

		anchor.setAttribute("href", url);
		anchor.style.display = "none";
		document.body.appendChild(anchor);
		anchor.click();
	}

	function fx_viewvv(num, category_type, category){
		sendRedirect( productViewURL + "?num=" + num
				+ "&category_type=" + category_type + "&category=" + category );
	}
	
	function fx_launchvv(num, program_num) {
		var op = window.open( launchProductURL + "?num=" + num +
				"&program_num=" + program_num + "&nextOp=close",
				"op", "width=200,height=100,scrollbars=no" );
		op.focus();
	}
	
	function fx_oplendvv(product_num, program_num) {
		var op = window.open( lendProductURL + "?product_num=" + product_num +
				"&program_num=" + program_num + "&nextOp=close",
				"op", "width=200,height=100,scrollbars=no" );
		op.focus();
	}
	
	function fx_lendvv(product_num) {
		sendRedirect( lendProductURL + "?product_num=" + product_num + "&nextOp=forward" );
	}
	
	function fx_reservevv(product_num) {
		sendRedirect( reserveProductURL + "?product_num=" + product_num );
	}
	
	function fx_returnvv(num, nextOp) {
		sendRedirect( returnProductURL + "?num=" + num );
	}
	
	function fx_cancelreservevv(num) {
		sendRedirect( cancelReserveProductURL + "?num=" + num );
	}
	
	function fx_extendvv(num) {
		sendRedirect( extendProductURL + "?num=" + num );
	}
	
	function fx_reviewvv(num) {
		sendRedirect( reviewViewURL + "?num=" + num);
	}
	
	function fx_heightvv(height) {
		$("#fx_product_box").css("height", height);
		$("#fx_product_swf").css("height", height);

		fxBodyHeight = fx_bodyheightvv();
	}

	function fx_bodyheightvv() {
		var bodyHeight;

		if (navigator.appName.indexOf("Microsoft") != -1) {
			bodyHeight = document.body.scrollHeight;
		} else {
			bodyHeight = document.body.offsetHeight;
		}

		return bodyHeight;
	}
	
	function fx_sortvv(sort) {
		var form = document.getElementById("searchPost");
		
		form.page.value = "1";
		form.sort.value = sort;
		form.submit();
	}
	
	function fx_searchoptionvv(option)	{
		var form = document.getElementById("searchPost");
		
		switch(option) {
			case 1:
			case 2:
			case 3:
				fx_searchoption_display(option);
				form.searchoption.value = option;
				break;
		}
	}
	
	function fx_readerdownloadvv(supplier) {
		var readerDownloadOp = window.open(readerDownloadGuideURL + "?supplier=" + encodeURIComponent(supplier)
				, "readerDownloadOp", "width=640px,height=300px,resizable=yes,scrollbars=yes");
		readerDownloadOp.focus();
	}
	
	function fx_searchoption_display(option) {
		$("#searchoption_and").attr("src", $("#searchoption_and").attr("src").replace("_on", "_off"));
		$("#searchoption_or").attr("src", $("#searchoption_or").attr("src").replace("_on", "_off"));
		$("#searchoption_fm").attr("src", $("#searchoption_fm").attr("src").replace("_on", "_off"));
		
		switch(option) {
			case 1:
				$("#searchoption_and").attr("src", $("#searchoption_and").attr("src").replace("_off", "_on"));
				break;
			case 2:
				$("#searchoption_or").attr("src", $("#searchoption_or").attr("src").replace("_off", "_on"));
				break;
			case 3:
				$("#searchoption_fm").attr("src", $("#searchoption_fm").attr("src").replace("_off", "_on"));
				break;
		}
	}
	
	function fx_lendmenu(num) {
		var params = "";
		
		switch(num) {
			case 1:
				params = "mode=lend&listOp=now";
				break;
			case 2:
				params = "mode=reserve";
				break;
			case 3:
				params = "mode=lend&listOp=past";
				break;
			case 4:
				openTerminal('list');
				return;
		}

		sendRedirect( lendListURL + "?" + params );
	}

	function cyberenglishPopup() {
		$.ajax({
			type: "POST",
			url: cevParamsURL,
			dataType: "json",
			success: function(data) {
				switch(data[0].success) {
					case true:
						var cevOp = window.open(cevAuthURL + "?" +
											"cev_id=" + data[0].cev_id +
											"&user_id=" + data[0].user_id +
											"&user_num=" + data[0].user_num +
											"&auth_num=" + data[0].auth_num +
											"&auth_key=" + data[0].auth_key
										, "cevOp", "width=1092px,height=720px,resizable=yes,scrollbars=yes");
						cevOp.focus();
						break;
					case false:
						showDialog("info", data[0].message);
						break;
				}
			},
			error: function(xhr, status) {
				alert("[" + status + "]\n\n" + xhr.responseText);
			}
		});
	}
	
	function onProductSearch() {
		var form = document.getElementById("searchPost");

		if (form.keyword.value == "") {
			alert("ê²€?‰ì–´ë¥??…ë ¥??ì£¼ì‹­?œì˜¤.");
			form.keyword.focus();
			return false;
		}
		
		form.page.value = "1";
		if(form.sort.value == "") {
			form.removeChild(form.sort);
		}
		form.category.value = "";
		//form.category_type.value = "";
		
		return true;
	}
	
	function fx_ctsearchvv(category_type, keyword, keyoption2, searchoption) {
		sendRedirect(productListURL + "?category_type=" + category_type +
								"&keyword=" + encodeURIComponent(keyword) +
								"&keyoption2=" + keyoption2 +
								"&searchoption=" + searchoption);
	}
	
	function isEmail(email) {
		var t = escape(email);
		var regExp = /[a-z0-9]{2,}@[a-z0-9-]{2,}\.[a-z0-9]{2,}/i;
		if (!regExp.test(t)){
			return false;
		}
		return true;
	}

	function isPhoneNumber(pn) {
		var regExp = /([0-9]{2,4}-)?[0-9]{3,4}-[0-9]{4}/;
		if (!regExp.test(pn)){
			return false;
		}
		return true;
	}
	
	function mEmbed() {
		var key = new Array();
		var value = new Array();
		var contents;
		var embed_type;
		var error_check=0;
		var i, j;
		var count;
		var data;
		var temp;
		if (mEmbed.arguments.length == 1) {
			contents = mEmbed.arguments[0];
		} else {
			for (i = 0; i < mEmbed.arguments.length; i++) {
				temp = mEmbed.arguments[i].replace(/"|'/g, "");
				data = temp.split('=');
				key[i] = data[0];
				value[i] = data[1];
				count = data.length;

				for (j = 2; j < count; j++) {
					value[i] += '=' + data[j];
				}
			}

			contents = "";
			srcdata = mGET(key,value, "src");

			if(/\.(swf)$/.test(srcdata)) {
				embed_type = 1;
			} else if (/\.(mov|avi|wma|wmv)$/.test(srcdata)) {
				embed_type = 2;
			}

			var classid = mGET(key,value, 'classid');
			var codebase = mGET(key,value, 'codebase');

			if (embed_type == 1) {
				classid = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
				codebase = (document.location.toString().substring(0,  5) == "https" ? "https" : "http")
					+ '://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0';
			} else if (embed_type == 2) {
				classid = 'clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95';
				codebase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715';
			}

			if (classid && codebase) {
				contents += '<object';
				if (classid) {
					contents += ' classid="' + classid + '"';
				}
				if (codebase) {
					contents += ' codebase="' + codebase + '"';
				}
				count = key.length;
				for (i = 0; i < count; i++) {
					if (value[i] != '' && key[i] != 'src') {
						if (/width|height|id/gi.test(key[i])) {
							contents += ' ' + key[i] + '="' + value[i] + '"';
						}
					}
				}
				contents += '>';
				
				for (i = 0; i < count; i++) {
					if (value[i] != '' && key[i] != '') {
						if (!/undefined|classid|codebase|width|height/gi.test(key[i])) {
							if (embed_type == 1 && key[i] == 'src') {
								contents += '<param name="movie" value="' + value[i] + '" />';
							} else {
								contents += '<param name="' + key[i] + '" value="' + value[i] + '" />';
							}
						}
					}
				}
			}
			count = key.length;
			contents += '<embed';
			for (i = 0; i < count; i++) {
				if (value[i] != '') {
					contents += ' ' + key[i] + '="' + value[i] + '"';
				}
			}
			contents += '>';
			contents += '</embed>';
			if (classid && codebase) {
				contents += '</object>';
			}
		}
		document.write(contents);
	}
	
	function mGET(arrayKey, arrayValue, Value) {
		var i;
		var count;
		count = arrayKey.length;
		for (i=0; i < count; i++) {
			if (arrayKey[i] == Value) {
				return arrayValue[i];
				break;
			}
		}
	}
	
	function getCookie(cookieName) {
		var find = false;
		var start, end;
		var i = 0;
		
		while (i <= document.cookie.length) {
			start = i;
			end = start + cookieName.length;
			if (document.cookie.substring(start, end) == cookieName) {
				find = true;
				break;
			}
			i++;
		}
		
		if (find == true) {
			start = end + 1;
			end = document.cookie.indexOf(";", start);
			if (end < start) {
				end = document.cookie.length;
			}
			
			return document.cookie.substring(start, end);
		}
		
		return "";
	}

	function setCookie(cookieName, value, expiredDays) {
		var today = new Date();
		today.setDate(today.getDate() + expiredDays);
		document.cookie = cookieName + "=" + escape(value) + ";path=/;expires=" + today.toGMTString() + ";";
	}
	
	function openBbsPopup(popupName, top, left) {
		var visible = getCookie(popupName);
		
		if (visible != "false") {
			window.open( bbsPopupURL + "?num=" + popupName.replace("fxbbs", ""),
						popupName,
						"top=" + top + ",left=" + left +
						",resizable=yes,titlebar=no," +
						"location=no,menubar=no,toolbar=no,status=no,scrollbars=yes" );
		}
	}
	
	function closeBbsPopup(popupName) {
		setCookie(popupName, "false", 1);
		window.close();
	}

	function openTerminal(type) {
		var url;

		switch(type) {
			case "list":
				url = terminalListURL;
				break;
			case "register":
				url = terminalRegisterURL;
				break;
			case "help":
				url = terminalIntroURL;
				break;
		}

		var terminalOp = window.open( url, "terminalOp",
						"width=900px,height=800px,resizable=no,titlebar=no," +
						"location=no,menubar=no,toolbar=no,status=no,scrollbars=yes" );
		terminalOp.focus();
	}

	function openWishProduct() {
		var wishProductOp = window.open( wishProductURL, "wishProductOp",
						"width=1010px,height=800px,resizable=yes,titlebar=no," +
						"location=no,menubar=no,toolbar=no,status=no,scrollbars=yes" );
		wishProductOp.focus();
	}
