function getElementStyle(elemID, IEStyleProp, CSSStyleProp){
  var elem;
  if(typeof(elemID) == "string"){
    elem = document.getElementById(elemID);
  }else{
    elem = elemID;
  }
  if(elem.currentStyle){
    return elem.currentStyle[IEStyleProp];
  }else if(window.getComputedStyle){
    var compStyle = window.getComputedStyle(elem, "");
    return compStyle.getPropertyValue(CSSStyleProp);
  }
}
/**
 * テロップ表示関数
 * msgs : 表示メッセージ配列
 * len  : 移動距離(px)
 * time : 移動間隔(ms)
 * id   : テロップ表示要素ID
 */
function terop(msgs, len, time, id){
  var base = document.getElementById(id);
  var stylePosition = getElementStyle(base, "position", "position");
  if(stylePosition == "" || stylePosition == "static"){
    base.style.position = "relative";
  }
  var styleWidth = getElementStyle(base, "width", "width");
  if(styleWidth == "" || styleWidth == "auto"){
    base.style.width = "100%";
  }
  base.style.overflow = 'hidden';
  var msg = document.createElement("span");
  base.appendChild(msg);
  msg.style.position = "relative";
  msg.style.left = (base.offsetWidth + 1) + "px";
  msg.style.whiteSpace = "nowrap";
  var i = 0;
  msg.innerHTML = msgs[i];

  var move = function(){
    if(parseInt(msg.style.left) < -(msg.offsetWidth)){
      msg.style.left = (base.offsetWidth + 1) + "px";
      i++;
      if(i >= msgs.length) i = 0;
      msg.innerHTML = msgs[i];
    }
    msg.style.left = (parseInt(msg.style.left) - len) + "px";
    setTimeout(move, time);
  };
  move();
}

function TextSwap(msgs,nummsgs,time,id)
{
  var base = document.getElementById(id);
  var stylePosition = getElementStyle(base, "position", "position");
  if(stylePosition == "" || stylePosition == "static"){
    base.style.position = "relative";
  }
  var styleWidth = getElementStyle(base, "width", "width");
  if(styleWidth == "" || styleWidth == "auto"){
    base.style.width = "100%";
  }
  base.style.overflow = 'hidden';

  var msg = document.createElement("span");
  base.appendChild(msg);
  msg.style.position = "relative";
  //msg.style.left = (base.offsetWidth + 1) + "px";
  msg.style.left = "0px";
  msg.style.whiteSpace = "nowrap";

  var i = 0;
  msg.innerHTML = msgs[i];

  var swap = function(){
		if(i >= nummsgs) i = 0;
		msg.innerHTML = msgs[i];
		i++;
    setTimeout(swap, time);
  };

  swap();
}

function PictureClicked(filepath,width,height)
{
	window.open('picture.html?filepath='+filepath,'','width='+width+',height='+height);
	return false;
}

function HomeLoaded(flag)
{
	if(flag==0)
		alert("お使いのブラウザでは正しく表示されないかもしれません\r\nIE7以上、Firefox、Opera9以上、Safariを推奨します");
}