// JavaScript Document
/*
-------------------------------
acu用
Copyright (c) 2011 quip Design
http://www.qpqp.jp
-------------------------------
*/

//外部jsの読み込み
if (!Array.prototype.forEach) {
    Array.prototype.forEach = function(fun /*, thisp*/) {
        var len = this.length;
        if (typeof fun != "function")
            throw new TypeError();
        var thisp = arguments[1];
        for (var i = 0; i < len; i++) {
            if (i in this)
                fun.call(thisp, this[i], i, this);
        }
    };
}
var rootPath="";
if(level == 0){
	rootPath = "./";
}else{
	for(var i=0;i<level;i++){
		rootPath += "../";
	}
}
rootPath += "src/";

//初期値
var clickableOver;
var clickableObj = {
	'pmarkmap':'pmark','pmarkDefoX':-380,'pmarkDefoY':0,'pmarkOverX':-619,'pmarkOverY':0
}
var topChara;
var topAnimBtn;

var bgAnim;
var badge;
var pageTopBtn;
var characteristic;
var contactForm;

var script = $script.noConflict();
script.path = rootPath;

script('js/lib/jquery-1.4.4.min', 'jquery');
/*script.ready('jquery', function() {
	//try{console.debug("get jquery");}catch(e){}
	//alert("get jquery");
	script('js/lib/jquery.easing.1.3', 'jeasing');
});*/
script.ready('jquery', function() {
	//try{console.debug("get jeasing");}catch(e){}
	//alert("get jeasing");
	script(['js/jp/qpqp/utils/pagetop','js/cojp/acu/common/bganim','js/cojp/acu/common/badge','js/cojp/acu/common/pagetopbtn'], 'common');//ここに背景アニメも
	//script(['js/net/jomo-univ/common/opennavi','js/jp/qpqp/utils/pagetop'], 'common');
});
script.ready('common', function() {
	//try{console.debug("get common");}catch(e){}
	//alert("get common");
	//openNavi = new OpenNavi("openNavi");//背景アニメを生成
	checkPage();
});

function checkPage(){
	var body = $("body");
	var bodyIdName = body.attr("id");
	//alert(bodyIdName);
	//try{console.debug("checkPage "+bodyIdName);}catch(e){}
	
	if(bodyIdName == "top"){
		script(['js/jp/qpqp/display/clickableover','js/jp/qpqp/utils/hashchecker'], 'topParts');
		script.ready('topParts', function() {
			//try{console.debug("get topParts");}catch(e){}
			script(['js/cojp/acu/top/topchara','js/cojp/acu/top/topanimbtn'], 'topPager');
		});
		script.ready('topPager', function() {
			//try{console.debug("get topPager");}catch(e){}
			clickableOver = new ClickableOver("clickableOver", clickableObj);
			topChara = new TopChara("topChara","1000");
			topAnimBtn = new TopAnimBtn("topAnimBtn");
			$(".rss").each(function(){
				$(this).find("li:even").addClass("even");
			});
		});
		
	}else if(bodyIdName == "characteristic"){
		script(['js/lib/jquery.belatedPNG.min','js/jp/qpqp/utils/hashchecker'], 'characteristicParts');
		script.ready('characteristicParts', function() {
			//try{console.debug("get topParts");}catch(e){}
			script('js/cojp/acu/service/characteristic', 'characteristicPager');
		});
		script.ready('characteristicPager', function() {
			//try{console.debug("get topPager");}catch(e){}
			$(".pngfix").each(function(){
			 	try{$(this).fixPng();}catch(e){}
		 	});
			characteristic = new Characteristic("characteristic","1000");
		});
	}else if(bodyIdName == "accessmap"){
		//try{console.debug("accessmap accessmap");}catch(e){}
		var latlng = new google.maps.LatLng(35.633506, 139.709751);
		var myOptions = {
		  zoom: 18,
		  center: latlng,
		  mapTypeId: google.maps.MapTypeId.ROADMAP
		};
		var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
		
		var contentString = '株式会社ACU';
		var infowindow = new google.maps.InfoWindow({
			content: contentString
		});
		
		var marker = new google.maps.Marker({
		  position: latlng, 
		  map: map, 
		  title:"株式会社ACU"
		});
		
		google.maps.event.addListener(marker, 'click', function() {
		  infowindow.open(map,marker);
		});
	}else if(bodyIdName == "contact"){
		script('js/cojp/acu/contact/contactform', 'contactParts');
		script.ready('contactParts', function() {
			//try{console.debug("get topParts");}catch(e){}
			contactForm = new ContactForm("contactForm");
		});
	}
	bgAnim = new BgAnim("bgAnim");
 	badge = new Badge("badge");
	pageTopBtn = new PageTopBtn("pageTopBtn");
	preLoadImages(rootPath+"images/common/bg1.jpg", rootPath+"images/common/bg2.jpg",rootPath+"images/common/bg3.jpg");
}
function preLoadImages() {
  for (var i = 0, I = arguments.length; i < I; ++i) {
    new Image().src = arguments[i];
  }
}

