// エフェクト制御用フラグ
var uwsEffectFlg = true;

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// BLOGの最新記事書き出し
function writeRSS() {
  if($('rss-reader')) {
    $('rss-reader').innerHTML = getRSSReader();
  }
}

// 画像プリロード
function onloadImages() {
  MM_preloadImages('../img/logo_joinusOn.png');
}

// ==== js class definition ====  
// make helper balloon
var divHelper = Class.create();
divHelper.prototype = {
	initialize: function(target, c, w, h) {
		var elem = target;
		if (typeof(target) == 'string') {
			elem = $(target);
		}
		this.element = elem;
		this.id = 'divhelper';
		this.helper = $(this.id);
		this.helpmarginleft = 4;
		this.helpmarginbottom = 4;
		if (c == undefined) c = 'popup';
		if (w == undefined) w = '250px';
		this.classname = c;
		this.width = w;
		if (h != undefined) this.height = h;

		if (this.helper == undefined) {
			//alert('helper div is not found');
			this.helper = document.createElement("div");
			this.helper.id = this.id;
			this.helper.className = this.classname;
			if (this.width != undefined)
				this.helper.style.width = this.width;
			if (this.height != undefined)
				this.helper.style.height = this.height;
			this.helper.className = this.classname;

			document.body.appendChild(this.helper);
		}

	},
	show: function(msg, add_top) {
		this.helper.innerHTML = msg;
		
		var helpdim = Element.getDimensions(this.helper);
		var elmdim = Element.getDimensions(this.element);
		var elmpos = Position.positionedOffset(this.element);
		
		var helpleft = elmpos[0] + this.helpmarginleft;
		var helptop = elmpos[1] + elmdim.height + this.helpmarginbottom + add_top;
		this.helper.style.left = helpleft+'px';
		this.helper.style.top  = helptop +'px';
		
		Element.show(this.helper);
	},
	hide: function() {
		Element.hide(this.helper);
	}
};
// ==== js class definition ====  

// show summary
function showsum(elem, visible, sum_id, add_top) {

	var target = elem;
	if (typeof(elem) == 'object') {
		target = elem.target || elem.srcElement;
	}
	var helper = new divHelper(target);
	var d = document.getElementById(sum_id);
	if (visible == 1) {
		if (d) {
			if (d.style.display == 'none') {
				helper.show(d.innerHTML, add_top);
			}
		}
	} else {
		helper.hide();
		if (d) {
			d.style.display = 'none';
		}
	}
}

function openWindow(url,win,target) {
  var option = "toolbar=yes,status=no,scrollbars=yes,resizable=yes,width=400,height=480";
  url = url + '?target=' + target;
  window.open(url,win,option);
}
