
document.write('<link rel="stylesheet" type="text/css" href="/works/elements/css/box.css" title="default" />');

var bdyWid;
var bdyHgt;
var baseWid;

var boxWid = 782;

var alpVal = 100;
if(gUsr.indexOf("MSIE",0) != -1) { alpVal = alpVal - 20 }



function getWinSize(){
	bdyWid = Element.getDimensions(document.getElementsByTagName("body")[0]).width;
	bdyHgt = Element.getDimensions(document.getElementsByTagName("body")[0]).height;
}



function setGallerySize(rszChk) {
	
	getWinSize();
	
	gSideWid = (bdyWid - boxWid)/2;
	if(gSideWid < 0) {
		gSideWid = 0;
	}
	gSideHgt = bdyHgt - 20;
	
	if(gUsr.indexOf("MSIE 6",0) != -1) {
		$("galleryExLeft").style.width = gSideWid - 25 + "px";
	}else{
		$("galleryExLeft").style.width = gSideWid - 15 + "px";
	}
	$("galleryExLeft").style.height = gSideHgt + "px";
	$("galleryExLeft").style.display = "block";
	
	if(gUsr.indexOf("MSIE 6",0) != -1) {
		$("galleryExRight").style.width = gSideWid - 25 + "px";
	}else{
		$("galleryExRight").style.width = gSideWid - 15 + "px";
	}
	$("galleryExRight").style.height = gSideHgt + "px";
	$("galleryExRight").style.display = "block";
	
	/*$("galleryExLeft").style.background = "#FF6600";
	$("galleryExLeft").style.filter = "alpha(opacity=30)";
	$("galleryExLeft").style.opacity = "0.3";
	$("galleryExLeft").style.mozOpacity = "0.3";
	$("galleryExRight").style.background = "#FF6600";
	$("galleryExRight").style.filter = "alpha(opacity=30)";
	$("galleryExRight").style.opacity = "0.3";
	$("galleryExRight").style.mozOpacity = "0.3";
	$("galleryOuter").style.background = "#0000FF";*/
	
}



function setGalleryWrap() {
	
	new Insertion.After("wrapper", '<div id="galleryOuter"><div id="gallerySlider"><div class="galleryBox"><div class="galleryContainer"></div></div></div></div>');
	new Insertion.After("wrapper", '<div id="galleryWrap"></div>');
	new Insertion.After("wrapper", '<div id="galleryExLeft"></div>');
	new Insertion.After("wrapper", '<div id="galleryExRight"></div>');
	
	$("galleryWrap").onclick = function(){
		outGallery();
	}
	$("galleryExLeft").onclick = function(){
		outGallery();
	}
	$("galleryExRight").onclick = function(){
		outGallery();
	}
	
}



function visibleBox() {
	
	$("gallerySlider").style.display = "block";
	
	/*bytefx.fade($("galleryWrap"), 0, alpVal, 70, function() {
		bytefx.fade($("gallerySlider"), 0, 100, 50);
	});*/
	$("galleryWrap").style.display = "block";
	$("galleryWrap").style.filter = "alpha(opacity=" + alpVal + ")";
	$("gallerySlider").style.display = "block";
	
}




function outGallery(){
	/*bytefx.fade($("gallerySlider"), alpVal, 0, 50, function() {
		bytefx.fade($("galleryWrap"), 100, 0, 70, function() {
			noneBox();
		});
	});*/
	noneBox();
}
function noneBox() {
	$("galleryWrap").style.display = "none";
	$("gallerySlider").style.display = "none";
	$("galleryExLeft").style.display = "none";
	$("galleryExRight").style.display = "none";
	Element.remove("galleryWrap");
	Element.remove("galleryOuter");
	Element.remove("galleryExLeft");
	Element.remove("galleryExRight");
}


var gObj;

function loadBox(webid){
	if(screen.width >= 1024){
		
		baseWid = Element.getDimensions(document.getElementsByTagName("body")[0]).width;
		setGalleryWrap();
		gObj = document.getElementsByClassName("galleryContainer")[0];
		visibleBox();
		loadXHTML(webid);
	
	}else{
		alert("モニタの解像度を1024x768以上にしてください。");
	}
}

function loadXHTML(webid) {
	q = "?" + "time=" + (new Date()).getTime();
	httpObj = createXMLHttpRequest(displayData);
	if (httpObj) {
		httpObj.open("GET","/works/detail.php" + q + "&code=" + webid);
		httpObj.send(null);
		pageTracker._trackPageview("/works/detail.php?code=" + webid);
	}
}

function createXMLHttpRequest(cbFunc) {
	var XMLhttpObject = null;
	try{
		XMLhttpObject = new XMLHttpRequest();
	}catch(e){
		try{
			XMLhttpObject = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				XMLhttpObject = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e){
				return null;
			}
		}
	}
	if (XMLhttpObject) XMLhttpObject.onreadystatechange = cbFunc;
	return XMLhttpObject;
}

function displayData() {
	if ((httpObj.readyState == 4) && (httpObj.status == 200)) {
		xmlTxt = httpObj.responseText;
		xmlTxt = xmlTxt.substring((xmlTxt.indexOf('<div class="workDtlWrap">',0)),(xmlTxt.indexOf('</div>',0)+6));
		gObj.innerHTML = xmlTxt;
		setGalleryLink();
		setGallerySize();
	}
}


function setGalleryLink() {
	gBox = document.getElementsByClassName("galleryBox")[0];
	if(gBox.getElementsByClassName("workDtlWrap")[0]){
		if(!gBox.getElementsByClassName("workDtlClose")[0]){
			gwObj = gBox.getElementsByClassName("workDtlWrap")[0];
			new Insertion.Bottom(gwObj, '<p class="workDtlClose"><a href="javascript:outGallery();"><img src="/works/elements/img/detail_close.gif" alt="このウィンドウを閉じる" width="99" height="14" /></a></p>');
		}
	}
	if(gBox.getElementsByClassName("workDtlBack")[0]){
		gBox.getElementsByClassName("workDtlBack")[0].getElementsByTagName("a")[0].onclick = function() {
			tLnk = this.getAttribute("href").split("code=")[1];
			loadXHTML(tLnk);
			return false;
		}
	}
	if(gBox.getElementsByClassName("workDtlNext")[0]){
		gBox.getElementsByClassName("workDtlNext")[0].getElementsByTagName("a")[0].onclick = function() {
			tLnk = this.getAttribute("href").split("code=")[1];
			loadXHTML(tLnk);
			return false;
		}
	}
	worksBlankLnk();
}







// works list Function ----------------------------------------------------------------------------------------------------
function setListLnk() {
	if(defStartCheck()==true){
		lnkObj = $("worksList").getElementsByTagName("li");
		
		for(i=0; i<lnkObj.length; i++){
			try {
				
				if(lnkObj[i].getElementsByTagName("a").length != 0){
					lnkObj[i].style.cursor = "pointer";
				}
				
				lnkObj[i].getElementsByTagName("a")[0].onclick = function() {
					return false;
				}
				
				lnkObj[i].onclick = function() {
					ancAry = this.getElementsByTagName("a");
					if(cssOnOffCheck() == "transparent"){ // browser's css onoff check
						if(ancAry.length == 1) {
							lnkURL = ancAry[0].getAttribute("href");
							window.open(lnkURL);
							return false;
						}
					}else{
						if(ancAry.length == 1) {
							lnkURL = ancAry[0].getAttribute("href");
							lnkStr = lnkURL.split("code=");
							loadBox(lnkStr[1]);
							return false;
						}
					}
				}
				
				lnkObj[i].onmouseover = function() {
					
					opcValue = 80;
					this.style.filter = 'alpha(opacity=' + opcValue + ')';
					this.style.MozOpacity = opcValue / 100;
					this.style.opacity = opcValue / 100;
					
					if((gUsr.indexOf("NETSCAPE/7",0) != -1)||(gUsr.indexOf("OPERA",0) != -1)){ //windowResize for NETSCAPE7.1 & OPERA
						this.getElementsByTagName("dl")[0].style.MozOpacity = opcValue / 500;
						this.getElementsByTagName("dl")[0].style.opacity = opcValue / 500;
					}
					
				}
				
				lnkObj[i].onmouseout = function() {
					
					opcValue = 100;
					this.style.filter = 'alpha(opacity=' + opcValue + ')';
					this.style.MozOpacity = opcValue / 100;
					this.style.opacity = opcValue / 100;
					
					if((gUsr.indexOf("NETSCAPE/7",0) != -1)||(gUsr.indexOf("OPERA",0) != -1)){ //windowResize for NETSCAPE7.1 & OPERA
						this.getElementsByTagName("dl")[0].style.MozOpacity = opcValue / 100;
						this.getElementsByTagName("dl")[0].style.opacity = opcValue / 100;
					}
					
				}
				
			}catch(e){
				
			}
		}
	}
}




function setBtmNavi() {
	qStr = location.search;
	if(qStr != ""){
		try{
			btmAry = $("worksBtmNavi").getElementsByTagName("a");
			for(i=0; i<btmAry.length; i++){
				if(btmAry[i].getAttribute("href").indexOf(qStr,0) != -1){
					btmAry[i].className = "actv";
				}
			}
		}catch(e){
			
		}
	}
	try{
		uStrLen = location.href.split(".jp");
		uStr = uStrLen[uStrLen.length - 1];
		if(uStr == "/works/"){
			try{
				btmAry = $("worksBtmNavi").getElementsByTagName("a");
				btmAry[0].className = "actv";
			}catch(e){
				
			}
		}
	}catch(e){
		
	}
}




// works pickup Function ----------------------------------------------------------------------------------------------------
var orgBg = "";
function setPickupLnk() {
	if(defStartCheck()==true){
		lnkObj = $("pkupIdxWrap").getElementsByTagName("li");
		orgBg = Element.getStyle(lnkObj[0], "background-image");
		orgFl = Element.getStyle(lnkObj[0], "filter");
		
		for(i=0; i<lnkObj.length; i++){
			try {
				
				if(lnkObj[i].getElementsByTagName("a").length != 0){
					lnkObj[i].style.cursor = "pointer";
				}
				
				lnkObj[i].onclick = function() {
					ancAry = this.getElementsByTagName("a");
					if(ancAry.length == 1) {
						lnkURL = ancAry[0].getAttribute("href");
						location.href = lnkURL;
					}
				}
				
				lnkObj[i].onmouseover = function() {
						bgStr = "#22251A";
						if(gUsr.indexOf("MSIE 6",0) != -1){
							this.style.filter = "none";
							this.style.background = bgStr;
						}else{
							this.style.background = bgStr;
						}
				}
				
				lnkObj[i].onmouseout = function() {
						if(gUsr.indexOf("MSIE 6",0) != -1){
							this.style.filter = orgFl;
							this.style.background = "none";
						}else{
							this.style.background = orgBg;
						}
				}
				
			}catch(e){
				
			}
		}
	}
}





// blanklink Function ----------------------------------------------------------------------------------------------------
function worksBlankLnk() {
	setClass = "blank";
	aArr = new Array;
	aArr = document.getElementsByTagName("a");
	aLen = aArr.length;
	for(i=0; i<aLen; i++) {
		if(aArr[i].className == setClass){
			aArr[i].setAttribute("target","_blank");
		}
	}
}






// Gallery Start function ----------------------------------------------------------------------------------------------------
function grlyResize(){
	if(defStartCheck()==true){
		if($("galleryWrap")){
			setGallerySize();
		}
	}
}












