// JavaScript Document

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// getitem
// setitem
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function newXmlHttp(){
	var xmlhttp = false;
	
	try{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}catch(e){
		try{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}catch(e){
			xmlhttp = false;
		} //end try
	} //end try
	
	if(!xmlhttp && document.createElement){
		xmlhttp = new XMLHttpRequest();
	} //end if
	
	return xmlhttp;
} //end function		


function getValReturn( prmkeyword, prmstring ) {	
	var inxpipe, inxequal;
	var inx = prmstring.indexOf( prmkeyword );
	var lssub = "";
	
	if ( inx >= 0 ) {
		inxequal 	= prmstring.indexOf( "=", inx );
		inxpipe 		= prmstring.indexOf( "|", inx );
		lssub 		= prmstring.substring( inxequal + 1, inxpipe );
	}else{
		lssub			= "";
	} //end if
	
	return lssub;
} //end function
									
function getitem( prmid ) {
	if ( document.getElementById( prmid ) ) {
		return document.getElementById( prmid ).value;	
	}else{
		alert("Not Found Object Name : " + prmid );
	} //end if
} //end function

function setitem( prmid, prmvalue ) {
	if ( document.getElementById( prmid ) ) {
		document.getElementById( prmid ).value = prmvalue;	
	}
} //end function

function focusitem( prmid ) {
	if ( document.getElementById( prmid ) ) {
		document.getElementById( prmid ).select();	
	}	
} //end function

function getCurDate() {
	var ldnow = new Date();
	var lsCurdate = padNum( String( ldnow.getDate() ) ) + "/" 
							+ padNum( String( ldnow.getMonth() + 1 ), 2 ) + "/" 
							+ ( ldnow.getFullYear() + 543 );	
	return lsCurdate;
} //end function

function padNum(number, numDigits) {
	var str = number.toString();
	while (str.length < numDigits) str = '0' + str;
	return(str);
}		


function iif( prmcondition, prmtrue, prmfalse ) {
	alert("mmmm");
	if ( prmcondition ) {
		return prmtrue;
	}else{
		return prmfalse;
	} //end if
} //end function

function isNumeric( sText ) {
	try {
		var ValidChars = "0123456789.";
		var IsNumber=true;
		var Char;
		
		for (i = 0; i < sText.length && IsNumber == true; i++) { 
			Char = sText.charAt(i);                 
				if (ValidChars.indexOf(Char) == -1) {
					IsNumber = false;
				} //end if
		} //end for
		return IsNumber;
		
   }catch(err) {
		alert( "ERROR : IsNumeric = " + err );
   } //end try
} //end function

function isDate(year, month, day) {
	month = month - 1; // javascript month range 0 - 11
	var tempDate = new Date(year,month,day);
	if ( (year == tempDate.getFullYear()) && (month == tempDate.getMonth()) && (day == tempDate.getDate()) ) {
		return true;
	} else {
		return false;
	}
}

function toExtD( prmval ) {
	var lsreturn   = "";
	var curdate   = new Date();
	 
	var lslength    = prmval + "";
	var lnlength    = lslength.length;
		  
	try {
	  if ( isNumeric( prmval ) == true ) {


		  if ( lnlength <= 5 ) {
			  curdate.setDate(curdate.getDate() + parseFloat( prmval ) );
		  }else{

				if ( lnlength == 6 ) {
					//alert( prmval.substr( 0, 2 ) + " - " + prmval.substr( 2, 2 ) + " - " + prmval.substr( 4, 2 )  );
					var lsdate 		= prmval.substr( 0, 2 );
					var lsmonth 	= prmval.substr( 2, 2 );
					var lsthyear 	= "25" + prmval.substr( 4, 2 );
					var lsyear 		= parseFloat( lsthyear ) - 543;
					var lsthdate;
					
					if ( isDate( lsyear, lsmonth, lsdate ) ) {
						lsthdate = lsdate + "/" + lsmonth + "/" + lsthyear;	
						return lsthdate;
					}else{
						return "";
					} //end if
					
				}else{
					return "";
				} //end if

		  } //end if
		   
		   var lnyear     = curdate.getFullYear();
		   var lnmonth  = curdate.getMonth();
		   var lndate     = curdate.getDate();  
			
		  lndate     = lndate + ""; 
		  lnmonth  = (parseFloat( lnmonth ) + 1) + ""; 
		  
		  if ( lndate.length == 1 ) {
				lndate = "0" + lndate;
		  } //end if
		  
		  if ( lnmonth.length == 1 ) {
				lnmonth = "0" + lnmonth ;
		  } //end if
			
		  lsreturn = lndate + "/" + lnmonth + "/" + ( lnyear + 543 );
		  return lsreturn;
			
	   }else{
		   
		   if ( lnlength == 10 ) {
			    return prmval;
		   }else{
			   return "";
		   } //end if
		   
			
	   } //end if     
	  
	  return "";
	   
   }catch(err) {
		 alert( "ERROR : ToExtD = " + err );
   } //end tyr
} //end function

function validdate( sender ) {
	sender.value = toExtD( sender.value );
	
	if (eval('typeof ' + sender.id + '_onchange') == 'function') {
		eval('typeof ' + sender.id + '_onchange( sender )');
	} //end if
	
} //end function

function bannedKey(evt, _allowen, _allowth, _allownm) {	
	var allowedEng		= false;
	var allowedThai		= false; 
	var allowedNum		= false;
	
	if(_allowen == 1 ) { allowedEng = true; }
	if(_allowth == 1 ) { allowedThai = true; }
	if(_allownm == 1 ) { allowedNum = true; }

	/* ?????????? 0-9 */
	var k = event.keyCode;
	if (k>=48 && k<=57) { return allowedNum; }
	
	/* ?????????????? a-z, A-Z */
	if ((k>=65 && k<=90) || (k>=97 && k<=122)) { return allowedEng; }
	
	/* ??????????? ??????? non-unicode ??? unicode */
	if ((k>=161 && k<=255) || (k>=3585 && k<=3675)) { return allowedThai; }
	
}       

function select_onchange( sender ) {	
	if (eval('typeof ' + sender.id + '_onchange') == 'function') {
		eval('typeof ' + sender.id + '_onchange( sender )');
	} //end if
} //end function


function toExtTime( prmval ) {
	try {
		var lstime;
		
		if ( isNumeric( prmval ) == true ) {		
		
		  var lslength    = prmval + "";
		  var lnlength    = lslength.length;
		  
			switch( lnlength ) {
				case 2:
					lstime = prmval + ":00:00";
					break;
					
				case 4:
					lstime = prmval.substr( 0, 2 ) + ":" + prmval.substr( 2, 2 ) + ":00";
					break;
				
				default:
					lstime = "";
					break;
			} //end switch
			
			return lstime;
			
		} //end if
		 
		 return "";
		
	}catch(err) {
		alert( "ERROR : toExtTime " + err );
	}
	
} //end function


function validtime( sender ) {
	sender.value = toExtTime( sender.value );
} //end function


function xdatediff( stdate, enddate ) {
	var arr1 	= stdate.split("/");
	var arr2 	= enddate.split("/");
	var t1 		= arr1[0] + "/" + arr1[1] + "/" + (parseFloat( arr1[2] ) - 543);
	var t2 		= arr2[0] + "/" + arr2[1] + "/" + (parseFloat( arr2[2] ) - 543);

	//t1="10/10/2006" ;
	//t2="15/10/2006";

	//Total time for one day
	var one_day=1000*60*60*24; 
	//Here we need to split the inputed dates to convert them into standard formatfor furter execution
	var x=t1.split("/");     
	var y=t2.split("/");
	
	//date format(Fullyear,month,date) 
	var date1=new Date(x[2],(x[1]-1),x[0]);
	var date2=new Date(y[2],(y[1]-1),y[0])
	var month1=x[1]-1;
	var month2=y[1]-1;
	
	//Calculate difference between the two dates, and convert to days
	_Diff	= Math.ceil((date2.getTime()-date1.getTime())/(one_day)); 		
	
	return _Diff;
	
} //end function


/*
 * jQuery Nivo Zoom v1.0
 * http://nivozoom.dev7studios.com
 *
 * Copyright 2010, Gilbert Pellegrom
 * Free to use and abuse under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 * 
 * April 2010
 */

eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(f($){$.R.C=f(16){b e=$.1z({},$.R.C.X,16);4(e.F){4(!($.15.1y&&$.15.1x.1A(0,1)<8)){$(\'1B\').1E(\'<18 1D="y" />\');$(\'#y\').9({O:\'1C\',v:0,u:0,m:\'J%\',q:\'J%\',1F:e.W,r:e.11,\'z-P\':1w,Q:\'1j\'})}}1a 7.17(f(){b 14=$(7);b 13=$(\'a.C\',14);13.17(f(){b 3=$(7);4(3.1o(\'a\')){b 6=$(7).1p(\'6:S\');3.9({O:\'1v\',Q:\'1u-1q\'});3.j(\'1l\',\'1n 1h 1t\');3.1f(\'<18 1s="h" />\');b h=$(\'.h\',3);h.9(\'r\',\'0\');3.1r(f(){4(!3.i(\'B\')){h.1c().E({r:e.V},1b)}},f(){4(!h.i(\'G\')){h.1c().E({r:0},1b)}});3.1G(\'1V\',f(){4($(\'6.N\',3).K==0){h.A(\'G\');Y(6,3,f(){h.12(\'G\');H(6,3,h)})}l{H(6,3,h)}1a T})}})});f H(6,3,h){b o=$(\'6.N\',3);4(3.i(\'B\')){4(e.F)$(\'#y\').I(e.n/2);4($(\'.c\',3).K>0){$(\'.c\',3).I(e.n/2)}o.I(e.n/2,f(){6.E({r:1},e.n/2)});3.12(\'B\')}l{4(e.F)$(\'#y\').M(e.n/2);h.9(\'r\',\'0\');6.E({r:0},e.n/2,f(){o.M(e.n/2,f(){1e(6,o,3)})});3.A(\'B\')}}f 1e(6,o,3){4($(\'.c\',3).K>0){b c=$(\'.c:S\',3);4(!c.i(\'10-Z\')){b s=6.m();4(s==0)s=6.j(\'m\');b t=6.q();4(t==0)t=6.j(\'q\');b p=o.m();4(p==0)p=o.j(\'m\');b k=o.q();4(k==0)k=o.j(\'q\');c.9({m:p,r:e.19});4(3.i(\'1g\')){c.9({v:(k-c.L())+\'w\',D:\'g\'})}l 4(3.i(\'1k\')){c.9({x:\'g\',D:\'g\'})}l 4(3.i(\'1m\')){c.9({x:\'g\',u:\'g\'})}l 4(3.i(\'U\')){c.9({v:1H.1I(t/2-k/2)+(k-c.L())+\'w\',u:(s/2-p/2)+\'w\'})}l{c.9({v:(k-c.L())+\'w\',u:\'g\'})}c.A(\'10-Z\')}c.M(e.n/2)}}f Y(6,3,1i){b 1d=1O 1X();$(1d).1P(f(){$(7).A(\'N\');$(7).9({O:\'1K\',Q:\'1j\',\'z-P\':1S});4(1T.1Z.1U(/1W \\d\\.\\d+/)){3.9(\'z-P\',\'J\')}4(3.i(\'1g\')){$(7).9({v:\'g\',D:\'g\'})}l 4(3.i(\'1k\')){$(7).9({x:\'g\',D:\'g\'})}l 4(3.i(\'1m\')){$(7).9({x:\'g\',u:\'g\'})}l 4(3.i(\'U\')){b s=6.m();4(s==0)s=6.j(\'m\');b t=6.q();4(t==0)t=6.j(\'q\');b p=$(7).m();4(p==0)p=$(7).j(\'m\');b k=$(7).q();4(k==0)k=$(7).j(\'q\');$(7).9({v:(t/2-k/2)+\'w\',u:(s/2-p/2)+\'w\'})}l{$(7).9({v:\'g\',u:\'g\'})}$(7).j(\'1l\',\'1n 1h 1M\');3.1f($(7));1i.1N(7)}).j(\'1Q\',3.j(\'1R\'))}};$.R.C.X={n:1J,V:0.8,F:T,W:\'#1Y\',11:0.5,19:0.8}})(1L);',62,124,'|||link|if||img|this||css||var|nivoCaption||settings|function|0px|nivoZoomHover|hasClass|attr|bigImgHeight|else|width|speed|imgLarge|bigImgWidth|height|opacity|imgWidth|imgHeight|left|top|px|bottom|nivoOverlay||addClass|zoomed|nivoZoom|right|animate|overlay|loading|doZoom|fadeOut|100|length|outerHeight|fadeIn|nivoLarge|position|index|display|fn|first|false|center|zoomHoverOpacity|overlayColor|defaults|loadImg|processed|nivo|overlayOpacity|removeClass|nivoZooms|context|browser|options|each|div|captionOpacity|return|300|stop|newImg|showCaption|append|topRight|to|callback|none|bottomRight|title|bottomLeft|Click|is|find|block|hover|class|zoom|inline|relative|90|version|msie|extend|substr|body|fixed|id|prepend|background|bind|Math|ceil|500|absolute|jQuery|close|call|new|load|src|href|99|navigator|match|click|MSIE|Image|333|userAgent'.split('|'),0,{}))







