$(document).ready(function(){
	
	// close notify error
	$(".close").click(
		function () {
			$(this).parent().fadeTo(400, 0, function () { // Links with the class "close" will close parent
				$(this).slideUp(400);
			});
			return false;
		}
	);

	// add red color for request field
	$('label:contains("*")').each(function(){$(this).html($(this).html().replace('*','<span>*</span>'));});

	$(".input-email, .input-password").bind("focus", focusLoginText);
	$(".input-email, .input-password").bind("blur", blurLoginText);

	$.nyroModalSettings({
		overflow: "hidden"
	});

	$.datepicker.regional['th'] = {
//		closeText: 'ปิด',
//		prevText: '&laquo;&nbsp;ย้อน',
//		nextText: 'ถัดไป&nbsp;&raquo;',
//		currentText: 'วันนี้',
//		monthNames: ['มกราคม','กุมภาพันธ์','มีนาคม','เมษายน','พฤษภาคม','มิถุนายน','กรกฏาคม','สิงหาคม','กันยายน','ตุลาคม','พฤศจิกายน','ธันวาคม'],
//		monthNamesShort: ['ม.ค.','ก.พ.','มี.ค.','เม.ย.','พ.ค.','มิ.ย.','ก.ค.','ส.ค.','ก.ย.','ต.ค.','พ.ย.','ธ.ค.'],
//		dayNames: ['อาทิตย์','จันทร์','อังคาร','พุธ','พฤหัสบดี','ศุกร์','เสาร์'],
//		dayNamesShort: ['อา.','จ.','อ.','พ.','พฤ.','ศ.','ส.'],
//		dayNamesMin: ['อา.','จ.','อ.','พ.','พฤ.','ศ.','ส.'],
		weekHeader: 'Wk',
		dateFormat: 'yy-mm-dd',
		firstDay: 0,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: '',};
	$.datepicker.setDefaults($.datepicker.regional['th']);
})


function dialogMessage(html, width, height, type) {
	if(type=="error") {
		html = "<div class='modal-error-title'>ERROR:</div><div class='modal-error-detail'>"+html+"</div>";
	}

	if(html!="") {
		$.nyroModalManual({
			minWidth: width,
			minHeight: height,
			content: html,
			bgColor: '#D5D5D5'
		});
	}
	return;
}

function focusLoginText() {
	$(this).removeClass("input-email");
	$(this).removeClass("input-password");
	$(this).removeClass("input-error");
}
function blurLoginText() {
	if($(this).val()=="") {
		if($(this).attr("name")=="email") {
			$(this).addClass("input-email");
		} else {
			$(this).addClass("input-password");
		}
	}
}

