//=============================================
// docRoot Search
//=============================================
if(document.domain.indexOf("bahamas") >= 0 ){
	var splitStr   = "bahamasrecords.com/";
}else if(document.domain.indexOf("onderland") >= 0 ){
	var splitStr   = "onderland.in/";
}else if(document.domain.indexOf("sakura") >= 0 ){
	var splitStr   = "sakura.ne.jp/";
	var rootpath = true;
}else if(document.domain.indexOf("heteml") >= 0 ){
	var splitStr   = "heteml.jp/";
}else if(document.domain.indexOf("birdman") >= 0 ){
	var splitStr   = "records/";
}else{
	var splitStr   = "bahama/";
}

var docRootlng = location.href.split(splitStr)[1].split("/");
var docRoot = "";
	for(var i=0;i<(docRootlng.length)-1;i++){
		docRoot += "../";
	}

if(rootpath){
	docRoot = "http://www.bahamasrecords.com/";
}

//=============================================
// SmartRollOver()
//=============================================
function initRollovers() {
	if (!document.getElementById) return

	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {	
		if (aImages[i].className == 'ov') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);

			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;

			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	

			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}


//=============================================
// BlWin2()
//=============================================
function BLinks() {
	if (!document.getElementsByTagName) return;

	var anchors = document.getElementsByTagName("a");

	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") &&
		anchor.getAttribute("rel") == "bl")
		anchor.target = "_blank";
		if(anchor.parentNode.className == "photo"){
			anchor.target = "photowin";
		}
	}

}


//=============================================
// curCheck
//=============================================
function curCheck(){	
	var myurl = location.href;
	var cdir = myurl.split(splitStr)[1].split("/");
		cdir.pop();
		if(cdir.length > 1){
			cdir.pop();
		}
		var val = cdir.join("/");
		
	if(document.getElementById("header")){var myobjs= document.getElementById("header").getElementsByTagName("ul")[0].getElementsByTagName("a");}
	if(myobjs){
		for( var i = 0; i < myobjs.length; i ++ ){
			if( cdir.length != 0 && myobjs[i].href.split("index.html")[0].indexOf(val) >= 0 ){
				myobjs[i].getElementsByTagName("img")[0].src = myobjs[i].getElementsByTagName("img")[0].src.split(".gif").join("_c.gif");
			}else{
				if(myobjs[i].getElementsByTagName("img")[0]){
					myobjs[i].getElementsByTagName("img")[0].setAttribute("class","ov");
				}
			}
		}
	}
}


//=============================================
// setHeader
//=============================================
function setHeader(){
	// HEADER
	var _str = ""
		_str += '<div id="header">';
		_str += '<h1 class="logo"><a href="'+docRoot+'index.html"><img src="'+docRoot+'common/images/logo_bahamas.gif" alt="BAHAMAS RECORDS" width="115" height="30" /></a></h1>';
		_str += '<ul>';
		_str += '<li class="h01"><a href="'+docRoot+'index.html"><img src="'+docRoot+'common/images/hmenu01.gif" alt="HOME" width="74" height="25" /></a></li>';
		_str += '<li class="h02"><a href="'+docRoot+'information/index.html"><img src="'+docRoot+'common/images/hmenu02.gif" alt="NEWS" width="74" height="25" /></a></li>';
		_str += '<li class="h03"><a href="'+docRoot+'live/index.html"><img src="'+docRoot+'common/images/hmenu03.gif" alt="LIVE" width="74" height="25" /></a></li>';
		_str += '<li class="h04"><a href="'+docRoot+'artists/index.html"><img src="'+docRoot+'common/images/hmenu04.gif" alt="ARTISTS" width="84" height="25" /></a></li>';
		_str += '<li class="h05"><a href="'+docRoot+'aboutus/index.html"><img src="'+docRoot+'common/images/hmenu05.gif" alt="ABOUT US" width="94" height="25" /></a></li>';
		_str += '<li class="h06"><a href="https://bahama.sakura.ne.jp/contact/form.php"><img src="'+docRoot+'common/images/hmenu06.gif" alt="CONTACT" width="84" height="25" /></li>';
		_str += '<li class="h07"><a href="http://www.miracleplaza.jp/" rel="bl"><img src="'+docRoot+'common/images/hmenu07.gif" alt="SHOPPING" width="94" height="25" /></a></li>';
		_str += '<li class="h08"><a href="http://www.bahamasrecords.com/blog/coba_u/"><img src="'+docRoot+'common/images/hmenu_blog.gif" alt="Coba-U blog" width="37" height="36" /></a></li>';
		_str += '</ul>';
		_str += '</div>';
	document.write(_str);

}

//=============================================
// setFooter
//=============================================
function setFooter(){
	// FOOTER
	var _str = ""
		_str += '<div id="footer">';
		_str += '<div id="footer-inner">';
		_str += '<p class="f01"><a href="'+docRoot+'index.html"><img src="'+docRoot+'common/images/fmenu01.gif" alt="HOME" width="30" height="9" class="ov" /></a></p>';
		_str += '<p class="f02"><a href="javascript:void(0)" onclick="backToTop(); return false"><img src="'+docRoot+'common/images/fmenu02.gif" alt="PAGE TOP" width="60" height="9" class="ov" /></a></p>';
		_str += '<p class="f03"><img src="'+docRoot+'common/images/copyrights.gif" alt="COPYRIGHTS BAHAMAS RECORDS All RIGHTS RESERVED." width="235" height="9" /></p>';
		_str += '</div>';
		_str += '</div>';
	document.write(_str);

}


//=============================================
// backToTop
//=============================================
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), Math.floor(y / 2));

    if (x > 0 || y > 0) {
        window.setTimeout("backToTop()", 25);
    }
}

// 
function writeEmail(path){
	
	document.write('<a href="mailto:coba-u&#64;bahamasrecords.com"><img src="'+path+'/images/btn_contact.gif" alt="感染ボタン" width="204" height="62" class="ov" /></a>');
	
}


//=============================================
// init()
//=============================================

function init() {
	curCheck();
	BLinks();
	initRollovers();
}


window.onload=init;


//=============================================
// closewin
//=============================================
function closewin() {
	window.close();
}


//=============================================
// openPopup
//=============================================
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
