// JavaScript Document

//---Set OBJ---//
function retunOBJ(objid){
	if(document.all){
		OBJ=document.all(objid);
	}
	else if(document.getElementById){
		OBJ=document.getElementById(objid);
	}
	else if(document.layers){
		OBJ=objid.target;
	}
	return OBJ;
}

//---ADD EVENT---//
function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	}
	else {
		elm['on' + evType] = fn;
	}
}

//---Set OBJ---//
function set_OBJ(objid){
	if(document.all){
		OBJ=document.all(objid);
	}
	else if(document.getElementById){
		OBJ=document.getElementById(objid);
	}
	else if(document.layers){
		OBJ=objid.target;
	}
	return OBJ;
}
//---MOUSE POSITION---//
function get_mouse(evt){
	if(document.all) evt=event;
	if(evt.pageX){X = evt.pageX; Y = evt.pageY;}
	else if(evt.clientX){X=evt.clientX; Y=evt.clientY;}
	if(document.all) Y+=document.body.scrollTop;
}
function set_mouse(){
	if(! document.all) window.document.captureEvents(Event.mousemove);
	window.document.onmousemove=get_mouse;
}
//---IE PNG---//
arVersion = navigator.appVersion.split("MSIE");
version = parseFloat(arVersion[1]);
ie=false;
if(version) ie=true;
if((version >= 5.5) && (version < 7)) fpng=true;
else fpng=false;
function fixPNG(myImage){
	if(fpng){
		var imgStyle="width:" + myImage.width + "px; height:" + myImage.height + "px; display:inline-block;" + myImage.style.cssText ;
		myImage.outerHTML = "<span style=\""+imgStyle+" filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>";
    }
}
//---Win Resize---//
function win_loaded(){
//	if(screen.width >1200 || screen.height >850) winLoadedTimer = setInterval(winResizeToDefault, 1);
	if(screen.width >1200 || screen.height >850) winResizeToLoaded();
}

/*function winResizeToDefault(){
	var tWidth = 1200;
	var tHeight = 850;
	if(document.all || document.getElementById){
		var scrW=document.body.clientWidth; var scrH=document.body.clientHeight;
		if((!scrH) && !(scrH==0)){scrW=window.innerWidth;scrH=window.innerHeight;}
	}
	else if(document.Layers){
		var scrW=win.innerWidth; var scrH=win.innerHeight;
	}
	var set_h=655;
	if(ie) set_h=750;
	if(scrH < set_h) tHeight += set_h - scrH;
	var vWidth = Math.round(tWidth - scrW) * .9 + scrW;
	var vHeight = Math.round(tHeight - scrH) * .9 + scrH;
	if(Math.abs(tWidth - vWidth) < 5){
		vWidth = tWidth;
		vHeight = tHeight;
		clearInterval(winLoadedTimer);
		winLoadedTimer = null;
		winLoadedTimer = setInterval(winAlphaToDefault, 100);
	}
	window.resizeTo(vWidth,vHeight);
}*/

function winResizeToLoaded(){
	var tWidth = 1200;
	var tHeight = 850;
	vWidth = tWidth;
	vHeight = tHeight;
	window.resizeTo(tWidth,tHeight);
/*090609WinIEで表示されず
	var contentsObj = set_OBJ('contents');
	ch_alpha(contentsObj, 100);　
	winLoadedTimer = setInterval(winAlphaToDefault, 100);*/
}

var vAlpha = 0;
function winAlphaToDefault(){
	var tAlpha = 100;
	vAlpha = Math.round( (tAlpha - vAlpha) * .9 ) + vAlpha;
	if(Math.abs(tAlpha - vAlpha) < 5){
		vAlpha = tAlpha;
		clearInterval(winLoadedTimer);
		winLoadedTimer = null;
		alert(vAlpha);
	}
	var contentsObj = set_OBJ('contents');
	ch_alpha(contentsObj, vAlpha);
}

//---Win Size---//
function returnWinSize(){
	if(document.all || document.getElementById){
		var scrW=document.body.clientWidth; var scrH=document.body.clientHeight;
		if((!scrH) && !(scrH==0)){scrW=window.innerWidth;scrH=window.innerHeight;}
	}
	else if(document.Layers){
		var scrW=win.innerWidth; var scrH=win.innerHeight;
	}
	var scrSize = new Array(scrW,scrH);
	return scrSize;
}

//---Ch Pointer---//
function ch_pointer(ch_obj,flag){
	if(ch_obj != now_obj){
		var po=set_OBJ('pointer_d');
		po.style.visibility="hidden";
		po.style.top=ch_obj.offsetTop;
		po.style.left=ch_obj.offsetLeft+ch_obj.offsetWidth;
		po.style.visibility="visible";
	}
	if(flag){
		var po=set_OBJ('pointer_d');
		po.style.visibility="hidden";
	}
}
//---Ch Alpha---//
now_obj=null;
function ch_alpha(ch_obj,op){
	ch_obj.style.filter = "alpha(opacity=" + op + ")";
	ch_obj.style.opacity = op/100;
	ch_obj.style.MozOpacity =  op/100;
	ch_obj.style.KhtmlOpacity =  op/100;
}
//---Ch_Contents
function ch_contents(ch_obj,num){
	if(num != 3){
		now_obj=ch_obj;
		now_num=num;
		var po=set_OBJ('pointer');
		po.style.visibility="hidden";
		po.style.top=ch_obj.offsetTop;
		po.style.left=ch_obj.offsetLeft+ch_obj.offsetWidth;
		po.style.visibility="visible";
	}
}