/*




<?php
    $GLOBALS['base_vars']['EN_BLOG_URL'] = 'http://en.j-cast.com/';
    $GLOBALS['base_vars']['EN_BLOG_SITE_PATH'] = '/home/httpd/webmaster-bus/NEWS/EN/';
    $GLOBALS['base_vars']['JP_BLOG_URL'] = 'http://www.j-cast.com/';
    $GLOBALS['base_vars']['JP_BLOG_SITE_PATH'] = '/home/httpd/webmaster-bus/NEWS/JP/';
    $GLOBALS['base_vars']['CN_BLOG_URL'] = 'http://cn.j-cast.com/';
    $GLOBALS['base_vars']['CN_BLOG_SITE_PATH'] = '/home/httpd/webmaster-bus/NEWS/CN/';
    $GLOBALS['base_vars']['TV_BLOG_URL'] = 'http://www.j-cast.com/tv/';
    $GLOBALS['base_vars']['TV_BLOG_SITE_PATH'] = '/home/httpd/webmaster-bus/NEWS/JP/tv/';
    $GLOBALS['base_vars']['MB_BLOG_URL'] = 'http://www.j-cast.com/m/';
    $GLOBALS['base_vars']['MB_BLOG_SITE_PATH'] = '/home/httpd/webmaster-bus/NEWS/JP/m/';
    $GLOBALS['base_vars']['MONO_BLOG_SITE_PATH'] = '/home/httpd/webmaster-bus/NEWS/JP/mono/';
    $GLOBALS['base_vars']['MONO_BLOG_URL'] = 'http://www.j-cast.com/mono/';
    $GLOBALS['base_vars']['KAISHA_BLOG_SITE_PATH'] = '/home/httpd/webmaster-bus/NEWS/JP/kaisha/';
    $GLOBALS['base_vars']['KAISHA_BLOG_URL'] = 'http://www.j-cast.com/kaisha/';
    $GLOBALS['base_vars']['JAPAN_BLOG_SITE_PATH'] = '/home/httpd/webmaster-bus/NEWS/JP/japan/';
    $GLOBALS['base_vars']['JAPAN_BLOG_URL'] = 'http://www.j-cast.com/japan/';
    $GLOBALS['base_vars']['SSL_BLOG_URL'] = 'https://ssl.j-cast.com';
    $GLOBALS['base_vars']['SSL_BLOG_SITE_PATH'] = '/home/httpd/webmaster-bus/NEWS/JP/';
    $GLOBALS['base_vars']['HONBAN'] = '1';
    $GLOBALS['base_vars']['COMMON_INC_DIR'] = '/home/httpd/webmaster-bus/NEWS/JP/include/common/';
    $GLOBALS['base_vars']['CUR_BLOG_ID'] = '12';

    // current access url & site
    if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI']) {
        $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
    } else {
        $GLOBALS['REQUEST_URI'] = null;
    }
    if (preg_match("/(tv|mono|kaisha|other|motto|japan|skytree)/", $GLOBALS['REQUEST_URI'], $regs)) {
        $GLOBALS['REQUEST_SITE'] = $regs[1];
    } else {
        $GLOBALS['REQUEST_SITE'] = 'news';
    }
    if ($GLOBALS['REQUEST_SITE'] == 'other') {
        $GLOBALS['REQUEST_SITE'] = 'mono';
    }
    $GLOBALS['CUR_PAGE_TYPE'] = 'entry';

    //HTTP or HTTP
    if (isset($_SERVER['HTTPS'])) {
        $GLOBALS['base_vars']['IS_SSL'] = 1;
    } else {
        $GLOBALS['base_vars']['IS_SSL'] = 0;
    }

    // Load common functions
    $INC_DIR = '/home/httpd/webmaster-bus/NEWS/JP/' . 'include/common/';
    require_once($INC_DIR . 'common_funcs.php');
    require_once($INC_DIR . 'print_ad.php');
    require_once($INC_DIR . 'ad/pc_overture.php');

    // Web page is built for PC or Mobile ?
    $page_device_type = 'pc';
    $cur_blog_id = '12';
    // jcast_page.php からロードされる場合
    if (empty($page_device_type)) {
        $page_device_type = $this->pageDeviceType;
    }
    if (empty($cur_blog_id)) {
        $cur_blog_id = $this->curBlogId;
    }

    // PCページへきたモバイル端末およびモバイル用クローラーはモバイルページへ転送
   if ($page_device_type=='pc' && (isMobile() OR isCrawler('mobile'))) {
        $url = getSelfURL();
        $host = 'www.j-cast.com';
        // 互換性のため。旧版で有効
        $relative_url = '/weather/';
        // 新版で有効
        if (isset($this->curBlogRelativeUrl)) {
            $relative_url = $this->curBlogRelativeUrl;
        }
        $pat = '/(^.+' . $host . ')(' . preg_replace("/\//", "\/", $relative_url) . ')(m\/)*(.*$)/';
        if (preg_match($pat, $url, $regs)) {
            $redirect_url = sprintf("%s%sm/%s", $regs[1], $regs[2], $regs[4]);
            header("Location: $redirect_url");
            exit(0);
        }
    }


    if ($page_device_type=='mobile') {
        if (isMobile()) {
            if (!isMobileTargetTerminal() && !isCrawler('mobile')) {

            }
        } else {
            // 携帯以外の端末(PC, iPhone... etc..) には基本的に非表示。
            $showMobilePage = false;
            if (isCrawler('mobile')) {
                // モバイル用クローラー
                $showMobilePage = true;
            }
            if (!empty($_SERVER['REMOTE_ADDR']) && preg_match("/(192\.168|124\.32\.51\.90)/", $_SERVER['REMOTE_ADDR'])) {
                // 自社からのアクセス
                $showMobilePage = true;
            }
            // PCページへ転送
            if (!$showMobilePage) {
                if (preg_match("/(.*)\/m\/(.*)/", getSelfURL(), $regs)) {
                    $redirect_url = sprintf("%s/%s", $regs[1], $regs[2]);
                    header("Location: $redirect_url");
                    exit;
                }
            }
        }
    }

    if ($page_device_type=='mobile') {
        // LOAD AD SETTING FOR MOBILE
        $MB_AD_DIR = $GLOBALS["base_vars"]["JP_BLOG_SITE_PATH"] . "include/common/ad/";
        require_once($MB_AD_DIR . 'mb_overture_hs.php');
        require_once($MB_AD_DIR . 'mb_advantage.php');
        require_once($MB_AD_DIR . 'mb_opast.php');
        require_once($MB_AD_DIR . 'mb_micro_ad.php');


        $GLOBALS['ad']['impactPageId'] = mt_rand();

        // PUT ONLY MAIN CONTENTS FOR GOO CRAWLERS
        // ex) gooMobileADcrawler/0.2.2 , WakameCrawler/0.02(+http://help.goo.ne.jp/door/crawler.html)
        if (preg_match("/(gooMobileADcrawler|WakameCrawler)/", $_SERVER['HTTP_USER_AGENT'])) {
          $GLOBALS['ad']['IS_GOO_CRAWLER'] = true;
        } else {
          $GLOBALS['ad']['IS_GOO_CRAWLER'] = false;
        }
    }



    // PHP設定など
    ini_set('default_charset', 'UTF-8');
    if ($page_device_type=='pc') {
        // PC Site, Set the encoding and put header
        if (!defined('HEADER_SENT')) {
          ini_set('mbstring.internal_encoding', 'UTF-8');
          ini_set('mbstring.script_encoding', 'UTF-8');
          ini_set('mbstring.http_output', 'UTF-8');
          header('Content-Type: text/html; charset=UTF-8');
          define('HEADER_SENT', true);
        }
    } else {
        ini_set('mbstring.language', 'Japanese');
        ini_set('mbstring.internal_encoding', 'SJIS');
        ini_set('mbstring.script_encoding', 'auto');
        ini_set('mbstring.http_output', 'SJIS');
        ini_set('default_socket_timeout', 30);
    }

?>
*/


/** J-CASTニュース トップページ 天気表示
 * 
 * @author	nagnao@j-cast.com
 * @version	1.2
 * @date	2009-10-16
 * 
 */


//　root object
var weatherGadget;
$(function()
{
    var weatherRoot = window.$( '#personalize-weather' );
	
	// 天気をラップする要素のクラスでフリッピングを初期状態としている場合、フリッピング用オブジェクトを生成
	
    if ( weatherRoot.hasClass('personalize-weather-defaultFlipping') ) {
		setTimeout(function(){
			weatherGadget = new WeatherGadget();
		}, 100);
	}
	
	// 吹出しの中のテキストの位置の調整
	
	var balloonMessageOuter, balloonMessageText, top;
	
	// local
	balloonMessageOuter			= $( '#personalize-weather-local-message-balloon' );
	balloonMessageText			= $( '#personalize-weather-local-message-balloon span:first' );
	top					= Math.round( ( balloonMessageOuter.height() - balloonMessageText.height() ) * 0.5 );
	balloonMessageText.css('top', top);
	
	// today
	balloonMessageOuter			= $( '#personalize-weather-today-message-balloon' );
	balloonMessageText			= $( '#personalize-weather-today-message-balloon span:first' );
	top					= Math.round( ( balloonMessageOuter.height() - balloonMessageText.height() ) * 0.5 );
	balloonMessageText.css('top', top);
	
	/*
	
	// adjutst balloon message position
	var balloonMessage			= $( '#weather_koalaView_balloon span:first' );
	var CENTER_OF_BALLOON		= 25;
	var balloonMessageHeight	= balloonMessage.height();
	var balloonMessageTop		= CENTER_OF_BALLOON - balloonMessageHeight * 0.5;
	balloonMessage	.css( 'top', balloonMessageTop )
					.animate({'opacity':1}, {duration:200});
					
	*/
	
});


/* WeatherGadget
 * トップページ天気表示のルートクラス
 * 
 */
var WeatherGadget = function()
{
	// private variables
	var self			= this;
	var	$				= window.$;				// jQuery
	var conf			= this.CONFIGURATION;	// configuration
	var indexOfstate	= 0;					// 0 or 1
	var states			= ['today','local'];	// view mode
	var toid;									// timeout id
	var counter			= 0;					// change view counter	- 090608 nagano@j-cast.com
	var CHANGE_MAX		= 4;					// 						- 090608 nagano@j-cast.com
	
	// private variables: reference
	var eachObjects		= {
		today	:{
			message			: $( '#personalize-weather-searching-today-date, #personalize-weather-searching-today-message' ),
			koala			: $( '#personalize-weather-wrap-today-koala' ),
			hiddenElements	: $( '#personalize-weather-balloon, #personalize-weather-today-message-balloon, #personalize-weather-wrap-todaysKoalaName' )
		},
		local	:{
			message			: $( '#personalize-weather-searching-local-message' ),
			koala			: $( '#personalize-weather-wrap-local-koala' ),
			hiddenElements	: $( '#personalize-weather-balloon, #personalize-weather-local-message-balloon, #personalize-weather-wrap-localKoalaName' )
		}
	}
	
	// create flap image view
	var flapImageView = new JCFlapImageView( this, '#personalize-weather-wrap-koala-flap', 'personalize-weather-wrap-koala-flapView' );
	
	
	
	// アクセサ
	
	this.getKoala = function() { return eachObjects[ states[indexOfstate] ].koala; }
	
	
	
	// flipImageView の用意が済んだらコールされる
	// 次のビューを表示する
	
	this.flapImageViewIsReady = function()
	{
		showNextView();
	}
	
	
	
	// 次のビューを表示する
	
	var showNextView = function()
	{
		indexOfstate = (++indexOfstate) % states.length;
	
		// フリップ開始
		
		flapImageView.startFlip();
		
		// フリップ中メッセージ表示
		
		eachObjects[ states[indexOfstate] ].message	.css(		{	opacity		: 0,
																	visibility	: 'visible' })
													.animate(	{	opacity		: 1 },
																{	duration	: conf.DURATION_OF_FADE });
	}
	
	
	
	// 『地域判定』終了後に呼ばれる
	// 『判定中』メッセージを消去し、コアラと吹出しを表示
	
	this.flapImageViewDidFinishSearching = function()
	{
		// フリップ中メッセージをフェードアウトし、
		// その他をフェードイン
		
		var views	= eachObjects[ states[indexOfstate] ];
		// searching message fadeout
		views.message			.animate(	{	opacity		: 0 },
											{	duration	: this.CONFIGURATION.DURATION_OF_FADE });
		// hidden elements fadein
		views.hiddenElements	.css(		{	opacity		: 0,
												visibility	: 'visible' })
								.animate(	{	opacity		: 1 },
											{	duration	: this.CONFIGURATION.DURATION_OF_FADE });
		
		// コアラジャンプ
		
		views.koala				.css(		{	visibility	: 'visible' });
		var koalaImage	= $( 'img:first', views.koala );
		koalaImage				.css( 'position', 'absolute' );
		var originRect	= {	width	: koalaImage.width(),
							height	: koalaImage.height() }
		var enlargeRect	= {	width	: originRect.width * this.CONFIGURATION.JUMP_SCALE,
							height	: originRect.height * this.CONFIGURATION.JUMP_SCALE}
		koalaImage				.animate(	{	top			: "+=0" },
											{	duration	: this.CONFIGURATION.DURATION_OF_JUMP*2 })
								.animate(	{	width		: enlargeRect.width,
												height		: enlargeRect.height,
												left		: -(enlargeRect.width-originRect.width)*0.5,
												top			: -(enlargeRect.height-originRect.height)*0.75 },
											{	duration	: this.CONFIGURATION.DURATION_OF_JUMP*0.5 })
								.animate(	{	width		: originRect.width,
												height		: originRect.height,
												left		: 0,
												top			: 0 },
											{	duration	: this.CONFIGURATION.DURATION_OF_JUMP*0.5 });
		
		// タイムアウトを設定し、次のフリップをセット
		
		//toid			= setTimeout( function(){ /*self.showNextView();*/for (var i in self) {window.console.log(i+': '+self[i]);} }, conf.VIEW_CHANGE_DURATION );
		toid			= setTimeout( function(){
			self.hideCurrentView();
		}, conf.VIEW_CHANGE_DURATION );
		
		/*
		// 地点ページの遷移のリンク領域を、地点名称のハイパーテキストではなく
		// 吹出し全域で取るよう変更
		// 2009.5.7 nagano@j-cast.com
		// html の仕様変更のため、この処理不要
		// 2009.5.27 nagano@j-cast.com
		//
		var pointURL			=  $('#personalize-weather-balloon-placeName').attr('href');
		var balloon				=  $('#personalize-weather-balloon');
		var balloonImage		=  $('#personalize-weather-balloon-image');
		var balloonImageSrc		=  balloonImage.attr('src');
		var balloonHoverImage	= new Image();
		balloonHoverImage.src	= conf.URL+'images/weather/misc/balloon-top-hover.gif';
		$('#personalize-weather-balloon')	.bind('click', function(){
				document.location = pointURL
			})								.bind('mouseover', function(){
				balloonImage.get(0).src = balloonHoverImage.src;
			})								.bind('mouseout', function(){
				balloonImage.get(0).src = balloonImageSrc;
			});
		*/
	}
	
	
	
	// 現在のビューを隠す
	
	this.hideCurrentView = function() {
		// 回数制限を設ける	- 090608 nagano@j-cast.com
		
		if (++counter < CHANGE_MAX) {
			var views	= eachObjects[ states[indexOfstate] ];
			// hidden elements fadeout
			views.hiddenElements	.animate(	{	opacity		: 0 },
												{	duration	: this.CONFIGURATION.DURATION_OF_FADE,
													complete	: function(){ $(this).css('visibility','hidden') } });
			views.koala				.css(		{	visibility	: 'hidden' });
			showNextView();
		}
	}
	
	
};

// configuration
WeatherGadget.prototype.CONFIGURATION =
{
	URL 					: 'http://www.j-cast.com/',
	KOALA_IMAGE_PATH		: 'images/weather/koala/',
	NUMBER_OF_FLIPS			: 5,
	NUMBER_OF_TIMES			: 5,
	DURATION_OF_FADE		: 1000,
	JUMP_SCALE				: 1.8,
	DURATION_OF_JUMP		: 250,
	VIEW_CHANGE_DURATION	: 6000,
	FLIP_IMAGES				: [
		'koala_area01.gif',
		'koala_area02.gif',
		'koala_area03.gif',
		'koala_area04.gif',
		'koala_area05.gif',
		'koala_area06.gif',
		'koala_area07.gif',
		'koala_area08.gif',
		'koala_area09.gif',
		'koala_area12.gif',
		'koala_area13.gif',
		'koala_area14.gif',
		'koala_area23.gif',
		'koala_area24.gif',
		'koala_area25.gif',
		'koala_area26.gif',
		'koala_area27.gif',
		'koala_area29.gif',
		'koala_area30.gif',
		'koala_area33.gif',
		'koala_area36.gif',
		'koala_area40.gif',
		'koala_area44.gif',
		'koala_area45.gif',
		'koala_area47.gif' ]
}


/* JCSlotImageView
 * フリップ画像のルートビュークラス
 * 
 * @parent		Object		親オブジェクト（JCView準拠）
 * @selector	String		生成先のセレクタ（JCView準拠）
 * @id			String		生成する HTMLElement の ID名称）
 */
function JCFlapImageView( parent, selector, id )
{
	// inherit JCView
	JCView.apply( this, [ parent, selector, {id:id} ] );
	
	// private variables
	var self			= this;
	var	$				= window.$;					// jQuery
	var conf			= parent.CONFIGURATION;		// configuration
	var loadImages		= [];						// 
	var flipImages;									// 
	var timerid;									// interval id
	var currentIndex;								// displaying image
	var isFirst			= true;
	var topView, bottomView, flipView;				// view parts
	var DURATION_OF_FADE	= 1500;
	
	
	
	// 読み込ませる画像名の配列を作成
	
	var tempArray	= conf.FLIP_IMAGES.concat();	// copy images array
	var newArray	= [];
	var counter		= conf.NUMBER_OF_FLIPS;
	while (counter-- > 0) {
		var index = Math.floor( Math.random()*tempArray.length );
		newArray.push( tempArray[index] );
		tempArray[index] = tempArray[tempArray.length-1];
		tempArray.length--;
    }
	
	// 画像の読み込み
	
	$.each( newArray, function(){
		var image = new Image();
		image.src = conf.URL+conf.KOALA_IMAGE_PATH+this;
		loadImages.push( image );
	});
	delete tempArray, newArray, counter;
	
	// 画像の読み込みの監視
	
	timerid	= setInterval( function() { self.observingImagesLoading(); }, 100 );
	this.observingImagesLoading = function()
	{
		var isComplete = true;
		$.each( loadImages, function(){ if ( !this.complete ) isComplete = false; });
		
		// 全ての画像の読み込みが完了したら、完了後メソッドをコール
		
		if ( isComplete )
		{
			clearInterval( timerid );
			self.didFinishLoadingImages();
		}
	}
	
	
	// 全ての画像が読み終わると呼ばれる
	// フリップ要素を作成し
	// 親オブジェクトに準備完了を報告
	
	this.didFinishLoadingImages = function()
	{
		// パーツの作成
		
		var initObj		= {	width	: loadImages[0].width,
							height	: loadImages[0].height  };
		initObj.kind	= 'top';
		topView			= new this.TopAndBottomPartView( this, this.$$, initObj );
		initObj.kind	= 'bottom';
		bottomView		= new this.TopAndBottomPartView( this, this.$$, initObj );
		delete initObj.kind;
		flipView		= new this.FlipPartView( this, this.$$, initObj );
		
		// 親オブジェクトに読み込み終了を報告
		
		parent.flapImageViewIsReady();
	}
	
	
	
	// フリップの開始
	
	this.startFlip = function()
	{
		currentIndex	= 0;
		
		// フリップさせる画像の配列を作成
		// ランダム、かつ前後の画像が同じにならないようにする
		
		flipImages		= [];
		flipImages.push( loadImages[0] );
		while ( flipImages.length < conf.NUMBER_OF_TIMES )
		{
			var index = Math.floor( Math.random()*loadImages.length );
			if ( flipImages[flipImages.length-1] != loadImages[ index ] ) flipImages.push( loadImages[ index ] );
		}
		flipImages.push( $( 'img', parent.getKoala() ).get(0) );
		
		// 初回であればフェードイン
		
		if ( isFirst ) {
			this.$$	.css(		{	opacity		: 0,
									visibility	: 'visible' })
					.animate(	{	opacity		: 1 },
								{	duration	: DURATION_OF_FADE });
			isFirst = false;
		} else {
			this.$$	.css(		{	visibility	: 'visible' });
		}
		this.showNextFlip();
	}
	
	
	
	// フリップを実行
	// フリップ画像用配列の末尾に到達したら、
	// フリップを終了し、親オブジェクトにフリップの終了を報告
	
	this.showNextFlip = function()
	{
		if ( currentIndex++ < flipImages.length-1 )
		{
			// pickup image
			var currentImageSrc	= flipImages[ currentIndex-1 ].src;
			var nextImageSrc	= flipImages[ currentIndex ].src;
			// flip
			flipView.showNextFlip	( currentImageSrc, nextImageSrc );
			topView.showNextFlip	( nextImageSrc );
			bottomView.showNextFlip	( currentImageSrc );
		}
		else
		{
			// send message
			parent.flapImageViewDidFinishSearching();
			// kill
			this.$$	.css({ visibility: 'hidden' })
			//this.terminate();
		}
		
	}
	
}


/* TopAndBottomPartView
 * 上下フリップ画像のビュークラス
 * 
 * @parent				Object		親オブジェクト（JCView準拠
 * @selector			String		生成先のセレクタ（JCView準拠）
 * @initobj				Object
 * 		width, height	Number		矩形サイズ
 * 		kind			String		'top' or 'bottom'
 */
JCFlapImageView.prototype.TopAndBottomPartView = function( parent, selector, initobj )
{
	// inherit JCView
	JCView.apply( this, [ parent, parent.$$ ] );
	
	// private variables
	var self			= this;
	var image	= document.createElement( 'IMG' );	// image
	var kind	= initobj.kind;						// kind
	
	// create
	var height		= initobj.height * 0.5
	var top			= ( kind=='top' ) ? 0 : height;
	this.$$
		.css	(	{	width		: initobj.width,
		 				height		: height,
						top			: top,
		 				position	: 'absolute',
	 					overflow	: 'hidden' })
		.append ( image );
	// image
	var imageTop	= ( kind=='top' ) ? 0 : -height;
	window.$( image )
		.css	(	{	position	: 'absolute',
						top			: imageTop });
	delete height, top, imageTop;
	
	
	// flip
	this.showNextFlip = function( imgsrc )
	{
		image.src = imgsrc;
	}
	
}


/* FlipPartView
 * フリップする画像のビュークラス
 * 
 * @parent				Object		親オブジェクト（JCView準拠
 * @selector			String		生成先のセレクタ（JCView準拠）
 * @initobj				Object
 * 		width, height	Number		矩形サイズ
 * 		kind			String		'top' or 'bottom'
 */
JCFlapImageView.prototype.FlipPartView = function( parent, selector, initobj )
{
	// inherit JCView
	JCView.apply( this, [ parent, parent.$$ ] );
	
	// private variables
	var self			= this;
	var image, $image/*, colorFilter, $colorFilter @date091016 影付け処理削除*/;	// subViews
	var width			= initobj.width;
	var height			= initobj.height;
	var imageSources	= { current:'', next:'' };
	var FLIP_DURATION	= 150;
	/*var BLIGHT_OPACITY	= 0.5;
	var DARK_OPACITY	= 0.2;
	var BLIGHT_COLOR	= 'rgb(255,255,255)';
	var DARK_COLOR		= 'rgb(0,0,0)'; @date091016 影付け処理削除*/
	var $image;
	
	// create
	image			= document.createElement( 'IMG' );
	/*colorFilter		= document.createElement( 'DIV' ); @date091016 影付け処理削除*/
	this.$$	.css	(	{	width		: initobj.width,
		 					height		: height * 0.5,
							top			: 0,
		 					position	: 'absolute',
	 						overflow	: 'hidden' })
			.append ( image )/*
			.append ( colorFilter ) @date091016 影付け処理削除*/;
	// image
	$image			= window.$( image );
	$image			.css	(	{	position		: 'absolute' });
	image.agent		= this;
	/*
	// colorFilter
	$colorFilter	= window.$( colorFilter );
	$colorFilter	.css	(	{	position		: 'absolute',
									width			: '100%',
									height			: '100%' }); @date091016 影付け処理削除*/
	
	
	// flip
	this.showNextFlip = function( currentImageSrc, nextImageSrc )
	{
		imageSources.current	= currentImageSrc;
		imageSources.next		= nextImageSrc;
		image.src				= imageSources.current;
		
		//
		$image			.css		(	{	top				: 0,
											height			: height })
						.animate	(	{	width			: width,
											height			: 0 },
										{	duration		: FLIP_DURATION });
		/*$colorFilter	.css		(	{	backgroundColor	: DARK_COLOR,
											opacity			: 0 })
						.animate	(	{	opacity			: DARK_OPACITY },
										{	duration		: FLIP_DURATION }); @date091016 影付け処理削除*/
		this.$$			.css		(	{	top				: 0,
											height			: height*0.5 })
						.animate	(	{	top				: height*0.5,
											height			: 0 },
										{	duration		: FLIP_DURATION,
											complete		: function(){ self.turnSide() } } );
	}
	this.turnSide = function()
	{
		image.src				= imageSources.next;
		$image			.css		(	{	top				: 0,
											height			: 0 })
						.animate	(	{	top				: -height*0.5,
											width			: width,
											height			: height },
										{	duration		: FLIP_DURATION });
		/*$colorFilter	.css		(	{	backgroundColor	: BLIGHT_COLOR,
											opacity			: BLIGHT_OPACITY })
						.animate	(	{	opacity			: 0 },
										{	duration		: FLIP_DURATION }); @date091016 影付け処理削除*/
		this.$$			.css		(	{	top				: height*0.5,
											height			: 0 })
						.animate	(	{	height			: height*0.5 },
										{	duration		: FLIP_DURATION	,
											complete		: function(){ self.completeFlip() } } );
	}
	this.completeFlip = function()
	{
		parent.showNextFlip();
	}
	
}


/* JCView
 * DOM と関連づけられた基本ビュークラス
 * 
 * 
 * @parent			Object		親オブジェクト（メソッドを定義できるものなら何でも可）
 * @selector		String		生成先の jQuery セレクタ
 * @initobj			Object		初期化オブジェクト（オプション）
 * 		tag			String		生成するタグ（未指定時は div）
 * 		id			String		生成する ID
 * 		className	String		生成する CLASS
 * 		method		String		生成方法（未指定時は append）
 * @attributes		Object		生成されたノードに加える属性（オプション）
 * 
 */
JCView = function(　parent, selector, initobj, attributes　)
{
	// private variables
	var	self			= this;			// reference
	var	$				= window.$;		// jQuery
	parent				= parent;		// parent
	
	// protected variables
	this.target;						// HTMLElement
	this.$$;							// jQuery object
	
	// create element
	var tag				= 'div';
	var method			= 'append';
	if ( initobj )
	{
		if ( initobj.tag )		tag = initobj['tag'];
		if ( initobj.method )	if ( $( selector )[ initobj.method ] ) method	= initobj.method;
	}
	this.target			= document.createElement( tag );
	this.target.agent	= this;			// define me as delegation object of HTMLElement 
	
	// append HTMLElement
	$( selector )[ method ]( this.target );
	this.$$				= $( this.target );	
	if ( initobj )
	{
		if ( initobj.id )			this.$$.attr( 'id',		initobj.id );
		if ( initobj.className )	this.$$.attr( 'class',	initobj.className );
	}
	
	// attributes
	if ( attributes ) for ( var i in attributes ) this.$$.attr( i, attributes[i] );
	
	
	// 終了メソッド
	//
	this.terminate = function()
	{
		this.$$	.queue([])
				.stop()
				.remove();
		delete this.$$;
		if ( parent[ 'aChildDidTerminate' ] ) this.parent[ 'aChildDidTerminate' ]( this );
	}
	
};




