//function get element from event listener element
//ฟังชั่นสำหรับรับค่า Element ที่ทำให้เกิด event
function getObjectReference(e){
		if(!e) e = window.event; //check "e" is event for firefox or not ... if it isn't, set "e" to window.event

		if( e && e.srcElement){ //<< event enable with in IE browser
				objectRef = e.srcElement;
		}else if(e && e.target){ //<< event enable with in natscape , firefox browser
				objectRef = e.target;
		}else{
				return(null); //<< if browsert unsupport 
		}
		return(objectRef);
}

//function get current form of object ;
//ฟังชั่นสำหรับรับค่า form ปัจจุบันของ object ที่กำหนด
function getCurrentForm(object){
	var currentForm;
	var tempObject = object ; 
	var unlimit = true;
	while( unlimit == true){
		tempObject = tempObject.parentNode
		if(tempObject.nodeName.toUpperCase() == "FORM"){
			currentForm = tempObject.name;
			unlimit = false;
		}else if(tempObject.nodeType == 9){ //<< node type  9: Document_Node  ...  that's mean this page don't have static form
			currentForm = false;
			unlimit = false;
		}//<< end if check tempObject
	}// << end while

	return(currentForm);
}

//function get browser from event listener element
//ฟังชั่นสำหรับรับค่า browser name กลับไปตรวจสอบ สำหรับการเขียนข้าม browserW
function getBrowserName(e){
		if(!e) e = window.event; //check "e" is event for firefox or not ... if it isn't, set "e" to window.event

		if( e && e.srcElement){ //<< event enable with in IE browser
				browserName = "IE";
		}else if(e && e.target){ //<< event enable with in natscape , firefox browser
				browserName = "Firefox";
		}else{
				return(null); //<< if browsert unsupport 
		}
		return(browserName);
}


//function remove left space of string
//ฟังชั่นสำหรับตัดช่องว่างทางด้านซ้ายของข้อความ
function leftTrim(sString) {
		while (sString.substring(0,1) == ' '){
				sString = sString.substring(1, sString.length);
		}
		return sString;
}

//function remove right space of string
//ฟังชั่นสำหรับตัดช่องว่างทางด้านขวาของข้อความ
function rightTrim(sString) {
		while (sString.substring(sString.length-1, sString.length) == ' '){
				sString = sString.substring(0,sString.length-1);
		}
		return sString;
}

//function remove left and right space of string
//ฟังชั่นสำหรับตัดช่องว่างทางด้านซ้ายและขวาของข้อความ
function allTrim(sString) { 
		while (sString.substring(0,1) == ' '){
				sString = sString.substring(1, sString.length);
		}
		
		while (sString.substring(sString.length-1, sString.length) == ' '){
				sString = sString.substring(0,sString.length-1);
		}
		
		return sString;
}


// Virtual layer populate by div tag 
// การแสดงข้อมูลแบบ popup 
function createVirtualLayerControl(e, dataShow, target_width, pX, pY, opacityValue) {
		if(!e) e = window.event; //check "e" is event for firefox or not ... if it isn't, set "e" to window.event
		browserName = getBrowserName(e);
		//alert(browserName);

		var object = getObjectReference(e);
		opacityValue = (typeof opacityValue != "undefined")?opacityValue : 95; //set opacity value for fade

		if( document.getElementById("virtualLayerControl") == null){
			virtualLayer= document.createElement("div");
			virtualLayer.setAttribute("id", "virtualLayerControl");
			document.body.appendChild(virtualLayer);
		}else{
			virtualLayer =  document.getElementById("virtualLayerControl"); 
			for(i=virtualLayer.childNodes.length; i > 0 ; i--){;
				virtualLayer.removeChild(virtualLayer.childNodes[0]); // remove childnode
			}// end for 
		}// end if check virtualLayerControl is NULL

		if(typeof dataShow != "object"){
			virtualLayer.innerHTML += ""+dataShow+""; //<< insert data into virtualLayer for show in web page
		}else{
			virtualLayer.appendChild(dataShow);
		}// end if check type of data show
		
		if(target_width > 0){
				virtualLayer.style.width = ""+ target_width +"px"; //<< set 'width' style to fix target width  
		}// end if check target width

		virtualLayer.style.fontFamily = "MS Sans Serif"; //<< set  font-family style to fix font family  
		virtualLayer.style.fontSize = "9px"; //<< set  font-size style to fix size  
		virtualLayer.style.border="1px solid #444444"; //<< set 'border' style to create border line  
		
		virtualLayer.style.backgroundColor =  "#FFFFFF";
		virtualLayer.style.padding =  "7px";
		virtualLayer.style.position = "absolute"; 	
		if(browserName == "IE"){
				var mousePixelX = (typeof pX != "undefined")? pX : e.clientX; // check parameter if defined pX value is pX, if not value is e.clientX
				var mousePixelY = (typeof pY != "undefined")? pY : e.clientY;  // check parameter if defined pY value is pY, if not value is e.clientY
				//var mousePixelX = e.clientX;
				//var mousePixelY = e.clientY;
				virtualLayer.style.filter = "Alpha(opacity=0)"; //<< set  alpha style to tranparentcy 
				virtualLayer.style.pixelLeft = mousePixelX+3 //<< set 'pixelLeft' style to move target data from left+3 of mouseX (event.clientX)
				virtualLayer.style.pixelTop = mousePixelY + 3; //<< set 'pixelTop' style to move target data from top+3 of mouseX (event.clientX)
				virtualLayer.style.display='';
				nereidFade(virtualLayer, opacityValue, 10, 3);
		}else if(browserName == "Firefox"){
				var mousePixelX = (typeof pX != "undefined")? pX : e.pageX; // check parameter if defined pX value is pX, if not value is e.clientX
				var mousePixelY = (typeof pY != "undefined")? pY : e.pageY;  // check parameter if defined pY value is pY, if not value is e.clientY

				//var mousePixelX = e.pageX;
				//var mousePixelY = e.pageY;
				//virtualLayer.style.mozOpacity = 55%;
				
				virtualLayer.style.MozOpacity= 0.0  ; //<< set  alpha style to tranparentcy 
				//alert(virtualLayer.style.MozOpacity);
				virtualLayer.style.left = mousePixelX+3; //<< set 'pixelLeft' style to move target data from left+3 of mouseX (event.clientX)
				virtualLayer.style.top = mousePixelY + 3; //<< set 'pixelTop' style to move target data from top+3 of mouseX (event.clientX)
				virtualLayer.style.display='';
				//virtualLayer.style.wordwrap = "break-word";
				nereidFade(virtualLayer, opacityValue, 20, 10);
		}
		
		
		
		//alert(e.type);
		if(e.type == "mouseover" || e.type == "mousemove"){ // check if event happen cause from onmouseover or on mouse move then onmouse out it disappear
			object.onmouseout = removeVirtualLayerControl; //<< onmouseout call function removeVirtualLayerControl
		}
}

// Virtual layer hidden 
// การซ่อนข้อมูล Virtual layer popup 
function removeVirtualLayerControl() {
		virtualLayer =  document.getElementById("virtualLayerControl"); 
		nereidFade(virtualLayer, 0, 20, 10);
}

// insert image to target object
// การแทรกรูปภาพลงใน object ที่กำหนด
function insertImageToObject(objectTarget, imagePath) {
		var object = (typeof objectTarget == "object")?objectTarget : document.getElementById(objectTarget); // check string or object
		var imageTemp = new Image();
		imageTemp.src = imagePath;
		setTimeout("insertImageToObjectLoadTime()",50);

		insertImageToObjectLoadTime = function(){ 
			var defaultWidth=imageTemp.width;
			var defaultHeight=imageTemp.height;
			//alert(defaultWidth);
			var img = document.createElement("img");
			img.setAttribute("src",imagePath);
			img.setAttribute("width",defaultWidth);
			img.setAttribute("height",defaultHeight);
			object.appendChild(img);
		}
}

function insertImagePreLoadToObject(objectTarget, imagePreLoad) {
		var object = (typeof objectTarget == "object")?objectTarget : document.getElementById(objectTarget); // check string or object
		var imageTemp = imagePreLoad;
		//alert(imagePreLoad.src);
		setTimeout("insertImagePreLoadToObjectLoadTime()",50);

		insertImagePreLoadToObjectLoadTime = function(){ 
			var defaultWidth=imageTemp.width;
			var defaultHeight=imageTemp.height;
			//alert(defaultWidth);
			var img = document.createElement("img");
			img.setAttribute("src",imagePreLoad.src);
			img.setAttribute("width",defaultWidth);
			img.setAttribute("height",defaultHeight);
			object.appendChild(img);
		}
}

//######################################################################################
// function Fade Alpha from siamdev.com
//การ Fade ข้อมูลให้แสดงแบบค่อย ๆ จางออกมาหรือ ค่อย ๆ จางหายไป 
//parameter description 
//destOp = Alpha value ..... 100 equal nomal ...... 0 equal tranparentcy
//rate = time millisec for setTimeout ....... 1000 equal 1 second
//delta = (Alpha value) per 1 time ... if this is 10 .. and rate  1000 .. that mean 1 second ... object + alpha value 10 until at destOp parameter
nereidFadeObjects = new Object();
nereidFadeTimers = new Object();
function nereidFade(object, destOp, rate, delta){
		if (!document.all){ // document.all is internet Explorer
				clearTimeout(nereidFadeTimers[object.sourceIndex]); 
				object.alpha = (object.style.MozOpacity * 100)
				var diff = destOp - object.alpha;
				direction = 1;
				if (object.alpha > destOp){
					direction = -1;
				}
				delta=Math.min(direction*diff,delta);
				object.alpha += direction*delta;
				object.style.MozOpacity = object.alpha / 100;//(direction*delta)/100;
				
				if(object.style.MozOpacity <= 0){
					setDisplay(object, "none"); // set display is none when opacity = 0
				}
				//alert((direction*delta)/100);
				if (direction*delta != destOp){
					nereidFadeObjects[object.sourceIndex]=object;
					nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
				}

			/*return
				if (object != "[object]"){  //do this so I can take a string too
					setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0);
					return;
				}// end if check object*/
		}else{
				 // alert(object.sourceIndex);
				clearTimeout(nereidFadeTimers[object.sourceIndex]);
				
				var 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;
				//alert("aaa");
				if(object.filters.alpha.opacity <= 0){
					setDisplay(object, "none"); // set display is none when opacity = 0
				}

				if (object.filters.alpha.opacity != destOp){
					nereidFadeObjects[object.sourceIndex]=object;
					nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
				}
		}// end if check document.all
}// end function


// set object left and top style 
// กำหนด style left and top  ให้กับ object 
function setLeftTop(objectTarget, leftValue, topValue) {
		//alert(typeof objectTarget);
		var object = (typeof objectTarget == "object")?objectTarget : document.getElementById(objectTarget);
		object.style.left = leftValue;
		object.style.top = topValue;
}

// Increase left and top position of object
// เพิ่มค่า left และ top ให้กับ object
function setLeftTopIncrease(objectTarget, increaseLeftValue, increaseTopValue) {
		//alert(typeof objectTarget);
		var object = (typeof objectTarget == "object")?objectTarget : document.getElementById(objectTarget);
		var leftOldValue = parseInt(object.style.left );
		var topOldValue = parseInt(object.style.top );
		object.style.left = leftOldValue + parseInt(increaseLeftValue);
		object.style.top = topOldValue + parseInt(increaseTopValue);
}

// Decrease left and top position of object
// ลดค่า left และ top ให้กับ object
function setLeftTopDecrease(objectTarget, decreaseLeftValue, decreaseTopValue) {
		//alert(typeof objectTarget);
		var object = (typeof objectTarget == "object")?objectTarget : document.getElementById(objectTarget);
		var leftOldValue = parseInt(object.style.left );
		var topOldValue = parseInt(object.style.top );
		object.style.left = leftOldValue - parseInt(decreaseLeftValue);
		object.style.top = topOldValue - parseInt(decreaseTopValue);
}

// get left position from object
// รับค่า left position จาก object
function getLeftValue(objectTarget) {
		//alert(typeof objectTarget);
		var object = (typeof objectTarget == "object")?objectTarget : document.getElementById(objectTarget);
		var leftValue = parseInt(object.style.left);
		return(leftValue);
}

// get top position from object
// รับค่า top position จาก object
function getTopValue(objectTarget) {
		//alert(typeof objectTarget);
		var object = (typeof objectTarget == "object")?objectTarget : document.getElementById(objectTarget);
		var topValue = parseInt(object.style.top);
		return(topValue);
}

// get top position from object
// รับค่า top position จาก object
function insertTextNode(objectTarget, textNodeData) {
		//alert(typeof objectTarget);
		var object = (typeof objectTarget == "object")?objectTarget : document.getElementById(objectTarget);
		var textData = document.createTextNode(textNodeData);
		for(i = object.childNodes.length;i > 0;i--){
				object.removeChild(object.childNodes[0]);
		}
		object.appendChild(textData);
}

//function for remove childnode of object target
//ฟังชั่นสำหรับ ลบข้อมูลใน object ทั้งหมด
function removeChildNode(objectTarget){
	var object = (typeof objectTarget == "object")?objectTarget : document.getElementById(objectTarget);
	for(i=object.childNodes.length; i > 0 ; i--){;
		object.removeChild(object.childNodes[0]); // remove childnode
	}// end for
}

//function for remove childnode by tag name of object target 
//ฟังชั่นสำหรับ ลบข้อมูลใน object โดยระบุ tag name
function removeChildNodeByTagName(objectTarget, tagName){
	var object = (typeof objectTarget == "object")?objectTarget : document.getElementById(objectTarget);
	objectByTagName = object.getElementsByTagName(tagName);
	for(i=objectByTagName.length; i > 0 ; i--){;
		object.removeChild(objectByTagName[0]); // remove childnode
	}// end for
}

// set object display style 
// กำหนด style display 
function setDisplay(objectTarget, displayStatus) {
		//alert(typeof objectTarget);
		var object = (typeof objectTarget == "object")?objectTarget : document.getElementById(objectTarget);
		object.style.display = displayStatus;
}

// set object display style to none
// กำหนด style display ให้มีค่าเท่ากับ none
function setDisplayHidden(objectTarget) {
		//alert(typeof objectTarget);
		var object = (typeof objectTarget == "object")?objectTarget : document.getElementById(objectTarget);
		object.style.display = "none";
}

// set object display style to not none
// กำหนด style display ให้มีค่าเท่ากับ not none
function setDisplayShow(objectTarget) {
		//alert(typeof objectTarget);
		var object = (typeof objectTarget == "object")?objectTarget : document.getElementById(objectTarget);
		object.style.display = "block";
}



//function set highlight into rows of table
//ฟังชั่นสำหรับกำหนดค่าการ highlight สีของแถวในตาราง
function rowOverShowColor( defaultColor, changeColor){
		object = getObjectReference(); //<< call function for Listener Event from which object
		if( object != null && object.nodeName.toUpperCase() == "TABLE"){
				objectTr = object.getElementsByTagName("tr");			
				for(i=0 ; i < objectTr.length ; i++){
						objectTr[i].onmouseover = function(){
								var tempObjectTd = this.getElementsByTagName("td");
								for(i=0; i < tempObjectTd.length ;i++){
										tempObjectTd[i].bgColor = changeColor
								}				
						}
						
						objectTr[i].onmouseout = function(){
								var tempObjectTd = this.getElementsByTagName("td");
								for(i=0; i < tempObjectTd.length ;i++){
									tempObjectTd[i].bgColor = defaultColor;
								}				
						}
				}
		}else{
				return(false);
		}
}


//function set highlight into cell of table
//ฟังชั่นสำหรับกำหนดค่าการ highlight สีของเซลล์ในตาราง
function cellOverShowColor(defaultColor, hRowColor, hCellColor){
		object = getObjectReference();  //<< call function for Listener Event from which object
		//alert(object.sourceIndex);
		if( object.nodeName.toUpperCase() == "TABLE"){
				
				var objectTr = object.getElementsByTagName("tr");

				for(i=0 ; i < objectTr.length ; i++){
						objectTr[i].onmouseout = function(){
								var tempObjectTd = this.getElementsByTagName("td");
								for(i=0; i < tempObjectTd.length ;i++){
									tempObjectTd[i].bgColor = defaultColor
								}
						}
				}
				
				var objectTd = object.getElementsByTagName("td");
				for(i=0 ; i < objectTd.length ; i++){
						objectTd[i].onmouseover = function(){
								var tempObjectTd = this.parentNode.getElementsByTagName("td");
								for(i=0; i < tempObjectTd.length ;i++){
									tempObjectTd[i].bgColor = hRowColor
								}
								this.bgColor = hCellColor;
						}
				}
		}else{
				return(false);
		}
}

//function open new window <auto screen center> (if open same window ... must set windowName same opened window)
//ฟังชั่นสำหรับเปิดหน้าต่างใหม่ <อยู่กลางจออัตโนมัติ> ในกรณีที่ต้องการเปิดหน้าต่างเดียวกับที่เปิดไปแล้วให้ตั้งชื่อ windowName ให้เหมือนกัน
function newWindow(url , windowName, w, h, scroll){
	leftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	topPosition = (screen.height) ? (screen.height-h)/2 : 0;
	scroll = (scroll == "yes")?"yes":"no";
	windowSetting = "toolbar=no, scrollbars="+scroll+", resizable=no, status=no, location=no , width="+w+",height="+h+", left="+leftPosition+",top="+topPosition+"";
	myWindow = window.open(url, windowName,windowSetting );
}

// function open window(popup) with image and it's resize window = image automatic
// ฟังชั่นสำหรับเปิดหน้าต่างใหม่ให้มีขนาดเท่ากับรูปภาพพอดี
function popupImage (imageURL, caption) {

/*
This routine creates a pop-up window, and ensures that it takes focus. It is 
intended to be called from an anchor tag. The new window will resize itself to 
the optimum size, so we make it as large as the largest required window to
overcome bugs in various manifestations of various browsers.
  
Author:   John Gardner
Written:  8th November 2003
Updated:  27th January 2004

Calling sequence: <a href="a.jpg" onClick="return openLargeImage('a.jpg','Caption');">

The first parameter is the URL of the image to be opened, and the second 
parameter is the caption for the image which is displayed in the window title
and in the alt property of the image tag.

Note that the calling sequence will simply open the image in the main window if
JavaScript isn't enabled.
  
*/
// update by Ngokung 19 / 10 / 2006

  // Constants - change these to suit your requirements Note that the defaultWidth
  // and defaultHeight variables should be set to more than your largest image to
  // overcome a bug in Mozilla (at least up to Firefox 0.9).

  var image1 = new Image();
  image1.src = imageURL;
	
  var defaultWidth=image1.width;
  var defaultHeight=image1.height;
  var windowTop = 100;                // Top position of popup
  var windowLeft = 100                // Left position of popup
  //var defaultWidth = 730;             // Default width (for browsers that cannot resize)
  //var defaultHeight = 532;            // Default height (for browsers that cannot resize)
  var onLoseFocusExit = true;         // Set if window to exit when it loses focus
  var undefined;

  // Set up the window open options
  var Options = "width=" + defaultWidth + ",height=" + defaultHeight + ",top=" + windowTop + ",left=" + windowLeft + ",resizable=0"
  
  // Now write the HTML markup to the new window, ensuring that we insert the 
  // parameter URL of the image and the parameter description of the image in 
  // the right place.
  var myScript = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" +
    "<html>\n" + 
    "<head>\n" + 
    "<title>" + caption + "\</title>\n" +
    "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n" +
    "<meta http-equiv=\"Content-Language\" content=\"en-gb\">\n" +
    "<script language=\"JavaScript\" type=\"text/javascript\">\n" +
    "function resizewindow () {\n" +
    "  var width = document.myimage.width;\n" + 
    "  var height = document.myimage.height;\n";
  
  // Netscape  
  if (navigator.appName.indexOf("Netscape") != -1) {  
    myScript = myScript +  "  window.innerHeight = height;\n  window.innerWidth = width;\n"
  }
   
  // Opera 
  else if (navigator.appName.indexOf("Opera") != -1) {
    myScript = myScript +  "  window.resizeTo (width+12, height+31);\n"
  }
  
  // Microsoft 
  else if (navigator.appName.indexOf("Microsoft") != -1) { 
    myScript = myScript + "  window.resizeTo (width+12, height+31);\n" 
  }
  
  // Assume a frig factor for any other browsers
  else {
    myScript = myScript + "  window.resizeTo (width+14, height+34);\n"
  }
      
  myScript = myScript + "}\n" + "window.onload = resizewindow;\n" +
    "</script>\n</head>\n" + "<body ";
    
  // If the window is required to close when it loses focus.
  if (onLoseFocusExit) {myScript = myScript + "onblur=\"self.close()\" ";}
    
  myScript = myScript + "style=\"margin: 0px; padding: 0px;\">\n" +
    "<img src=\"" + imageURL + "\" alt=\"" + caption + "\" title=\"" + caption + "\" name=\"myimage\">\n" + 
    "</body>\n" +  "</html>\n";
        
  // Diagnostic - uncomment the next line if you wish to see the script generated.   
  //alert (myScript);
  
  // Create the popup window
  var imageWindow = window.open ("","imageWin",Options);
  imageWindow.document.write (myScript)
  imageWindow.document.close ();
  if (window.focus) imageWindow.focus();
  return false;
}

// function open window(popup) with image and it's resize window = image automatic
// ฟังชั่นสำหรับเปิดหน้าต่างใหม่ให้มีขนาดเท่ากับรูปภาพพอด
function popupImage2(imgPath, titleName){
	var image1 = new Image();
	image1.src = imgPath;
	
	var width=image1.width;
	var height=image1.height;
	//alert(width);
	var leftPosition = (screen.width) ? (screen.width-width)/2 : 0;
	var topPosition = (screen.height) ? (screen.height-height)/2 : 0;
	var imagesWindow = window.open('Untitled-1.html',"Images","width=" + width + ",height=" + height + ", left="+leftPosition+",top="+topPosition+", toolbar=0, status=0, menubar=0, resizable=0, scrollbars=no, directories=0"); 
	
	var imagesWindowHTML = imagesWindow.document.getElementsByTagName("html")[0];
	var imagesWindowHead = imagesWindow.document.getElementsByTagName("head")[0];
	var imagesWindowBody = imagesWindow.document.getElementsByTagName("body")[0];
	//alert("aaa");
	//alert(imagesWindowHead.outerHTML);
	var htmlCode = "<html><head><title>"+titleName+"</title></head><body style='margin:0px;padding:0px;'><img src='"+imgPath +"' border='0'></body></html>" 
	//alert("bbb");

	imagesWindow.document.writeln(htmlCode);
	imagesWindow.document.close();

	/*var title = imagesWindow.document.createElement("title");
	var titleText = imagesWindow.document.createTextNode("zzzzzzzzzzzzz");
	title.appendChild(titleText);*/

	/*var meta = imagesWindow.document.createElement("meta");
	meta.setAttribute("content"," text/html; charset=windows-874");
	meta.setAttribute("http-equiv","Content-Type");
	imagesWindowHead.appendChild(meta);*/
	/*
	var img = imagesWindow.document.createElement("img");
	img.setAttribute("src", imgPath);
	imagesWindowBody.style.margin =  0;
	imagesWindowBody.style.padding =  0;
	imagesWindowBody.appendChild(img);

	imagesWindow.document.title = "zzzzz";
	//alert("ccc");
	//imagesWindow.document.appendChild(html2);
	//var aaa = imagesWindow.document.getElementsByTagName("html");
	//alert(aaa[0]);
//	imagesWindowHead.appendChild(title)
//	alert(imagesWindowHTML.innerHTML);
	//imagesWindow.document.location.reload();
	
	//alert("dddd");
	//alert(imagesWindow);
	imagesWindow = null;
	imagesWindowHTML = null;
	imagesWindowHead = null;
	imagesWindowBody = null;
*/
}

// function open window(popup) with full screen mode
// ฟังชั่นสำหรับเปิดหน้าต่างใหม่งพร้อมกับสั่งให้เป็น full screen mode (ยังไม่ได้ใส่ esc เวลาออกจาก fullscreen นะ)
function newWindowFullscreen(url , windowName){
	//leftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	//topPosition = (screen.height) ? (screen.height-h)/2 : 0;
	//scroll = (scroll == "yes")?"yes":"no";
	windowSetting = "channelmode=yes, fullscreen=yes, directories=no, menubar=no , titlebar=no, toolbar=no, scrollbars=no, resizable=no, status=no, location=no";
	myWindow = window.open(url, windowName,windowSetting );
}

//#################################################################################################
//#################################################################################################
// FORM CONTROL
//#################################################################################################

//function check event for input number (event such as onkeypress)
//ฟังชั่นสำหรับตรวจสอบ event เพื่อทำการกรอกข้อมูลให้เป็นตัวเลข
function chkNumber(e){
		var browserName = getBrowserName(e); // get browser name for write script cross browser
		 if(!e) e = window.event; //check "e" is event for firefox or not ... if it isn't, set "e" to window.event
		 key = (e.which)? e.which : e.keyCode; // check e.which key event for for firefox .... if it isn't  e.which , then set it to e.keyCode 


		 if(key != 46 && key < 48 || key > 57 ){
				alert("Please Enter Number and Dot Only");
					//alert("กรุณาใส่ตัวเลขเท่านั้น");
						if(browserName == "IE"){
								e.returnValue = false;
						}else if(browserName == "Firefox"){
								e.preventDefault();
						}// end if check browser name
						return(false)
		}else{
			return(true);		
		}//<< end if check event.keyCode
}//<< end function

//function check event for input email character (event such as onkeypress)
//ฟังชั่นสำหรับตรวจสอบ character ที่พิมพ์ ซึ่งพิมได้เฉพาะตัวอักษรภาษาอังกฤษตัวเล็ก ตัวเลข และ  ตัวอักษรพิเศษสำหรับ email เท่านั้น
function chkEmail(e){
		 var browserName = getBrowserName(e); // get browser name for write script cross browser
		 if(!e) e = window.event; //check "e" is event for firefox or not ... if it isn't, set "e" to window.event
		 key = (e.which)? e.which : e.keyCode; // check e.which key event for for firefox .... if it isn't  e.which , then set it to e.keyCode 



		if ( key != 46 && key < 48 || (key > 57 && key < 64) || (key>90 && key<95) || (key>95 && key<97) || key>122){
				//alert("กรุณาตรวจสอบรูปแบบการเขียนเมลล์ของคุณอีกครั้ง");
				alert("Please Enter Email Character Only");
				if(browserName == "IE"){
						e.returnValue = false;
				}else if(browserName == "Firefox"){
						e.preventDefault();
				}// end if check browser name
		}// end if check key
}// end function

//function check event for input id character (event such as onkeypress)
//ตรวจสอบ character ที่พิมพ์ ซึ่งพิมได้เฉพาะตัวอักษรภาษาอังกฤษตัวเล็กและตัวเลขเท่านั้น
function ChkID(e){
		 var browserName = getBrowserName(e); // get browser name for write script cross browser
		 if(!e) e = window.event; //check "e" is event for firefox or not ... if it isn't, set "e" to window.event
		 key = (e.which)? e.which : e.keyCode; // check e.which key event for for firefox .... if it isn't  e.which , then set it to e.keyCode 

		if (key<13 || (key>13 && key<48) || (key>57 && key<97) || key>122) {
				//alert("กรุณาใส่ตัวอักษรพิมพ์เล็กภาษาอังกฤษ หรือตัวเลขเท่านั้น");
				alert("Please Enter Lower English Character or Number Only");
				if(browserName == "IE"){
						e.returnValue = false;
				}else if(browserName == "Firefox"){
						e.preventDefault();
				}// end if check browser name
		}// end if check key
}// end function

//function check complete value is "email character" before onsubmit enable
//ตรวจสอบ character ที่พิมพ์ถ้าไม่มีการระบุไว้จะพิมพ์ไม่ได้  "ใช้ตรวจสอบ E-Mail"
function chk_char_email(t_email) {
	chkstr = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@-_."
	chkstr += '"';
	for (count = 0;count < t_email.length;count++) {
		chk_ok = 0
		for (count2 = 0;count2 < chkstr.length;count2++) {
			if (t_email.charAt(count) == chkstr.charAt(count2)) {
				chk_ok = 1;
				break;
			}
		}
		if (chk_ok == 0) {
			if (t_email.charCodeAt(count) != 13 && t_email.charCodeAt(count) != 10) {
				return false;
			}
		}
	}
	
	//if(t_email == "") return false;
	if(t_email.indexOf('@',0) < 1) { return false; }
	else if(t_email.indexOf('.',0) == -1 || t_email.lastIndexOf('.') == t_email.length-1 || t_email.lastIndexOf('@') != t_email.indexOf('@',0)) { return false; }
	else if(t_email.indexOf('.',0) == t_email.indexOf('@',0)+1) { return false; }
	else {
			return true;
	}

}

//function check complete value is "id character" before onsubmit enable
//ตรวจสอบ character ที่พิมพ์ถ้าไม่มีการระบุไว้จะพิมพ์ไม่ได้  "ใช้ตรวจสอบชื่อและid"
function chk_char_id(chkmsg) {
	chkstr = "0123456789abcdefghijklmnopqrstuvwxyz"
	chkstr += '"';
	for (count = 0;count < chkmsg.length;count++) {
		chk_ok = 0
		for (count2 = 0;count2 < chkstr.length;count2++) {
			if (chkmsg.charAt(count) == chkstr.charAt(count2)) {
				chk_ok = 1;
				break;
			}
		}
		if (chk_ok == 0) {
			if (chkmsg.charCodeAt(count) != 13 && chkmsg.charCodeAt(count) != 10) {
				return false;
			}
		}
	}
	return true;
}


// check rude word 
// ตรวจสอบคำที่ไมต้องการให้ใช้
function chk_rude(chkmsg){
	var rude = new Array(20);
	rude = new Array("fuck","gamemaster","gamesmaster","webmaster","wm","dq","admin","ini3","galaxy","asshole","bitch","shit","dick","kuy","kvy","yed", "gm", "GM", "hanbitsoft", "aeonsoft", "ntreev", "ntreevsoft");
	for (var i=0;i<rude.length;i++){
		chk_ok = 0;
		if (chkmsg.match(rude[i])){
			chk_ok = 1;
			//alert("in");
			return false;
			//break;
		}
	}
	//if (chk_ok == 0) {
	//	return false;
	//}
	return true;
}

function arrayAutoTabMaxLengthReached(validation, e) 
{
		if(!e) e = window.event; //check "e" is event for firefox or not ... if it isn't, set "e" to window.event
		key = (e.which)? e.which : e.keyCode; // check e.which key event for for firefox .... if it isn't  e.which , then set it to e.keyCode 
		//alert("aaa");
		//alert(e.type);

		var object = getObjectReference(e);
		var objectRef = object.id; //<< Reference to object by id 
		var currentForm = getCurrentForm(object);
		var objectRefCount = document.forms[currentForm].elements[objectRef].length; //<< Length of  Array
		//alert(validation);
		var tempObject = object ; 
		var tempValidation = validation.toUpperCase();

		if(key != 8){
				if( (tempValidation == "NUMBER") || (tempValidation == "NUM") || (tempValidation == "N")){
					chkNumber(e); //<< call to function check number  format
				}else if( (tempValidation == "E-MAIL") || (tempValidation == "EMAIL") ||  (tempValidation == "E")){
					chkEmail(e);  //<< call to function check email format
				}else if( (tempValidation == "CHARACTER") ||  (tempValidation == "CHAR") ||  (tempValidation == "C")){
					chkCharacter(e);  //<< call to function check character format
				}else if( (tempValidation == "ID") ){
					chkId(e);  //<< call to function check id format
				/*}else{*/

				}//end if check tempValidation
		}//end if check key
		//alert("bbb");
		
		object.onkeyup = function(e){ //<< this enable when onkeyup only
					if(!e) e = window.event; //check "e" is event for firefox or not ... if it isn't, set "e" to window.event
					key = (e.which)? e.which : e.keyCode; // check e.which key event for for firefox .... if it isn't  e.which , then set it to e.keyCode 
					tempObject = object; 
					if(object.maxLength == object.value.length && key != 8){
							var unlimit = true;
							var numCheck = 1;
							while( unlimit == true ){
								tempObject = (tempObject.nextSibling != null)? tempObject.nextSibling : tempObject ; //<< get next node for reference 
								if(tempObject.nodeType == 3){  //<< nodeType... 1: Element_Node , 2: Attribute_Node, 3:Text_Node ....and  so on.
									//alert(tempObject.nodeValue);
									unlimit = true;
									if(numCheck > 10){
											nextTarget = object; //<< next target is original object  (same object)
											break;
									}
									numCheck++;
								}else if( (tempObject.nodeName.toUpperCase() == "INPUT")  && (tempObject.type == "text")){
									//alert("bbb");
									nextTarget = tempObject; //<< next target is next textbox  object  (new object)
									unlimit = false;
								}else{
									//alert("ccc");
									nextTarget = object; //<< next target is original object  (same object)
									unlimit = false;
								}//<< end if check tempObject
							} //<< end while
							nextTarget.focus();
					}//<< end if check maxLength
		}//<< end function enable when onkeyup



		object.onkeydown = function(e){
					if(!e) e = window.event; //check "e" is event for firefox or not ... if it isn't, set "e" to window.event
					key = (e.which)? e.which : e.keyCode; // check e.which key event for for firefox .... if it isn't  e.which , then set it to e.keyCode 
					tempObject = object ; 
					if(object.value.length == 0 && key == 8){
							var unlimit = true;
							var numCheck = 1;
							while( unlimit == true){
									tempObject = (tempObject.previousSibling != null)? tempObject.previousSibling : tempObject ;
									if(tempObject.nodeType == 3){  //<< nodeType... 1: Element_Node , 2: Attribute_Node, 3:Text_Node ....and  so on.
										unlimit = true;
										if(numCheck > 10){
											previousTarget = object; //<< previous target is original object  (same object)
											break;
										}
										numCheck++;
									}else if( (tempObject.nodeName.toUpperCase() == "INPUT") && (tempObject.type == "text")){
										previousTarget = tempObject; //<< next target is previous textbox  object  (new object)
										unlimit = false;
									}else{
										previousTarget = object; //<< previous target is original object  (same object)
										unlimit = false;
									}//<< end if check tempObject
							}//<< end while
							previousTarget.focus();
					}// end if check maxLength and press backspace
		}// end function enable when onkeydown




						var objectRefName = object.name + "_full";
						var tempValue = "";
						if(document.getElementById(objectRefName) == null){
							createElem = document.createElement("input");
							createElem.setAttribute("type", "hidden");
							createElem.setAttribute("name", objectRefName);
							createElem.setAttribute("id", objectRefName);
							document.forms[currentForm].appendChild(createElem);

						}
	
}//end function


function validation1Char(objectFullname, status, e){
		var tempName;
		if(document.getElementById(objectFullname) != null){
				var object = document.getElementById(objectFullname);
				var currentForm = getCurrentForm(object);
				//alert(object.name);
				tempName = object.name.split("_full");
				var object1Char = document.forms[currentForm].elements[tempName[0]];
				var tempValue = "";

				for (i=0; i < object1Char.length ; i++){
							tempValue += object1Char[i].value+"";
				}
				
				object.value = tempValue;
				//alert(object.value.length+" == "+object1Char.length);
				if((object.value.length == object1Char.length) ){
						return(true);
				}else if( (object.value.length == 0) && (status.toUpperCase() == "NOT REQUIRE") ){
						return(true);
				}else{
						return(false);
				}// end if check length
		}else{
				var object = getObjectReference(e);
				var currentForm = getCurrentForm(object);
				tempName = objectFullname.split("_full");
				var objectChk = document.forms[currentForm].elements[ tempName[0] ];
				if(objectChk != null){
						var object1Char = document.forms[currentForm].elements[tempName[0]];
						var tempValue = "";
						
						createElem = document.createElement("input");
						createElem.setAttribute("type", "hidden");
						createElem.setAttribute("name", objectFullname);
						createElem.setAttribute("id", objectFullname);
						document.forms[currentForm].appendChild(createElem);


						for (i=0; i < object1Char.length ; i++){
									tempValue += object1Char[i].value+"";
						}

						var object = document.getElementById(objectFullname);
						object.value = tempValue;
						//alert(object.value.length+" == "+object1Char.length);
						if(object.value.length == object1Char.length){
								return(true);
						}else if(object.value.length == 0 && status.toUpperCase() == "NOT REQUIRE"){
								return(true);
						}else{
								return(false);
						}// end if check length
				}
				return(false);
		}//<< end if check object is null
}//<< end function

function validationFormENG(e){
	if(!e) e = window.event; //check "e" is event for firefox or not ... if it isn't, set "e" to window.event
	var err="";
	var args = validationFormENG.arguments;
	var objectTarget, objectRef, currentForm, elementFocus=null;
	var validation, objectName, objectShowName, validationSpecifically, tempObjectRef, tempValidation, min, max, v1Char;
	var i , j;
	objectRef = getObjectReference(e);
	//alert(objectRef.nodeName);
	currentForm =  getCurrentForm(objectRef);


	for(i = 1;i < args.length; i++){ // this for loop .... check amount argument for validation, start at 1 because array 0 is "event"
			validations = args[i].split(":");
			tempObjectRef =  validations[0].split("->");//<< split data into temp variable for specify object name and object show name
			objectName = allTrim( tempObjectRef[0]);//<< object name for assign object target
			objectShowName =  allTrim( tempObjectRef[1]);//<< show data of object  into alert
			validationSpecifically = validations.slice(1); //<< copy array since [1] to end ..... validation type for this object target
			objectTarget = document[currentForm][objectName];//<< dynamic object target;
			//alert(objectName);
			//alert(document.getElementById("elmtInformationZipcode1Char_full"));

			for(j = 0; j < validationSpecifically.length; j++){ // this for loop .... check amount validation Specifically for validation to object target
						tempValidation = allTrim( validationSpecifically[j].toUpperCase() );
						if(tempValidation == "REQ" || tempValidation == "R"){ //<< if validation object to  require
								if(objectTarget.selectedIndex == undefined){ //<< check object target isnot select (Combo box) 
											if (allTrim(objectTarget.value) == ""){
												err += "Please specify in "+objectShowName+".\n"
														if(elementFocus == null){
																elementFocus = objectName;
														}//<< end if check element focus
												break;
											}//<< end if check allTrim
								}else{//<< if object target is select (Combo box) 
											if (allTrim(objectTarget.value) == "" || allTrim(objectTarget.value) == "-"){
												err += "Please select "+objectShowName+".\n"
														if(elementFocus == null){
																elementFocus = objectName;
														}//<< end if check element focus
												break;
											}//<< end if check allTrim
								}
								
								
						}else if(tempValidation == "NUM" || tempValidation == "NUMBER"){ //<< if validation object to number
								if (isFinite(objectTarget.value) == false){ //<< check value is number or not?
									err += "Please specify number only into "+objectShowName+".\n"
									if(elementFocus == null){
											elementFocus = objectName;
									}//<< end if check element focus
									break;
								}//<< end if check isFinite
						}else if(tempValidation == "EMAIL" || tempValidation == "MAIL"){ //<< if validation object to mail format
								if(chk_char_email(objectTarget.value) == false && objectTarget.value.length != 0){
									err += "Please check value "+objectShowName+" again, because it isn't email format .\n";
									if(elementFocus == null){
											elementFocus = objectName;
									}//<< end if check element focus
									break;
								}//<< end if check chk_char_email
						}else if(tempValidation.indexOf("MIN") >= 0){ //<< if validation object to number and min value
								if(isFinite(objectTarget.value) == true){ //<< check value is number or not?
									min = tempValidation.split("->");
									if(objectTarget.value < parseInt(min[1])  && objectTarget.value.length != 0 ){
											err += "Please check value "+objectShowName+" again, because it less than "+min[1]+" .\n";
											if(elementFocus == null){
													elementFocus = objectName;
											}//<< end if check element focus
											break;
									}//<< end if check value less than minimum 
								}else{
									err += "Please specify number only into "+objectShowName+".\n";
									break;
								}//<< end if check isFinite
						}else if(tempValidation.indexOf("MAX") >= 0){ //<< if validation object to number and max value
								if(isFinite(objectTarget.value) == true){ //<< check value is number or not?
									max = tempValidation.split("->");
									if(objectTarget.value > parseInt(max[1])  && objectTarget.value.length != 0 ){
											err += "Please check value "+objectShowName+" again, because it more than "+max[1]+" .\n";
											if(elementFocus == null){
													elementFocus = objectName;
											}//<< end if check element focus
											break;
									}//<< end if check value more than maximum 
								}else{
									err += "Please specify number only into "+objectShowName+".\n";
									break;
								}//<< end if check isFinite
						}else if(tempValidation.indexOf("1CHAR") >= 0){ //<< if validation object to 1 char format
								v1Char =  tempValidation.split("->");
								if(allTrim(v1Char[1].toUpperCase()) == "R" || allTrim(v1Char[1].toUpperCase()) == "REQ" ){
									v1Char[1] = "require";
								}else{
									v1Char[1] = "not require";
								}//<< end if check 1char upper case == require

								if(validation1Char(objectName+"_full", v1Char[1], e) == false){
									if(document.getElementById( objectName+"_full").value.length != 0 && document.getElementById( objectName+"_full").value.length != document[currentForm].elements[objectName].length){
											err += "You specify in "+objectShowName+" incomplete.\n";
									}else{
											err += "Please specify in "+objectShowName+".\n";
									}
									
									if(elementFocus == null){
										elementFocus = objectName;
									}//<< end if check element focus
									break;
								}//<< end if check validation1Char
						}// end if check validation type

			}//<< end for check validation length
	}//<< end for check args length

	if(err != ""){
				err = "You specify information incomplete.\n\n" + err
				alert(err);
				objectTarget = document[currentForm].elements[elementFocus];
				//alert(objectTarget.length);
				if( objectTarget.length != undefined){ //<< check .... Is object an array?
						objectTarget[0].focus();
				}else{
						objectTarget.focus();
				}
		}else{
				document[currentForm].submit(true);
	}//end if check err
}//<< end function


function validationFormTH(e){
	if(!e) e = window.event; //check "e" is event for firefox or not ... if it isn't, set "e" to window.event
	var err="";
	var err="";
	var args = validationFormTH.arguments;
	var objectTarget, objectRef, currentForm, elementFocus=null;
	var validation, objectName, objectShowName, validationSpecifically, tempObjectRef, tempValidation, min, max, v1Char;
	var i , j;
	objectRef = getObjectReference(e);
	currentForm =  getCurrentForm(objectRef);
	
	for(i = 1;i < args.length; i++){ // this for loop .... check amount argument for validation
			validations = args[i].split(":");
			tempObjectRef =  validations[0].split("->");//<< split data into temp variable for specify object name and object show name
			objectName = allTrim( tempObjectRef[0]);//<< object name for assign object target
			objectShowName =  allTrim( tempObjectRef[1]);//<< show data of object  into alert
			validationSpecifically = validations.slice(1); //<< copy array since [1] to end ..... validation type for this object target
			objectTarget = document[currentForm][objectName];//<< dynamic object target;


			for(j = 0; j < validationSpecifically.length; j++){ // this for loop .... check amount validation Specifically for validation to object target
						tempValidation = allTrim( validationSpecifically[j].toUpperCase() );
						if(tempValidation == "REQ" || tempValidation == "R"){ //<< if validation object to  require
								if(objectTarget.selectedIndex == undefined){ //<< check object target isnot select (Combo box) 
											if (allTrim(objectTarget.value) == ""){
												err += "กรุณากรอก"+objectShowName+".\n"
														if(elementFocus == null){
																elementFocus = objectName;
														}//<< end if check element focus
												break;
											}//<< end if check allTrim
								}else{//<< if object target is select (Combo box) 
											if (allTrim(objectTarget.value) == "" || allTrim(objectTarget.value) == "-"){
												err += "กรุณาเลือก"+objectShowName+".\n"
														if(elementFocus == null){
																elementFocus = objectName;
														}//<< end if check element focus
												break;
											}//<< end if check allTrim
								}
								
								
						}else if(tempValidation == "NUM" || tempValidation == "NUMBER"){ //<< if validation object to number
								if (isFinite(objectTarget.value) == false){ //<< check value is number or not?
									err += "กรุณากรอก"+objectShowName+"เป็นตัวเลขเท่านั้น.\n"
									if(elementFocus == null){
											elementFocus = objectName;
									}//<< end if check element focus
									break;
								}//<< end if check isFinite
						}else if(tempValidation == "EMAIL" || tempValidation == "MAIL"){ //<< if validation object to mail format
								if(chk_char_email(objectTarget.value) == false && objectTarget.value.length != 0){
									err += "กรุณาตรวจสอบ"+objectShowName+"อีกครั้ง, เนื่องจากไม่อยู่ในรูปแบบของ E-mail .\n";
									if(elementFocus == null){
											elementFocus = objectName;
									}//<< end if check element focus
									break;
								}//<< end if check chk_char_email
						}else if(tempValidation.indexOf("MIN") >= 0){ //<< if validation object to number and min value
								if(isFinite(objectTarget.value) == true){ //<< check value is number or not?
									min = tempValidation.split("->");
									if(objectTarget.value < parseInt(min[1]) ){
											err += "กรุณาตรวจสอบ"+objectShowName+"อีกครั้ง, เนื่องจากค่าที่ระบุน้อยกว่า  "+min[1]+" .\n";
											if(elementFocus == null){
													elementFocus = objectName;
											}//<< end if check element focus
											break;
									}//<< end if check value less than minimum 
								}else{
									err += "กรุณากรอก"+objectShowName+"เป็นตัวเลขเท่านั้น.\n";
									break;
								}//<< end if check isFinite
						}else if(tempValidation.indexOf("MAX") >= 0){ //<< if validation object to number and max value
								if(isFinite(objectTarget.value) == true){ //<< check value is number or not?
									max = tempValidation.split("->");
									if(objectTarget.value > parseInt(max[1]) ){
											err += "กรุณาตรวจสอบ"+objectShowName+"อีกครั้ง, เนื่องจากค่าที่ระบุมากกว่า  "+max[1]+" .\n";
											if(elementFocus == null){
													elementFocus = objectName;
											}//<< end if check element focus
											break;
									}//<< end if check value more than maximum 
								}else{
									err += "กรุณากรอก"+objectShowName+"เป็นตัวเลขเท่านั้น.\n";
									break;
								}//<< end if check isFinite
						}else if(tempValidation.indexOf("1CHAR") >= 0){ //<< if validation object to 1 char format
								v1Char =  tempValidation.split("->");
								if(allTrim(v1Char[1].toUpperCase()) == "R" || allTrim(v1Char[1].toUpperCase()) == "REQ" ){
									v1Char[1] = "require";
								}else{
									v1Char[1] = "not require";
								}//<< end if check 1char upper case == require

								if(validation1Char(objectName+"_full", v1Char[1], e) == false){
									if(document.getElementById( objectName+"_full").value.length != 0 && document.getElementById( objectName+"_full").value.length != document[currentForm].elements[objectName].length){
											err += "กรุณากรอก"+objectShowName+"ให้สมบูรณ์.\n";
									}else{
											err += "กรุณากรอก"+objectShowName+".\n";
									}
									
									if(elementFocus == null){
										elementFocus = objectName;
									}//<< end if check element focus
									break;
								}//<< end if check validation1Char
						}// end if check validation type

			}//<< end for check validation length
	}//<< end for check args length

	if(err != ""){
				err = "ข้อมูลไม่ครบถ้วนกรุณาตรวจสอบอีกครั้ง.\n\n" + err
				alert(err);
				objectTarget = document[currentForm].elements[elementFocus];
				//alert(objectTarget.length);
				if( objectTarget.length != undefined){ //<< check .... Is object an array?
						objectTarget[0].focus();
				}else{
						objectTarget.focus();
				}
		}else{
				document[currentForm].submit(true);
	}//end if check err
}//<< end function

//#################################################################################################
//#################################################################################################


//function reservation hotel (now, don't perfect function)
//ฟังชั่นสำหรับการจองโรงแรมเท่านั้น (ยังทำไม่ค่อยดีเท่าไร)
function checkSelectDate(){
	var myDate = new Date();
	var myYear = myDate.getYear();
	var myMonth = myDate.getMonth()+1;
	var today = "";
	today = today+myYear+"";
	today = today+myMonth+"";
	today = today+myDate.getDate()+"";
	//alert(today);
	var numDate1 =  document.forms[0].cboYear1.value+""+ document.forms[0].cboMonth1.value+""+ document.forms[0].cboDay1.value;

	var numDate2 =  document.forms[0].cboYear2.value+""+ document.forms[0].cboMonth2.value+""+ document.forms[0].cboDay2.value;
	y1 = parseInt(document.forms[0].cboYear1.value);
	y2 = parseInt(document.forms[0].cboYear2.value);
	//m1= document.forms[0].cboMonth1.value;
	//m2= document.forms[0].cboMonth2.value;
	m1= parseInt(document.forms[0].cboMonth1.value);
	m2= parseInt(document.forms[0].cboMonth2.value);
	numDate1 = parseInt(numDate1);
	numDate2 = parseInt(numDate2);

	if((numDate1 < today) && (m1 <= myMonth) && ((y1 <= myYear) ) ){
		alert("You selected date error please check 'Arrival Date'");	
	}else if((numDate2 > numDate1) || (m2 > m1) || (y2 > y1)){
		document.forms[0].submit(true);
	}else{
		alert("You selected date error please check it , then try again");		
	}
}


