/*@cc_on _d=document;eval('var document=_d')@*/
/* 
 * module
 * Copyright 2008 [c!]COLORS <shimizu@colors.jp>
 * http://www.colors.jp/
 */

/* ---- CSS Selectors ---- */
/*IE*/
$(document).ready(function() {
$("h2+p,h3+p,h4+p,h5+p,h6+p")
.css("margin-top","0")
})

/* 日付取得 */
function getDateSet() {
	nowDate = new Date();
	nowYear = nowDate.getYear();
	nowYear4 = new String((nowYear < 2000) ? nowYear+1900 : nowYear);
	nowMonth = nowDate.getMonth() + 1;
	nowMonth2 = new String((nowMonth < 10) ? "0"+nowMonth : nowMonth);
	nowDate = nowDate.getDate();
	nowDate2 = new String((nowDate < 10) ? "0"+nowDate : nowDate);

	return nowYear4 + nowMonth2 + nowDate2;
}

/* ポップアップレイヤーの出現位置をブラウザの上下左右中央に出現させるための現状スクロール量取得 */
function TB_getPageScrollTop(){
	var yScrolltop;
	var xScrollleft;
	if (self.pageYOffset || self.pageXOffset) {
		yScrolltop = self.pageYOffset;
		xScrollleft = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop || document.documentElement.scrollLeft ){	 // Explorer 6 Strict
		yScrolltop = document.documentElement.scrollTop;
		xScrollleft = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScrolltop = document.body.scrollTop;
		xScrollleft = document.body.scrollLeft;
	}
	arrayPageScroll = new Array(xScrollleft,yScrolltop) 
	return arrayPageScroll;
}

/* 開いているブラウザの領域取得 */
function TB_getPageSize(){
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	arrayPageSize = new Array(w,h);
	return arrayPageSize;
}

/* ブラウザ判定 */
function getBrowserName() {
	var aName  = navigator.appName.toUpperCase();
    var uName = navigator.userAgent.toUpperCase();
    if (uName.indexOf("SAFARI") >= 0)  return "Safari";
    if (uName.indexOf("OPERA") >= 0)  return "Opera";
    if (uName.indexOf("FIREFOX") >= 0)  return "Firefox";
    if (aName.indexOf("NETSCAPE") >= 0)  return "Netscape";
    if (aName.indexOf("MICROSOFT") >= 0) return "Explorer";
    return "";
}

/* NEWS用　ポップアップレイヤー出現 */
function showNews(flag) {
	if(flag=="on"){
	$("body").append("<div id='TB_overlay'></div>");
	}
	TB_overlaySize_News();
	TB_position_News();
	$(window).resize(TB_position_News);
}
/* LIVE用　ポップアップレイヤー出現 */
function showLive(flag) {
	if(flag=="on"){
	$("body").append("<div id='TB_overlay'></div>");
	}
	TB_overlaySize_Live();
	TB_position_Live();
	$(window).resize(TB_position_Live);
}
/* STAFF用　ポップアップレイヤー出現 */
function showStaff(flag) {
	if(flag=="on"){
	$("body").append("<div id='TB_overlay'></div>");
	}
	TB_overlaySize_Staff();
	TB_position_Staff();
	$(window).resize(TB_position_Staff);
}

/* MEDIA用　ポップアップレイヤー出現 */
function showMedia() {
	$('body').append('<div id="TB_overlay"></div>');

	TB_overlaySize();
	TB_position();
	$(window).resize(TB_position);

	$('#mediaBox').fadeIn("slow");

}

/* NEWS用　ポップアップレイヤー出現時に背景に敷くオーバーレイをクリックでポップアップとオーバーレイを削除 */
/* ポップアップレイヤー内のクローズボタンクリックでポップアップとオーバーレイを削除 */
function deleteInfo() {
		$('#TB_overlay').remove();
		$('#informationBox').fadeOut("fast");
		$('#informationBox').html("");
		return false;
}


/* MEDIA用　ポップアップレイヤー出現時に背景に敷くオーバーレイをクリックでポップアップとオーバーレイを削除 */
function deleteMedia() {
	$('#TB_overlay').bind('click',function(){
		$('#TB_overlay').remove();
		$('#mediaLoad').remove();
		$('#mediaBox').fadeOut("fast");
		$('#media_input li').remove();

		$('#mediaTitle').html('');
		$('#media_input').html('');
		return false;
	});
}

/* MEDIA用 ポップアップレイヤーの出現位置 */
function TB_position() {
	var pagesize = TB_getPageSize();	
	var arrayPageScroll = TB_getPageScrollTop();
	var style = {width: "776px", left: (arrayPageScroll[0] + (pagesize[0] - 776)/2), top: (arrayPageScroll[1] )};
	$("#mediaBox").css(style);
}


/* MEDIA用 ポップアップレイヤーの出現時に背景黒のオーバーレイを敷く （BLACK:30%） */
function TB_overlaySize(){
	if (window.innerHeight && window.scrollMaxY || window.innerWidth && window.scrollMaxX) {	
		yScroll = window.innerHeight + window.scrollMaxY;
		xScroll = window.innerWidth + window.scrollMaxX;
		var deff = document.documentElement;
		var wff = (deff&&deff.clientWidth) || document.body.clientWidth || window.innerWidth || self.innerWidth;
		var hff = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight;
		xScroll -= (window.innerWidth - wff);
		yScroll -= (window.innerHeight - hff);
	} else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth){ // all but Explorer Mac
		yScroll = document.body.scrollHeight;
		xScroll = document.body.scrollWidth;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		yScroll = document.body.offsetHeight;
		xScroll = document.body.offsetWidth;
	}

	$("#TB_overlay").css({"height": yScroll, "width": "100%"});

	$('#TB_overlay').css({
		'position': 'absolute',
		'z-index':'100',
		'top': '0px',
		'left': '0px',
		'background-color':'#000',
		'filter':'alpha(opacity=30)',
		'-moz-opacity': '0.3',
		'opacity': '0.3'
	});

}
