  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-23210021-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

//
//ドメインを確認
//

//************************
//実行
//************************
$(document).ready(function(){
	pageScroll(".to-top","#container");
	smartRollover();
	checkURI();
	newWidewin();
});


//************************
//関数
//************************

//メインナビゲーションのカレント
//---------------------------
var checkURI = function(){
	
	var chPath = "/common/images/"
	
	var chImgs = new Array(chPath+'nav1_cr.gif',
							chPath+'nav2_cr.gif',
							chPath+'nav3_cr.gif',
							chPath+'nav4_cr.gif',
							chPath+'nav5_cr.gif',
							chPath+'nav6_cr.gif');
	
	var loc = location.href;
	var nav = document.getElementById("nav");
	var navImgs = document.getElementsByTagName("img");
	
	if(document.getElementById("local-nav")){
		var lnav = document.getElementById("local-nav");
		var lnavList = lnav.getElementsByTagName("li");
	}
	
	if(loc.indexOf("/company/") != -1 ){
		navImgs[2].src = chImgs[0];
	}
		if(document.getElementById("local-nav")){
			if(loc.indexOf("/company/index.html") != -1 ){
				lnavList[0].id = "lnav-current";
			}
			if(loc.indexOf("/company/overview.html") != -1 ){
				lnavList[1].id = "lnav-current";
			}
		}
	
	if(loc.indexOf("/lpgus/") != -1 ){
		navImgs[3].src = chImgs[1];
	}
		if(document.getElementById("local-nav")){
			if(loc.indexOf("/safety/") != -1 ){
				lnavList[0].id = "lnav-current";
			}
			if(loc.indexOf("/howto/") != -1 ){
				lnavList[1].id = "lnav-current";
			}
			if(loc.indexOf("/usage/") != -1 ){
				lnavList[2].id = "lnav-current";
			}
		}
	
	if(loc.indexOf("/sunvista/") != -1 ){
		navImgs[4].src = chImgs[2];
	}
		if(document.getElementById("local-nav")){
			if(loc.indexOf("/mechanism/") != -1 ){
				lnavList[0].id = "lnav-current";
			}
			if(loc.indexOf("/item/") != -1 ){
				lnavList[1].id = "lnav-current";
			}
			if(loc.indexOf("/flow/") != -1 ){
				lnavList[2].id = "lnav-current";
			}
			if(loc.indexOf("/construction/") != -1 ){
				lnavList[3].id = "lnav-current";
			}
			if(loc.indexOf("/case/") != -1 ){
				lnavList[4].id = "lnav-current";
			}
			if(loc.indexOf("/works/") != -1 ){
				lnavList[5].id = "lnav-current";
			}
			if(loc.indexOf("/sunvista/faq/") != -1 ){
				lnavList[6].id = "lnav-current";
			}
			if(loc.indexOf("/subsidy/") != -1 ){
				lnavList[7].id = "lnav-current";
			}
			if(loc.indexOf("/selling/") != -1 ){
				lnavList[8].id = "lnav-current";
			}
		}
	
	if(loc.indexOf("/reform/") != -1 ){
		navImgs[5].src = chImgs[3];
	}
		if(document.getElementById("local-nav")){
			if(loc.indexOf("/product/") != -1 ){
				lnavList[0].id = "lnav-current";
			}
			if(loc.indexOf("/construction/") != -1 ){
				lnavList[1].id = "lnav-current";
			}
		}
	
	if(loc.indexOf("/products/") != -1 ){
		navImgs[6].src = chImgs[4];
	}
		if(document.getElementById("local-nav")){
			if(loc.indexOf("/enefarm/") != -1 ){
				lnavList[3].id = "lnav-current";
			}
			if(loc.indexOf("/cooker/") != -1 ){
				lnavList[2].id = "lnav-current";
			}
			if(loc.indexOf("/boiler/") != -1 ){
				lnavList[1].id = "lnav-current";
			}
			if(loc.indexOf("/gas-table/") != -1 ){
				lnavList[0].id = "lnav-current";
			}
		}
	
	if(loc.indexOf("/faq/") != -1 ){
		navImgs[7].src = chImgs[5];
	}
			
}



//スマートロールオーバー
//---------------------------
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."));  
					}
				}
			}
		}  
}

//スマートスクロール
//---------------------------
var pageScroll = function (trg,target){
	$(trg).click(function () {
		$(this).blur();
		$('html,body').animate({ scrollTop: $(target).offset().top }, 'fast');
		return false;
	});
}

//ウィンドウオープン
//---------------------------

var newWin = function(file){
	var w = window.open(file,"win","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=580,height=600");
	w.focus();
}

var newWidewin = function(){
	$(".wide-win").click(function () {
		window.open($(this).attr("href"),"","scrollbars=yes,resizable=yes,width=780,height=690");
		return false;
	});
}
