/**********************************************************
* showParts
*/

var typhoonSWF = "http://front.eye.tc/typhoon-gahou/parts/typhoon_parts.swf";

function showTyphoonParts(photoVer, dMode){
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="160" height="260" id="typhoon" align="middle"><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+typhoonSWF+'?satellite='+photoVer+'&mode='+dMode+'" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="'+typhoonSWF+'?satellite='+photoVer+'&mode='+dMode+'" quality="high" bgcolor="#ffffff" wmode="transparent" width="160" height="260" name="typhoon" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
}


/**********************************************************
* openTyphoonFront
*/

function openTyphoonFront(typhoonURL) {
	typhoonWindow = window.open(typhoonURL,"typhoon", "width=800,height=600,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no,location=no,menubar=no");
	typhoonWindow.focus();
	return false;
}


/**********************************************************
* showSatellite
*/

var satelliteBgId = "satelliteFloatBg";
var satelliteId = "satelliteFloat";
var satelliteFloatBg = "http://front.eye.tc/typhoon-gahou/parts/sbg.png";
var typhoonClose = "http://front.eye.tc/typhoon-gahou/parts/clearbtn.gif";
var typhoonCloseBg = "http://front.eye.tc/typhoon-gahou/parts/btnbg.gif";

function showSatellite(_img) {
	var satelliteLayer;
	var layerWidth;
	var layerHeight;

	satelliteLayer = document.createElement("div");
	satelliteLayer.setAttribute("id", satelliteBgId);
	satelliteLayer.style.position = "absolute";
	satelliteLayer.style.zIndex = 999;
	satelliteLayer.style.display = "block";

	layerWidth = getWindowSize("width");
	layerHeight = getWindowSize("height");

	if(checkBrowserMode()){
		satelliteLayer.style.width = layerWidth + "px";
		satelliteLayer.style.height = layerHeight + "px";
		satelliteLayer.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + satelliteFloatBg + ", sizingmethod=scale)";
	} else {
		satelliteLayer.style.width = "100%";
		satelliteLayer.style.height = "100%";
		satelliteLayer.style.backgroundImage = "url('" + satelliteFloatBg + "')";
	}

	satelliteLayer.style.top = getScrollPosition("top") + "px";
	satelliteLayer.style.left = getScrollPosition("left") + "px";

	var sHtml = "&nbsp;";

	satelliteLayer.innerHTML = sHtml;

	if(!document.getElementById(satelliteBgId)){
		document.getElementsByTagName("body")[0].appendChild(satelliteLayer);
	}

	satelliteLayer = document.createElement("div");
	satelliteLayer.setAttribute("id", satelliteId);
	satelliteLayer.style.position = "absolute";
	satelliteLayer.style.zIndex = 1000;
	satelliteLayer.style.display = "block";
	satelliteLayer.style.textAlign = "center";

	layerWidth = getWindowSize("width");
	layerHeight = getWindowSize("height");

	if(checkBrowserMode()){
		satelliteLayer.style.width = layerWidth + "px";
		satelliteLayer.style.height = layerHeight + "px";
	} else {
		satelliteLayer.style.width = "100%";
		satelliteLayer.style.height = "100%";
	}

	satelliteLayer.style.top = getScrollPosition("top") + "px";
	satelliteLayer.style.left = getScrollPosition("left") + "px";

	var sHtml = "";
	var overStyle = "this.style.backgroundPosition='bottom'";
	var outStyle = "this.style.backgroundPosition='top'";
	var typh = "document.getElementById('ty').focus()";
	sHtml += '<table height="100%" style="margin:auto" id="ty"><tr><td><img src="'+_img+'" width="640" height="480" style="border:3px solid #24284a;" onload="'+typh+'" /><br /><a href="javascript:closeSatellite()" style="border-left:3px solid #24284a;border-bottom:3px solid #24284a;border-right:3px solid #24284a;display:block;width:640px;background:url('+typhoonCloseBg+') no-repeat;margin-right:auto;margin-left:auto;" onmouseover="'+overStyle+'" onmouseout="'+outStyle+'"><img src="'+typhoonClose+'" width="640" height="22" style="border:0px;" alt="CLOSE" /></a></td></tr></table>';

	satelliteLayer.innerHTML = sHtml;

	if(!document.getElementById(satelliteId)){
		document.getElementsByTagName("body")[0].appendChild(satelliteLayer);
	}

	layerBgInterval = setInterval("setLayPosition('" + satelliteBgId + "')", 100);
	layerInterval = setInterval("setLayPosition('" + satelliteId + "')", 100);
}


/**********************************************************
* closeSatellite
*/

function closeSatellite() {
	var closeLayer = document.getElementById(satelliteId);
	var objBody = document.body;
	objBody.removeChild(closeLayer);

	closeLayer = document.getElementById(satelliteBgId);
	var objBody = document.body;
	objBody.removeChild(closeLayer);

	clearInterval(layerBgInterval);
	clearInterval(layerInterval);
}


/**********************************************************
* showTyphoonGaHo
*/

var floatSwf = "http://front.eye.tc/typhoon-gahou/parts/typhoon_float.swf";
var swfName = "typhoonexternal";
var floatId = "typhoonFloat";

function showTyphoonGaHo(typhoonNum){
	var typhoonLayer;
	var layerWidth;
	var layerHeight;

	typhoonLayer = document.createElement("div");
	typhoonLayer.setAttribute("id", floatId);
	typhoonLayer.style.position = "absolute";
	typhoonLayer.style.zIndex = 1000;
	typhoonLayer.style.display = "block";

	layerWidth = getWindowSize("width");
	layerHeight = getWindowSize("height");

	if(checkBrowserMode()){
		typhoonLayer.style.width = layerWidth + "px";
		typhoonLayer.style.height = layerHeight + "px";
	} else {
		typhoonLayer.style.width = "100%";
		typhoonLayer.style.height = "100%";
	}

	typhoonLayer.style.top = getScrollPosition("top") + "px";
	typhoonLayer.style.left = getScrollPosition("left") + "px";

	var sHtml = "";
	sHtml += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="100%" id="' + swfName + '" align="middle">';
	sHtml += '<param name="bgcolor" value="#ffffff" />';
	sHtml += '<param name="allowScriptAccess" value="always" />';
	sHtml += '<param name="movie" value="' + floatSwf + '?ty=' + typhoonNum + '" />';
	sHtml += '<param name="quality" value="high" />';
	sHtml += '<param name="wmode" value="transparent" />';
	sHtml += '<embed align="middle" src="' + floatSwf + '?ty=' + typhoonNum + '" quality="high" bgcolor="#ffffff" wmode="transparent" width="100%" height="100%" name="' + swfName + '" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	sHtml += '</object>';

	typhoonLayer.innerHTML = sHtml;
	document.getElementsByTagName("body")[0].appendChild(typhoonLayer);

	layerInterval = setInterval("setLayPosition('" + floatId + "')", 100);
}


/**********************************************************
* closeTyphoonGaHo
*/

function closeTyphoonGaHo(){
	var closeLayer = document.getElementById(floatId);
	var objBody = document.body;
	objBody.removeChild(closeLayer);

	clearInterval(layerInterval);
}


/**********************************************************
* 
*/

function setLayPosition(sId){
	var trgLayer = document.getElementById(sId);

	if(checkBrowserMode()) {
		trgLayer.style.width = getWindowSize("width") + "px";
		trgLayer.style.height = getWindowSize("height") + "px";
	}

	trgLayer.style.top = getScrollPosition("top") + "px";
	trgLayer.style.left = getScrollPosition("left") + "px";
}


/**********************************************************
* 
*/

function getScrollPosition(sMode){

	var scrollPosition;

	if(sMode == "left"){
		if(self.pageXOffset){
			scrollPosition = self.pageXOffset;
		// Explorer 6 Strict
		}else if(document.documentElement && document.documentElement.scrollLeft){
			scrollPosition = document.documentElement.scrollLeft;
		// all other Explorers
		}else if(document.body){
			scrollPosition = document.body.scrollLeft;
		}
	} else {

		if(self.pageYOffset){
			scrollPosition = self.pageYOffset;
		// Explorer 6 Strict
		}else if(document.documentElement && document.documentElement.scrollTop){
			scrollPosition = document.documentElement.scrollTop;
		// all other Explorers
		}else if(document.body){
			scrollPosition = document.body.scrollTop;
		}
	}

	return scrollPosition;
}


/**********************************************************
* 
*/

function getWindowSize(sMode){
	var windowWidth, windowHeight;

	// all except Explorer
	if(self.innerHeight){
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	// Explorer 6 Strict Mode
	}else if(document.documentElement && document.documentElement.clientHeight){
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	// other Explorers
	}else if(document.body){
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	if(sMode == "width"){
		return (windowWidth);
	} else {
		return (windowHeight);
	}
}


/**********************************************************
* 
*/

function checkBrowserMode(){
	var sOs = getOsName();
	var sBrowser = getNavigatorName();

	if(sOs == "Windows" && sBrowser == "Explorer"){
		return true;
	}
	return false;
}


/**********************************************************
* 
*/

function getOsName()
{
	var uAgent  = navigator.userAgent.toUpperCase();
	if (uAgent.indexOf("MAC OS X") >= 0) return "MacOSX";
	if (uAgent.indexOf("MAC") >= 0) return "MacOS";
	if (uAgent.indexOf("WIN") >= 0) return "Windows";
	if (uAgent.indexOf("X11") >= 0) return "UNIX";
	return "";
}


/**********************************************************
* 
*/

function getNavigatorName(){
	if(navigator.IBM_HPR) return "HomepageReader";

	aName  = navigator.userAgent.toUpperCase();
	if (aName.indexOf("SAFARI") >= 0) return "Safari";
	if (aName.indexOf("CHIMERA") >= 0) return "Camino";
	if (aName.indexOf("OPERA") >= 0) return "Opera";
	
	aName = navigator.appName.toUpperCase();
	if (aName.indexOf("NETSCAPE") >= 0)  return "Netscape";
	if (aName.indexOf("MICROSOFT") >= 0) return "Explorer";
	return "";
}

