﻿// flash //
function embedf(src,width,height)
{
	var src,width,height;
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="'+width+'" height="'+height+'">');
	document.write('<param name="allowScriptAccess" value="always" />');
	document.write('<param name="movie" value="'+src+'">');
	document.write('<param name="quality" value="autohigh">');
	document.write('<param name="menu" value="false">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<embed src="'+src+'"quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash type=application/x-shockwave-flash" width="'+width+'" height="'+height+'">');
	document.write('</embed>');
	document.write('</object>');
}

// Email Check
function isEmail(s) {
	return s.search(/^\s*[\w\~\-\.]+\@[\w\~\-]+(\.[\w\~\-]+)+\s*$/g) >= 0;
}

// Windows Popup
function OpenCenterWindow(winW, winH, sURL, winName, blnScrollbar) {
	var strScrolbar = "no";

	if (blnScrollbar) {
		strScrolbar = "yes";
	}

	var winL = (screen.width - winW) / 2;
	var winT = (screen.height - winH) / 2;

	var win = window.open(sURL, winName, "width=" + winW + ",height=" + winH + ",scrollbars=" + strScrolbar + ",resizable=no,top=" + winT + ", left=" + winL);

	win.focus();
}

// CheckStr
function CheckStr(strOriginal, strFind, strChange) {
	var position, strOri_Length;
	position = strOriginal.indexOf(strFind);

	while (position != -1) {
		strOriginal = strOriginal.replace(strFind, strChange);
		position = strOriginal.indexOf(strFind);
	}

	strOri_Length = strOriginal.length;
	return strOri_Length;
}

// CheckPW
function fnCheckPW(str) {
	var permit = /^[a-zA-Z0-9]{4,20}$/;

	if (!permit.test(str)) {
		return false;
	}
	else {
		return true;
	}
}

// fnCheckPW2
function fnCheckPW2(str) {
	var permit = /(.)\1{3,}/;

	if (permit.test(str)) {
		return false;
	}
	else {
		return true;
	}
}

// checkOnlyAlphabetNumber
function checkOnlyAlphabetNumber(todo) {
	var checkRe = /^[a-zA-Z0-9]+$/;
	return checkRe.test(todo);
}

// isValidDay
function isValidDay(yyyy, mm, dd) {
	var m = parseInt(mm, 10) - 1;
	var d = parseInt(dd, 10);

	var end = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
	if ((yyyy % 4 == 0 && yyyy % 100 != 0) || yyyy % 400 == 0) {
		end[1] = 29;
	}

	return (d >= 1 && d <= end[m]);
}

// ImagePopup
function ImagePopup(strUrl, strScrollbar) {
	var winW = 100;
	var winH = 100;

	window.open("/Common/ImgView.aspx?ImgUrl=" + strUrl, "RanWorldImageViewer", "width=" + winW + ",height=" + winH + ",scrollbars=yes,resizable=no,top=100, left=100");
}

// ImageUpload
function callImgUpload( strUrl ) {
	OpenCenterWindow(440, 240, strUrl, "RanWorldImgUpload", false);
}

// ImageUpload Screenshot
function callImgUploadScreenshot(strUrl) {
	OpenCenterWindow(440, 240, strUrl, "RanWorldImgUpload", false);
}

// ImageUpload User
function callImgUploadUser(strUrl) {
	OpenCenterWindow(440, 240, strUrl, "RanWorldImgUpload", false);
}

// CheckLogin
function CheckLogin(UserID) {

	if (UserID == "") {
		if (confirm("You need to log in first to use this menu. Move to the login page now?")) {
			parent.document.location.href = "/Member/Login.aspx?ReturnUrl=" + escape(document.location.href);
		}
	}
}
