onload = function(){
    variousButOnclick();
}

/**
 * ページ先頭へ
 */
function backToTop() {
    var x1 = x2 = x3 = 0;
    var y1 = y2 = y3 = 0;
    if (document.documentElement) {
        x1 = document.documentElement.scrollLeft || 0;
        y1 = document.documentElement.scrollTop || 0;
    }
    if (document.body) {
        x2 = document.body.scrollLeft || 0;
        y2 = document.body.scrollTop || 0;
    }
    x3 = window.scrollX || 0;
    y3 = window.scrollY || 0;
    var x = Math.max(x1, Math.max(x2, x3));
    var y = Math.max(y1, Math.max(y2, y3));
    window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));
    if (x > 0 || y > 0) {
        window.setTimeout("backToTop()", 25);
    }
}

/*
 * ブログ、イベント・・
 */
var OnClass = 'variousButtonOn';
var OffClass = 'variousButtonOff';
//liタグのID
var ButtonLiArr= new Array( 'blogNewArticleButton', 'blogNewArrivalButton');
//aタグのID
var ButtonAArr= new Array("blogNewArticleA","blogNewArrivalA");
//表示のdivのID
var ButtonDivArr= new Array("blogNewArticleDiv","blogNewArrivalDiv");

function variousButOnclick(){
    //項目のボタンが押されたときに実行
    ButtonAArr.each(function(obj) {
        //IDが存在しないページ
        if($(obj)==null) return;
        
        Event.observe(obj, "click", changeDisp, false);
    });
}
//表示を変更する
function changeDisp(event){
    var eID = Event.element(event); 
    var OnclickLiId = '';//変更するliタグのID
    
    //クリックされたIDのLIのクラスを変更
     for (var i = 0; i < ButtonAArr.length; i++) {
         if (eID.id == ButtonAArr[i]) {
             OnclickLiId = ButtonLiArr[i];
             $(OnclickLiId).className = OnClass;
             Element.show(ButtonDivArr[i]);
         }else{
             $(ButtonLiArr[i]).className = OffClass;
             Element.hide(ButtonDivArr[i]);
         }
     }
}

//ページサイズの取得
function getPageSize(){
  var xScroll, yScroll;
  if (window.innerHeight && window.scrollMaxY) {
    xScroll = document.body.scrollWidth;
    yScroll = window.innerHeight + window.scrollMaxY;
  } else if (document.body.scrollHeight > document.body.offsetHeight){
    // all but Explorer Mac
    xScroll = document.body.scrollWidth;
    yScroll = document.body.scrollHeight;
  } else {
    // Explorer Mac...would also work in Explorer 6 Strict,
    // Mozilla and Safari
    xScroll = document.body.offsetWidth;
    yScroll = document.body.offsetHeight;
  }

  var windowWidth, windowHeight;
  if (self.innerHeight) {      // all except Explorer
    windowWidth = self.innerWidth;
    windowHeight = self.innerHeight;
  } else if (document.documentElement
  && document.documentElement.clientHeight) {
    // Explorer 6 Strict Mode
    windowWidth = document.documentElement.clientWidth;
    windowHeight = document.documentElement.clientHeight;
  } else if (document.body) { // other Explorers
    windowWidth = document.body.clientWidth;
    windowHeight = document.body.clientHeight;
  }

  // for small pages with total height less then height of the viewport
  if(yScroll < windowHeight){
    pageHeight = windowHeight;
  } else {
    pageHeight = yScroll;
  }

  // for small pages with total width less then width of the viewport
  if(xScroll < windowWidth){
    pageWidth = windowWidth;
  } else {
    pageWidth = xScroll;
  }

 var obj = new Object();
 obj.x = document.documentElement.scrollLeft || document.body.scrollLeft;
 obj.y = document.documentElement.scrollTop || document.body.scrollTop;
 //return obj;

  return {
    'pageWidth':pageWidth,
    'pageHeight':pageHeight,
    'windowWidth':windowWidth,
    'windowHeight':windowHeight,
    'yScroll':yScroll,
    'xScroll':xScroll,
    'ScrollTop':obj.y,
    'ScrollLeft':obj.x
  }

}
//dialog
function Dialog(){

	Element.show("Dialog");
	size = getPageSize();
	//トップからの位置

	var contentDivTop = size.windowHeight / 2 - parseInt($("Dialog_contentDiv").style.height) / 2 + size.ScrollTop;
    var contentDivLeft = size.windowWidth / 2 - parseInt($("Dialog_contentDiv").style.width) / 2 + size.ScrollLeft;
    //半透明外枠
	$("Dialog_transparentDivs").style.width = size.xScroll+"px";
	$("Dialog_transparentDivs").style.height = size.yScroll+"px";
    //コンテント
	$("Dialog_contentDiv").style.top = contentDivTop + "px";
	$("Dialog_contentDiv").style.left = contentDivLeft + "px";
    //影
    $("Dialog_contentDiv_shadow").style.width = $("Dialog_contentDiv").style.width;
    $("Dialog_contentDiv_shadow").style.height = $("Dialog_contentDiv").style.height;
	$("Dialog_contentDiv_shadow").style.top = contentDivTop + 15 + "px";
	$("Dialog_contentDiv_shadow").style.left = contentDivLeft + 15 + "px";
//	alert('pageWidth:'+size.pageWidth+' pageHeight:'+size.pageHeight+' windowWidth:'+size.windowWidth+' windowHeight:'+size.windowHeight+' yScroll:'+size.yScroll+' xScroll:'+size.xScroll+' ScrollTop:'+size.ScrollTop+' ScrollLeft:'+size.ScrollLeft);
}
function CloseDialog(){
	Element.hide("Dialog");
}


