var get = getRequest();
var x = get['page'];
var y = 'btn_l' + x;

function init() {
	if(x==null){
	blurLinks()
	smartRollover();
	}else{
	blurLinks();
	smartRollover();
	activate(x);
	makeActive(y);
	}
}

function getRequest(){
	if(location.search.length > 1) {
		var get = new Object();
		var ret = location.search.substr(1).split("&");
			for(var i = 0; i < ret.length; i++) {
				var r = ret[i].split("=");
			get[r[0]] = r[1];
		}
		return get;
	} else {
		return false;
	}
}


/*display操作*/

function activate(n){
	for(i=1;i<6;i++){
		document.getElementById('btn_l' + i).style.display = "none";
	}
	for(i=1;i<=n;i++){
		document.getElementById('btn_l' + i).style.display = "block";
	}
	for(i=1;i<6;i++){
		document.getElementById('btn_r' + i).style.display = "block";
	}
	for(i=1;i<=n;i++){
		document.getElementById('btn_r' + i).style.display = "none";
	}
}


/*make active*/
function makeActive(id){
	for(i = 1; i < 6; i++){
		if(document.getElementById('btn_l' + i).className) {
			document.getElementById('btn_l' + i).className = document.getElementById('btn_l' + i).className.replace(/active/g, "");
		}
	}
	document.getElementById(id).className += " active";
	deleteActive();
	var element = document.getElementById(id);
	element.style.backgroundPosition = "100% 0";
}

function deleteActive(){
	for(i = 1; i < 6; i++){
		var elements = document.getElementById('btn_l' + i);
		elements.style.backgroundPosition = "50% 0";
	}
}

/*page format*/
function pageFormat(){
	document.getElementById('btn_l1').style.display = "none";
	document.getElementById('btn_r1').style.display = "block";
}

/*focus outline*/
function unblur() {
this.blur();
}

function blurLinks() {
	if (!document.getElementById) return;
	theLinks = document.getElementsByTagName("a");
	for(i=0; i<theLinks.length; i++) {
		theLinks[i].onfocus = unblur;
	}
}

/*roll over*/

function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");

		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_out."))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_out.", "_over."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_over.", "_out."));
				}
			}
		}
	}
}

/*smoothscroll*/

var pointTOP=0;

function ECOGetVersion(){
if (navigator.userAgent.indexOf('Mac',0) != -1){ useos='Mac';}
else if (navigator.userAgent.indexOf('Win',0) != -1){ useos='Win';}
else {useos='other'; }
if (navigator.userAgent.indexOf('MSIE 3.',0) != -1){usebrowser='IE3';}
else if (navigator.userAgent.indexOf('MSIE 4.',0) != -1){usebrowser='IE4';}
else if (navigator.userAgent.indexOf('MSIE 5.',0) != -1){usebrowser='IE5';}
else if (navigator.userAgent.indexOf('MSIE 6.',0) != -1){usebrowser='IE6';}
else if (navigator.userAgent.indexOf('MSIE 7.',0) != -1){usebrowser='IE7';}
else if (navigator.userAgent.indexOf('Netscape/7.',0) != -1){usebrowser='NN7';}
else if (navigator.userAgent.indexOf('Netscape/6.',0) != -1){usebrowser='NN6';}
else if (navigator.userAgent.indexOf('Mozilla/4.',0) != -1){usebrowser='NN4';}
else if (navigator.userAgent.indexOf('Firefox',0) != -1){usebrowser='Firefox_NN';}
else if (navigator.userAgent.indexOf('Gecko',0) != -1){usebrowser='other_Gecko_NN';}
else {usebrowser='other_IE';}
return (usebrowser);
}

function ECOpagemove(Y){
ua=ECOGetVersion();
if ( ua.indexOf('IE',0)!= -1){ 
	if ( document.compatMode == 'CSS1Compat'){ nowY=document.documentElement.scrollTop; }
	else{ nowY=document.body.scrollTop; }
windowY=document.body.clientWidth
}
else if ( ua.indexOf('NN',0)!= -1){
nowY=window.pageYOffset;
windowY=window.innerWidth;
}
else { return(0,0) ; }
if (Y < nowY){ setTimeout("Lscroll("+Y+","+nowY+")",20); }
else{ setTimeout("Rscroll("+Y+","+nowY+")",8); }
}

function Lscroll(Y,nowY){
if (Y >= nowY)return;
moveY = Math.ceil( (nowY - Y) * 0.16)+2;
if (Y >= (nowY-moveY)){moveY=nowY-Y;}
scrollBy(0,-moveY);
nowY=nowY-moveY;
setTimeout("Lscroll("+Y+","+nowY+")",20);
}

function Rscroll(Y,nowY){
if (Y <= nowY)return;
moveY = Math.ceil( (Y - nowY) * 0.16)+2;
if (Y <= (nowY+moveY)){moveY=Y-nowY;}
scrollBy(0,moveY);
nowY=nowY+moveY;
setTimeout("Rscroll("+Y+","+nowY+")",20);
}

/*google map*/

function accessMap() {
var map = new GMap(document.getElementById('map'));

//所在地の座標設定
var lon  = 139.704129 ;//経度
var lat  = 35.710683 ;//緯度
var myoffice = new GPoint(lon,lat);

//所在地を中心にする
map.centerAndZoom(myoffice , 0);// 数値部分を変えると詳細-広域に変更できます。0-17
//中心を所在地と別に設定する場合
//map.centerAndZoom(new GPoint(135.6591796875, 34.70549341022544) , 0);

//コントロール追加
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());

// 所在地の地点にアイコンを設定する
// Create a base icon for all of our markers that specifies the
// shadow, icon dimensions, etc.
var baseIcon = new GIcon();
baseIcon.shadow = 'http://www.odysseus.co.jp/wp-content/themes/odysseus/images/odysseus_shadow.png';
baseIcon.iconSize = new GSize(75, 60);
baseIcon.shadowSize = new GSize(75, 60);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);
baseIcon.infoShadowAnchor = new GPoint(18, 25);

var icon = new GIcon(baseIcon);
icon.image = 'http://www.odysseus.co.jp/wp-content/themes/odysseus/images/odysseus.png';

//所在地を表示する
var marker = new GMarker(myoffice,icon);
//var marker = new GMarker(myoffice);// デフォルトのマーカー画像を利用する場合
map.addOverlay(marker);
}

window.onload=init;
