// ジャッキーの画像数
var MAX	= 5;

// swfobject
var url		= "/f/header.swf";
var params	= { allowScriptAccess: "always" };
var atts	= { id: "rfplayer" };
$(function(){
	flashvars.path	= '/f/';
	// PC版
	if(navigator.userAgent.indexOf("iPhone") == -1 && navigator.userAgent.indexOf("iPad") == -1){ 
		swfobject.embedSWF(url, "header", "100%", "230", "8", null, flashvars, params, atts);

 		$('div#js-blog-parts').html('<a href="http://bears-school.com/special/download/index.html" title="ブログパーツ"><div class="box-blog-parts"><div class="area-blog-parts"><object classid="clsid:D27CDB6E- AE6D-11cf-96B8-444553540000" codebase="http:// download.macromedia.com/pub/shockwave/cabs/flash/ swflash.cab#version=6,0,29,0" width="150" height="240"><param name="movie" value="special/download/bear_clock.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed src="special/download/bear_clock.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" width="150" height="240"></embed></object></div></div></a>');
			

	// iPhone/iPad版
	} else {

 		$('div#header').html('<div id="sub-header"><div id="header-front"><h1 id="logo"><a href="/">くまのがっこう the bear\'s school</a></h1><ul id="menu"><li id="mitem-news"><a href="http://bears-school.com/blog/">ニュース</a></li><li id="mitem-goods"><a href="/goods/">グッズ</a></li><li id="mitem-mobile"><a href="/mobile/">モバイル</a></li><li id="mitem-cheer"><a href="/cheer/">チアジャッキー</a></li><li id="mitem-ehon"><a href="/book/">えほん</a></li><li id="mitem-world"><a href="/bear/">「くまのがっこう」の世界</a></li></ul></div></div>');

 		$('div#js-blog-parts').html('<a href="http://bears-school.com/special/download/index.html" title="ブログパーツ"><div class="box-blog-parts"><div class="area-blog-parts"><img src="images/blog_parts.jpg" /></div></div></a>');


	}

	var rand	= Math.floor(Math.random()*(MAX-1))+1;
	$('div#area-anime').html('<img src="/images/top_jackie/jackie0' + rand + '.jpg" />');
});



//---------------------------------------------
// ポップアップウインドウの位置を決めて開く
newWin=""; var width, height;
function OpenWin(URL, W, H, OPTION, TARGET, E){
	var w = W ? W : 410;
	var h = H ? H : 550;
	var option = OPTION ? OPTION : "status=no,scrollbars=yes,toolbar=no,menubar=no,location=no";
	option += ",height=" + h;
	option += ",width=" + w;
	if (E) option += ",top=" + getMouseX(E) - (w);
	if (E) option += ",left=" + getMouseY(E) - (50);
	if( is_open_child(newWin) ) {
		newWin = window.open(URL, TARGET, option);
	} else {
		if( w == width && h == height ) {
			window.open(URL, TARGET, option);
		} else {
			newWin.location.href = URL;
		}
	}
	width = w; height = h;
	newWin.focus();
}

newHelpWin="";
function OpenHelpWin(URL){
	var option	= "status=no,scrollbars=yes,toolbar=no,menubar=no,location=no";
	option		+= ",width=410,height=550"
	if( is_open_child(newWin) ) {
		newHelpWin	= window.open(URL, 'HELPWIN', option);
	} else {
		if( w == width && h == height ) {
			window.open(URL, 'HELPWIN', option);
		} else {
			newHelpWin.location.href = URL;
		}
	}
	newHelpWin.focus();
}

//□ サブ関数 □□□□□□□□□□□□□□□□□□□□□□
//---------------------------------------------
// マウスの位置取得
function getMouseX(E){
	if( document.all ){
		return window.event.screenX;
	} else if ( document.layers || document.getElementById ){
		return E.screenX;
	}
}
function getMouseY(E){
	if( document.all ){
		return window.event.screenY;
	} else if ( document.layers || document.getElementById ){
		return E.screenY;
	}
}
function is_open_child(NW){
    var ua = navigator.userAgent;
    if( !!NW ){
        if( ua.indexOf('MSIE')!=-1 && ua.indexOf('Win')!=-1 ){
            return NW.closed;
        }else {
			return typeof NW.document != 'object'
		}
	} else {
		return true;
	}
}
//---------------------------------------------

