function LTrim(s) {
	return s.replace(/^\s+/g,"");
}

function RTrim(s) {
	return s.replace(/\s+$/g,"");
}

function Trim(s) {
	return LTrim(RTrim(s));
}

function Len(s) {
	var s1 = Trim(s);
	return s1.length;
}

function num_only()
{
	if(((event.keyCode<48) || (event.keyCode>57)) && (event.keyCode != 46)) {
	event.returnValue=false;
	}
}

function CheckNum(s) {
    if (Len(s) == 0) return false;

    for (i=0; i < s.length; i++) {
        if (!(s.charAt(i) >= "0" && s.charAt(i) <= "9")) 
            return false;
	}

    return true;
}

function CheckStrNum(s) {
    if (Len(s) == 0) return false;

    for (i=0; i < s.length; i++) {
        if (!((s.charAt(i) >= "a" && s.charAt(i) <= "z") ||
	      (s.charAt(i) >= "A" && s.charAt(i) <= "Z") ||
	      (s.charAt(i) >= "0" && s.charAt(i) <= "9")))
            return false;
	}

    return true;
}

function CheckExceptStrNum(s) {
    if (Len(s) == 0) return false;

    for (i=0; i < s.length; i++) {
        if (!((s.charAt(i) >= "a" && s.charAt(i) <= "z") ||
	      (s.charAt(i) >= "A" && s.charAt(i) <= "Z") ||
	      (s.charAt(i) >= "0" && s.charAt(i) <= "9") ||
	      (s.charAt(i) == "_"))) 
            return false;
	}

    return true;
}

function CheckSpace(s) {
    if (Len(s) == 0) return false;

    for (i=0; i < s.length; i++) {
        if (s.charAt(i) == " ") 
            return false;
	}

    return true;
}

function namosw_exchange_src() { 
	str = namosw_exchange_src.arguments[0];
	str = (navigator.appName == 'Netscape') ? 'document.' + str : 'document.all.' + str;
	img = eval(str);
	if (img) {
		if (img.ori_src == null) {
			img.ori_src = img.src;
			img.src     = namosw_exchange_src.arguments[1];
		} else {
			var temp    = img.src;
			img.src     = img.ori_src;
			img.ori_src = temp;
		}
	} 
}

function namosw_preload_img() { 
	var img_list = namosw_preload_img.arguments;
	if (document.preloadlist == null) document.preloadlist = new Array();

	var top = document.preloadlist.length;

	for (var i=0; i < img_list.length; i++) {
		document.preloadlist[top+i]     = new Image;
		document.preloadlist[top+i].src = img_list[i];
	} 
}
function CheckLogin(theForm) {
	if (Len(theForm.member_id.value) == 0) {
		alert('Fill in the account member ID.');
		theForm.member_id.focus();
		return false;
	}
	
	if (Len(theForm.passwd.value) == 0) {
		alert('Fill in the Password.');
		theForm.passwd.focus();
		return false;
	}
	
	return true;
}

function CheckSearch(theForm) {
	if (Len(theForm.search_value.value) == 0) {
		alert('Fill in the search word.');
		theForm.search_value.focus();
		return false;
	}

	if (theForm.search_key.options[theForm.search_key.selectedIndex].value == '') {
		alert('Select the search options');
		theForm.search_key.focus();
		return false;
	}

	theForm.action = theForm.search_key.options[theForm.search_key.selectedIndex].value;
	return true;
}

function CheckEmail(s) {
	var strEmail = s;
	var invalidChars = "~`!@#$%^&*()+=|\<,>?/'";
	
	if (Len(strEmail) == 0) {
		alert('Fill in the email address.');
		return false;
	}
	
	if (strEmail.indexOf("@") < 1) {
		alert('Wrong Email form.\n type : accountname@servername');
		return false;
	}
	
	var atPos = strEmail.indexOf("@", 1);
	var strID = strEmail.substring(0, atPos);
	var strServerName = strEmail.substring(atPos + 1);
	
	for(var i=0; i<invalidChars.length; i++ ) {
		var strBadChar = invalidChars.charAt(i);
		
		if (strID.indexOf(strBadChar) > -1) {
			alert('Email Wrong address. Confirm again please');	
			return false;
		}	
	}
	
	if (strServerName.indexOf(".") < 1) {
		alert('Email Wrong address. Confirm again please');	
		return false;
	}	
	
	for(var i=0; i<invalidChars.length; i++ ) {
		var strBadChar = invalidChars.charAt(i);
		
		if (strServerName.indexOf(strBadChar) > -1) {
			alert('Email Wrong address.Confirm again please');	
			return false;
		}	
	}
	
	return true;
}

function FlashWrite(url, f_width, f_height) {
	document.write("<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=" + f_width + " height=" + f_height + ">");
	document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\" />");
	document.write("<param name=\"movie\" value=" + url + " /><param name=\"loop\" value=\"false\" /><param name=\"menu\" value=\"false\" /><param name=\"quality\" value=\"high\" />");
	document.write("<param name=\"bgcolor\" value=\"#ffffff\" />");
	document.write("</object>");

}

function MovieWrite(url) {
	document.write("<OBJECT ID=\"mplayer\" classid=\"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6\" codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715\" width=\"468\" type=\"application/x-oleobject\" standby=\"Loading Microsoft Windows Media Player components...\" width=\"520\" height=\"510\" VIEWASTEXT>");
	document.write("<PARAM NAME=\"AutoSize\" value=\"0\" />");
	document.write("<PARAM NAME=\"url\" value=" + url + " />");
	document.write("<PARAM NAME=\"EnableContextMenu\"  value=\"false\" />");
	document.write("<PARAM NAME=\"enabled\"  VALUE=\"true\" />");
	document.write("<PARAM NAME=\"stretchToFit\"  VALUE=\"true\" />");
	document.write("<PARAM NAME=\"fullScreen\"  value='' />");
	document.write("<PARAM NAME=\"playCount\" VALUE=\"1\" />");
	document.write("</OBJECT>");
}