<!--
/*************************** String Helper functions ***************************/

function IsEmailCorrect(szEmail) {
	var i;
	var strtmp = Trim(szEmail);

	for (i=0; i<strtmp.length; i++) {
		if (strtmp.charAt(i) > 'z' || strtmp.charAt(i) < '-' || ("/:;<=>?[\\]^` ".indexOf(strtmp.charAt(i)) != -1))
			return false;
	}
	if (CountStr(strtmp, "@") != 1 || strtmp.indexOf("..") != -1)
		return false;

	if (strtmp.charAt(0) == '@' || strtmp.charAt(strtmp.length - 1) == '@')
		return false;

	while ((i = strtmp.indexOf(".")) != -1) {
		if (i <= 0 || i >= (strtmp.length - 1))
			return false;
		if (strtmp.charAt(i - 1) == '@' || strtmp.charAt(i + 1) == '@')
			return false;
		strtmp = strtmp.substring(i + 1);
	}

	return true;
}

// return true if szStr contains space or empty. Otherwise, return false
function IsEmpty(szStr) {
	for(var i=0; i<szStr.length; i++) {
		if(szStr.charAt(i) == ' ')
			szStr = szStr.substring(i-- + 1, szStr.length);
		else
			break;
	}
	if(szStr.length)
		return false;
	else
		return true;
}

function IsEngString(szStr) {
	szStr = szStr.toLowerCase();
	for(var i=0; i<szStr.length; i++) {
		if(!((szStr.charAt(i) >= 'a' && szStr.charAt(i) <= 'z') || szStr.charAt(i) == ' ' || szStr.charAt(i) == '.'))
			return false;
	}
	return true;
}

function IsThaiString(szStr) {
	for(var i=0; i<szStr.length; i++) {
		//if(szStr.charCodeAt(i) <= 128 && szStr.charAt(i) != ' ')
		if(szStr.charCodeAt(i) >= 161)
			return true;
	}
	return false;
}

function IsAlphaNumeric(szStr) {
	szStr = szStr.toLowerCase();
	for(var i=0; i<szStr.length; i++) {
		if(!((szStr.charAt(i) >= 'a' && szStr.charAt(i) <= 'z') || (szStr.charAt(i) >= '0' && szStr.charAt(i) <= '9')))
			return false;
	}
	return true;
}

function IsNumeric(szStr) {
	for(var i=0; i<szStr.length; i++) {
		if("0123456789+-.,".indexOf(szStr.charAt(i)) == -1)
			return false;
	}
	return true;
}

function CountStr(strSrc, strFind) {
	var i, nCount = 0;

	while ((i = strSrc.indexOf(strFind)) != -1) {
		nCount++;
		strSrc = strSrc.substring(i + strFind.length, strSrc.length);
	}

	return nCount;
}

function Left(szStr, nChar)
{
	if(szStr.length > nChar)
		return szStr.substring(0, nChar);
	else
		return szStr
}

function Right(szStr, nChar)
{
	if(szStr.length > nChar)
		return szStr.substring(szStr.length - nChar, szStr.length);
	else
		return szStr;
}

// Because of the build-in function ".replace" cannot replace any string with the empty string
// the only way we can do is the following...
function RemoveStr(szStr, szRemove)
{
	var sztmp, i;

	while((i = szStr.indexOf(szRemove)) != -1) {
		sztmp = szStr.substring(0, i);
		sztmp += szStr.substring(i + szRemove.length, szStr.length);
		szStr = sztmp;
	}

	return szStr;
}

// Remove white space on the both side;
function Trim(szStr) {
	return TrimLeft(TrimRight(szStr));
}

// Remove white space on the left side;
function TrimLeft(szStr) {
	for(var i=0; i<szStr.length; i++) {
		if(szStr.charAt(i) == ' ')
			szStr = szStr.substring(i-- + 1, szStr.length);
		else
			break;
	}
	return szStr;
}

// Remove white space on the right side;
function TrimRight(szStr) {
	for(var i=szStr.length - 1; i>=0; i--) {
		if(szStr.charAt(i) == ' ')
			szStr = szStr.substring(0, i);
		else
			break;
	}
	return szStr;
}

// Is there the szStr contain any space ?
function ContainSpace(szStr) {
	if(szStr.indexOf(' ') != -1)
		return true;
	return false;
}

// Conver two or more space to the single space
function CompactSpace(szStr) {
	var nSpace = 0;
	var sztmp;
	for(var i=0; i<szStr.length; i++) {
		if(szStr.charAt(i) == ' ') {
			nSpace++;
		}
		else
			nSpace = 0;

		if(nSpace >= 2) {
			nSpace = 0;
			sztmp = szStr.substring(0, i);
			szStr = sztmp + szStr.substring(i + 1, szStr.length);
			i--;
		}
	}
	return szStr;
}


/*************************** Day Month and Year Helper functions ***************************/

/*
	Initialize Day, Month and Year comboboxes with Thai or English style and display the current
	day, month and year if necessary.
	Ex 1.. fill-up the day month and year comboboxes with the english style
		- InitDate(document.frm.cmbMonth, document.frm.cmbDay, document.frm.cmbYear, false, null);

	Ex 2.. fill-up the day month and year comboboxes with the thai style and display the current day month and year
		- InitDate(document.frm.cmbMonth, document.frm.cmbDay, document.frm.cmbYear, true, new Date());
*/
function InitDate(cmbMonth, cmbDay, cmbYear, bThai, dtDefault) {
	var i, j, n;
	var dt = new Date();
	var arrThMonth = new Array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
	var arrEnMonth = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

	if(cmbMonth != null) {
		while(cmbMonth.options.length)
			cmbMonth.options[0] = null;
		cmbMonth.options[0] = new Option(" -- ", 0);
		for(i=0; i<arrThMonth.length; i++)
			cmbMonth.options[i + 1] = new Option((bThai)? arrThMonth[i]:arrEnMonth[i], i + 1);
		if(dtDefault != null) {
			cmbMonth.selectedIndex = dtDefault.getMonth() + 1;
		}
	}

	if(cmbDay != null) {
		while(cmbDay.options.length)
			cmbDay.options[0] = null;
		cmbDay.options[0] = new Option(" -- ", 0);
		for(i=1; i<=31; i++)
			cmbDay.options[i] = new Option(i, i);
		if(dtDefault != null)
			cmbDay.selectedIndex = dtDefault.getDate();
	}

	if(cmbYear != null) {
		while(cmbYear.options.length)
			cmbYear.options[0] = null;
		cmbYear.options[0] = new Option(" -- ", 0);
		if(dtDefault != null)
			j = dtDefault.getYear() + ((dtDefault.getYear() < 1900)? 1900:0)
		n = dt.getYear() + ((dt.getYear() < 1900)? 1900:0);
		for(i=n-4; i<n + 3; i++) {
			cmbYear.options[cmbYear.options.length] = new Option((bThai)? i + 543:i, i);
			if(dtDefault != null)
				if(i == j)
					cmbYear.selectedIndex = cmbYear.options.length - 1;
		}
	}
}

/*
	Validate the selected day month and year for leap year, worng date and correct them if necessary.
	Ex 1..
		- <select name="cmbDay" onChange="dateValidation(this, this.form.cmbMonth, this.form.cmbYear);"></select>
*/
function dateValidation(cmbDay, cmbMonth, cmbYear) {
	if(cmbDay.options.selectedIndex == 0 || cmbMonth.options.selectedIndex == 0 || cmbYear.options.selectedIndex == 0)
		return;

	var nDay = cmbDay.options[cmbDay.options.selectedIndex].value;
	var nMonth = cmbMonth.options[cmbMonth.options.selectedIndex].value;
	var nYear = cmbYear.options[cmbYear.options.selectedIndex].value;
	var nMaxDay = 0;

	if(nMonth == 4 || nMonth == 6 || nMonth == 9 || nMonth == 11)
		nMaxDay = 30;
	else if(nMonth == 2) {
		if(nYear % 4 == 0 && (nYear % 100 != 0 || nYear % 400 == 0))
			nMaxDay = 29;
		else
			nMaxDay = 28;
	}
	else
		nMaxDay = 31;

	if(nDay > nMaxDay) {
		cmbDay.options.selectedIndex = nMaxDay;
	}
}

/*
	Force the specified Day, Month and Year couldn't be selects date before the specified Date or Now!
	Ex ..
		- DMYFromNow(cmbDay, cmbMonth, cmbYear, new Date('Jan 1, 2000'));
		- DMYFromNow(cmbDay, cmbMonth, cmbYear, null);
*/
function DMYFromNow(cmbDay, cmbMonth, cmbYear, dtmComp) {
	if (cmbDay == null || cmbMonth == null || cmbYear == null)
		return;
	if (dtmComp == null)
		dtmComp = new Date();

	var dtmtmp = new Date(cmbYear.options[cmbYear.selectedIndex].value, cmbMonth.options[cmbMonth.selectedIndex].value - 1, cmbDay.options[cmbDay.selectedIndex].value);
	if (dtmtmp < dtmComp) {
		cmbDay.selectedIndex = dtmComp.getDate();
		cmbMonth.selectedIndex = dtmComp.getMonth() + 1;
		for (var i=0; i<cmbYear.options.length; i++) {
			if (cmbYear.options[i].value == dtmComp.getYear()) {
				cmbYear.selectedIndex = i;
				break;
			}
		}
	}
}

function DMYToNow(cmbDay, cmbMonth, cmbYear, dtmComp) {
	if (cmbDay == null || cmbMonth == null || cmbYear == null)
		return;
	if (dtmComp == null)
		dtmComp = new Date();

	var dtmtmp = new Date(cmbYear.options[cmbYear.selectedIndex].value, cmbMonth.options[cmbMonth.selectedIndex].value - 1, cmbDay.options[cmbDay.selectedIndex].value);
	if (dtmtmp > dtmComp) {
		cmbDay.selectedIndex = dtmComp.getDate();
		cmbMonth.selectedIndex = dtmComp.getMonth() + 1;
		for (var i=0; i<cmbYear.options.length; i++) {
			if (cmbYear.options[i].value == dtmComp.getYear()) {
				cmbYear.selectedIndex = i;
				break;
			}
		}
	}
}

/*
Get Max Day of the given month and year
*/
function GetMaxDay(nMonth, nYear) {
	var nMaxDay = 0;

	if(nMonth == 4 || nMonth == 6 || nMonth == 9 || nMonth == 11)
		nMaxDay = 30;
	else if(nMonth == 2) {
		if(nYear % 4 == 0 && (nYear % 100 != 0 || nYear % 400 == 0))
			nMaxDay = 29;
		else
			nMaxDay = 28;
	}
	else
		nMaxDay = 31;

	return nMaxDay;
}

/*
format the given data in currency format ex. xx,xxx,xxx.xxx
*/
function GetCurrency(szInput) {
	var sztmp;
	var szSubfix;
	var i, n;
	var bDot;

	if(szInput.length <= 3 || szInput.indexOf(",") != -1)
		return szInput;

	szSubfix = "";
	if((i = szInput.indexOf(".")) != -1) {
		bDot = true;
		szSubfix = szInput.substring(i + 1);
		szInput = szInput.substring(0, i);
		if(szSubfix.length >= 2)
			szSubfix = szSubfix.substring(0, 2);
		else
			szSubfix += "0";
	}
	else
		bDot = false;

	sztmp = "";
	n = szInput.length - 1;
	i = 0;
	while(n >= 0) {
		sztmp += szInput.charAt(n--);
		if(++i >= 3 && n >= 0) {
			sztmp += ",";
			i = 0;
		}
	}
	if(bDot)
		sztmp = ReverseString(sztmp) + "." + szSubfix;
	else
		sztmp = ReverseString(sztmp);
	return sztmp;
}

/*
just reverse the given string (GetCurrency's helper function)
*/
function ReverseString(szInput) {
	var sztmp;
	var i;

	i = 0;
	sztmp = "";
	for(i = szInput.length; i>=0; i--)
		sztmp += szInput.substring(i - 1, i);

	return sztmp;
}

function DoOpenPicServer(picName)
{
  var winHandle = window.open("","picwin","resizable=yes,scrollbars=yes,status=yes,width=400,height=400")
  if(winHandle != null){
    var htmlString = "<html><head><title>Picture</title></head>"  
          htmlString += "<img src='"+   picName + "'>"
          htmlString += "</body></html>"
    winHandle.document.open()
    winHandle.document.write(htmlString)
    winHandle.document.close()
    }	
  //if(winHandle != null) winHandle.focus() //brings window to top
  //return winHandle 	  
}

function DoOpenPicLocal(picName)
{
     /*alert(picName);
     mywin = window.open(picName,"picwin","scrollbars=yes,status=yes,width=400,height=400");  */
	if ( picName == "" ) {
		alert("Please select the picture file first!");
		return ;
	}
	var strPic = '';
	//alert(picName);
   	for(var i=0; i<picName.length; i++) {
		   //alert( picName.charAt(i));
		   if(   picName.substring(i ,i+1)  == "\\"  ) 
		   {
		        strPic = strPic  + "/" ;
		   }
		   else

		    strPic = strPic + picName.charAt(i);
		
	} 

   //alert(strPic);

   var winHandle = window.open("","picwin","resizable=yes,scrollbars=yes,status=yes,width=400,height=400")
   if(winHandle != null){
    var htmlString = "<html><head><title>Picture</title></head>"  
          htmlString += "<img src='file://"+   strPic + "'>"
          htmlString += "</body></html>"
    winHandle.document.open()
    winHandle.document.write(htmlString)
    winHandle.document.close()
    } 	
}

function DoOpenPicLocalThai(picName)
{
     /*alert(picName);
     mywin = window.open(picName,"picwin","scrollbars=yes,status=yes,width=400,height=400");  */
	if ( picName == "" ) {
		alert("กรุณาเลือกรูปที่จะส่ง");
		return ;
	}
	var strPic = '';
	//alert(picName);
   	for(var i=0; i<picName.length; i++) {
		   //alert( picName.charAt(i));
		   if(   picName.substring(i ,i+1)  == "\\"  ) 
		   {
		        strPic = strPic  + "/" ;
		   }
		   else

		    strPic = strPic + picName.charAt(i);
		
	} 

   //alert(strPic);

   var winHandle = window.open("","picwin","resizable=yes,scrollbars=yes,status=yes,width=400,height=400")
   if(winHandle != null){
    var htmlString = "<html><head><title>Picture</title></head>"  
          htmlString += "<img src='file://"+   strPic + "'>"
          htmlString += "</body></html>"
    winHandle.document.open()
    winHandle.document.write(htmlString)
    winHandle.document.close()
    } 	
}

function MM_openMailToWindow(theURL) { //v2.0
  var features = "width=577,height=382,screenx=0,screeny=0,top=0,left=0";
  var winName = "popmail";
  window.open(theURL,winName,features);
}

function IsInteger(szStr) {
	for(var i=0; i<szStr.length; i++) {
		// dot is not allow for integer
		if("0123456789+-,".indexOf(szStr.charAt(i)) == -1)
			return false;
	}
	return true;
}

function IsDecimal(szStr, leading, decimal) {
	var dotCount = 0;
	for(var i=0;i<szStr.length;i++) {
		if("0123456789+-.,".indexOf(szStr.charAt(i)) == -1) {
			return false;
		}
		else { // need to check if there are more than one dot
			if(".".indexOf(szStr.charAt(i)) != -1)
				dotCount++;
		}
	}

	if(dotCount > 1)  // more than one dot
		return false;

	if(decimal < 1 && dotCount > 0)
		return false;

	var dotIndex = szStr.indexOf(".");
	if(dotIndex == -1) { // no dot, consider only leading and leght of number
		if(szStr.length > leading)
			return false;
	}
	else {
		if(dotIndex > leading)  // integer number is more than leading allow
			return false;
		if((szStr.length - (dotIndex+1)) > decimal) // decimal number is more than decimal allow
			return false;
	}

	return true;
}

/*
		just like InitDate, only some slightly changes
*/
function InitLongRangeDate(cmbMonth, cmbDay, cmbYear, bThai, dtDefault, below, more) {
	var i, j, n;
	var dt = new Date();
	var arrThMonth = new Array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
	var arrEnMonth = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

	if(cmbMonth != null) {
		while(cmbMonth.options.length)
			cmbMonth.options[0] = null;
		cmbMonth.options[0] = new Option("เดือน", 0);
		for(i=0; i<arrThMonth.length; i++)
			cmbMonth.options[i + 1] = new Option((bThai)? arrThMonth[i]:arrEnMonth[i], i + 1);
		if(dtDefault != null) {
			cmbMonth.selectedIndex = dtDefault.getMonth() + 1;
		}
		else {
			cmbMonth.selectedIndex = 0;
		}
	}

	if(cmbDay != null) {
		while(cmbDay.options.length)
			cmbDay.options[0] = null;
		cmbDay.options[0] = new Option("วันที่", 0);
		for(i=1; i<=31; i++)
			cmbDay.options[i] = new Option(i, i);
		if(dtDefault != null)
			cmbDay.selectedIndex = dtDefault.getDate();
		else {
			cmbDay.selectedIndex = 0;
		}
	}

	if(cmbYear != null) {
		while(cmbYear.options.length)
			cmbYear.options[0] = null;
		cmbYear.options[0] = new Option("ปี", 0);
		if(dtDefault != null)
			j = dtDefault.getYear() + ((dtDefault.getYear() < 1900)? 1900:0)
		n = dt.getYear() + ((dt.getYear() < 1900)? 1900:0);
		for(i=n-below; i<n+more+1; i++) {
			cmbYear.options[cmbYear.options.length] = new Option((bThai)? i + 543:i, i);
			if(dtDefault != null)
				if(i == j)
					cmbYear.selectedIndex = cmbYear.options.length - 1;
		}
		if(dtDefault == null)
			cmbYear.selectedIndex = 0;
	}
}

/*
		just like InitDate, only some slightly changes, special for premium offer and policy service in is
*/
function InitShorterLongRangeDate(cmbMonth, cmbDay, cmbYear, bThai, dtDefault, below, more) {
	var i, j, n;
	var dt = new Date();
	var arrThMonth = new Array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
	var arrEnMonth = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

	if(cmbMonth != null) {
		while(cmbMonth.options.length)
			cmbMonth.options[0] = null;
		cmbMonth.options[0] = new Option("เดือน", 0);
		for(i=0; i<arrThMonth.length; i++)
			cmbMonth.options[i + 1] = new Option((bThai)? arrThMonth[i]:arrEnMonth[i], i + 1);
		if(dtDefault != null) {
			cmbMonth.selectedIndex = dtDefault.getMonth() + 1;
		}
		else {
			cmbMonth.selectedIndex = 0;
		}
	}

	if(cmbDay != null) {
		while(cmbDay.options.length)
			cmbDay.options[0] = null;
		cmbDay.options[0] = new Option("วันที่", 0);
		for(i=1; i<=31; i++)
			cmbDay.options[i] = new Option(i, i);
		if(dtDefault != null)
			cmbDay.selectedIndex = dtDefault.getDate();
		else {
			cmbDay.selectedIndex = 0;
		}
	}

	if(cmbYear != null) {
		while(cmbYear.options.length)
			cmbYear.options[0] = null;
		cmbYear.options[0] = new Option("ปี", 0);
		if(dtDefault != null)
			j = dtDefault.getYear() + ((dtDefault.getYear() < 1900)? 1900:0)
		n = dt.getYear() + ((dt.getYear() < 1900)? 1900:0);
		for(i=n-below; i<n+more+1; i++) {
			cmbYear.options[cmbYear.options.length] = new Option((bThai)? i + 543:i, i);
			if(dtDefault != null)
				if(i == j)
					cmbYear.selectedIndex = cmbYear.options.length - 1;
		}
		if(dtDefault == null)
			cmbYear.selectedIndex = 0;
	}
}

// boom added
function skip(e) {
	this.blur();
}

function disable(component) {
	component.disabled = true;
	// netscape also add this
	component.onfocus = skip;
}

function enable(component) {
	component.disabled = false;
	// netscape also add this
	component.onfocus = null;
}
// end boom added

// balloon added

// get all checkbox value (String formate)
function  Chk_DeleteId_char(frm,chkname) 
{ 
	var del_id = "";
	for (var i = 0; i < frm.elements.length; i++)  
	{ 
		if(frm.elements[i].name == chkname )	 
		{ 
			if (frm.elements[i].checked == true ) {
				if(frm.elements[i].value.length > 0) {
					del_id = del_id+"'"+frm.elements[i].value+"',";
				}
			}
		}       
	} 
	return del_id;
}	

// get all checkbox value (String formate)
function  Chk_DeleteId(frm,chkname) 
{ 
	var del_id = "";
	var count = 0;
	for (var i = 0; i < frm.elements.length; i++)  
	{ 
		if(frm.elements[i].name == chkname )	 
		{ 
			if (frm.elements[i].checked == true ) {
				if(frm.elements[i].value.length > 0) {
					if (count > 0)
					{
						del_id = del_id + ","
					}
					del_id = del_id+frm.elements[i].value;
					count++;
				}
			}
		}       
	} 
	return del_id;
}	

// count checkbox checked
function Chk_Count(frm,chkname)
{
	var count = 0;
	for (var i = 0; i < frm.elements.length; i++)  
	{ 
		if(frm.elements[i].name == chkname )	 
		{ 
			if (frm.elements[i].checked == true ) {
				if(frm.elements[i].value.length > 0) {
					count++;
				}
			}
		}       
	} 
	return count;
}

function IsMonthYear(szStr) {
	if(szStr.length != 7)
		if(szStr.length != 6)
			return false;

    var szMonth;
	var szSlash;
	var szYear;

	if(szStr.length == 7) {
		szMonth = szStr.substring(0, 2);
		szSlash = szStr.substring(2, 3);
		szYear = szStr.substring(3,  7);
	}
	else if(szStr.length == 6) {
		szMonth = szStr.substring(0, 1);
		szSlash = szStr.substring(1, 2);
		szYear = szStr.substring(2, 6);
	}

	var nMonth = parseInt(szMonth);
	if(nMonth < 1 || nMonth > 12)
		return false;

	 var x = IsInteger(szYear) && (szSlash == "/");
	 return x;
	}

	function IsOnlyNumber(szStr) {
		for(var i=0;i<szStr.length;i++) {
			// except number, nothing is allow
			if("0123456789".indexOf(szStr.charAt(i)) == -1)
				return false;
		}
		return true;
	}

function IsPositiveNumeric(szStr) {
	for(var i=0; i<szStr.length; i++) {
		if("0123456789+.,".indexOf(szStr.charAt(i)) == -1)
			return false;
	}
	return true;
}

function popup(filename,wname,wnum,hnum){
//alert ('width='+wnum+','+'height='+hnum)
	cx=((screen.width-wnum)/2);
	cy=((screen.height-hnum)/2);
	window.open(filename,wname,'width='+wnum+','+'height='+hnum+','+'left='+cx+','+'top='+cy);
}
function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.0
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

nereidFadeObjects = new Object();
nereidFadeTimers = new Object();
function nereidFade(object, destOp, rate, delta){
if (!document.all)
return
    if (object != "[object]"){  //do this so I can take a string too
        setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0);
        return;
    }
        
    clearTimeout(nereidFadeTimers[object.sourceIndex]);
    
    diff = destOp-object.filters.alpha.opacity;
    direction = 1;
    if (object.filters.alpha.opacity > destOp){
        direction = -1;
    }
    delta=Math.min(direction*diff,delta);
    object.filters.alpha.opacity+=direction*delta;

    if (object.filters.alpha.opacity != destOp){
        nereidFadeObjects[object.sourceIndex]=object;
        nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
    }
}

function selectAll(Obj,RecCnt){
if (RecCnt==1) {
	Obj.checkBox.checked=Obj.selectall.checked;	
}

if (RecCnt>1) {
 	for(i = 0; i < Obj.checkBox.length; i++) {
    	Obj.checkBox[i].checked = Obj.selectall.checked;
	}
}
}

function addbookmark() {
	bookmarkurl=window.location.href;
	bookmarktitle=document.title;

	if (window.external) {
		window.external.AddFavorite(bookmarkurl,bookmarktitle)
	} else {
		msg = "Your browser does not support this feature.  If you are using Netscape Navigator\n";
		msg = msg + "Click \"Bookmarks\" and then \"Add Bookmark\"  or type \"Ctrl+D\" to add this site to your favorites.";
		alert(msg);
	}
}

function mail2friend(email) {
	window.open('http://203.107.136.8/global/mail2friend/mail2friend.php?url=' + window.location.href + '&email=' + email, 'mail2friend', 'width=557,height=360,status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no');
}

function chkAll(frm, arr, mark) 
{  
//<input type="checkbox" class="checkbox" name="ca" value="true" onClick="chkAll(this.form, 'del[]', this.checked)"> 
//กำหนดให้ checkbox อื่น ชื่อ name=del[]
  for (i = 0; i <= frm.elements.length; i++) {
   try{
     if(frm.elements[i].name == arr) {
       frm.elements[i].checked = mark;
     }
   } catch(er) {}
  }
}

function check_text(iform,el_name) //iform ระบุ this.form, el_name ระบุ ชื่อ control ตามลำดับ
{
var message=" Application Form \nThe following   field(s) needs to be completed or redone before your application is complete: \n";
var objForm = eval(iform);
var len = eval(objForm.length);
var sum=el_name.split(",");
var check=0;
var y=0;

for(var i=0;i<len;i++){
	if(objForm.elements[i].name==sum[y])
	{
		if (objForm.elements[i].value=='')
        {
			message=message+"   * "+sum[y].toUpperCase()+" \n";
            y++;
            check=1;
        } else {
            y++;
        }
    }
}

if (check==1)
{
	alert(message);
    return false;
} else {
    return true;
}

}

function handleEnter (field, event) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 
		else
		return true;
	}      

//generic popup window
function popup(winname, url, height, width, scroll) {
	var features = "dependent=yes,height=" + height + ",width=" + width + ",location=no,menubar=no,resizable=yes,screenX=200,left=200,screenY=200,top=200,status=no,toolbar=no,scrollbars=" + scroll;
	var remote = open(url, winname, features);
	if (remote.opener == null)
		remote.opener = window;
}

function popImage(imageURL,imageTitle){

PositionX = 0;
	PositionY = 0;

	defaultWidth  = "800";
	defaultHeight = "600";

	var AutoClose = true;

	// Do not edit below this line...
	// ================================
	
if (parseInt(navigator.appVersion.charAt(0))>=4){
	var isNN=(navigator.appName=='Netscape')?1
		:0;
	var isIE=(navigator.appName.indexOf('Microsoft')!=-1)?1:0;}
	if(defaultHeight > screen.height)
	{
		var optNN='scrollbars=no,width='+defaultWidth+',height='+screen.heigth+',left='+PositionX+',top='+PositionY;
	}
	else if(defaultWidth > screen.width)
	{
		var optNN='scrollbars=no,width='+screen.width+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
	}
	else if((defaultWidth > screen.width) && (defaultHeight > screen.height))
	{
		var optNN='scrollbars=no,width='+screen.width+',height='+screen.height+',left='+PositionX+',top='+PositionY;
	}
	else
	{
		var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
	}
	var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;	

if (isNN){imgWin=window.open('about:blank','',optNN);}
	
if (isIE){imgWin=window.open('about:blank','',optIE);}
	
with (imgWin.document){

writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
writeln('<sc'+'ript>');
	
writeln('var isNN,isIE;');
writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
	
writeln('isNN=(navigator.appName==\"Netscape\")?1:0;');
writeln('isIE=(navigator.appName.indexOf(\"Microsoft\")!=-1)?1:0;}');
	
writeln('function reSizeToImage(){');
writeln('if (isIE){');
writeln('window.resizeTo(100,100);');
	
writeln('width=100-(document.body.clientWidth-document.images[0].width);');
	
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
	
writeln('if(width > screen.width){width = screen.width-50;}');
	
writeln('if(height > screen.height){height = screen.height-50;}');
	
writeln('window.resizeTo(width,height);}');
writeln('if (isNN){');   
	
writeln('window.innerWidth=width;');
writeln('window.innerHeight=height;}}');
	
writeln('function doTitle(){document.title=\"'+imageTitle+'\";}');
writeln('</sc'+'ript>');
	
if (!AutoClose) writeln('</head><body bgcolor=#ffffff scroll=\"auto\" onload=\"reSizeToImage();doTitle();self.focus()\">')
	else writeln('</head><body bgcolor=#ffffff scroll=\"\" onload=\"reSizeToImage();doTitle();self.focus()\" onblur=\"self.close()\">');
	
writeln('<img src='+imageURL+' style=\"display:block\"></body></html>');

close();}
}


// load htmlarea
	_editor_url = "";                     // URL to htmlarea files
	var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
	if (navigator.userAgent.indexOf('Mac')        >= 0) { win_ie_ver = 0; }
	if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
	if (navigator.userAgent.indexOf('Opera')      >= 0) { win_ie_ver = 0; }
	if (win_ie_ver >= 5.5) {
		 document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
		 document.write(' language="Javascript1.2"></scr' + 'ipt>');  
	} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
	

browserName = navigator.appName; 
browserVer = parseInt(navigator.appVersion); 

ns3up = (browserName == "Netscape" && browserVer >= 3); 
ie4up = (browserName.indexOf("Microsoft") >= 0 && browserVer >= 4); 
// end 
//-->