// JavaScript Document

function ticket_window(id) {
	var p = 'reserve.php';
	if(id){
		p = p+'?id='+id;
	}
		window.open(p,'ticket',"toolbar=0,menuber=0,scrollbars=0,width=400,height=600,top=0,left=0,resizable");
}

function ticket_send_form(d) {
	//mode追加
	var ele = document.createElement("input");
	ele.setAttribute("name", "mode");
	ele.setAttribute("type", "hidden");
	ele.setAttribute("value", "sendmail");
	document.form.appendChild(ele);
	
	var n = document.form.name.value;
	var e = document.form.email.value;
	var a = document.form.amount.selectedIndex;
	a = document.form.amount.options[a].text;
	
	if (!n || !e || !a) {
		var err_msg ='';
		if (!n) {err_msg = "名前を記入してください。\n";}
		if (!e) {err_msg = err_msg +"メールアドレスを記入してください。\n";}
		if (!a) {err_msg = err_msg +'枚数を選んでください。';}
		alert (err_msg);
	} else {
		var msg = "以下の内容でよろしいですか？\n"+
		d+"\n"+
		a+"枚\n"+
		n+'さま '+"\n"+
		e;
		if(window.confirm(msg)){

			document.form.submit();
		}
	}
}

//scroll to top
$(function() {
	$('.pgtop a[href*=#]').click(function() {
		//if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') &&　location.hostname == this.hostname) {
			var target = $(this.hash);
			target = target.length && target;
			if (target.length) {
				var scldurat = 800;
				var targetOffset = target.offset().top;
				$('html,body')
					.animate(
						{scrollTop: targetOffset}, 
						{duration: scldurat, 
						easing: "easeOutExpo"
						}
					);
				return false;
			}
		//}
	});
});

// pop up
$(function() {
	$('.emeralwin a').click(function() {
		
		var t = String(this);
		
		window.open(
			t,
			'popup',
			'width=620, height=800, toolbar=0, menuber=0, scrollbars=1, status=1, resizable=1, top=0, left=0'
			//'width=' +i.width+ ', height=' +i.height+ ', toolbar=0, menuber=0, scrollbars=0, status=1, resizable=1, top=0, left=0'
		);
			
		return false;
		
	});
});


