$(function(){
$("#aboutReplace").replaceWith('<div id="aboutImg01"><img src="common/images/acerca01.jpg" width="825" height="100" /></div><div id="aboutImg02"><img src="common/images/about_img_03.jpg" width="108" height="218" /></div><div id="aboutImg03"><img src="common/images/about_img_04.jpg" width="62" height="157" /></div><div id="aboutImg04"><img src="common/images/about_img_05.jpg" width="123" height="78" /></div><div id="aboutImg05"><img src="common/images/about_img_06.jpg" width="108" height="216" /></div><div id="aboutImg06"><img src="common/images/about_img_07.jpg" width="57" height="217" /></div>');
$("#messageReplace").replaceWith('<div id="messageImg01"><img src="common/images/disenio01.jpg" width="825" height="101"></div><div id="messageImg02"><img src="common/images/message_img_02.jpg" width="50" height="65"></div><div id="messageImg03"><img src="common/images/message_img_03.jpg" width="66" height="131"></div><div id="messageImg04"><img src="common/images/message_img_04.jpg" width="123" height="62"></div><div id="messageImg05"><img src="common/images/message_img_05.jpg" width="108" height="144"></div><div id="messageImg06"><img src="common/images/message_img_06.jpg" width="69" height="138"></div>');
$("#consultoriaReplace").replaceWith('<div id="consultoriaImg01"><img src="common/images/consultoria01.jpg" width="825" height="101"></div><div id="consultoriaImg02"><img src="common/images/message_img_02.jpg" width="50" height="65"></div><div id="consultoriaImg03"><img src="common/images/message_img_03.jpg" width="66" height="131"></div><div id="consultoriaImg04"><img src="common/images/message_img_04.jpg" width="123" height="62"></div><div id="consultoriaImg05"><img src="common/images/message_img_05.jpg" width="108" height="144"></div><div id="consultoriaImg06"><img src="common/images/message_img_06.jpg" width="69" height="138"></div>');
$("#bookmarkReplace").replaceWith('<div id="bookmarkImg01"><img src="common/images/bookmark_img_01.png" width="184" height="138"></div><div id="bookmarkImg02"><img src="common/images/bookmark_img_02.png" width="167" height="126"></div><div id="bookmarkImg03"><img src="common/images/bookmark_img_03.png" width="150" height="115"></div><div id="bookmarkImg04"><img src="common/images/bookmark_img_04.png" width="151" height="115"></div><div id="bookmarkImg05"><img src="common/images/bookmark_img_05.png" width="136" height="103"></div><div id="bookmarkImg06"><img src="common/images/bookmark_img_06.png" width="135" height="104"></div><div id="bookmarkImg07"><img src="common/images/bookmark_img_07.png" width="136" height="104"></div><div id="bookmarkImg08"><img src="common/images/bookmark_img_08.png" width="151" height="115"></div><div id="bookmarkImg09"><img src="common/images/bookmark_img_09.png" width="151" height="115"></div><div id="bookmarkImg10"><img src="common/images/bookmark_img_10.png" width="166" height="126"></div><div id="bookmarkImg11"><img src="common/images/bookmark_img_11.png" width="184" height="139"></div>');
$(".menu li:last-child").css({background:"none","padding-right":"0","margin-right":"0"});

var b=!!document.createElement("audio").canPlayType;

if(b!==true){
	$("#soundBtn").hide();
	$("#soundCredit").css("right","10px");
	$("#respect").css("right","122px")
}
if(b===true){if($.browser.mozilla){
	$("#audioOver").attr("src","common/sound/over.m4a");
	$("#audioClick").attr("src","common/sound/click.m4a");
	$("#audioBgm").attr("src","common/sound/bgm.m4a").attr("loop","loop").attr("autoplay","autoplay").attr("autobuffer","autobuffer")
}
else{
	$("#audioOver").attr("src","common/sound/over.mp3");
	$("#audioClick").attr("src","common/sound/click.mp3");
	$("#audioBgm").attr("src","common/sound/bgm.mp3").attr("loop","loop").attr("autoplay","autoplay").attr("autobuffer","autobuffer")
}
if(typeof HTMLAudioElement==="object"||typeof HTMLAudioElement==="function"){
	$("#audioBgm").bind("canplay",function(){$("#audioBgm").get(0).play()});
	$("#nav img, #aboutClose, #messageClose, #consultoriaClose, #bookmarkClose, #soundBtn, .roll img, img.roll, input.roll, .menuAbout, .menuMessage, .menuConsultoria, .menuBookmark").hover(
		function(){$("#audioOver").load();$("#audioOver").get(0).play()},function(){});
	$("#aboutClose, #messageClose, #consultoriaClose, #bookmarkClose, #contactClose").click(function(){$("#audioClick").load();$("#audioClick").get(0).play()})
}
else{
$("#audioBgm, #audioOver, #audioClick").hide()
}

$("#audioBgm").bind("ended",function(){if($.browser.mozilla===true){$("#audioBgm").get(0).play()}});
$("#soundBtn").hover(function(){$(this).css("cursor","pointer")},
					 function(){$(this).css("cursor","default")});
$("#soundBtn").click(function(){$("#soundBtnOn, #soundBtnOff").toggleClass("none")});
$("#soundBtnOn").click(function(){
	document.getElementById("audioOver").volume=0;
	document.getElementById("audioClick").volume=0;
	document.getElementById("audioBgm").pause()});
$("#soundBtnOff").click(function(){
	document.getElementById("audioOver").volume=1;
	document.getElementById("audioClick").volume=1;
	document.getElementById("audioBgm").play()})}
	
	$("#nav .item01 a, #about .item01 a, #bookmark .item02 a, #contactSubmit, #soundCredit a, #thecssawards a").click(function(){
		if(b===true){
			document.getElementById("audioBgm").pause()
		}
		$("#siteSleep").show();
		$("#bgScreen").hide()
	});
	$("#siteSleep").hover(function(){
		$(this).css("cursor","pointer")},function(){
		$(this).css("cursor","default")});
		$("#siteSleep").click(function(){
		$(this).hide();
		if($("#soundBtnOff").css("display")==="none"&&b===true){
			document.getElementById("audioBgm").play()
		}
		$("#bgScreen").show()});
	$("#bookmark .menuAbout, #bookmark .menuMessage,#bookmark .menuConsultoria, #bookmark #bookmarkClose").click(function(){clearInterval(bookmarkInterval)});
			$("#navInner").hover(function(){
			$(this).stop();
			$(this).animate({opacity:0.9},400)},function(){
				$(this).stop();$(this).animate({opacity:0.4},1200)});
			$("#nav ul.item00 li img, #nav ul.item01 img").hover(function(){
				$(this).stop();$(this).css({cursor:"pointer",opacity:"1"})},function(){
					$(this).css({cursor:"default"}).animate({opacity:0.7},400)});
			$(".menuAbout, .menuMessage, .menuConsultoria, .menuBookmark").hover(function(){
				$(this).stop();$(this).css({cursor:"pointer"})},function(){$(this).css({cursor:"default"})});
					var a={};
					$("img.roll, .roll img, input.roll").not("[src*='_o.']").each(function(){
						var d=$(this).attr("class");
							if(d!="noneSwap"){
								var f=this.src,
								c=this.src.lastIndexOf("."),e=this.src.substr(0,c)+"_o"+this.src.substr(c,4);
								a[this.src]=new Image();
								a[this.src].src=e;
								$(this).hover(function(){$(this).css("cursor","pointer");
								this.src=e;$(this).click(function(){$(this).css("cursor","default");this.src=f})},
								function(){$(this).css("cursor","default");this.src=f})}});
					$("#aboutClose, #messageClose, #consultoriaClose, #bookmarkClose").hover(function(){$(this).stop();$(this).css({cursor:"pointer",opacity:"1"})},
						function(){$(this).css({cursor:"default"}).animate({opacity:0.7},400)});
					$("#profileBtn").click(function(){$("#aboutProfile table, #aboutProfile dl").toggleClass("none")});
					$("a").attr("target","_blank").each(function(){$("a").attr("title","Open New Window")});
						if($.browser.msie){$("a").click(function(){$(this).blur()})}
});

(function(a){
	a.fn.openWindow=function(){
		var k=this;
		var b=!!document.createElement("audio").canPlayType;
	
	function j(){
		g(this,k);
		return false
	}
	function g(s,p){
		if(a("#soundBtnOff").css("display")==="none"&&b===true){a("#audioClick").load();a("#audioClick").get(0).play()}
			var t=s.getAttribute("id");
			var r=s.getAttribute("class");
			var q=a("#nav").width();
			
			if(q<1){switch(r){
				case"menuAbout":o();
					break;
				case"menuMessage":c();
					break;
				case"menuConsultoria":c2();
					break;
				case"menuBookmark":h();
					break
			}}
			else{
				a("#nav .item00 li:eq(2)").delay(0).animate({top:-10,opacity:0},{duration:400,easing:"easeInQuad"});
				a("#nav .item00 li:eq(1)").delay(100).animate({top:-10,opacity:0},{duration:400,easing:"easeInQuad"});
				a("#nav .item00 li:eq(0)").delay(200).animate({top:-10,opacity:0},{duration:400,easing:"easeInQuad"});
				a("#nav .item01 li:eq(3)").delay(0).animate({top:-10,opacity:0},{duration:400,easing:"easeInQuad"});
				a("#nav .item01 li:eq(2)").delay(100).animate({top:-10,opacity:0},{duration:400,easing:"easeInQuad"});
				a("#nav .item01 li:eq(1)").delay(200).animate({top:-10,opacity:0},{duration:400,easing:"easeInQuad"});
				a("#nav .item01 li:eq(0)").delay(300).animate({top:-10,opacity:0},{duration:400,easing:"easeInQuad"});
				a("#nav").delay(600).animate({width:0},{duration:1000,easing:"easeOutExpo",complete:function(){
					switch(t){
						case"openAbout":l();
							break;
						case"openMessage":f();
							break;
						case"openConsultoria":con();
							break;
						case"openBookmark":d();
							break
						}}
				})
			}
			
			a("#aboutClose").click(function(){n()});
			a("#messageClose").click(function(){m()});
			a("#consultoriaClose").click(function(){con2()});
			a("#bookmarkClose").click(function(){i()})
	}
	
	function l(){
		a("*").clearQueue();
		a("#about").css({width:0,opacity:1}).show().animate({width:822},{duration:1000,easing:"easeOutExpo"});
		a("#about .menu li").css({top:-10,opacity:0});
		a("#about .menu li:eq(0)").delay(600).animate({top:0,opacity:1},{duration:1000,easing:"easeOutExpo"});
		a("#about .menu li:eq(1)").delay(700).animate({top:0,opacity:1},{duration:1000,easing:"easeOutExpo"});
		a("#about .menu li:eq(2)").delay(800).animate({top:0,opacity:1},{duration:1000,easing:"easeOutExpo"});
		a("#about .menu li:eq(3)").delay(800).animate({top:0,opacity:1},{duration:1000,easing:"easeOutExpo"});
		a("#aboutImg01, #aboutImg02, #aboutImg03, #aboutImg04, #aboutImg05, #aboutImg06").css({top:428,opacity:0});
		a("#aboutImg02").delay(800).animate({top:-1,opacity:1},{duration:1200,easing:"easeOutExpo"});
		a("#aboutImg04").delay(1000).animate({top:-1,opacity:1},{duration:1200,easing:"easeOutExpo"});
		a("#aboutImg06").delay(1200).animate({top:-1,opacity:1},{duration:1200,easing:"easeOutExpo"});
		a("#aboutImg01").delay(1200).animate({top:-1,opacity:1},{duration:1200,easing:"easeOutExpo"});
		a("#aboutImg03").delay(1400).animate({top:-1,opacity:1},{duration:1200,easing:"easeOutExpo"});
		a("#aboutImg05").delay(1600).animate({top:140,opacity:1},{duration:1200,easing:"easeOutExpo"})
	}
	
	function f(){
		a("*").clearQueue();
		a("#message").css({width:0,opacity:1}).show().animate({width:822},{duration:1000,easing:"easeOutExpo"});
		a("#message .menu li").css({top:-10,opacity:0});
		a("#message .menu li:eq(0)").delay(600).animate({top:0,opacity:1},{duration:1000,easing:"easeOutExpo"});
		a("#message .menu li:eq(1)").delay(700).animate({top:0,opacity:1},{duration:1000,easing:"easeOutExpo"});
		a("#message .menu li:eq(2)").delay(800).animate({top:0,opacity:1},{duration:1000,easing:"easeOutExpo"});
		a("#message .menu li:eq(3)").delay(800).animate({top:0,opacity:1},{duration:1000,easing:"easeOutExpo"});
		a("#messageImg01, #messageImg02, #messageImg03, #messageImg04, #messageImg05, #messageImg06").css({top:428,opacity:0});
		a("#messageImg02").delay(800).animate({top:-1,opacity:1},{duration:1200,easing:"easeOutExpo"});
		a("#messageImg04").delay(1000).animate({top:-1,opacity:1},{duration:1200,easing:"easeOutExpo"});
		a("#messageImg06").delay(1200).animate({top:-1,opacity:1},{duration:1200,easing:"easeOutExpo"});
		a("#messageImg01").delay(1200).animate({top:-1,opacity:1},{duration:1200,easing:"easeOutExpo"});
		a("#messageImg03").delay(1400).animate({top:-42,opacity:1},{duration:1200,easing:"easeOutExpo"});
		a("#messageImg05").delay(1600).animate({top:-31,opacity:1},{duration:1200,easing:"easeOutExpo"})
	}
	
	function con(){
		a("*").clearQueue();
		a("#consultoria").css({width:0,opacity:1}).show().animate({width:822},{duration:1000,easing:"easeOutExpo"});
		a("#consultoria .menu li").css({top:-10,opacity:0});
		a("#consultoria .menu li:eq(0)").delay(600).animate({top:0,opacity:1},{duration:1000,easing:"easeOutExpo"});
		a("#consultoria .menu li:eq(1)").delay(700).animate({top:0,opacity:1},{duration:1000,easing:"easeOutExpo"});
		a("#consultoria .menu li:eq(2)").delay(800).animate({top:0,opacity:1},{duration:1000,easing:"easeOutExpo"});
		a("#consultoria .menu li:eq(3)").delay(800).animate({top:0,opacity:1},{duration:1000,easing:"easeOutExpo"});
		a("#consultoriaImg01, #consultoriaImg02, #consultoriaImg03, #consultoriaImg04, consultoriaImg05, #consultoriaImg06").css({top:428,opacity:0});
		a("#consultoriaImg02").delay(800).animate({top:-1,opacity:1},{duration:1200,easing:"easeOutExpo"});
		a("#consultoriaImg04").delay(1000).animate({top:-1,opacity:1},{duration:1200,easing:"easeOutExpo"});
		a("#consultoriaImg06").delay(1200).animate({top:-1,opacity:1},{duration:1200,easing:"easeOutExpo"});
		a("#consultoriaImg01").delay(1200).animate({top:-1,opacity:1},{duration:1200,easing:"easeOutExpo"});
		a("#consultoriaImg03").delay(1400).animate({top:-42,opacity:1},{duration:1200,easing:"easeOutExpo"});
		a("#consultoriaImg05").delay(1600).animate({top:-31,opacity:1},{duration:1200,easing:"easeOutExpo"})
	}
	
	function d(){
		a("*").clearQueue();
		a("#bookmark").css({width:0,opacity:1}).show().animate({width:822},{duration:1000,easing:"easeOutExpo"});
		a("#bookmark .menu li").css({top:-10,opacity:0});
		a("#bookmark .menu li:eq(0)").delay(600).animate({top:0,opacity:1},{duration:1000,easing:"easeOutExpo"});
		a("#bookmark .menu li:eq(1)").delay(700).animate({top:0,opacity:1},{duration:1000,easing:"easeOutExpo"});
		a("#bookmark .menu li:eq(2)").delay(800).animate({top:0,opacity:1},{duration:1000,easing:"easeOutExpo"});
		a("#bookmark .menu li:eq(3)").delay(800).animate({top:0,opacity:1},{duration:1000,easing:"easeOutExpo"});
		e()
	}
	
	function e(){
		var K=a("#bookmarkImg01").position();
		var I=a("#bookmarkImg02").position();
		var G=a("#bookmarkImg03").position();
		var F=a("#bookmarkImg04").position();
		var E=a("#bookmarkImg05").position();
		var D=a("#bookmarkImg06").position();
		var C=a("#bookmarkImg07").position();
		var B=a("#bookmarkImg08").position();
		var z=a("#bookmarkImg09").position();
		var y=a("#bookmarkImg10").position();
		var v=a("#bookmarkImg11").position();
		var p=K.top;
		var u=I.top;
		var H=G.top;
		var q=F.top;
		var w=E.top;
		var J=D.top;
		var r=C.top;
		var x=B.top;
		var L=z.top;
		var M=y.top;
		var t=v.top;
		var A=428;
		var s=-150;
		bookmarkInterval=setInterval(
			function(){
				if(p<=s){p=A}
				p-=0.6;
				a("#bookmarkImg01").css("top",p);
				
				if(u<=s){u=A}
				u-=0.3;
				a("#bookmarkImg02").css("top",u);
				
				if(H<=s){H=A}
				H-=0.5;
				a("#bookmarkImg03").css("top",H);
				
				if(q<=s){q=A}
				q-=0.2;
				a("#bookmarkImg04").css("top",q);
				
				if(w<=s){w=A}
				w-=0.5;
				a("#bookmarkImg05").css("top",w);
				
				if(J<=s){J=A}
				J-=0.2;
				a("#bookmarkImg06").css("top",J);
				
				if(r<=s){r=A}
				r-=0.5;
				a("#bookmarkImg07").css("top",r);
				
				if(x<=s){x=A}
				x-=0.3;
				a("#bookmarkImg08").css("top",x);
				
				if(L<=s){L=A}
				L-=0.2;
				a("#bookmarkImg09").css("top",L);
				
				if(M<=s){M=A}
				M-=0.6;
				a("#bookmarkImg10").css("top",M);
				
				if(t<=s){t=A}
				t-=0.5;
				a("#bookmarkImg11").css("top",t)
			},1)
	}
	
	function o(){
		a("*").clearQueue();
		a("#message").fadeOut(800).css({zIndex:99});
		a("#consultoria").fadeOut(800).css({zIndex:99});
		a("#bookmark").fadeOut(800).css({zIndex:99});
		a("#about").css({width:0,zIndex:98,opacity:1}).show().animate({width:822},{duration:1000,easing:"easeOutExpo"})
	}
	
	function c(){
		a("*").clearQueue();
		a("#about").fadeOut(800).css({zIndex:99});
		a("#consultoria").fadeOut(800).css({zIndex:99});
		a("#bookmark").fadeOut(800).css({zIndex:99});
		a("#message").css({width:0,zIndex:98,opacity:1}).show().animate({width:822},{duration:1000,easing:"easeOutExpo"})
	}
	
	function c2(){
		a("*").clearQueue();
		a("#about").fadeOut(800).css({zIndex:99});
		a("#message").fadeOut(800).css({zIndex:99});
		a("#bookmark").fadeOut(800).css({zIndex:99});
		a("#consultoria").css({width:0,zIndex:98,opacity:1}).show().animate({width:822},{duration:1000,easing:"easeOutExpo"})
	}
	
	function h(){
		a("*").clearQueue();
		a("#about").fadeOut(800).css({zIndex:99});
		a("#message").fadeOut(800).css({zIndex:99});
		a("#consultoria").fadeOut(800).css({zIndex:99});
		a("#bookmark").css({width:0,zIndex:98,opacity:1}).show().animate({width:822},{duration:1000,easing:"easeOutExpo"});
		e()
	}
	
	function n(){
		a("*").clearQueue();
		a("#about").fadeOut(800);
		a("#nav li").css({top:0,opacity:1});
		a("#nav").delay(800).css({width:0}).animate({width:"150px"},{duration:1000,easing:"easeOutExpo"})
	}
	
	function m(){
		a("*").clearQueue();
		a("#message").fadeOut(800);
		a("#nav li").css({top:0,opacity:1});
		a("#nav").delay(800).css({width:0}).animate({width:"150px"},{duration:1000,easing:"easeOutExpo"})
	}
	
	function con2(){
		a("*").clearQueue();
		a("#consultoria").fadeOut(800);
		a("#nav li").css({top:0,opacity:1});
		a("#nav").delay(800).css({width:0}).animate({width:"150px"},{duration:1000,easing:"easeOutExpo"})
	}
	
	function i(){
		a("*").clearQueue();
		a("#bookmark").fadeOut(800);
		a("#nav li").css({top:0,opacity:1});
		a("#nav").delay(800).css({width:0}).animate({width:"150px"},{duration:1000,easing:"easeOutExpo"})
	}
	
	return this.unbind("click").click(j)
	
	}
})

(jQuery);$(function(){	$("#openAbout, #openMessage, #openConsultoria, #openBookmark, .menuAbout, .menuMessage, .menuConsultoria, .menuBookmark").openWindow()});

(function(a){
	a.fn.openContact=function(){
		var b=this;
		var d=!!document.createElement("audio").canPlayType;
		
		function f(){c(this,b);return false}
		function c(i,h){e();a("#contactClose").click(function(){g()})}
		function e(){
			if(a("#soundBtnOff").css("display")==="none"&&d===true){
				a("#audioClick").load();
				a("#audioClick").get(0).play()
			}
			a("#contact").after('<div id="overlay" style="background-color:#000; position:absolute; top:0; left:0; width:100%; height:100%; z-index:199; opacity:0;"></div>');
			a("#overlay").animate({opacity:0.9},400);
			a("#contact").hide().delay(400).fadeIn(400);
			a("#contactClose img").hide().css({left:"-28px"}).delay(400).show().animate({left:0},{duration:600,easing:"easeOutExpo"})
		}
		function g(){
			a("#overlay").remove();
			a("#contact").hide()
		}
		return this.unbind("click").click(f)
	}
})

(jQuery);$(function(){$(".openContact").openContact()});
