// ================================================
//	defalut.js 
//	Version 1.0
//	2008.12.06
//
//	1 . Pass Setting
//	2 . Default JS Load
//	3 . Default Setting
//	5 . Browser Check
//	5 . Browser Switch Css
//	6 . Favicon
//	7 . Jrails
//	8 . Flash Load
//	9 . Swap Image
//
// ================================================


// 1 . Pass Setting
// ================================================

var relativePass = "./";

// ================================================


// 2 . Default JS Load
// ================================================

document.write('<script src="'+relativePass+'js/yuga.js" type="text/javascript"></script>');
document.write('<script src="'+relativePass+'plugin/lightbox/js/jquery.lightbox-0.5.js" type="text/javascript"></script>');
document.write('<script src="'+relativePass+'js/fadeIn.js" type="text/javascript"></script>');
/*
document.write('<script src="'+relativePass+'js/thickbox.js" type="text/javascript"></script>');
*/

// ================================================


// 3 . Default Setting
// ================================================

var cssSwitch     = true;
var jrails        = false;
var favicon       = true;

// ================================================


// 4 . Browser Check
// ================================================
function BrowserInfo(userAgent) {

	/*****************************************
	 * Geckoエンジンバージョンチェッカー
	 * (返値 int 合致しない場合は-1)
	 *****************************************/
	this.geckoVersionChecker = function(){
		var num = this.ua.match(new RegExp("Gecko/20[0-9]{6}"));
		return ( num == null ) ? -1 : parseInt(String(num).replace("Gecko/",""));
	}

	/*****************************************
	 * WebKitバージョンチェッカー
	 * (返値 float 合致しない場合は-1)
	 *****************************************/
	this.webkitVersionChecker = function(){
		var num = this.ua.match(new RegExp("WebKit/[0-9]{1,4}(\.[0-9]{1,2})?"));
		return ( num == null ) ? -1 : parseFloat(String(num).replace("Firefox/",""));
	}

	/*****************************************
	 * IEバージョンチェッカー
	 * (返値 float 合致しない場合は-1)
	 *****************************************/
	this.ieVersionChecker = function(){
		var ienum = this.ua.match(new RegExp("MSIE [0-9]{1,2}\.[0-9]{1,3}"));
		return ( ienum == null ) ? -1 : parseFloat(String(ienum).replace("MSIE ",""));
	}
	

	/*****************************************
	 * Firefoxバージョンチェッカー
	 * (返値 float 合致しない場合は-1)
	 *****************************************/
	this.firefoxVersionChecker = function(){
		var num = this.ua.match(new RegExp("Firefox/[0-9]{1,2}\.[0-9]{1,2}"));
		return ( num == null ) ? -1 : parseFloat(String(num).replace("Firefox/",""));
	}

	/*****************************************
	 * Operaバージョンチェッカー
	 * (返値 float 合致しない場合は-1)
	 *****************************************/
	this.operaVersionChecker = function(){
		var num = this.ua.match(new RegExp("Opera[/ ][0-9]{1,2}\.[0-9]{1,2}"));
		return ( num == null ) ? -1 : parseFloat(String(num).substr(6));
	}

	/*****************************************
	 * Safariバージョンチェッカー
	 * (返値 float 合致しない場合は-1)
	 *****************************************/
	this.safariVersionChecker = function(){
		var num = this.ua.match(new RegExp("Safari/[0-9]{1,4}\.[0-9]{1,2}"));
		return ( num == null ) ? -1 : parseFloat(String(num).replace("Safari/",""));
	}

	/*****************************************
	 * Netscapeバージョンチェッカー
	 * (返値 float 合致しない場合は-1)
	 *****************************************/
	this.netscapeVersionChecker = function(){
		var num = this.ua.match(new RegExp("Netscape[0-9]?/[0-9]{1,2}\.[0-9]{1,3}"));
		return ( num == null ) ? -1 : parseFloat(String(num).replace(new RegExp("Netscape[0-9]?/"),""));
	}

	/*****************************************
	 * Mozillaバージョンチェッカー
	 * (返値 float 合致しない場合は-1)
	 *****************************************/
	this.mozillaVersionChecker = function(){
		var num = this.ua.match(new RegExp("Mozilla/[0-9]{1,2}\.[0-9]{1,2}"));
		return ( num == null ) ? -1 : parseFloat(String(num).replace("Mozilla/",""));
	}
	// -- コンストラクタ --

	this.ua = (userAgent) ? userAgent : navigator.userAgent;

	this.geckoVersion = this.geckoVersionChecker();
	this.gecko = (this.geckoVersion > 0 );

	this.webkitVersion = this.webkitVersionChecker();
	this.webkit = (this.webkitVersion > 0 );

	this.ieVersion = this.ieVersionChecker();
	this.ieMVersion = Math.floor(this.ieVersion);
	this.ie = ( this.ieVersion >= 3 );
	this.macie = ( this.ua.match("Mac_PowerPC") != null );

	this.firefoxVersion = this.firefoxVersionChecker();
	this.firefoxMVersion = Math.floor(this.firefoxVersion);
	this.firefox = (this.firefoxVersion > 0 );

	this.safariVersion = this.safariVersionChecker();
	this.safariMVersion = Math.floor(this.safariVersion);
	this.safari = (this.safariVersion > 85 );

	this.operaVersion = this.operaVersionChecker();
	this.operaMVersion = Math.floor(this.operaVersion);
	this.opera = (this.operaVersion > 1 );
	
	this.netscapeVersion = this.netscapeVersionChecker();
	this.netscapeMVersion = Math.floor(this.netscapeVersion);
	this.netscape = (this.netscapeVersion > 1 );
	
	this.mozillaVersion = this.mozillaVersionChecker();
	this.mozilla = ( !this.firefox && !this.opera && !this.ie && !this.netscape && this.mozillaVersion > 0 ); 
	
	this.toString = function(){
		return ("[ua:"+this.ua+"  netscapeVersion:"+this.netscapeVersion+"  operaVersion:" + this.operaVersion + "  webkitVersion:"+ this.webkitVersion +"  safariVersion:"+this.safariVersion+"  ieVersion:"+ this.ieVersion +"  macie:" + this.macie  + "  geckoVersion:" +this.geckoVersion + " firefoxVersion:" +this.firefoxVersion +"]" );
	}
}

var UA = new BrowserInfo();

// ================================================


// 5 . Browser Switch Css
// ================================================

if (cssSwitch == true) {
	if (UA.ie) {
		UA['css'] = 'winie.css'; 
	}
	if (UA.firefox) {
		UA['css'] = 'firefox.css'; 
	}
	if (UA.safari) {
		UA['css'] = 'safari.css'; 
	}
	if (UA.macie) {
		UA['css'] = 'macie.css'; 
	}
	document.write('<link href="'+relativePass+'css/'+UA.css+'" rel="stylesheet" type="text/css" />');
}

// ================================================


// 6 . Favicon
// ================================================

if (favicon == true) {
	document.write('<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />');
}

// ================================================



// 7 . Jrails
// ================================================

if (jrails == true) {
	document.write('<script src="'+relativePass+'js/jquery-fx.js" type="text/javascript"></script>');
	document.write('<script src="'+relativePass+'js/jquery-ui.js" type="text/javascript"></script>');
	document.write('<script src="'+relativePass+'js/aplication.js" type="text/javascript"></script>');
	document.write('<script src="'+relativePass+'js/jrails.js" type="text/javascript"></script>');
}

// ================================================


// 8 . Flash Load
// ================================================

document.write('<script src="'+relativePass+'js/AC_RunActiveContent.js" type="text/javascript"></script>');
function flashObject(file,width,height){
	
	document.write('<script type="text/javascript">');
	document.write("AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','"+width+"','height','"+height+"','src','"+file+"','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','"+file+"' ); ");
	document.write('</script>');
	document.write('<noscript>');
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+width+'" height="'+height+'">');
	document.write('<param name="movie" value="'+file+'.swf" />');
	document.write('<param name="quality" value="high" />');
	document.write('<embed src="'+file+'.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed>');
	document.write('</object>');
	document.write('</noscript>');
	
}

// ================================================



// 9 . Swap Image
// ================================================

function swapImage(target,zoomImage,outImage){
	$(target).attr("src",zoomImage);
	if(outImage){
		$(this).mouseout(function(){
			$(target).attr("src",outImage);					  
		});
	}
}

// ================================================
