var visitedNum = 0;
var nowPage = 0;
var rootDir = "recruitsite";
var fileNames = new Array(
	"../company/index.html", 
	"../company/president.html", 
	"../company/code.html", 
	"../company/swat.html", 
	"../company/world.html", 
	"../company/info.html",
	"../company/map.html",
	"../service/index.html", 
	"../service/idc.html", 
	"../service/cloud.html",
	"../service/application.html",
	"../service/website.html",
	"../service/pureaxis.html",
	"../service/purepicture.html",
	"../service/okinawa.html",
	"../crew/maeda.html",
	"../crew/miyazato.html",
	"../crew/shimojo.html",
	"../recruit/index.html",
	"../recruit/info.html",
	"../recruit/link.html",
	"../company/dictionary.html",
//	"../recruit/entry.php",
//	"../recruit/entry.html",
	"../recruit/contact.html",
	"../recruit/faq.html"
);

(function ($) {
	$.fn.visitedContents = function () {
//		$.cookie("Cookieの名前", "Cookieの値");
		
		var i = 0;
		var dir = "";
		var tmpDir = location.href.split("/");
/*
		while (rootDir != tmpDir[tmpDir.length - (i + 1)]) {
			if (i > 2) {
				break;
			}
			dir = tmpDir[tmpDir.length - (i + 1)] + "/" + dir;
			i++;
		}
*/
		if (tmpDir[tmpDir.length - 2] == "recruit2013" || tmpDir[tmpDir.length - 2] == "public_html") {
			dir = "../" + tmpDir[tmpDir.length - 1];
		}
		else {
			dir = "../" + tmpDir[tmpDir.length - 2] + "/" + tmpDir[tmpDir.length - 1];
		}
		
		for (var j = 0; j < fileNames.length; j++) {
			if (fileNames[j] == dir) {
				$.cookie("lex" + j, "true", { path:'/' });
				break;
			}
		}
		
		
		for (var k = 0; k < fileNames.length; k++) {
			if ($.cookie("lex" + k) == "true") {
				$("footer div#footerNav div#visitedContents li").eq(k).addClass("visited");
				visitedNum++;
			}
		}
		var percent = parseInt(visitedNum / fileNames.length * 100);
		$("footer div#footerNav div#visitedRate span#percent").text(percent);
		
//		if (percent >= 95) {
		if (percent >= 99) {
			if ($.cookie("lexMax") != "true") {
				
				popUpMessage();
				//window.open("http://www.google.co.jp/imgres?q=%E3%83%AC%E3%82%AD%E3%82%B5%E3%82%B9&um=1&hl=ja&client=firefox-a&rls=org.mozilla:ja:official&biw=1254&bih=689&tbm=isch&tbnid=U-YqtCHFn9bGQM:&imgrefurl=http://memui.ti-da.net/d2010-05.html&docid=nm6mMyBBeV1gQM&w=400&h=300&ei=QaBwTvEfotKYBeepnP8J&zoom=1&iact=hc&vpx=201&vpy=159&dur=481&hovh=194&hovw=259&tx=106&ty=86&page=1&tbnh=154&tbnw=221&start=0&ndsp=15&ved=1t:429,r:0,s:0", "WindowName","width=600,height=500,resizable=yes,scrollbars=yes");
			}
			$.cookie("lexMax", "true", { path:'/' });
			
			$("p span#percent").css("cursor", "pointer");
			$("p span#percent").click(function(event) {
				popUpMessage();
			});
		}
		
		$("div#sub li").mouseover(
			function() {
				$(this).addClass("hover");
			}
		);
		$("div#sub li").mouseout(
			function() {
				$(this).removeClass("hover");
			}
		);
		
	}
})(jQuery);



function popUpMessage() {
	var parent = $("body"); 
	var mask = document.createElement('div');
	parent.append(mask);
	$(mask).addClass("mask");
	
	var message = document.createElement('div');
	message.innerHTML = '<div id="moveBox"><iframe width="500" height="284" src="http://www.youtube.com/embed/cbHQXEMhX3g" frameborder="0" allowfullscreen></iframe></div><p id="closeMovie"></p><p id="textBox">「100%」の文字をクリックすると、もう一度再生できます。</p>';
	
	
	parent.append(message);
	$(message).addClass("message100");
	
	
	$(mask).click(function(event) {
		$("iframe").remove();
		$(mask).removeClass("mask");
		$(mask).remove();
		$(message).remove();
	});
	
	$("p#closeMovie").click(function(event) {
		$("iframe").remove();
		$(mask).remove();
		$(message).remove();
	});
}



