/*
##########################################
# Custom and modify jQuery by MindDezign เขียนใช้งานเอง
##########################################
# Title : website.js
# Author : Mr. Anuluck Nantajan
# Email : anuluck@minddezign.com
# URL : www.minddezign.com
# Description : All Custom script for jQuery
# Created : 2010-07-23
# Last modified : 2010-07-23
# Copyright : MindDezign 2010.
##########################################
*/
<!-- Begin: Custom : jQuery -->
$(document).ready(function() {

	<!-- Begin: Custom : Menu top Background Position with jQuery -->
	(function($) { // Start : ฟังก์ชั่นหลักของเมนูห้ามเอาออกไป
		$.extend($.fx.step,{
			backgroundPosition: function(fx) {
				if (fx.state === 0 && typeof fx.end == 'string') {
					var start = $.curCSS(fx.elem,'backgroundPosition');
					start = toArray(start);
					fx.start = [start[0],start[2]];
					var end = toArray(fx.end);
					fx.end = [end[0],end[2]];
					fx.unit = [end[1],end[3]];
				}
				var nowPosX = [];
				nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
				nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
				fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];
	
			   function toArray(strg){
				   strg = strg.replace(/left|top/g,'0px');
				   strg = strg.replace(/right|bottom/g,'100%');
				   strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
				   var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
				   return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
			   }
			}
		});
	})(jQuery); // End : ฟังก์ชั่นหลักของเมนูห้ามเอาออกไป
	$('#header-menu-top-wrapper #background-position a') // ส่วนของเมนูในการอ้างอิงถึง <ul id="background-position">
		.css( {backgroundPosition: "0 0"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-150px 0)"}, {duration:500})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(-300px 0)"}, {duration:200, complete:function(){
				$(this).css({backgroundPosition: "0 0"})
			}})
		})
	<!-- End: Custom : Menu top Background Position with jQuery -->

	<!-- Begin: กำหนดค่าเริ่มต้นการใช้งาน ajax -->
	// กำหนดค่าเริ่มต้นการใช้งาน ajax
	$.ajaxSetup ({
		cache: false // ไม่ให้ระบบเก็บ cache ป้องกันการเก็บ cache ของ IE
	});
	<!-- End: กำหนดค่าเริ่มต้นการใช้งาน ajax -->

	<!-- Begin: Custom : Equal Height Columns with jQuery -->
	var content = $("div#content-wrapper").height(); // เก็บค่าความสูงของ div ที่1ไว้ (ใช้แสดงเนื้อหา)
	
	var height_menu_product = $("div#sidebar-right-menu-product").height(); // เก็บค่าความสูงของเมนู Product แบบรวมเมนูย่อยที่อยู่ข้างในทั้งหมดไว้
	//alert("ความสูงของเมนู Product แบบรวมเมนูย่อยที่อยู่ข้างในทั้งหมดคือ: " + height_menu_product + " px");
	
	var height_menu_product_tag_dt = $("div#sidebar-right-menu-product > dl > dt").height() + 10; // เก็บค่าความสูงของเมนู Product เฉพาะ Product group แต่บวกเพิ่ม 10px ตาม css
	//alert("ความสูงของเมนู Product เฉพาะ Product group แต่ละอันคือ: " + height_menu_product_tag_dt + " px");
	var count_dt = 0; // เก็บค่าจำนวน Product group
	$('div#sidebar-right-menu-product > dl > dt').each(function(index) { // ทำการวนลูปนับจำนวน Product group
		//alert(index + ': ' + $(this).text()); // ยกตัวอย่างดึงข้อความออกมาแสดง
		count_dt = count_dt + 1;  // ทำการบวกเพิ่มไปจนกว่าจะครบ
	});
	//alert("นับ Product group ได้ทั้งหมด: " + count_dt + " อัน");
	var total_height_menu_product_group = count_dt * height_menu_product_tag_dt; // ทำการคำนวณหาค่าเฉพาะ Product group อย่างเดียว
	//alert("ความสูงทั้งหมดเฉพาะ Product group คือ: " + total_height_menu_product_group + " px");
	
	var height_menu_product_tag_dd = $("div#sidebar-right-menu-product > dl > dd").height(); // เก็บค่าความสูงของเมนู Product เฉพาะ Product category
	//alert("ความสูงของเมนู Product เฉพาะ Product category แต่ละอันคือ: " + height_menu_product_tag_dd + " px");
	var total_height_menu_product_category = 0; // เก็บค่าจำนวน Product category
	$('div#sidebar-right-menu-product > dl > dd').each(function(index) {
		//alert(index + ': ' + $(this).text()); // ยกตัวอย่างดึงข้อความออกมาแสดง
		//alert(index + ': ' + $(this).height()); // ยกตัวอย่างแสดงความสูงออกมา
		total_height_menu_product_category = total_height_menu_product_category + $(this).height();
	});
	//alert("ความสูงทั้งหมดเฉพาะ Product category คือ: " + total_height_menu_product_category + " px");
	
	var total_height_sidebar = $("div#sidebar-right-wrapper").height(); // เก็บค่าความสูงของ div ที่2 ไว้ (ใช้แสดงเมนูด้านขวามือ)
	//alert("ความสูงทั้งหมดของ div sidebar คือ: " + total_height_sidebar + " px");
	
	var sidebar = total_height_sidebar - total_height_menu_product_category; // ทำการคำนวณหาความสูงจริงๅของ sidebar โดยเอาความสูงของ sidebar ทั้งหมด ลบออกด้วยเมนู Product category ที่เป็นเมนูย่อยข้างในออกเพื่อความถูกต้องจริงๆ

	if (content > sidebar) { // ถ้าค่าของ div conten มีความสูงมากกว่า ก็ให้ทำการเพิ่มความสูงของ div sidebar ให้เท่ากันกับ div content
		$("div#sidebar-right-wrapper").css("height", content); // ให้เพิ่มความสูงของ div ที่ 2 ให้เท่ากัน
	}
	if (content < sidebar) { // ถ้าค่าของ div content มีความสูงน้อยกว่า ก็ให้ทำการเพิ่มความสูงของ div content ให้เท่ากันกับ div sidebar
		$("div#content-wrapper").css("height", sidebar); // ให้เพิ่มความสูงของ div แรกให้เท่ากัน
	}
	<!-- End: Custom : Equal Height Columns with jQuery -->
	
	<!-- Begin: Custom : Textarea resizer by jQuery -->
	/* jQuery textarea resizer plugin usage */
	$('textarea#comment_contact:not(.processed)').TextAreaResizer(); // module : contact
	$('textarea#knowledge_comment_detail:not(.processed)').TextAreaResizer(); // module : knowledge comment
	$('textarea#webboard_item_detail:not(.processed)').TextAreaResizer(); // module : webboard, action : post
	$('textarea#webboard_comment_detail:not(.processed)').TextAreaResizer(); // module : webboard, action : info
	$('textarea#user_address:not(.processed)').TextAreaResizer(); // module : user
	// Add on module: Shopping Cart
	$('textarea#user_delivery_address:not(.processed)').TextAreaResizer(); // module : checkout
	$('textarea#order_annotation:not(.processed)').TextAreaResizer(); // module : checkout
	$('textarea#order_tax_invoice_issued_address:not(.processed)').TextAreaResizer(); // module : checkout
	<!-- End: Custom : Textarea resizer by jQuery -->
	
	<!-- Begin: Custom : Textbox to accept only numbers (digits) by jQuery -->
    // called when key is pressed in textbox : secret_code
	$("#secret_code").keypress(function (e) { 
	  // if the letter is not digit then display error and don't type anything
	  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)) {
		//display error message
		$("#msg_err").html("Numeric only.").show().fadeOut("slow"); 
	    return false;
      }	
	});
    // called when key is pressed in textbox : user_postal_code
	$("#user_postal_code").keypress(function (e)  
	{ 
	  // if the letter is not digit then display error and don't type anything
	  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
	  {
		// display error message
		$("#msg_err_postal_code").html("Numeric only.").show().fadeOut("slow"); 
	    return false;
      }	
	});
    // called when key is pressed in textbox : user_postal_code
	$("#user_delivery_postal_code").keypress(function (e)  
	{ 
	  // if the letter is not digit then display error and don't type anything
	  if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
	  {
		// display error message
		$("#msg_err_delivery_postal_code").html("Numeric only.").show().fadeOut("slow"); 
	    return false;
      }	
	});	
	<!-- End: Custom : Textbox to accept only numbers (digits) by jQuery -->	
	
	<!-- Begin: Custom : Validate signup form on keyup and submit by jQuery -->
	/* Start: ตรวจสอบข้อมูล Module: contact */
	var validator_contact = $("#frm_contact").validate({
		rules: {
			name_contact: "required",
			email_contact: {
				required: true,
				email: true
			},
			comment_contact: "required",
			secret_code: {
				required: true,
				number: true,
				minlength: 5
			}
		},
		messages: {
			name_contact: "Field is required.",
			email_contact: {
				required: "Field is required.",
				email: "Field must contain a valid email address."
			},
			//comment_contact: "กรุณาระบุ: ข้อความที่จะส่งถึงเรา", // ไปกำหนดให้แสดงยังตำแหน่งที่ต้องการแล้วใน form นั้นๆ
			secret_code: {
				required: "Field is required.",
				number: "Numeric only.",
				minlength: "Least 5 characters in length."
			}
		}
	}); // end validate()
	$("#btn_reset_contact").click(function() {
		validator_contact.resetForm();
	});				
	/* End: ตรวจสอบข้อมูล Module: contact */
	
	/* Start: ตรวจสอบข้อมูล Module: knowledge ในส่วนของ comment */
	$("#frm_knowledge_comment_add").validate({
		rules: {
			knowledge_comment_post_name: "required",
			knowledge_comment_detail: "required",
			secret_code: {
				required: true,
				number: true,
				minlength: 5
			}
		},
		messages: {
			knowledge_comment_post_name: "Field is required.",
			//knowledge_comment_detail: "กรุณาระบุ: ข้อความ", // ไปกำหนดให้แสดงยังตำแหน่งที่ต้องการแล้วใน form นั้นๆ
			secret_code: {
				required: "Field is required.",
				number: "Numeric only",
				minlength: "Least 5 characters in length."
			}
		}
	}); // end validate()
	/* End: ตรวจสอบข้อมูล Module: knowledge ในส่วนของ comment */
	
	/* Start: ตรวจสอบข้อมูล Module: webboard ในส่วนของ post กระทู้ใหม่ */
	$("#frm_webboard_add").validate({
		rules: {
			webboard_category_id: "required",
			webboard_item_topic: "required",
			webboard_item_detail: "required",
			webboard_item_post_name: "required",
			secret_code: {
				required: true,
				number: true,
				minlength: 5
			}
		},
		messages: {
			webboard_category_id: "กรุณาเลือก: หมวดหมู่กระทู้",
			webboard_item_topic: "กรุณาระบุ: หัวข้อกระทู้",
			//webboard_item_detail: "กรุณาระบุ: รายละเอียดกระทู้", // ไปกำหนดให้แสดงยังตำแหน่งที่ต้องการแล้วใน form นั้นๆ
			webboard_item_post_name: "กรุณาระบุ: ชื่อผู้ตั้งกระทู้",
			secret_code: {
				required: "กรุณาระบุ: อักขระ (ตัวเลข) ที่ท่านเห็น",
				number: "กรุณาระบุ: เป็นตัวเลขเท่านั้น",
				minlength: "กรุณาระบุ: ตัวเลข ที่ท่านเห็นให้ครบ"
			}
		}
	}); // end validate()
	/* End: ตรวจสอบข้อมูล Module: webboard ในส่วนของ post กระทู้ใหม่ */
	
	/* Start: ตรวจสอบข้อมูล Module: webboard ในส่วนของ comment กระทู้ */
	$("#frm_comment_add").validate({
		rules: {
			webboard_comment_post_name: "required",
			webboard_comment_detail: "required",
			secret_code: {
				required: true,
				number: true,
				minlength: 5
			}
		},
		messages: {
			webboard_comment_post_name: "กรุณาระบุ: ชื่อผู้ตอบกระทู้",
			//webboard_comment_detail: "กรุณาระบุ: รายละเอียดคำตอบ", // ไปกำหนดให้แสดงยังตำแหน่งที่ต้องการแล้วใน form นั้นๆ
			secret_code: {
				required: "กรุณาระบุ: อักขระ (ตัวเลข) ที่ท่านเห็น",
				number: "กรุณาระบุ: เป็นตัวเลขเท่านั้น",
				minlength: "กรุณาระบุ: ตัวเลข ที่ท่านเห็นให้ครบ"
			}
		}
	}); // end validate()
	/* End: ตรวจสอบข้อมูล Module: webboard ในส่วนของ comment กระทู้ */		
	
	/* Start: ตรวจสอบข้อมูล Quick login */
	var validator_quick_login = $("#frm_quick_login").validate({
		rules: {
			quick_username: "required",
			quick_password: "required"
		},
		messages: {
			quick_username: "<img src=\"extensions/validate/icon-error.png\" width=\"16\" height=\"16\" style=\"vertical-align: -4px;\" /> กรุณาระบุ: Username",
			quick_password: "<img src=\"extensions/validate/icon-error.png\" width=\"16\" height=\"16\" style=\"vertical-align: -4px;\" /> กรุณาระบุ: Password"
		}
	}); // end validate()
	$("#btn_reset_quick_login").click(function() {
		validator_quick_login.resetForm();
	});		
	/* End: ตรวจสอบข้อมูล Quick login */	
	
	/* Start: ตรวจสอบข้อมูล Module: user ในส่วนของ login */
	var validator_frm_login = $("#frm_login").validate({
		rules: {
			username: "required",
			password: "required",
			secret_code: {
				required: true,
				number: true,
				minlength: 5
			}
		},
		messages: {
			username: "Field is required.",
			password: "Field is required.",
			secret_code: {
				required: "Field is required.",
				number: "Numeric only.",
				minlength: "Least 5 characters in length."
			}
		}
	}); // end validate()
	$("#btn_reset_login").click(function() {
		validator_frm_login.resetForm();
	});				
	/* End: ตรวจสอบข้อมูล Module: user ในส่วนของ login */
	
	/* Start: ตรวจสอบข้อมูล Module: user ในส่วนของ ลืมรหัสผ่าน */
	$("#frm_user_forgot_pass").validate({
		rules: {
			user_username: "required",
			secret_code: {
				required: true,
				number: true,
				minlength: 5
			}
		},
		messages: {
			user_username: "Field is required.",
			secret_code: {
				required: "Field is required.",
				number: "Numeric only.",
				minlength: "Least 5 characters in length."
			}
		}
	}); // end validate()
	/* End: ตรวจสอบข้อมูล Module: user ในส่วนของ ลืมรหัสผ่าน */				

	/* Start: ตรวจสอบข้อมูล Module: user ในส่วนของ สมัครสมาชิกใหม่ */
	$("#frm_user_add").validate({
		rules: {
			user_username: {
				required: true,
				minlength: 4
			},
			user_password: "required",
			user_password_confirm: {
				required: true,
				equalTo: "#user_password"
			},
			user_email: {
				required: true,
				email: true
			},
			user_first_name: "required",
			user_last_name: "required",
			user_address: "required",
			province_id: "required",
			amphur_id: "required",
			district_id: "required",
			user_postal_code: {
				required: true,
				number: true
			},
			user_telephone_mobile: "required",
			check_accept: "required",
			secret_code: {
				required: true,
				number: true,
				minlength: 5
			}
		},
		messages: {
			user_username: {
				required: "Field is required.",
				minlength: "Least 4 characters in length."
			},
			user_password: "Field is required.",
			user_password_confirm: {
				required: "Field is required.",
				equalTo: "The same password as above."
			},
			user_email: {
				required: "Field is required.",
				email: "Field must contain a valid email address."
			},
			user_first_name: "Field is required.",
			user_last_name: "Field is required.",
			//user_address: "กรุณาระบุ: ที่อยู่ที่สามารถติดต่อได้", // ไปกำหนดให้แสดงยังตำแหน่งที่ต้องการแล้วใน form นั้นๆ
			province_id: "Field is required.",
			amphur_id: "Field is required.",
			district_id: "Field is required.",
			user_postal_code: {
				required: "Field is required.",
				number: "Numeric only."
			},
			user_telephone_mobile: "Field is required.",
			//check_accept: "กรุณาเลือก: ยอมรับข้อตกลงการใช้งาน", // ไปกำหนดให้แสดงยังตำแหน่งที่ต้องการแล้วใน form นั้นๆ
			secret_code: {
				required: "Field is required.",
				number: "Numeric only.",
				minlength: "Least 5 characters in length."
			}
		}
	}); // end validate()
	/* End: ตรวจสอบข้อมูล Module: user ในส่วนของ สมัครสมาชิกใหม่ */	
	
	/* Start: ตรวจสอบข้อมูล Module: user ในส่วนของ แก้ไขข้อมูลส่วนตัวของสมาชิก */
	$("#frm_user_edit").validate({
		rules: {
			user_username: {
				required: true,
				minlength: 4
			},
			user_password_confirm: {
				equalTo: "#user_password"
			},
			user_email: {
				required: true,
				email: true
			},
			user_first_name: "required",
			user_last_name: "required",
			user_address: "required",
			province_id: "required",
			amphur_id: "required",
			district_id: "required",
			user_postal_code: {
				required: true,
				number: true
			},
			user_telephone_mobile: "required"
		},
		messages: {
			user_username: {
				required: "Field is required.",
				minlength: "Least 4 characters in length."
			},
			user_password_confirm: {
				equalTo: "The same password as above."
			},
			user_email: {
				required: "Field is required.",
				email: "Field must contain a valid email address."
			},
			user_first_name: "Field is required.",
			user_last_name: "Field is required.",
			//user_address: "กรุณาระบุ: ที่อยู่ที่สามารถติดต่อได้", // ไปกำหนดให้แสดงยังตำแหน่งที่ต้องการแล้วใน form นั้นๆ
			province_id: "Field is required.",
			amphur_id: "Field is required.",
			district_id: "Field is required.",
			user_postal_code: {
				required: "Field is required.",
				number: "Numeric only."
			},
			user_telephone_mobile: "Field is required."
		}
	}); // end validate()
	/* End: ตรวจสอบข้อมูล Module: user ในส่วนของ แก้ไขข้อมูลส่วนตัวของสมาชิก */			

	/* Start: ตรวจสอบข้อมูล Module: user ในส่วนของ แจ้งการชำระเงิน */
	var validator_login = $("#frm_inform").validate({
		rules: {
			order_transfer_pay_detail: "required",
			order_transfer_pay_date: "required",
			order_transfer_pay_amount: "required"
		},
		messages: {
			order_transfer_pay_detail: "Field is required.",
			//order_transfer_pay_date: "กรุณาระบุ: วันที่ชำระเงิน", // ไปกำหนดให้แสดงยังตำแหน่งที่ต้องการแล้วใน form นั้นๆ
			order_transfer_pay_amount: "Field is required."
		}
	}); // end validate()
	/* ส่วนของการทำงานเมื่อมีการกด submit ของฟอร์ม frm_inform มาเพื่อต้องการให้มี Confirm Alert เตือนเพื่อยืนยัน */
	$('#frm_inform').submit(function(){
		/* หาก from ที่ชื่อว่า #frm_inform ผ่านการ validate() มาแล้วส่งค่ากับมา valid() เป็น 0 ก็คือกรอกข้อมูลถูกต้อง ก็ให้ทำงานต่อไป */
		if ($("#frm_inform").valid()) { // หากผ่านการตรวจสอบมา
				/* Confirm ให้ทำการ Confrim*/
				if ( confirm( 'Confirm : are you sure?' ) ){
					return true;
				} // end if confirm		
		} // end if ($("#frm_inform").valid() ) { // หากผ่านการตรวจสอบมา
		return false;
	}); // end .submit()
	/* End: ตรวจสอบข้อมูล Module: user ในส่วนของ แจ้งการชำระเงิน */

	/* Start: ตรวจสอบข้อมูล Module: checkout ในส่วนของ ข้อมูลการจัดส่งสินค้า */
	$("#frm_user_delivery").validate({
		rules: {
			user_delivery_first_name: "required",
			user_delivery_last_name: "required",
			user_delivery_address: "required",
			province_id: "required",
			amphur_id: "required",
			district_id: "required",
			user_delivery_postal_code: {
				required: true,
				number: true
			},
			user_delivery_telephone: "required",
			shipping_type_id: "required"
		},
		messages: {
			user_delivery_first_name: "Field is required.",
			user_delivery_last_name: "Field is required.",
			//user_delivery_address: "กรุณาระบุ: ที่อยู่สำหรับส่งสินค้า", // ไปกำหนดให้แสดงยังตำแหน่งที่ต้องการแล้วใน form นั้นๆ
			province_id: "Field is required.",
			amphur_id: "Field is required.",
			district_id: "Field is required.",
			user_delivery_postal_code: {
				required: "Field is required.",
				number: "Numeric only."
			},
			user_delivery_telephone: "Field is required."
			//shipping_type_id: "กรุณาเลือก: วิธีการจัดส่งสินค้า", // ไปกำหนดให้แสดงยังตำแหน่งที่ต้องการแล้วใน form นั้นๆ
		}
	}); // end validate()
	/* End: ตรวจสอบข้อมูล Module: checkout ในส่วนของ ข้อมูลการจัดส่งสินค้า */

	/* Start: ตรวจสอบข้อมูล Module: checkout ในส่วนของ วิธีการชำระเงิน */
	$("#frm_user_payment").validate({
		rules: {
			payment_type_id: "required"
		},
		messages: {
			//payment_type_id: "กรุณาเลือก: วิธีการชำระเงิน", // ไปกำหนดให้แสดงยังตำแหน่งที่ต้องการแล้วใน form นั้นๆ
		}
	}); // end validate()
	/* End: ตรวจสอบข้อมูล Module: checkout ในส่วนของ วิธีการชำระเงิน */

	/* Start: ตรวจสอบข้อมูล Module: checkout ในส่วนของ สรุปรายการสั่งซื้อสินค้า */
	$("#frm_user_approval").validate({
		rules: {
			order_tax_invoice_issued_name: "required",
			order_tax_invoice_issued_address: "required"
		},
		messages: {
			//order_tax_invoice_issued_name: "กรุณาระบุ: ชื่อ)", // ไปกำหนดให้แสดงยังตำแหน่งที่ต้องการแล้วใน form นั้นๆ
			//order_tax_invoice_issued_address: "กรุณาระบุ: ที่อยู่" // ไปกำหนดให้แสดงยังตำแหน่งที่ต้องการแล้วใน form นั้นๆ
		}
	}); // end validate()
	/* ส่วนของการทำงานเมื่อมีการกด submit ของฟอร์ม frm_inform มาเพื่อต้องการให้มี Confirm Alert เตือนเพื่อยืนยัน */
	$('#frm_user_approval').submit(function(){
		/* หาก from ที่ชื่อว่า #frm_user_approval ผ่านการ validate() มาแล้วส่งค่ากับมา valid() เป็น 0 ก็คือกรอกข้อมูลถูกต้อง ก็ให้ทำงานต่อไป */
		if ($("#frm_user_approval").valid()) { // หากผ่านการตรวจสอบมา
				/* Confirm ให้ทำการ Confrim*/
				if ( confirm( 'Confirm : are you sure?' ) ){
					return true;
				} // end if confirm		
		} // end if ($("#frm_user_approval").valid() ) { // หากผ่านการตรวจสอบมา
		return false;
	}); // end .submit()
	/* End: ตรวจสอบข้อมูล Module: checkout ในส่วนของ สรุปรายการสั่งซื้อสินค้า */

	<!-- End: Custom : Validate signup form on keyup and submit by jQuery -->

	<!-- Begin: Custom : แสดงเมนูแบบ Slide by jQuery -->
	if($("#sidebar-right-menu-product").length > 0) {
		$("#sidebar-right-menu-product dd").hide();  //:not(:first)
		$("#sidebar-right-menu-product dt a").click(function() {
			$("#sidebar-right-menu-product dl").removeClass();
			if($(this).hasClass("active")) {
				$(this).parent().next().slideUp(200);
				$(this).removeClass("active");
			} else {
				$("#sidebar-right-menu-product dt a").removeClass("active");
				$(this).addClass("active");
				$("#sidebar-right-menu-product dd:visible").slideUp(200);
				$(this).parent().next().slideDown(220);
			}
			return false;
		});
		if ($("#sidebar-right-menu-product dl.active").length > 0) {
			$("#sidebar-right-menu-product dl.active a").click();
		} else {
			//$("#sidebar-right-menu-product dt a:first").click(); /* Display first menu on open : ทำการเปิดเมนูย่อยอันแรกเอาไว้ก่อนเพื่อแสดงเป็น default */
		}
	}
	<!-- End: Custom : แสดงเมนูแบบ Slide by jQuery -->

	<!-- Begin: Custom : Alpha numeric by jQuery -->
	$("#user_telephone").numeric("-"); // module : user, system : register (เบอร์โทรศัพท์ที่บ้าน หรือที่ทำงาน)
	$("#user_telephone_mobile").numeric("-"); // module : user, system : register (เบอร์โทรศัพท์มือถือ)
	$("#user_fax").numeric("-"); // module : user, system : register (เบอร์แฟกซ์)
	$("#user_delivery_telephone").numeric("-"); // module : checkout, system : shipping (เบอร์โทรศัพท์ที่บ้าน, ที่ทำงาน หรือเบอร์มือถือ)
	$("#user_delivery_fax").numeric("-"); // module : checkout, system : shipping (เบอร์แฟกซ์)
	$("#product_item_unit_measure").numeric(); // module : admin, system : product (ขนาดหน่วยวัดปริมาตรสินค้า)
	$("#product_item_unit_count").numeric(); // module : admin, system : product (ขนาดหน่วยนับสินค้า)
	$("#product_item_price").numeric(); // module : admin, system : product (ราคาสินค้า (ปกติ))
	$("#product_item_price_special").numeric(); // module : admin, system : product (ราคาสินค้า (พิเศษ))
	// Add on module: Shopping Cart
	$("#shipping_type_price").numeric(); // module : admin, system : shipping (ค่าบริการจัดส่งสินค้า)
	$("#order_transfer_pay_amount").numeric(); // module : user, system : inform (จำนวนเงินที่ชำระ)
	<!-- End: Custom : Alpha numeric by jQuery -->
	
	<!-- Begin: Custom : Tipsy Facebook style tooltip by jQuery -->
	$('.split-page').tipsy({gravity: 's', fade: true, fallback: "Show All."}); // module: all สำหรับเลือกแบบแบ่งหน้่า
	$('.back-page').tipsy({gravity: 's', fade: true}); // module: all สำหรับเลือกที่ back page
	$('.top-page').tipsy({gravity: 's', fade: true}); // module: all สำหรับเลือกที่ top page
	$('.read-more').tipsy({gravity: 's', fade: true}); // module: all สำหรับเลือกที่ read more
	$('.news-img').tipsy({gravity: 'w', fade: true, fallback: "Read news."}); // module: news สำหรับเลือกที่รูป
	$('.knowledge-img').tipsy({gravity: 'w', fade: true, fallback: "Read knowledge."}); // module: knowledge สำหรับเลือกที่รูป
	$('.bbcode-insert-picture').tipsy({gravity: 'w', fade: true, fallback: "Insert picture."}); // module: webboard สำหรับเลือกแทรกรูปจากเว็บอื่นๆ
	$('.bbcode-insert-youtube').tipsy({gravity: 'w', fade: true, fallback: "Insert youtube."}); // module: webboard สำหรับเลือกแทรกรูปจากเว็บอื่นๆ
	// แบบไม่ Fix ค่อยไปวนลูปแสดงเอาที่ tag: title
	$('.form-button-order-history').tipsy({gravity: 'w', html: true, fade: false}); // module: admin, action: orders_list สำหรับเลือกที่ปุ่ม order no
	// Menu top กำหนดแบบนี้จะเป็นแบบ Fix ไปเลย
	/*
	$('#nav-home').tipsy({gravity: 's', fade: true, fallback: "หน้าแรก."}); // navigation: Home
	$('#nav-product').tipsy({gravity: 's', fade: true, fallback: "สินค้าของเรา."}); // navigation: Product
	$('#nav-news').tipsy({gravity: 's', fade: true, fallback: "ข่าวสาร."}); // navigation: News
	$('#nav-knowledge').tipsy({gravity: 's', fade: true, fallback: "บทความ."}); // navigation: Articles
	$('#nav-webboard').tipsy({gravity: 's', fade: true, fallback: "กระทู้ถาม-ตอบ."}); // navigation: Forum
	$('#nav-about').tipsy({gravity: 's', fade: true, fallback: "เกี่ยวกับเรา."}); // navigation: About us
	$('#nav-contact').tipsy({gravity: 's', fade: true, fallback: "ติดต่อเรา."}); // navigation: Contact
	$('#nav-link').tipsy({gravity: 's', fade: true, fallback: "ลิงค์."}); // navigation: Link
	$('#nav-cart').tipsy({gravity: 's', fade: true, fallback: "ตะกร้าสินค้า."}); // navigation: Cart
	*/
	<!-- End: Custom : Tipsy Facebook style tooltip by jQuery -->
	
	<!-- Begin: Custom : jCapSlide by jQuery -->
	$("#capslide-last-new-product-img").capslide({
		caption_color: '#FFFFFF',
		caption_bgcolor: '#000000',
		overlay_bgcolor: '#000000',
		border: '5px solid #b10201',
		showcaption: true
	});
	$("#capslide-products-recommended-img").capslide({
		caption_color: '#FFFFFF',
		caption_bgcolor: '#000000',
		overlay_bgcolor: '#000000',
		border: '5px solid #b10201',
		showcaption: true
	});
	<!-- End: Custom : jCapSlide by jQuery -->	

	<!-- Begin: Custom : ส่วนของการ Fixed Table Header by jQuery -->
	$("#table-cart").fixedtableheader();
	<!-- End: Custom : ส่วนของการ Fixed Table Header by jQuery -->

	<!-- Begin: Custom : ส่วนของการใช้ datepicker ของ jQuery UI -->
	$('#order_delivery_tacking_date').datepicker({ // ?module=admin&action=orders_info
		//dateFormat: 'yy-mm-dd',
		numberOfMonths: 1,
		duration: '',
		showOn: 'button', 
		buttonImage: 'images/icon/icon-jquery-ui-calendar.png', 
		buttonText: 'เลือกวันที่',
		buttonImageOnly: true,
		showButtonPanel: true
	});	
	$('#order_transfer_pay_date').datepicker({ // ?module=user&action=inform
		//dateFormat: 'yy-mm-dd',
		numberOfMonths: 1,
		duration: '',
		showOn: 'button', 
		buttonImage: 'images/icon/icon-jquery-ui-calendar.png', 
		buttonText: 'เลือกวันที่',
		buttonImageOnly: true,
		showButtonPanel: true
	});	
	$('#filter_date_start').datepicker({ // ?module=user&action=inform
		//dateFormat: 'yy-mm-dd',
		numberOfMonths: 1,
		duration: '',
		showOn: 'button', 
		buttonImage: 'images/icon/icon-jquery-ui-calendar.png', 
		buttonText: 'เลือกวันที่เริ่มต้น',
		buttonImageOnly: true,
		showButtonPanel: true
	});	
	$('#filter_date_end').datepicker({ // ?module=user&action=inform
		//dateFormat: 'yy-mm-dd',
		numberOfMonths: 1,
		duration: '',
		showOn: 'button', 
		buttonImage: 'images/icon/icon-jquery-ui-calendar.png', 
		buttonText: 'เลือกวันที่สิ้นสุด',
		buttonImageOnly: true,
		showButtonPanel: true
	});		
	$("img[src$='icon-jquery-ui-calendar.png']").mouseover(function() {
		$(this).css('cursor','pointer');
	});
	<!-- End: Custom : ส่วนของการใช้ datepicker ของ jQuery UI -->

});
<!-- End: Custom : jQuery -->	
