function init_with_load()
{
	//上部メニュー,work,archive
	$(".menu_work").hover(function()
	{
		$(".menu_work .bg").stop().animate({top:-60},250,'easeOutQuart');
		//$(".menu_work .menu_item").stop().animate({height:250},200,'easeOutQuart');
		$(".menu_work .menu_item").height(250);
		$(".menu_work .menu_item #sm_01").stop().delay(250).animate({opacity:"1"},200);
		$(".menu_work .menu_item #sm_02").stop().delay(300).animate({opacity:"1"},200);
		$(".menu_work .menu_item #sm_03").stop().delay(350).animate({opacity:"1"},200);
		$(".menu_work .menu_item #sm_04").stop().delay(400).animate({opacity:"1"},200);
		$(".menu_work .menu_item #sm_05").stop().delay(450).animate({opacity:"1"},200);
		$(".menu_work .menu_item #sm_06").stop().delay(500).animate({opacity:"1"},200);
		$(".menu_work .menu_item #sm_07").stop().delay(550).animate({opacity:"1"},200);
		$(".menu_work .menu_item #sm_08").stop().delay(600).animate({opacity:"1"},200);
		$(".menu_work .menu_item #sm_09").stop().delay(650).animate({opacity:"1"},200);
		$(".menu_work .menu_item #sm_10").stop().delay(700).animate({opacity:"1"},200);
	},
	function()
	{
		$(".menu_work .bg").stop().animate({top:-500},300);
		$(".menu_work .menu_item").height(0);
		$(".menu_work .menu_item #sm_01").stop().delay(10).animate({opacity:"0"},200);
		$(".menu_work .menu_item #sm_02").stop().delay(20).animate({opacity:"0"},200);
		$(".menu_work .menu_item #sm_03").stop().delay(30).animate({opacity:"0"},200);
		$(".menu_work .menu_item #sm_04").stop().delay(40).animate({opacity:"0"},200);
		$(".menu_work .menu_item #sm_05").stop().delay(50).animate({opacity:"0"},200);
		$(".menu_work .menu_item #sm_06").stop().delay(60).animate({opacity:"0"},200);
		$(".menu_work .menu_item #sm_07").stop().delay(70).animate({opacity:"0"},200);
		$(".menu_work .menu_item #sm_08").stop().delay(80).animate({opacity:"0"},200);
		$(".menu_work .menu_item #sm_09").stop().delay(90).animate({opacity:"0"},200);
		$(".menu_work .menu_item #sm_10").stop().delay(100).animate({opacity:"0"},{duration:200,complete:onCompOut});
	});
	
	$(".menu_archive").hover(function()
	{
		$(".menu_archive .bg").stop().animate({top:-300},150);
		$(".menu_archive .menu_item").stop().height(200);
		$(".menu_archive .menu_item #sm_01").stop().delay(250).animate({opacity:"1"},200);
		$(".menu_archive .menu_item #sm_02").stop().delay(300).animate({opacity:"1"},200);
		$(".menu_archive .menu_item #sm_03").stop().delay(350).animate({opacity:"1"},200);
	},
	function()
	{
		$(".menu_archive .bg").stop().animate({top:-500},300);
		$(".menu_archive .menu_item").stop().height(0);
		$(".menu_archive .menu_item #sm_01").stop().delay(10).animate({opacity:"0"},200);
		$(".menu_archive .menu_item #sm_02").stop().delay(20).animate({opacity:"0"},200);
		$(".menu_archive .menu_item #sm_03").stop().delay(30).animate({opacity:"0"},200);
	});
	
	var con = $('#content');
	var speed = 200;
	//all
	/*$(".menu_work .menu_item #sm_01").click(function(){
		con.children('.invis').toggleClass('invis').fadeIn(speed);
		con.masonry();
	});*/
	//category-art-direction
	$(".menu_work .menu_item #sm_02").click(function(){
		con.children().not('.category-art-direction').not('.invis').toggleClass('invis').fadeOut(speed);
		con.children('.category-art-direction.invis').toggleClass('invis').fadeIn(speed);
		con.masonry();
	});
	//category-artwork
	$(".menu_work .menu_item #sm_03").click(function(){
		con.children().not('.category-artwork').not('.invis').toggleClass('invis').fadeOut(speed);
		con.children('.category-artwork.invis').toggleClass('invis').fadeIn(speed);
		con.masonry();
	});
	//category-web-design
	$(".menu_work .menu_item #sm_04").click(function(){
		con.children().not('.category-web').not('.invis').toggleClass('invis').fadeOut(speed);
		con.children('.category-web.invis').toggleClass('invis').fadeIn(speed);
		con.masonry();
	});
	//category-interactive-design
	$(".menu_work .menu_item #sm_05").click(function(){
		con.children().not('.category-interactive-design').not('.invis').toggleClass('invis').fadeOut(speed);
		con.children('.category-interactive-design.invis').toggleClass('invis').fadeIn(speed);
		con.masonry();
	});
	//category-illustration
	$(".menu_work .menu_item #sm_06").click(function(){
		con.children().not('.category-illustration').not('.invis').toggleClass('invis').fadeOut(speed);
		con.children('.category-illustration.invis').toggleClass('invis').fadeIn(speed);
		con.masonry();
	});
	//category-fashion
	$(".menu_work .menu_item #sm_07").click(function(){
		con.children().not('.category-fashion').not('.invis').toggleClass('invis').fadeOut(speed);
		con.children('.category-fashion.invis').toggleClass('invis').fadeIn(speed);
		con.masonry();
	});
	//category-movie
	$(".menu_work .menu_item #sm_08").click(function(){
		con.children().not('.category-movie').not('.invis').toggleClass('invis').fadeOut(speed);
		con.children('.category-movie.invis').toggleClass('invis').fadeIn(speed);
		con.masonry();
	});
	//category-others
	$(".menu_work .menu_item #sm_09").click(function(){
		con.children().not('.category-others').not('.invis').toggleClass('invis').fadeOut(speed);
		con.children('.category-others.invis').toggleClass('invis').fadeIn(speed);
		con.masonry();
	});
	//category-all
	$(".menu_work .menu_item #sm_10").click(function(){
		con.children('.invis').toggleClass('invis').fadeIn(speed);
		con.masonry();
	});
	
	/***Archive***/
	//all
	$(".menu_archive .menu_item #sm_01").click(function(){
		con.children('.invis').toggleClass('invis').fadeIn(speed);
		con.masonry();
	});
	//event & exhibition
	$(".menu_archive .menu_item #sm_02").click(function(){
		con.children().not('.category-event-exhibition').not('.invis').toggleClass('invis').fadeOut(speed);
		con.children('.category-event-exhibition.invis').toggleClass('invis').fadeIn(speed);
		con.masonry();
	});
	//featured
	$(".menu_archive .menu_item #sm_03").click(function(){
		con.children().not('.category-featured').not('.invis').toggleClass('invis').fadeOut(speed);
		con.children('.category-featured.invis').toggleClass('invis').fadeIn(speed);
		con.masonry();
	});
	
	//mode
	$(".mode_photo").click(function(){
		set_cookie_val("text_photo");
	});
	$(".mode_text").click(function(){
		set_cookie_val("text");
	});
}

function onCompOut(){
	fOverWork = false;
}

//formのチェック
function check_form()
{
	var flg_t  = false;
	var flg_ml = false;
	var flg_ms = false;
	if(document.contact.title.value == ""){
		flg_t = true;
	}
	if(document.contact.mailadress.value == ""){
		flg_ml = true;
	}
	if(document.contact.message.value == ""){
		flg_ms = true;
	}
	if(flg_t == true || flg_ml == true || flg_ms == true)
	{
		alert("すべての項目を記入してください");
		return false;
	}
}

//set_cookie
function set_cookie_val(val)
{
	document.cookie = "disp_mode="+val;
}

//メーラー立ち上げ
function mail_to() {
	var my_antname = "hogehoge";
	var domain = "hoge.com";
	var msg = "このまま送信してください。";
	var sbj = "メールマガジン登録";
	this.location.href = "mailto:" + my_antname + "@" + domain + "?subject=" + sbj + "&body=" + msg; 
}

//topへ戻る
function backToTop() {
	var x1 = x2 = x3 = 0;
	var y1 = y2 = y3 = 0;
	
	if (document.documentElement) {
		x1 = document.documentElement.scrollLeft || 0;
		y1 = document.documentElement.scrollTop || 0;
	}
	
	if (document.body) {
		x2 = document.body.scrollLeft || 0;
		y2 = document.body.scrollTop || 0;
	}
	
	x3 = window.scrollX || 0;
	y3 = window.scrollY || 0;
	
	var x = Math.max(x1, Math.max(x2, x3));
	var y = Math.max(y1, Math.max(y2, y3));
	
	window.scrollTo(Math.floor(x / 2.0), Math.floor(y / 2.0));
	
	if (x > 0 || y > 0) {
		window.setTimeout("backToTop()", 25);
	}
}

//文字のバイト数計算
function countByte(str) {
    var count = 0;
    for(var i = 0; i < str.length; i++) {
       if (escape(str.charAt(i)).length < 4) {
          count++;
       }
       else {
          count += 2;
       }
    }
    return count;
}

function cutTxt(txt,num) {
	if(countByte(txt) >= num){
		var cTxt = txt;
		while(countByte(cTxt) > num){
			cTxt = cTxt.substr(0,cTxt.length-1);
		}
		return cTxt;
	}else{
		return txt;
	}
}
