//******************************************************************************
//汎用関数群
//******************************************************************************


//エレメント取得(document.getElementById)
function $(tagId)
{
  return document.getElementById(tagId);
}
//------------------------------------------------------------------------------

//指定時間だけ処理を中断
function sleep(Millissecounds)
{
  now      = new Date();
  exitTime = now.getTime() + Millissecounds;
  while (true) {
    now = new Date();
    if (now.getTime() > exitTime)
    return;
  }
}
//------------------------------------------------------------------------------

//背景色変更
function changeBGColor(obj, BGColor)
{
  obj.style.backgroundColor = BGColor;
}
//------------------------------------------------------------------------------

//Cooki 設定関数
function setCookie(name, value, expire)
{
  document.cookie = name + '=' + escape(value) + ((expire==null)?'':('; expires='+expire.toGMTString()));
}
//------------------------------------------------------------------------------

//Cookie取得関数
function getCookie(name)
{
  var search = name + '=';
  if (document.cookie.length>0) {
    offset = document.cookie.indexOf(search);
    if (offset != -1){
      offset += search.length;
      end     = document.cookie.indexOf(';',offset);
      if(end == -1) end = document.cookie.length;
      return unescape(document.cookie.substring(offset,end));
    }
  }
  return null;
}
//------------------------------------------------------------------------------

// Query String から 配列を返す
function getParameter(str){
  var dec = decodeURIComponent;
  var par = new Array, itm;
  if(typeof(str) == 'undefined') return par;
  if(str.indexOf('?', 0) > -1) str = str.split('?')[1];
  str = str.split('&');
  for(var i = 0; str.length > i; i++){
    itm = str[i].split("=");
    if(itm[0] != ''){
      par[itm[0]] = typeof(itm[1]) == 'undefined' ? true : dec(itm[1]);
    }
  }
  return par;
}
//------------------------------------------------------------------------------

// 配列 から Query Stringを返す
function setParameter(par){
  var enc = encodeURIComponent;
  var str = '', amp = '';
  if(!par) return '';
  for(var i in par){
    str = str + amp + i + "=" + enc(par[i]);
    amp = '&'
  }
  return str;
}
//------------------------------------------------------------------------------

//不透過度の変更
function changeOpacity(obj, Percent)
{
  obj.opacity          = Percent / 100;
  obj.style.MozOpacity = Percent / 100;
  obj.style.filter = "alpha(opacity=" + Percent + ")";
}
//------------------------------------------------------------------------------
