// プラットフォーム・ブラウザごとのフォントスタイル読込
var plat = (navigator.userAgent.indexOf("Win") >= 0) ;
if(plat) {
	document.write('<link rel="stylesheet" href="/css/font_win.css" type="text/css" media="all">');
}else{
	var plat = (navigator.userAgent.indexOf("Safari") >= 0) ;
	if(plat) {
		document.write('<link rel="stylesheet" href="/css/font_safari.css" type="text/css" media="all">');
	}else
	{document.write('<link rel="stylesheet" href="/css/font_mac.css" type="text/css" media="all">');}
}

var plat = (navigator.userAgent.indexOf("Opera") >= 0) ;
if(plat) {
	document.write('<link rel="stylesheet" href="/css/font_opera.css" type="text/css" media="all">');
}else{}

// トップフラッシュ
function setFlash(){
　　var so = new SWFObject("/swf/mainimg.swf", "mainimg", "860", "201", "8", "#ffffff");
　　//ムービーファイル名、ムービーのID、width,height,Flashのバージョン,背景色
　　//パラメーターの追加
　　so.addParam("quality", "high");
　　so.addParam("salign", "lt");
　　//変数を渡す場合
　　document.write(so.getSWFHTML());
}

// ポップアップ
function popupmap(filename,winname) {
newWin=window.open(filename,winname,"width=670,height=600,menubar=1,scrollbars=1,toolbar=1,resizable=1,status=1");
}

function popupgallery(filename,winname) {
newWin=window.open(filename,winname,"width=640,height=640,menubar=1,scrollbars=1,toolbar=1,resizable=1,status=1");
}

function popupmovie(filename,winname) {
newWin=window.open(filename,winname,"width=640,height=540,menubar=1,scrollbars=1,toolbar=1,resizable=1,status=1");
}

function PrintPage(){
	if(document.getElementById || document.layers){
		window.print();	
	}
}

// 汎用ロールオーバー
function smartRollover() {  
    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."));  
                }  
            }  
        }  
    }  
}  
if(window.addEventListener) {  
    window.addEventListener("load", smartRollover, false);  
}  
else if(window.attachEvent) {  
    window.attachEvent("onload", smartRollover);  
} 

// プリント
function PrintPage(){
	if(document.getElementById || document.layers){
		window.print();
	}
}

// このページの最初へ
function scrollToTop() {
	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 / 1.4), Math.floor(y / 1.4));
	if (x > 0 || y > 0) {
		window.setTimeout("scrollToTop()", 10);
	}
}

// 検索フォーム初期テキスト
function cText(obj){
if(obj.value==obj.defaultValue){
obj.value="";
}
}

// ボックス高さ合わせ
$.fn.equalHeights = function(px) {
	$(this).each(function(){
		var currentTallest = 0;
		$(this).children().each(function(i){
			if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
		});
		if (!px || !Number.prototype.pxToEm) currentTallest = currentTallest.pxToEm(); //use ems unless px is specified
		// for ie6, set height since min-height isn't supported
		if ($.browser.msie && $.browser.version == 6.0) { $(this).children().css({'height': currentTallest}); }
		$(this).children().css({'min-height': currentTallest}); 
	});
	return this;
};

Number.prototype.pxToEm = String.prototype.pxToEm = function(settings){
	//set defaults
	settings = jQuery.extend({
		scope: 'body',
		reverse: false
	}, settings);
	
	var pxVal = (this == '') ? 0 : parseFloat(this);
	var scopeVal;
	var getWindowWidth = function(){
		var de = document.documentElement;
		return self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
	};	
	
	if (settings.scope == 'body' && $.browser.msie && (parseFloat($('body').css('font-size')) / getWindowWidth()).toFixed(1) > 0.0) {
		var calcFontSize = function(){		
			return (parseFloat($('body').css('font-size'))/getWindowWidth()).toFixed(3) * 16;
		};
		scopeVal = calcFontSize();
	}
	else { scopeVal = parseFloat(jQuery(settings.scope).css("font-size")); };
			
	var result = (settings.reverse == true) ? (pxVal * scopeVal).toFixed(2) + 'px' : (pxVal / scopeVal).toFixed(2) + 'em';
	return result;
};
