// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaultsz

String.prototype.trimstr = function() {
   return this.replace( /^[\s　]+|[\s　]+$/g , '' );
}

function space_check(_form) {
//	_form[2].value = _form[2].value.trimstr();
	return true;}


//チェックボックス全選択
function allcheck(targetForm,flag){
	for(n=0;n<=targetForm.length-1;n++){
		if(targetForm.elements[n].type == "checkbox"){
			targetForm.elements[n].checked = flag;
		}
	}
}

$(function(){
	$("#toForm").click(function(){
		window.open("/contacts/form/", "メール応募フォーム", "width=600, height=600, scrollbars=1");
		return false;
	});
	$("#toInfo").click(function(){
		window.open($(this).attr("href"), "当院詳細情報", "width=600, height=600, scrollbars=1");
		return false;
	});
	$("span.closeForm").click(function(){
		window.close();
	});
	$("#pagetop").click(function(){
		val = 50;
		scrollTimer = setInterval(smoothScroll, 10);
		return false;
	});
});

function smoothScroll(){
	$("#image").empty();
	if(navigator.userAgent.toLowerCase().indexOf("safari") == -1){
		if(document.documentElement.scrollTop > 0){
			num = document.documentElement.scrollTop;
			num -= val;
			document.documentElement.scrollTop = num;
			val += 10;
		}
		else{
			clearInterval(scrollTimer);
		}
	}
	else{
		if(document.body.scrollTop > 0){
			num = document.body.scrollTop;
			num -= val;
			document.body.scrollTop = num;
			val += 10;
		}
		else{
			clearInterval(scrollTimer);
		}
	}
}