var header;
$(function() {
	header = $("#accordion>h3");
	jQuery.each(header,function() {
		$(this).mouseup(openAcc);
		if ($(this).hasClass("open")) {
			$(this).addClass("accOpen");
		} else {
			$(this).addClass("accClose");
			$(this).next().hide();
		}
	});
	
});
function openAcc() {
	var temp = $(this).attr("id");
	jQuery.each(header,function() {
		if (temp !== $(this).attr("id") && $(this).hasClass("accOpen")) {
			$(this).next().hide(500);
			$(this).addClass("accClose");
			$(this).removeClass("accOpen");
		}
	});
	$(this).addClass("accOpen");
	$(this).removeClass("accClose");
	$(this).next().show(500);
}

jQuery.each($('.tip a'),function() {
	$(this).qtip(
	{
		style: {
			name: 'light',
			tip: 'bottomMiddle'
		},
		position: {
			corner: {
				target: 'topMiddle',
				tooltip: 'bottomMiddle'
			}
		},
		show: {
			effect: { type: 'slide',length: 500 }
		},
		hide: {
			effect: { type: 'slide',length: 300 }
		},
		content: $(this).next("div")
	});
	$(this).hover(
		function(){$(this).css("opacity",0.8)},
		function(){$(this).css("opacity",1)}
	);
});

var list = $("#web-list");
list.children(":not(h3)").hide();
list.children(":not(h3)").eq(0).show("slow");
list.find("h3").click(function() {
	if ($(this).next().css("display") == "none") {
		now = this;
		list.children(":not(h3)").slideUp("slow");
		jQuery.each($(this).nextAll(),function() {
			if (this.tagName.toLowerCase() != "h3") {
				$(this).show("slow");
			} else {
				return false;
			}
		});
	} else {
		jQuery.each($(this).nextAll(),function() {
			if (this.tagName.toLowerCase() != "h3") {
				$(this).slideUp("slow");
			} else {
				return false;
			}
		});
	}
}).css("cursor","pointer");

function openForm(type) {
	var url = 'https://panor275.securesites.net/form';
	if (typeof document.body.style.maxHeight != "undefined") {
		if(type) {
			url += '?type='+type;
		}
		var frame = $('<div id="contact"><iframe src="'+url+'" width="100%" height="100%" frameborder="0"></iframe></div>');
		frame.dialog({
			title: 'お問い合わせ',
			bgiframe: true,
			width: 645,
			height: 600,
			resizable: false,
			modal: true,
			close: function(){$(this).parents(".ui-dialog").remove();}
		});
	} else {
		window.open(url, 'contact', 'width=645, height=600, menubar=no, toolbar=no, scrollbars=yes,location=no,status=no');
	}
	return false;
	
}
function openPanorama(title,href) {
	var frame = $('<div><iframe src="'+href+'" width="100%" height="100%" frameborder="0"></iframe></div>');
	frame.dialog({
		title: title,
		bgiframe: true,
		width: 800,
		height: 600,
		resizable: false,
		modal: true,
		close: function(){$(this).parents(".ui-dialog").remove();}
	});
	return false;
}
$(".totop").smoothScroll();
$(".rollover").rollover();

$(".entry a:has(img)").fancybox();