// schedule

function sendForm(selectedDate) {
	document.criteria.selectedDate.value=selectedDate;
	document.criteria.orientation.value='';
	if (checkBrowser() == "IE") {
//		if (checkIEVersion() == "IE") {
			document.criteria.submit();
			return;
//		}
	}

	document.criteria.ajax.value=true;
	
	uri = "index.php";
	data = Form.serialize(document.criteria);
	options ={method: "post",
			parameters: data,
			onComplete: processRequest};
			 
	new Ajax.Request(uri,options);
}
function checkBrowser() {
	var app = navigator.appName;
	var ua = navigator.userAgent;
	if ((app.charAt(0) == "M") && (ua.indexOf("Opera") == -1)) {
		return "IE";
	}
}

function checkIEVersion() {

	var ua = navigator.userAgent;
	parts = new Array();
	parts = ua.split(";");
	for (i=0;i<parts.length;i++){
		if (parts[i]==" MSIE 7.0") {
			return 7;
		} else {
			if (parts[i]==" MSIE 6.0") {
				return 6;
			}
		}				
	}
	return "IE";
}

function sendForward(orientation) {
	
	document.criteria.orientation.value=orientation;
	if (checkBrowser() == "IE") {
//		if (checkIEVersion() < 7) {
			document.criteria.submit();
			return;
//		}
	}

	document.criteria.ajax.value=true;
	
	uri = "index.php";
	data = Form.serialize(document.criteria);
	options ={method: "post",
			parameters: data,
			onComplete: processRequest};
			 
	new Ajax.Request(uri,options);
}


function processRequest(xmlhttp){
		
	res = xmlhttp.responseText;
	document.criteria.selectedDate.value=getTagValue(res,'selectedDate');

	$("cal1").innerHTML =getTagValue(res,'cal1');
	$("cal2").innerHTML =getTagValue(res,'cal2');
	$("cal3").innerHTML =getTagValue(res,'cal3');
	$("sc_data").innerHTML =getTagValue(res,'schedule');
}

function getTagValue(str,tagname){
	var value='';
	p1=	str.indexOf("<" + tagname + ">",0);
	if (p1>=0) {
		p2 = str.indexOf("</" + tagname +">",p1);
		if (p2>=0) {
			value = str.substring(p1 + tagname.length +2,p2);
		}
	}
	return value;
}
	
function RentalConfirm(rentalId) {

	if (confirm("予約ページに移動します。\nよろしいですか?")) {
		
		document.criteria.orientation.value="";
		document.criteria.ajax.value="";
		document.criteria.rental_id.value=rentalId;
		
		window.location.href="reserve.php?rental_id=" + rentalId + "&referer=index.php";

	} 
}

function EventConfirm(eventId) {
	
	if (confirm("イベント参加申込ページに移動します。\nよろしいですか?")) {
		document.criteria.orientation.value="";
		document.criteria.ajax.value="";
		document.criteria.rental_id.value=eventId;
		window.location.href="event_list.php?event_id=" + eventId + "&referer=index.php";
	}

}

function EventConfirmTemp(url) {
	
	w = window.open(url, "イベント情報", "width=880,height=600,scrollbars=1,resizable=1");

}

