//////////////////////////////////////////////////////////////////////////////////////
// Filename : funclib.js
// Writer : Andrew(ratsbomb@gmail.com)
// Create Date : 2005-11-07
// Last Update
// +12-19-2005 : added insert_selLanguage, insert_selCurrency ...
// +12-21-2005 : added WindowOpen
// +12-26-2005 : added insert_selCity
// +01-02-2006 : added getRadioValue(), modified selectAll() support FireFox.
// +02-13-2006 : added getSelectValue()
// Description : inbox page's javascript in common
//////////////////////////////////////////////////////////////////////////////////////

function getSelectValue(select_name)
{
	var result;
    var temp = document.getElementById(select_name); 

	result = temp.options[temp.options.selectedIndex].value;

	return result;
}

// Sorting Select Box
// boxIdObj : select box object, isValuesort : sort by value(default is false, sort by text)
function sboxSort(boxIdObj, isValuesort) 
{ 
    var obj, sArr, oArr, idx, op; 
    
    if (typeof boxIdObj == 'string') obj = document.getElementById(boxIdObj); 
    else obj = boxIdObj; 

    if (obj.tagName.toLowerCase() != 'select') return false; 
    if (typeof isValuesort == 'undefined') isValuesort = false; 

    sArr = new Array(obj.options.length); 
    oArr = new Array; 
	tempArr = new Array(obj.options.length); 

    for (idx = 1; idx < obj.options.length; idx++) 
    { 
        if (isValuesort) sArr[idx] = obj.options[idx].value; 
        else
		{
			sArr[idx] = obj.options[idx].text.toUpperCase(); 
		}
        oArr[sArr[idx]] = obj.options[idx]; 
    } 
    sArr.sort(); 

    //for (idx in sArr) obj.appendChild(oArr[sArr[idx]]); 
	var i;
    for (i = 0; i < sArr.length - 1; i++)
	{
//		document.write("idx : " + i + " - ");
//		document.write("sArr : " + sArr[i] + " <BR /> ");
		obj.appendChild(oArr[sArr[i]]); 
	}
}

function image_window(img) 
{ 
	var popup_window_maxsize = false;

	if (img.tmp_width == undefined)
		img.tmp_width = img.width;
	if (img.tmp_height == undefined)
		img.tmp_height = img.height;

	var w = img.tmp_width;  
	var h = img.tmp_height;  
	var winl = (screen.width-w)/2;  
	var wint = (screen.height-h)/3;  

	if (w >= screen.width) {  
		winl = 0;  
		h = (parseInt)(w * (h / w));  
	}  

	if (h >= screen.height) {  
		wint = 0;  
		w = (parseInt)(h * (w / h));  
	}  

	var js_url = "<script language='JavaScript1.2'> \n";  
		js_url += "<!-- \n";  
		js_url += "var ie=document.all; \n";  
		js_url += "var nn6=document.getElementById&&!document.all; \n";  
		js_url += "var isdrag=false; \n";  
		js_url += "var x,y; \n";  
		js_url += "var dobj; \n";  
		js_url += "function movemouse(e) \n";  
		js_url += "{ \n";  
		js_url += "  if (isdrag) \n";  
		js_url += "  { \n";  
		js_url += "    dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x; \n";  
		js_url += "    dobj.style.top  = nn6 ? ty + e.clientY - y : ty + event.clientY - y; \n";  
		js_url += "    return false; \n";  
		js_url += "  } \n";  
		js_url += "} \n";  
		js_url += "function selectmouse(e) \n";  
		js_url += "{ \n";  
		js_url += "  var fobj      = nn6 ? e.target : event.srcElement; \n";  
		js_url += "  var topelement = nn6 ? 'HTML' : 'BODY'; \n";  
		js_url += "  while (fobj.tagName != topelement && fobj.className != 'dragme') \n";  
		js_url += "  { \n";  
		js_url += "    fobj = nn6 ? fobj.parentNode : fobj.parentElement; \n";  
		js_url += "  } \n";  
		js_url += "  if (fobj.className=='dragme') \n";  
		js_url += "  { \n";  
		js_url += "    isdrag = true; \n";  
		js_url += "    dobj = fobj; \n";  
		js_url += "    tx = parseInt(dobj.style.left+0); \n";  
		js_url += "    ty = parseInt(dobj.style.top+0); \n";  
		js_url += "    x = nn6 ? e.clientX : event.clientX; \n";  
		js_url += "    y = nn6 ? e.clientY : event.clientY; \n";  
		js_url += "    document.onmousemove=movemouse; \n";  
		js_url += "    return false; \n";  
		js_url += "  } \n";  
		js_url += "} \n";  
		js_url += "document.onmousedown=selectmouse; \n";  
		js_url += "document.onmouseup=new Function('isdrag=false'); \n";  
		js_url += "//--> \n";  
		js_url += "</"+"script> \n";  

	var settings; 

	if (popup_window_maxsize) { 
		settings  ='width='+(w+10)+',';  
		settings +='height='+(h+10)+',';  
	} else { 
		settings  ='width='+w+',';  
		settings +='height='+h+',';  
	} 
	settings +='top='+wint+',';  
	settings +='left='+winl+',';  
	settings +='scrollbars=no,';  
	settings +='resizable=yes,';  
	settings +='status=no';  


	win=window.open("","image_window",settings);  
	win.document.open();  
	win.document.write ("<html><head> \n<meta http-equiv='imagetoolbar' CONTENT='no'> \n<meta http-equiv='content-type' content='text/html; charset=UTF-8'>\n");  
	var size = "IMAGE SIZE : "+w+" x "+h; 
	win.document.write ("<title>"+size+"</title> \n");  
	if(w >= screen.width || h >= screen.height) {  
		win.document.write (js_url);  
		var click = "ondblclick='window.close();' style='cursor:move' title=' "+size+" \n\n IMAGE SIZE BIGGER THAN SCREEN SIZE. \n CLICK LEFT BUTTON AND MOVE THE MOUSE. \n\n CLOSE IF YOU DOUBLE CLICK. '";  
	}  
	else  
		var click = "onclick='window.close();' style='cursor:pointer' title=' "+size+" \n\n Click to close this window. '";  
	win.document.write ("<style>.dragme{position:relative;}</style> \n");  
	win.document.write ("</head> \n\n");  
	win.document.write ("<body leftmargin=0 topmargin=0 bgcolor=#dddddd style='cursor:arrow;'> \n");  
	win.document.write ("<table width=100% height=100% cellpadding=0 cellspacing=0><tr><td align=center valign=middle><img src='"+img.src+"' width='"+w+"' height='"+h+"' border=0 class='dragme' "+click+"></td></tr></table>"); 
	win.document.write ("</body></html>");  
	win.document.close();  

	if(parseInt(navigator.appVersion) >= 4){win.window.focus();}  
} 

// Function Name : insert_selCity
// Description : Insert City List to select box(with Country name)
// Paramter : objElement = form element object (need area.js)
// Return : nothing
function insert_selCity(form_name, element_name)
{ 
	var i, j, k, l;

	var objCityList = eval("document.forms['"+form_name+"'].elements['"+element_name+"']");
	var nCountTotalCity;				// number of total City(source from area.js)
	var nCountTotalCountry;				// number of total Country(source from area.js)
	var strCountryName;					// Country Name


	nCountTotalCity = arrCity.length;
	nCountTotalCountry = arrCountry.length;

	var nCount = 1;						// Index number of City List Options

	for (i = 1; i < nCountTotalCity; i++)
	{
		if (arrCity[i] != undefined)
		{
			for (j in arrCity[i])
			{
				// Get Country Name of City
				for (k = 1; k < nCountTotalCountry; k++)
				{
//					for (l in arrCountry[k])
//					{
						if (i == arrCountry[k].value)
							strCountryName = arrCountry[k].text;
//					}
				}
				objCityList.options[nCount] = new Option(strCountryName + ", " + arrCity[i][j].text, arrCity[i][j].value); 
				nCount = nCount + 1;
			}
		}
	}

	// Sort by Name(Alphabetic)
	sboxSort(objCityList);
} 

// Function Name : showMessageLayer
// Description : show Loading Message Layer(need div tag name, "PopupMsg")
// Paramter : nothing
// Return : nothing
function showMessageLayer()
{
	var table = '';
	var nPercent = 100;
	//nPercent = Math.ceil(parseInt((nPercent / 1000) * 100));

	//table += '<div id+="LoadMsgLayer" style="position:absolute; left:261px; top:112px; width:250px; height:110px; z-index:1">\n';
	table += '<table width="280"  border="0" align="center" cellpadding="0" cellspacing="3" bgcolor="#DDDDDD">\n';
	table += '<tr><td bgcolor="#FFFFFF" align="center">\n';
	table += '<br>\n';
	table += '<h4 style="color: #333333;font-weight: bold;font-size: 12px;">Data Loading</h4>\n';
	table += 'Wait a minute\n';
	table += '<br>\n';
	table += '<table width="90%"  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">\n';
	table += '<tr><td height="10"></td></tr>\n';
	table += '<tr>\n';
	table += '<td height="12" width="' + nPercent + '%" bgcolor="#6699CC" align="center"><span class="text_white11">This Window Disappears after Loading.</span></td>\n';
//	table += '<td></td>\n';
	table += '</tr>\n';
	table += '</table>\n';
	table += '<br>\n';
	table += '</td></tr>\n';
	table += '</table>\n';
	//table += '</div>\n';

	var div = document.getElementById('PopupMsg');
	div.style.zindex = 25;

	div.innerHTML = table;
	div.style.display = 'block';
}

// Function Name : closeMessageLayer
// Description : close Loading Message Layer(need div tag name, "PopupMsg")
// Paramter : nothing
// Return : nothing
function closeMessageLayer()
{
	var div = document.getElementById('PopupMsg');
	div.style.display = 'none';
}

// Window Open in Center on Parent Window.
// page : url, w : width, h : height, s : scrollbars, r : resizable
function WindowOpen(page,w,h,s,r) 
{ 
	var win=null; 
	// If frame exists
	// parent.window.screenLeft
	// document.body.offsetWidth, document.body.offsetHeight can editable follow window size.
	var x=window.screenLeft; 
	var y=window.screenTop; 
	var l=x+((document.body.offsetWidth-w)/2); 
	var t=y+((document.body.offsetHeight-h)/2); 
	var settings=''; 
	 
	settings ='width='+w+'px,'; 
	settings +='height='+h+'px,'; 
	settings +='top='+t+'px,'; 
	settings +='left='+l+'px,'; 
	settings +='scrollbars='+s+','; 
	settings +='resizable='+r+','; 
	settings +='status=0'; 
	 
	var windows=window.open(page,win,settings); 
	windows.focus(); 
} 

// Array for Language List
var arrLanguage = new Array();
arrLanguage[1] = new Option('ENGLISH','1');
arrLanguage[2] = new Option('KOREAN','2');
arrLanguage[3] = new Option('JAPANESE','3');
arrLanguage[4] = new Option('CHINESE','4');

// Function Name : insert_selCountry
// Description : Insert Country List to select box
// Paramter : objForm = form object
// Return : nothing
function insert_selCountry(objElement)
{ 
	var i, j;

	var objCountryList = objElement;

	var nCountTotalCountry;				// number of total country(source from country.js)

	nCountTotalCountry = arrCountry.length;

	for (i = 1; i < nCountTotalCountry; i++) 
	{ 
		objCountryList.options[i] = arrCountry[i]; 
	}

	// Sort by Name(Alphabetic)
	sboxSort(objCountryList);
} 

function insert_selBankCountry(objElement)
{ 
	var i, j;

	var objBankCountryList = objElement;

	var nCountTotalCountry;				// number of total country(source from country.js)

	nCountTotalCountry = arrCountry.length;

	for (i = 1; i < nCountTotalCountry; i++) 
	{ 
		objBankCountryList.options[i] = new Option(arrCountry[i].text, arrCountry[i].value); 
	}
}

// Function Name : insert_selLanguage
// Description : Insert Language List to select box
// Paramter : objForm = forn object
// Return : nothing
function insert_selLanguage(objForm)
{ 
	var i;

	var objLanguageList = objForm.elements['selLanguage'];			// Select Box Name

	var nCountTotalLanguage;										// number of total Language

	nCountTotalLanguage = arrLanguage.length - 1;

	for (i = 0; i < nCountTotalLanguage; i++) 
	{ 
		objLanguageList.options[i] = arrLanguage[i + 1]; 
	}
} 

// Function Name : insert_selCurrency
// Description : Insert Currency List to select box
// Paramter : objForm = forn object
// Return : nothing
function insert_selCurrency(objForm)
{ 
	var i;
	var objCurrencyList = objForm.elements['selCurrency'];			// Select Box Name
	var nCountTotalCurrency;										// number of total Currency

	nCountTotalCurrency = arrCurrency.length - 1;

	for (i = 0; i < nCountTotalCurrency; i++) 
	{ 
		objCurrencyList.options[i] = arrCurrency[i + 1]; 
	}
} 

//--------------------------- Inbox Account -------------------------//
// Select All Textarea's Contents
// Paramter : objElement = form's element object
// Return : null
function selectAll(objElement)
{
  //var tval = eval("document.selForm." + element)
  if (navigator.appName == "Microsoft Internet Explorer")
	   codecopy_clip(objElement.value);
  objElement.focus();
  objElement.select();
}

// String Copy To CLIPBOARD
// Paramter : strVal : string that should be copy
// Return : null
// Browser : IE(O) / NE(O) / FF(X)
function codecopy_clip(strVal)
{
	if (window.clipboardData) 
	{
		window.clipboardData.setData("Text", strVal);
	}
	else if (window.netscape) 
	{ 
		netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
		var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
		if (!clip) return;
		var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
		if (!trans) return;
		trans.addDataFlavor('text/unicode');
		var str = new Object();
		var len = new Object();
		var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
		var copytext=strVal;
		str.data=copytext;
		trans.setTransferData("text/unicode",str,copytext.length*2);
		var clipid=Components.interfaces.nsIClipboard;
		if (!clip)	return false;
		clip.setData(trans,null,clipid.kGlobalClipboard);
	}
	alert('ALL CODES ARE SAVED IN YOUR CLIPBOARD.\n\nJUST POINT ANYWHERE TO PASTE AND CTRL+V');
}

// Change Table Row Color 
function display_row(cnt, form_name, checkbox_name)
{
	var tcolor='#DAE8FA';
	var fcolor='#FFFFFF';
	var val;
	var o;
		
   // var o=document.frmAccount.chkbox;
	o = eval("document." + form_name + "." + checkbox_name);
    if ( o.length != null ){
        clr = ( o[cnt-1].checked == true ) ? tcolor: fcolor; 
	}
	else
	{
		clr = ( o.checked == true ) ? tcolor: fcolor; 
	}
	// using in Inbox, SetProperty.asp
	if (checkbox_name == "myHostel" || checkbox_name == "myTour")
	{
		val = "tr_my_" + cnt;
	}
	else
	{
	    val = "tr_" + cnt; 	
	}

	eval(val).style.backgroundColor= clr;
}

// SELECT/UNSELECT ALL CHECKBOX
// parameters : form_name = string(form's name), checkbox_name = string(checkbox_name), sel_name = id tag name 
// RETURN : string(delimiter ",")
function select_message(form_name, checkbox_name, sel_name)
{
	var value;
	var clr;
	var o;
	var tElement = eval("document." + form_name + "." + checkbox_name);
	
	// Check Whether checkbox exists...
	if (tElement == undefined)
	{
		alert("There are no checkbox...");
		return;
	}

	if (sel_name == undefined)
	{
		o = document.all['allsel'];
	}
	else
	{
		o = eval("document.all['" + sel_name + "'];");
	}


	if ( __select_mode == 0 )
	{
		value = true;
		__select_mode = 1;
		o.innerHTML = "<img src='/Images/Button/bt_unselectall.gif' border='0'>";
		clr = '#FCF8F1';	
	}
	else
	{
		value = false;
		__select_mode = 0;
		o.innerHTML = "<img src='/Images/Button/bt_selectall.gif' border='0'>";
		clr = '#FFFFFF';	
	}

	o = eval("document." + form_name + "." + checkbox_name);

	var nCount = 0;
	if ( o != null )
	{
		if ( o.length != null ) 
		{
			for ( var i = 0 ; i < o.length ; i++ )
			{
//				if ((i % 100) == 0 && i != 0)
//				{
//					//alert("It takes a seconds. Wait... ");
//					//nCount = nCount + 10;
//					//document.getElementById("progbar").setAttribute("width", nCount);		
//				}
				o[i].checked = value;
				display_row(i+1, form_name, checkbox_name);
			}
		}
		else 
		{
			o.checked = value;
			display_row(1, form_name, checkbox_name);
		}
	}
}

// Get Checkbox Number String.(delimiter ",")
// parameters : form_name = string(form's name), checkbox_name = string(checkbox_name)
// RETURN : string(delimiter ",")
function get_sequence_string(form_name, checkbox_name)
{
	var s = "";

	var o = eval("document." + form_name + "." + checkbox_name);
	if ( o != null )
	{
		var lenobj = eval(o.length);
		if(lenobj != null)
		{	
			for ( var i = 0 ; i < o.length ; i++ )
			{
				if ( o[i].checked )
					s += (( s.length > 0 ? "," : "" ) + o[i].value );
			}
		}
		else {
			if ( o.checked )
				s += (( s.length > 0 ? "," : "" ) + o.value );
		}
	}
	return s;
}

//validate web address
function notWebAddress(field, fieldName, msg) {
	var webaddress = trim(field.value)

	if (webaddress == "") return false

	var http = false
	var dot = false

	if (webaddress.match("http://"))
	{
		http = true
		for (var i=0; i<webaddress.length; i++)
		{
			if (webaddress.charAt(i) == ".") dot = true
		}
	}

	if (!(http && dot && webaddress.length > 10)) {
		if (msg == null)
			msg = "The " + fieldName + " you entered is not a valid web address."

		alert(msg)
		field.focus()
		field.select()
		return true
	}

	//check for invalid characters
	if (invalidChars(field, "Web Address", '`%,;|" <>\\')) return true

	return false
}
//--------------------------- Admin Account -------------------------//
// Window Position  Setting to Center in Monitor
// Body Onload Event
function set_window_pos()
{
	var scrWidth = window.screen.width;
	var scrHeight = window.screen.height;
	var left = (scrWidth - 290) / 2;
	var top = (scrHeight - 165) / 2;

	this.resizeTo(290, 165);
	this.moveTo(left, top);
}
// Form(select, radio, checkbox) initialize by value
function select_input(input_name,input_value) {
    for ( i = 0 ; i < document.forms.length; i ++ ) {
        for ( j = 0 ; j < document.forms[i].elements.length; j++) {
            with(document.forms[i].elements[j]) {
                if(name == input_name) {
                    if( value == input_value) { checked=true; }
                        else if(type!='radio' && type != 'checkbox') { value=input_value; }
                }
            }
        }
    }
}

// Form(select, radio, checkbox) initialize by value
// Same upper, form_name added
function select_input2(form_name,input_name,input_value) {
    form_name = eval("document."+form_name);
    for ( j = 0 ; j < form_name.elements.length; j++) {
        with(form_name.elements[j]) {
            if(name == input_name) {
                if( value == input_value) { checked=true; }
                    else if(type!='radio' && type != 'checkbox') { value=input_value; }
            }
        }
    }
}

// Select Tag Initialize by value.
// obj : select name, value : option value
function setSelect(obj,value)
{
	if(value)
	{
		var tgtObj = document.getElementById(obj);
		tgtObj.value = value;
	}
}

// Edit Selected Affiliate Information
function edit_select()
{
	var s = get_sequence_string();
	if ( s == "" )
	{
		alert( "There are no selected affiliates..." );
		return;
	}
	var dm = "";
	if ( dm != "" || confirm( "Are  you sure that selected affiliate to edit??" ) )
	{
		//location = '/AUTH/mail.cgi?c=d&fm=&rnd=437b7cd117ff5145&m=SU5CT1g@&dm='+dm+'&n='+s+'&sk=&st=&so=0msgno&nc=l&r=0';
		alert(s);
	}
}

function approve_select()
{
	var s = get_sequence_string();
	if ( s == "" )
	{
		alert( "There are no selected affiliates..." );
		return;
	}
	var dm = "";
	if ( dm != "" || confirm( "Are  you sure that selected affiliate to approve??" ) )
	{
		//location = '/AUTH/mail.cgi?c=d&fm=&rnd=437b7cd117ff5145&m=SU5CT1g@&dm='+dm+'&n='+s+'&sk=&st=&so=0msgno&nc=l&r=0';
		alert(s);
	}
}

var __select_mode = 0;



// Close Window in Time
function startTime(){ 
        var time= new Date(); 
        hours= time.getHours(); 
        mins= time.getMinutes(); 
        secs= time.getSeconds(); 
        closeTime=hours*3600+mins*60+secs; 
        closeTime+=5;  // This number is how long the window stays open 
        Timer(); 
} 

function Timer(){ 
        var time= new Date(); 
        hours= time.getHours(); 
        mins= time.getMinutes(); 
        secs= time.getSeconds(); 
        curTime=hours*3600+mins*60+secs 
        if (curTime>=closeTime){ 
                self.close();} 
        else{ 
                window.setTimeout("Timer()",1000)} 
} 

// Change Cell Color in Table HTML Tag
function mouse_over(src, m_over){ 
  if (!src.contains(event.fromElement)) { 
   src.bgColor = m_over; 
  }
}

function mouse_out(src,m_out) { 
  if (!src.contains(event.toElement)) { 
   src.style.cursor = 'default'; 
   src.bgColor = m_out; 
  }
}

// Confirm Delete Command
function confirmDel(form, idx)
{
	if (confirm("Are you sure this deletion?\n it will be deleted!!!"))
	{
		form.idx.value = idx;
		form.submit();
	} 
	return true;
}

//open new window
function openWnd(url, name, height, width, directories, location, menubar, resizable, scrollbars, status, toolbar) {
	wnd = window.open(url, name, "alwaysRaised=1,height=" + height + ",width=" + width + ",directories=" + directories + ",locaton=" + location + ",menubar=" + menubar + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",status=" + status + ",toolbar=" + toolbar)
	wnd.focus()

}

//check whether text-box is empty
function isEmpty(field, fieldName, msg) {
	if (trim(field.value) == "") {
		if (msg == null || msg=="")
			msg = "Please enter " + fieldName + "."

		alert(msg)
		field.focus()
		return true
	}

	return false
}

//trim string
function trim(stringToTrim) {
	var i, j

	//left trim
	for(i=0; i<stringToTrim.length; i++) {
		if (stringToTrim.charAt(i) != " ") break
	}

	//right trim
	for(j=stringToTrim.length-1; j>=i; j--) {
		if (stringToTrim.charAt(j) != " ") break
	}

	return stringToTrim.substring(i, j + 1)
}

//validate email address
function notEmail(field, fieldName, msg) {
	var email = trim(field.value)

	if (email == "") return false

	var at = false
	var dot = false

	for (var i=0; i<email.length; i++) {
		if (email.charAt(i) == "@") at = true
		if (email.charAt(i) == "." && at) dot = true
	}

	if (!(at && dot && email.length > 5)) {
		if (msg == null)
			msg = "The " + fieldName + " you entered is not a valid e-mail address."

		alert(msg)
		field.focus()
		field.select()
		return true
	}

	//check for invalid characters
	if (invalidChars(field, "E-mail", '%,;|" <>\\/')) return true

	return false
}

//check whether passed validated control contains any of passes invalid characters (case insensitive)
function invalidChars(validatedControl, validatedName, charString, msg) {
	var validatedString = trim(validatedControl.value).toLowerCase()
	charString = charString.toLowerCase()

	for (var i=0; i<validatedString.length; i++) {
		for (var j=0; j<charString.length; j++) {
			if (validatedString.charAt(i) == charString.charAt(j)) {

				if (typeof (Common_Scripts_FuncLib_Space) == "undefined")
					Common_Scripts_FuncLib_Space = "space"

				var alertString = charString.split("").join("  ")
				alertString = alertString.split("     ").join("  " + Common_Scripts_FuncLib_Space + "  ")

				if (msg == null)
					msg = validatedName + " cannot contain any of the following illegal characters:\n\n " + alertString

				msg = msg.replace(/\[IllegalCharacters\]/, alertString)
				alert(msg)
				validatedControl.focus()
				return true
			}
		}
	}

	return false
}


// when click the input box, input box area cleared.
function clearText(thefield){
	if (thefield.defaultValue==thefield.value)
		thefield.value = ""
} 

// toggle div area show & hide
function toggleDiv(Id)
{
    div = document.getElementById(Id);
    if(div.style) {
      if ( div.style.display == 'block' ) {
        HideDiv(Id);
      }else if ( div.style.display == 'none' ) {
        ShowDiv(Id);
      }
    } else {
      if ( div.display == 'block' ) {
        HideDiv(Id);
      }else if ( div.display == 'none' ) {
        ShowDiv(Id);
      }
    }
  }

   function ShowDiv(Id) {
    div = document.getElementById(Id);
    if(div.style) {
      div.style.display = 'block';
    } else {
      div.display = 'block';
    }
  }

  function HideDiv(Id) {
    div = document.getElementById(Id);
    if(div.style) {
      div.style.display = 'none';
    } else {
      div.display = 'none';
   	}
  }

/*
function toggleDiv(element) {
	if (element.style.display == "none")
		{ element.style.display = ""; }
	else 	{ element.style.display = "none";
	}
}

function toggleDiv(element) {
	var tval = eval("document.selForm" + element);
	if (tval.style.visibility == "hidden") {
		tval.style.visibility = "visible"; 
		}
	else 	{
		tval.style.visibility = "none"; 
		}
}


function toggleDiv(name)
{
  var nscp = (navigator.appName == "Netscape") 
    var ismc = (navigator.appVersion.indexOf("Mac") != -1) 
    var vers = parseFloat(navigator.appVersion.substring(22,25)) 

    function getObj(obj) { 
       if (nscp) { 
           compLayr = document.layers[obj] 
       }else{ 
           compLayr = eval("document.all." + obj + ".style") 
       } 
       return compLayr 
    } 

    function showHide(name){ 
       obj = getObj(name) ;
           
       if (obj.visibility=="hidden"){ 
       obj.visibility = "visible" ;
       } else {
       obj.visibility = "hidden" ;
       } 
    } 
}
*/

// Function Name : getRadioValue
// Description : get checked radio button's value
// Paramter : radio_name = string that radio button's name
// Return : checked radio button's value
function getRadioValue(radio_name)
{
	var result;
    var temp = document.getElementsByName(radio_name); 

    for (i=0; i < temp.length; i++)
    { 
      if (temp[i].checked == true)
      {
        result = temp[i].value;
        break;
      }
    }

	return result;
}

//'===========================================================================================================
//' Addtional Functions were added by sooyong Kim
//'===========================================================================================================

//

// Check Number Or Dash Character
function checkNumDash(field,fieldName)
{	
	if(field.value=="")
	{
		return true;
	}else{
		var regNumDash = /^[0-9 ]+([0-9 ]|[\- ]{0,1})+$/; 

		pattern = regNumDash;
		if(!pattern.test(field.value))
		{ 
			alert("The "+fieldName+" that you provided is Invalid Type.\nYou Should Provide Numbers or - (dash) For "+fieldName+".\n"); 
			field.focus(); 
			return false; 
		} 
		return true; 
	}
}

// type==1 the name of a company
// type==2 a person's name


function checkNameType(field,fieldName,types){
	

	if(field.value=="")
	{
		
		return true;
	}else{
		
		
		if(types=='1'){
			
			var regNameType=/^([a-zA-Z ]|[0-9])+(([0-9]|[a-zA-Z])|[\' \.])+([0-9]|[a-zA-Z \.]{1})+$/;
			var msg="The "+fieldName+" that you provided is Invalid Type.\nYou Should Provide Alphabets,Numbers or '(single quote) For "+fieldName+".\n";
			
		}else if(types=='2'){
			var regNameType=/^[a-zA-Z ]+([a-zA-Z]|[\. ])+([a-zA-Z\. ]{1})+$/;
			var msg="The "+fieldName+" that you provided is Invalid Type.\nYou Should Provide Alphabets or .(dot) For "+fieldName+".\n";
		}
		pattern=regNameType;
		
		if(!pattern.test(field.value))
		{
			alert(msg); 
			field.focus(); 
			return false; 
		}else{
			return true;
		}
		
	}

}


// type 1 : for numbers
// type 2 : for characters
// type 3 : for characters and comma
function checkOneType(field,fieldName,types){
	if(field.value=="")
	{
		return true;
	}else{
		if(types=='1'){

			var regOneType=/^[0-9 ]+$/;
			var msg="You should use only NUMBERS for "+fieldName;
		}else if(types=='2'){
			var regOneType=/^[a-zA-Z ]+$/;
			var msg="You should use only Alphabets for "+fieldName;
		}else if(types=='3'){
			var regOneType=/^[a-zA-Z ,]+$/;
			var msg="You should use Alphabets and , (comma) for "+fieldName;
		}
		pattern=regOneType;

		if(!pattern.test(field.value)){
			alert(msg);
			field.focus();
			return false;
		}else{
			return true;
		}
	}
}

function checkEmail(field,fieldName,msg)
{
	
	if(field.value=="")
	{

		return true;
	}else{

		var msg=null;

		var retn_value=notEmail(field, fieldName, msg);

		return retn_value;
	}

}

function checkDateType(field,fieldName){
	if(field.value==""){
		return true;
	}else{
		var regDate=/^([0-9]|[0-9][0-9]){1}\-([0-9]|[0-9][0-9]){1}\-([0-9]{2}|[0-9]{4}){1}$/
		var msg="The Date,"+field.value+", you provided is invalid type\n\nPlease check it again.\n\nex) 11-19-2005(month-day-year)";

		pattern=regDate;
		if(!pattern.test(field.value)){
			alert(msg);
			field.focus();
			return false;
		}else{

			return true;
		}
	}
}

function ChkEmail(field,fieldName){
	if(field.value==""){
		return true;
	}else{
		var regDate=/(^\w+|\w+[.]{0,2}\w+)(@{1})([a-zA-Z\.]+$)/
		var msg="The Email Address That You Provided Is Invalid.\n\nPlease Check It Again.";
		pattern=regDate;
		if(!pattern.test(field.value)){
			alert(msg);
			return false;
		}else{
			return true;
		}
	}
}


function checkAddress(field,fieldName){
	if(field.value==""){
		return true;
	}else{
		var regAddr=/^([0-9#@ ]|[a-zA-Z@# ])+[\w\.\s\-@&,]*([0-9\. ]|[a-zA-Z\. ])$/
		var msg="The Address, "+field.value+", That You Provide\n Is Invalid Type. Please Check It Again.";

		pattern=regAddr;
		if(!pattern.test(field.value)){
			alert(msg);
			field.focus();
			return false;
		}else{

			return true;
		}
	}
}



// Open Pop-up Window  
function open_popup(url,name,width,height,left,top,scrollbars,resizable) 
{
window.open(url,name,'width='+width+',height='+height+',left='+left+',top='+top+',scrollbars='+scrollbars+',resizable='+resizable+'');
}


