/***************************************************************************

img a brightness

***************************************************************************/

$(document).ready(function(){
	/*seltab('box', 'head', 10, 1);	*/
	pageScroll(".to-top","#container");
	smartRollover();	   
	checkURI();

	$("#contents-inner a img").mouseover(function () {
	  $(this).fadeTo("fast", 0.8);
	});
	
	$("#contents-inner a img").mouseout(function () {
	  $(this).fadeTo("fast", 1);
	});
});

/***************************************************************************

グローバルナビに色をつける

***************************************************************************/
var checkURI = function(){
	var loc = location.href;
	var nav = document.getElementById("gnav");
	var lists = nav.getElementsByTagName("li");
	/*if(loc.indexOf("/index.html") != -1 ){
		lists[0].getElementsByTagName("img")[0].src = "common/images/gnav00_cr.jpg";
	}*/
	if(loc.indexOf("/company/index.html") != -1 ){
		lists[1].getElementsByTagName("img")[0].src = "../common/images/gnav01_cr.jpg";
	}
	if(loc.indexOf("/intro/index.html") != -1 ){
		lists[2].getElementsByTagName("img")[0].src = "../common/images/gnav02_cr.jpg";
	}
	if(loc.indexOf("/inquiry/index.html") != -1 ){
		lists[3].getElementsByTagName("img")[0].src = "../common/images/gnav04_cr.jpg";
	}
	if(loc.indexOf("/link/index.html") != -1 ){
		lists[4].getElementsByTagName("img")[0].src = "../common/images/gnav03_cr.jpg";
	}
}
/***************************************************************************

form checkbox all choose

***************************************************************************/

function allcheck(obj,flag){
/*var target=obj.parentNode.getElementsByClassName("checkall");*/
var target=obj.parentNode.parentNode.getElementsByTagName("input");
for(var i=0;i<target.length;i++){
if(target[i].type=="checkbox") target[i].checked=flag;
}
}

//スマートロールオーバー
//---------------------------
var smartRollover = function () {  
	if(document.getElementsByTagName) {  
		var images = document.getElementsByTagName("img");  
			for(var i=0; i < images.length; i++) {  
				if(images[i].getAttribute("src").match("_off.")){  
					images[i].onmouseover = function() {  
					this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));  
				}
				images[i].onmouseout = function(){
					this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));  
					}
				}
			}
		}  
}


//スマートスクロール
//---------------------------
function pageScroll(patrg,target){
    jQuery(patrg).click(function () {
        jQuery(this).blur();
        jQuery('html,body').animate({ scrollTop: jQuery(target).offset().top }, 'fast');
        return false;
    });
}

//ウインドウオープン
//---------------------------
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/***************************************************************************

tab

***************************************************************************/
var tab = {
	init: function(){
		var tabs = this.setup.tabs;
		var pages = this.setup.pages;
		
		for(i=0; i<pages.length; i++) {
			if(i !== 0) pages[i].style.display = 'none';
			tabs[i].onclick = function(){ tab.showpage(this); return false; };
		}
	},
	
	showpage: function(obj){
		var tabs = this.setup.tabs;
		var pages = this.setup.pages;
		var num;
		
		for(num=0; num<tabs.length; num++) {
			if(tabs[num] === obj) break;
		}
		
		for(var i=0; i<pages.length; i++) {
			if(i == num) {
				pages[num].style.display = 'block';
				tabs[num].className = 'present';
			}
			else{
				pages[i].style.display = 'none';
				tabs[i].className = null;
			}
		}
	}
}
