﻿//扱うデータを入れておくオブジェクト
var storenews_obj = new Object();

//ローカルタイム
storenews_obj.lctime = new Date().getTime();
//再生されているURL
storenews_obj.site_url = document.URL;


//変数に格納：ウィンドウ
storenews_obj.window_element;
//変数に格納：body
storenews_obj.body_element;
//変数に格納：ストアニュースのリスト全体のID
storenews_obj.storenews_id = 'newsList';


(function () {

//変数に格納：jQuery
//var jQuery;

//コンフリクトを防ぐ
jQuery = window.jQuery.noConflict( true );

jQuery(document).ready(function(){
	
	//幅・高さを取得
	storenews_obj.pageSize = function(){
		var xScroll, yScroll;
		if(window.innerHeight && window.scrollMaxY){
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		}else if(document.body.scrollHeight > document.body.offsetHeight){
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		}else{
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		if(self.innerHeight) {
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		}else if(document.documentElement && document.documentElement.clientHeight){
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		}else if(document.body){
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}
		
		var pageWidth = xScroll < windowWidth ? xScroll : windowWidth;
		var pageHeight = yScroll < windowHeight ? windowHeight : yScroll;
		
		return [pageWidth,pageHeight,windowWidth,windowHeight];
	};
	
	storenews_obj.window_element = jQuery(window);
	storenews_obj.body_element = jQuery('html');
	storenews_obj.storenews_lsit = jQuery('#' + storenews_obj.storenews_id);

	//Win9X系
	storenews_obj.isWin9X = (navigator.appVersion.toLowerCase().indexOf('windows 98')+1);
	//IEか
	storenews_obj.isIE = (navigator.appName.toLowerCase().indexOf('internet explorer')+1?1:0);
	//Operaか
	storenews_obj.isOpera = (navigator.userAgent.toLowerCase().indexOf('opera')+1?1:0);
	if (storenews_obj.isOpera) storenews_obj.isIE = false;
	//Safariか
	storenews_obj.isSafari = (navigator.appVersion.toLowerCase().indexOf('safari')+1?1:0);
	
	
	//開閉式
	jQuery('#newsList > li > h4').css('cursor', 'pointer').click(function(){
		// 引数には開閉する速度を指定します
		jQuery(this).next().slideToggle(500);
	});
	
	//アンカー取得
	storenews_obj.anchr = window.location.hash;
	var target_newsitem_id;
	if(storenews_obj.anchr == ""){
		target_newsitem_id = jQuery('#newsList > li').attr("id");
	}else{
		target_newsitem_id = jQuery(storenews_obj.anchr).attr("id");
	}
	
	jQuery('#newsList > li').each(function(){
		var newsitem_id = jQuery(this).attr("id");
		var newsitem_el = jQuery('#' + newsitem_id);
		
		if(target_newsitem_id == newsitem_id){
			moveToAnchor(newsitem_id);
		}else{
			jQuery('#' + newsitem_id + ' > div.folding').hide();
		}
		
	});
	
});
	
})();
