
if(!jss){
	var jss = new Object();
}
jss.suns = new Object();
jss.suns.util = new Object();
jss.suns.app = new Object();

// SorryMsg 2008/11/12 add start ueno 
// browser close event
window.onbeforeunload = function(e){
	if(((event.clientX>document.body.clientWidth) && (event.clientY<0)) || event.altKey){
		jss.suns.util.sesInvalidate();
	}
}
	
jss.suns.util.sesInvalidate = function () {
	// Servlet Url
	var url = "../SessionInvalidateSV";
	// Updater Enter
	var a = new Ajax.Request( url,  { 
	            "method": "post", 
                // Is Success
	            onSuccess: function(request) { 
					//alert(request.getSession());
	            }, 
                // isComplete
	            onComplete: function(request) { 
	            	//alert('Is Complete');
	            }, 
	            // isFailure
	            onFailure: function(request) { 
	                alert('Is failure Load'); 
	            }, 
	            // do Exception
	            onException: function (request) { 
	                alert('Do Exception sesInvalidate'); 
	            } 
	        } 
	    );
}
// SorryMsg 2008/11/12 add end ueno 
jss.suns.util.setYear = function(yObj, count, selectedVal){
	jss.dom.core.removeChildNodes(yObj);
	var today = new Date();
	for(var i=today.getFullYear() ; i<today.getFullYear()+count ; i++){
		var selected = (selectedVal == i);
		jss.dom.form.addSelectOption(yObj, i, i, selected);
	}
}


jss.suns.util.setMonth = function(yObj, mObj, selectedVal){
	var y = yObj.value;
	var today = new Date();
	var nowYear = today.getFullYear();
	var minMonth = 1;
	if(y == nowYear){
		minMonth = today.getMonth() + 1;
	}
	
	jss.dom.core.removeChildNodes(mObj);
	for(var i=minMonth ; i<=12 ; i++){
		var date = i;
		if(i<10){ date = "0"+i; }
		var selected = (selectedVal == date);
		jss.dom.form.addSelectOption(mObj, date, date, selected);
	}
}

jss.suns.util.setDay = function(yObj, mObj, dObj, selectedVal){
	var y = yObj.value;
	var m = mObj.value;
	var limit = jss.suns.util.getLimitDayOfMonth(y, m);
	
	var today = new Date();
	var nowYear = today.getFullYear();
	var nowMonth = today.getMonth() + 1;
	var minDate = 1;
	if(y == nowYear && m == nowMonth){
		minDate = today.getDate();
	}
	jss.dom.core.removeChildNodes(dObj);
	for(var i=minDate ; i<=limit ; i++){
		var date = i;
		if(i<10){ date = "0"+i; }
		var selected = false;
		var selected = (selectedVal == date);
		jss.dom.form.addSelectOption(dObj, date, date, selected);
	}
}

jss.suns.util.getLimitDayOfMonth = function(y, m){
	if(!y || !m){return null;}
	if(m==1 || m==3 || m==5 || m==7 || m==8 || m==10 || m==12){
		return 31;
	}else if(m == 4 || m==6 || m==9 || m==11){
		return 30;
	}
	
	if(m == 2){
		if(y % 400 == 0){
			return 29;
		}else if(y % 100 == 0){
			return 28;
		}else if(y % 4 == 0){
			return 29;
		}
		return 28;
	}
	return null;
}

jss.suns.util.getUID = function(){
	var date = new Date();
	return date.getTime();
}


jss.suns.app.toHotelInfoBySelect = function(selectObj, resvEnterprise){
	var hotelCode = selectObj.options[selectObj.selectedIndex].value.substr(0, 4);
	
	if(hotelCode == ""){return;}
	
	var url = "/HotelInfoSV?HotelCode="+ hotelCode;
	if(resvEnterprise && resvEnterprise.length > 0){
		url = url + "&ResvEnterprise="+ resvEnterprise;
	}
	document.location.href = url;
}

jss.suns.app.showAccommodationTax = function(){
	var win = window.open('/win_accommodationTax.html', 'accommodationTax', 
	'width=560px, height=500px, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes');
	win.focus();
}

jss.suns.app.showCancelCharge = function(){
	var win = window.open('/win_cancel.html', 'cancel', 
	'width=520px, height=200px, toolbar=no, location=no, directories=no, status=no, menubar=no');
	win.focus();
}

jss.suns.app.showAssessment = function(){
	var win = window.open('/win_assessment.html', 'assessment', 
	'width=310px, height=250px, toolbar=no, location=no, directories=no, status=no, menubar=no');
	win.focus();
}

jss.suns.app.showThreeCategory = function(){
	var win = window.open('/win_threeCategory.html', 'threeCategory', 
	'width=310px, height=430px, toolbar=no, location=no, directories=no, status=no, menubar=no');
	win.focus();
}

//DirectIn URL H-00275 tmiwa
jss.suns.app.getDirectInURL = function(){
	var url = "https://asp.hotel-story.ne.jp";
	return url;
}

//DirectIn URL_SSL H-00275 tmiwa
//DirectIn URL H-00275 azuma 2009/08/17(DirectInTest NoSSL)
jss.suns.app.getDirectInURLSSL = function(){
	var url = "https://asp.hotel-story.ne.jp";
	return url;
}

