function doDisplayDate(obj,objTxt){
	//var ff = 'forms[0].' + objTxt;
	var ff = $(objTxt);
	if($F(objTxt).trim() != ""){
		if($F(objTxt).trim().length > 10){
			//alert("The date is error!");
			g_Calendar.show(event,ff,false,"ddmmmyy", new Date(),null);
			return;
		}
		var _y = $F(objTxt).split("/")[2];
		var _m = parseInt($F(objTxt).split("/")[1],10)-1;
		var _d = $F(objTxt).split("/")[0];
		if(_y!= null && _m!= null && _d!= null){
			var selectDate = new Date(_y,_m,_d);
			if(!checkDate($F(objTxt))) {
				//alert("The Date is error.");
				if(document.all){
					g_Calendar.show(event,ff,false,"ddmmmyy", new Date(),null);
				}else{
					g_Calendar.show(obj,ff,false,"ddmmmyy", new Date(),null);
				}
				return;
			}
			if(document.all){
				g_Calendar.show(event,ff,false,"ddmmmyy", selectDate,null);
			}else{
				g_Calendar.show(obj,ff,false,"ddmmmyy", selectDate,null);
			}
		}else{
			if(document.all){
				g_Calendar.show(event,ff,false,"ddmmmyy", new Date(),null);
			}else{
				g_Calendar.show(obj,ff,false,"ddmmmyy", new Date(),null);
			}
			//alert("Please check your input HTML code!");
			return;
		}
	}else{
		if(document.all){
			g_Calendar.show(event,ff,false,"ddmmmyy",new Date(),null);
		}else{
			g_Calendar.show(obj,ff,false,"ddmmmyy",new Date(),null);
		}
	}	
}

function checkDate(objStr){
	var _y = objStr.split("/")[2];
	var _m = parseInt(objStr.split("/")[1],10) - 1;
	var _d = objStr.split("/")[0];
	if(_y != null && _m != null && _d != null){
		var newDate = new Date(_y,_m,_d);
		if(newDate.getFullYear() != _y || newDate.getMonth() != _m || newDate.getDate() != _d){
			return false;
		}else{
			return true;
		}
	}else{
		return false;
	}
}

function trimFormObj(){
	var frmObj = document.forms[0];
	for (var i = 0; i < frmObj.elements.length; i++) {
		var o = frmObj.elements[i];
		if ((o.type != undefined && o.type == "text") || (o.type != undefined && o.type == "textarea")) {
			o.value = o.value.trim();
		}
	}
}

function isNum(objTxt){
	var numReg=/^[0-9]*[ 0-9]*$/;
	if(objTxt.value != "" && !numReg.test(objTxt.value)){
		return false;
	}
	return true;	
}

function isInt(objTxt){
	var numReg=/^[0-9]+[0-9]*$/;
	if(objTxt.value != "" && !numReg.test(objTxt.value)){
		return false;
	}
	return true;	
}

function isValidEmail(str) {
	var reg = /.+[@].+[.].+/;
	return reg.test(str);
}


function setPage(action,doStr) {
	processing();
	$("doAction").value = "query";
	switch(action){
		case "0":
			$("pageNo").value = "0";
			document.forms[0].action = "../" + doStr + ".do";
			document.forms[0].submit();
        	break;
		case "-":
			$("pageNo").value = "-";
			document.forms[0].action = "../" + doStr + ".do";
			document.forms[0].submit();
			break;
		case "+":
			$("pageNo").value = "+";
			document.forms[0].action = "../" + doStr + ".do";
			document.forms[0].submit();
			break;
		case "~":
			$("pageNo").value = "~";
			document.forms[0].action = "../" + doStr + ".do";
			document.forms[0].submit();
			break;
		default:
	}
}

function openEventDetail(url,id) {
	
	return openCenteredWindow(url,id, 600,500,false,true);
}

function openCenteredWindow(url, id, width, height, status, scrollbars, moreProperties, openerName) {
	var x = 0;
	var y = 0;
	if (screen) x = (screen.availWidth - width) / 2;
	if (screen) y = (screen.availHeight - height) / 2;
	if (!status) status == '';
	if (!openerName) openerName == '';
	var winchangeCourse = openPositionedWindow(url, id, width, height, x, y, status, scrollbars, moreProperties, openerName);
	return winchangeCourse;
}	

function openPositionedWindow(url, name, width, height, x, y, status, scrollbars, moreProperties, openerName) {

	// ie4.5 mac - windows are 2 pixels too short; if a statusbar is used, the window will be an additional 15 pixels short
	var agent = navigator.userAgent.toLowerCase();
	if (agent.indexOf("mac")!=-1 && agent.indexOf("msie") != -1 && agent.indexOf("msie 5.0")==-1) {
		height += 2;
		if (status) height += 15;
	}
	// Adjust width if scrollbars are used (pc places scrollbars inside the content area; mac outside) 
	width += (scrollbars != '' && scrollbars != null && agent.indexOf("mac") == -1) ? 16 : 0;
	var properties = 'width=' + width + ',height=' + height + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + ((status) ? ',status' : '') + ',scrollbars' + ((scrollbars) ? '' : '=no') + ((moreProperties) ? ',' + moreProperties : '');
	if(window.winchangeCourse != null){
		window.winchangeCourse.close();
		window.winchangeCourse = null;
	}
	winchangeCourse = window.open(url, 'aa', properties);
	return winchangeCourse;
}

function doViewFlyer(type,filename){
	if(filename.indexOf("http")>=0){
		window.open(filename,"","height=600px, width=600px,top=0,left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no");
	}else{
		filename=encodeURIComponent(filename);
		var action = "/nanhwa/viewFlyerServlet?type="+type+"&filename="+filename;
		window.open(action,"","height=600px, width=600px,top=0,left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no");
	}
}
			
function doViewPackageCruise(type,filename){
	if(filename.indexOf("http")>=0){
	  	if(document.all){ 
			showModalDialog(filename,window,'help:no;status:no;dialogHeight=500px;dialogWidth=600px;');
		}else{    
		   openEventDetail(filename);
		}
  	}else{
		filename=encodeURIComponent(filename);
		var action = "/nanhwa/viewFlyerServlet?type="+type+"&filename="+filename;
		window.open(action,"","height=600px, width=600px,top=0,left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no");
	}
}
