/***** Control *****/
var old_bgcolor;
var old_class;
function ShowBar(src) {
	if (!src.contains(event.fromElement)) {
		src.style.cursor = 'hand';
		old_class = src.className;
		src.className = 'tableselecteditem';
	}
}
function ShowBar2(src) {
	if (!src.contains(event.fromElement)) {
		old_class = src.className;
		src.className = 'tableselecteditem';
	}
}
function HideBar(src) {
	if (!src.contains(event.toElement)) {
		src.style.cursor = 'default';
		src.className = old_class;
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


/***** Utility *****/
function To_Num(N){
	if (N != ''){
		if (typeof(N)=='string') {
			var convertedString = N.split(',');
			convertedString = convertedString.join('');
			return parseFloat(convertedString);
		} else { 
			return N; 
		}
	} else {
		return 0;
	}
}

function FormatDate(DateToFormat,FormatAs){
	if(DateToFormat==""){return"";}
	if(!FormatAs){FormatAs="dd/mm/yyyy";}
	var strReturnDate;
	FormatAs = FormatAs.toLowerCase();
	DateToFormat = DateToFormat.toLowerCase();
	var arrDate;
	var arrMonths = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	var strMONTH;
	var Separator;
	while(DateToFormat.indexOf("st")>-1){
		DateToFormat = DateToFormat.replace("st","");
	}
	while(DateToFormat.indexOf("nd")>-1){
		DateToFormat = DateToFormat.replace("nd","");
	}
	while(DateToFormat.indexOf("rd")>-1){
		DateToFormat = DateToFormat.replace("rd","");
	}
	while(DateToFormat.indexOf("th")>-1){
		DateToFormat = DateToFormat.replace("th","");
	}
	if(DateToFormat.indexOf(".")>-1){
		Separator = "/";
	}
	if(DateToFormat.indexOf("-")>-1){
		Separator = "/";
	}
	if(DateToFormat.indexOf("/")>-1){
		Separator = "/";
	}
	if(DateToFormat.indexOf(" ")>-1){
		Separator = "/";
	}
	arrDate = DateToFormat.split(Separator);
	DateToFormat = "";
	for(var iSD = 0;iSD < arrDate.length;iSD++){
		if(arrDate[iSD]!=""){
			DateToFormat += arrDate[iSD] + Separator;
		}
	}
	DateToFormat = DateToFormat.substring(0,DateToFormat.length-1);
	arrDate = DateToFormat.split(Separator);
	if(arrDate.length < 3){
		return "";
	}
	var DAY = arrDate[0];
	var MONTH = arrDate[1];
	var YEAR = arrDate[2];
	if(parseFloat(arrDate[1]) > 12){
		DAY = arrDate[1];
		MONTH = arrDate[0];
	}
	if(parseFloat(DAY) && DAY.toString().length==4){
		YEAR = arrDate[0];
		DAY = arrDate[2];
		MONTH = arrDate[1];
	}
	for(var iSD = 0;iSD < arrMonths.length;iSD++){
		var ShortMonth = arrMonths[iSD].substring(0,3).toLowerCase();
		var MonthPosition = DateToFormat.indexOf(ShortMonth);
		if(MonthPosition > -1){
			MONTH = iSD + 1;
			if(MonthPosition == 0){
				DAY = arrDate[1];
				YEAR = arrDate[2];
			}
			break;
		}
	}
	var strTemp = YEAR.toString();
	if(strTemp.length==2){
		if(parseFloat(YEAR)>40){
			YEAR = "19" + YEAR;
		} else {
			YEAR = "20" + YEAR;
		}
	}
	if(parseInt(MONTH)< 10 && MONTH.toString().length < 2){
		MONTH = "0" + MONTH;
	}
	if(parseInt(DAY)< 10 && DAY.toString().length < 2){
		DAY = "0" + DAY;
	}
	switch (FormatAs){
		case "dd/mm/yyyy":
			return DAY + "/" + MONTH + "/" + YEAR;
		case "mm/dd/yyyy":
			return MONTH + "/" + DAY + "/" + YEAR;
		case "dd/mmm/yyyy":
			return DAY + " " + arrMonths[MONTH -1].substring(0,3) + " " + YEAR;
		case "mmm/dd/yyyy":
			return arrMonths[MONTH -1].substring(0,3) + " " + DAY + " " + YEAR;
		case "dd/mmmm/yyyy":
			return DAY + " " + arrMonths[MONTH -1] + " " + YEAR;	
		case "mmmm/dd/yyyy":
			return arrMonths[MONTH -1] + " " + DAY + " " + YEAR;
	}
	return DAY + "/" + strMONTH + "/" + YEAR;;
}

function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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_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];}
}



/******************** Print ********************/
function Pageprint()
{ 
  var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,resizable=yes,"; 
      disp_setting+="scrollbars=yes,width=700, height=620, left=100, top=25"; 
  var content_P = document.getElementById("printcontent").innerHTML; 
  
  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-874" /><title>ºÃÔÉÑ· »µ·. ¨Ó¡Ñ´ (ÁËÒª¹)</title>'); 
   //docprint.document.write('<link href="../css/tab_ngvfocus.css" rel="stylesheet" type="text/css" /><script src="../js/tab_ngv_focus_new.js" type="text/javascript"></script>');
   docprint.document.write('<link href="../css/NGV.css" rel="stylesheet" type="text/css" /><script src="../includes/Utility.js" type="text/javascript"></script></head>');
   docprint.document.write('<body onLoad="self.print()">');
   docprint.document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
   docprint.document.write('<tr><td height="300" valign="top">');
   docprint.document.write(content_P);
   docprint.document.write('</td></tr><tr><td height="1" bgcolor="#999999"></td></tr>');
   docprint.document.write('<tr><td height="30" class="ptt1"><b>Print from:</b>  <script>document.write(document.URL)</script></td>');
   docprint.document.write('<tr><td height="30" class="ptt1">&copy; Ê§Ç¹ÊÔ¢ÊÔ·¸Ôì 2551 ºÃÔÉÑ· »µ·. ¨Ó¡Ñ´ (ÁËÒª¹)</td></tr></table>');
   docprint.document.write('</body></html>'); 
   docprint.document.close(); 
   docprint.focus(); 
}