/*
  共通Javascript
  http://pirkar.ashikunep.org
*/

// 設定
//var Host = "pirkar";	//ドメイン名
var Host = "pirkar.ashikunep.org";	//ドメイン名

//shadowboxのoption設定
var option = { 
	 language: 'ja',
	//players:  ['img', 'html', 'iframe', 'qt', 'wmp', 'swf', 'flv']
	players:  ['img'],
	fadeDuration: 0.2,	//Defaults to 0.35.
	resizeDuration: 0.3,	//Defaults to 0.55.
	//handleOversize:     'drag',
	overlayColor: "#090000",
	//handleUnsupported:  'remove',
	counterType: 'skip',
	autoplayMovies:     false
};
Shadowbox.init(option);



//----------------------------------------------------------------
//イベントハンドラ：onload
//----------------------------------------------------------------
$(document).ready( function() {
	//Shadowboxのイベントセット (a class="shadowbox"に対して設定)
	Shadowbox.setup("a.shadowbox", {
		gallery:            "pirkar"
	});
	//外部リンク、内部リンクのアイコンclass
	linkAddClass();
	//リストの最後にclass設定
	$("#contents li:last").addClass('li_last');

	//Shadowboんのリンクの横幅をサムネイル画像と同じ幅に設定
	$("#contents a.shadowbox img").each(function(){
		var a = $(this).parent();
		var w = $(this).width();
		if(w==0) w = a.width() - 2;
		a.css("width", w );
	});
	//Shadowboxのリンクにポップアップできるアイコンを設定
	$("#contents a.shadowbox").append('<span></span>');
});


//----------------------------------------------------------------
//設定：Shadowbox
//----------------------------------------------------------------
/* スキンの指定と、読み込むディレクトリの指定 */
/* 公開時にパス指定を以下に変更
The Ashikunep Kotan */
/* 1次リリースでは不使用なのでOFF
Shadowbox.loadSkin('classic', '/_common/js/shadowbox/skin');
*/
//----------------------------------------------------------------
//関数：外部内部リンクにtargetとclass定義
//----------------------------------------------------------------
/*
<a href="http://google.com" class="link_out">外部リンク</a>
<a href="../index.html" class="link_in">内部リンク</a>
*/
function linkAddClass(){
	//リンク要素取得(<a><img></a>は除外。テキストのみ。)
	var linkDOM = $("#mainContents a:not(:has(img))");
	//現在のホスト名(ドメイン)取得
	var myHost = location.hostname;
	var myHost2 ="";
	//ドメインに"www."が省略されてる場合の前処理
	if( myHost.indexOf("www.") == -1) {
		myHost2 = "www."+myHost;
	}else{
		myHost2 = myHost.slice(4);
	}
	//リンク要素毎にチェック
	for( i=0; i<linkDOM.length; i++){
		//外部リンク：フルパス指定で尚かつ、同じhost(ドメイン)で無い場合
		if ($(linkDOM[i]).attr('href').indexOf("http") == 0 
			&& linkDOM[i].hostname != myHost
			&& linkDOM[i].hostname != myHost2
			&& linkDOM[i].hostname != "" 
			&& linkDOM[i].hostname != Host)
		{	
			if(jQuery.browser.msie){
				//IEのみJSでOPEN
				$(linkDOM[i]).attr('onclick','window.open(\'this.href\',\'status=yes,scrollbars=yes,directories=yes,menubar=yes,resizable=yes,toolbar=yes\'); return false;');
			}else{
				//classとtargetを定義
				$(linkDOM[i]).attr('target','_blank');
			}
			$(linkDOM[i]).attr('class','link_out');
		}else{	//内部リンク
			$(linkDOM[i]).attr('class','link_in');
		}
	}	
}


//----------------------------------------------------------------
//関数：指定文字列の除去
//----------------------------------------------------------------
function replaceStr(str){
	str = str.replace("<![CDATA[","");
	str = str.replace("]]>","");
	str = str.replace("<br />"," ");
	str = str.replace("<br/>"," ");
	str = str.replace("<br>"," ");
	return str;
}
//----------------------------------------------------------------
//関数：ブラウザ判別(Mac OS X / Firefox かどうか)
//----------------------------------------------------------------
function chkMacFF(){
	var uAgent = navigator.userAgent.toUpperCase();
	var uName = navigator.userAgent.toUpperCase();
	if (uAgent.indexOf("MAC") >= 0 && uName.indexOf("FIREFOX") >= 0) return true;
	return false;
}


