﻿/*************************************************
* functions with jQuery
* since:	2010-11-25
* last update: 2011-01-11
* create: morita
*************************************************/
/*====================================================================


 ■　function.js


--------------------------------------------------------------------*/


/*====================================================================

 □　初期設定

--------------------------------------------------------------------*/
/* pngfix */
document.write('<script type="text/javascript" src="common/js/jquery.pngFix.js" charset="utf-8"></script>')


/*====================================================================

 □　処理リスト

--------------------------------------------------------------------*/

$(document).ready(function(){
	//実行する処理を記述
	funcHighlightPages();
	funcRollOver();
	funcPageScroll()
	funcPopup();
	funcPngfix();
	//funcCrossBrowser()
});
/*--------------------------------------------
	HighlightPages [グローバルナビ制御]
--------------------------------------------*/
function funcHighlightPages(){
	var url=document.URL
	var protocol=document.location.protocol
	var domain=document.domain
	var path=protocol+"//"+domain
	var onHref=url.substring(url.lastIndexOf("/")+1,url.length);
	//
	$('#nav a[href]').each(function(){
		var a=$(this);
    var hrefSrc=a.attr('href');
		//var href=hrefSrc.substring(0,hrefSrc.lastIndexOf("/")+1)
		//
		if(hrefSrc==onHref){
    	a.each(function(){
					activeImg($(this))
      })
		}else if(onHref.match("menu_")){
			if(hrefSrc=="menu.html"){
				activeImg($(this))
			}
		}else if(onHref.match("know")){
			if(hrefSrc=="knowcurry.html"){
				activeImg($(this))
			}
		}else if(onHref==""){
			if(hrefSrc=="./"){
				activeImg($(this))
			}
		}
	});
	$('.side-nav a[href]').each(function(){
		var a=$(this);
    var hrefSrc=a.attr('href');
		if(hrefSrc==onHref){
    	a.each(function(){
					activeImg($(this))
      })
		}
	})
	//active
	function activeImg(obj){
		var onSrc=obj.find('img').attr('src').replace('_off.','_on.')
		obj.find('img').attr('src',onSrc)
		var tags=obj.find('img');
		obj.replaceWith(tags);
	}
};
/*--------------------------------------------
	funcRollOver [ロールオーバー制御]
--------------------------------------------*/
function funcRollOver(){
	var cache = [];
	$('img[src*=_off.],input[src*=_off.]').hover(function(){
           var onSrc=$(this).attr('src').replace('_off.','_on.')
           $(this).attr('src',onSrc)
       },function(){
           var offSrc=$(this).attr('src').replace('_on.','_off.')
           $(this).attr('src',offSrc)
       }).each(function(){
		var cacheImage = $(this)
		var cacheSrc=cacheImage.attr('src').replace('_off.','_on.')
		cacheImage.src = cacheSrc;
		cache.push(cacheImage);
	})
};

/*--------------------------------------------
	funcPageScroll [ページスクロール制御]
--------------------------------------------*/

function funcPageScroll(){
	$(".pagetop a").click(function(e){
		e.preventDefault(); 																
		$((navigator.userAgent.indexOf("Opera") != -1) ? document.compatMode == 'BackCompat' ? 'body' : 'html' :'html,body').animate({scrollTop:0}, 'normal');
	});
}

/*--------------------------------------------
	funcPopup [ポップアップ]
--------------------------------------------*/
function funcPopup(){
	$(".popup").click(function(){	
		var w=window.open(this.href, "popup","width=670,height=600,resizable=yes,scrollbars=yes");
		w.focus();
		return false;
	});
}		

/*--------------------------------------------
	funcPngfix [pngfix]
--------------------------------------------*/
function funcPngfix(){
	$('img[src*=.png]').pngFix();
}

/*--------------------------------------------
	funcCrossBrowser [ブラウザバグ調整]
--------------------------------------------*/
/*
function funcCrossBrowser(){

	if(navigator.userAgent.indexOf("Firefox/3.0") != -1 || navigator.userAgent.indexOf("Firefox/3.5") != -1){
		;	
	}
	
	if(navigator.userAgent.indexOf("Opera") != -1){ 
		
	}
	
	if(navigator.userAgent.indexOf("Mac") != -1 && navigator.userAgent.indexOf("Safari") != -1 ){ 
		
	}
	
	if(navigator.userAgent.indexOf("Mac") != -1 && navigator.userAgent.indexOf("Firefox") != -1 ){
		
	}	
	
	if(navigator.userAgent.indexOf("iPad") != -1){
		
	}	

}
*/
