﻿// Adjust Layout
//  width によって、float やリキッドレイアウトを適用する。

// get window width
function getWindowWidth()
{
    if(window.innerWidth){
        return window.innerWidth;
    }else if(document.documentElement && document.documentElement.clientWidth){
        return document.documentElement.clientWidth;
    }else if ( document.body && document.body.clientWidth){
        return document.body.clientWidth;
    }
}

// set float property
function cssFloat(obj, style)
{
	if (navigator.appName == "Microsoft Internet Explorer") {
		obj.style.styleFloat = style;
	} else {
		obj.style.cssFloat = style;
	}
}

// main function
//  デフォルトのCSS上は、float:left で sidebar も minicontainer も完全回り込み。
//  PC の画面サイズなら、sidebar と minicontainer で2段組み。
//     なお、minicontainer は常にリキッド。
function adjustLayout(objLeftContainer, objRightContainer, width1column, debug)
{
	var widthScreen = screen.width;
	var widthWindow = getWindowWidth();
	
	if (debug) {
		document.write(navigator.userAgent);
		document.write('<br/>');
		document.write(navigator.appName);
		document.write('<br/>');
		document.write(navigator.platform);
		document.write('<br/>');
		document.write("Screen Width:" + widthScreen); 
		document.write("<br/>");
		document.write("Window Width:" + widthWindow); 
		document.write("<br/>");
	}
	
	if (widthScreen >= width1column || widthWindow >= width1column) {
		objLeftContainer.style.width = "160px";
		cssFloat(objLeftContainer, "left");
		objRightContainer.style.width = "auto";
		objRightContainer.style.marginLeft = "163px";
	}
	
}

function dummy() 
{
if (screen.width >= 800 || getWindowWidth() >= 800) {
	if (document.getElementById("minicontainer")) {
		document.write("GetElementById ok<br/>");
//		document.write(document.getElementById("minicontainer").style.display);
//		document.getElementById("minicontainer").style.float = "right";
//		cssFloat(document.getElementById("minicontainer"), "left");
//		document.getElementById("minicontainer").style.			
	} else {
		document.write("GetElementById ng<br/>");
	}
//	if (document.getElementById("
	if (screen.width >= 960 || getWindowWidth() >= 960) {
//		document.getElementById("container").style.width = "900px";
//		document.getElementById("minicontainer").style.width = "740px";
//		cssFloat(document.getElementById("minicontainer"), "right");
//		document.getElementById("sidebar").width = "150px";
//		cssFloat(document.getElementById("sidebar"), "left");
		document.getElementById("sidebar").style.width = "160px";
		cssFloat(document.getElementById("sidebar"), "left");
		document.getElementById("minicontainer").style.width = "auto";
		document.getElementById("minicontainer").style.marginLeft = "161px";
	} else {
		document.getElementById("container").style.width = "510px";
		document.getElementById("minicontainer").style.width = "360px";
		cssFloat(document.getElementById("minicontainer"), "right");
		document.getElementById("sidebar").width = "160px";
		cssFloat(document.getElementById("sidebar"), "left");
	}
	document.write('<br/>');
//	}
}

}
