/*------------------------------ initialize Variables ------------------------------*/
var OS;
var fullSizeWindowCalled = false;

var ie5=document.all&&document.getElementById;
var ns6=document.getElementById&&!document.all;

var initialwidth = 650;
var initialheight = 650;

var boxObj;
var topGap, leftGap;

var windowMaxWidth;
var windowMaxHeight;

document.domain = "hasselclub.net";


/// hooking for FSCommand

var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

function mainSWF_DoFSCommand(command, args) {
	var flashObj = isInternetExplorer ? document.all.mainSWF : document.mainSWF;

	if(command == "resizeWin")	{
		OS = OSDetect();
		if(OS == "Windows") {
			args_array = args.split(",");
			resizeWin(Number(args_array[0]), Number(args_array[1]));
		}
	}

	if(command == "contentBoxPopUp") {
		OS = OSDetect();
		args_array = args.split(",");
		contentBoxPopUp(args_array[0], Number(args_array[1]), Number(args_array[2]));
	}

	if(command == "closeContentWin") {
		OS = OSDetect();
		if(OS == "Windows") {
			closeContentWin();
		}
	}
}

if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub mainSWF_FSCommand(ByVal command, ByVal args)\n');
	document.write('Call mainSWF_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}



/*------------------------------ Define Functions ------------------------------*/

function contentBoxPopUp(url, boxWidth, boxHeight) {

	boxObj = document.getElementById("contentWindow").style;

	if(OS == "notWindows") { // 작동 비호환

		featureStr = 'width='+boxWidth+', height='+boxHeight+', scrollbars=yes, toolbar=no, menubar=no';
		contentBoxWindow = window.open(url, '', featureStr);

	}
	else { // 작동호환

		if(boxWidth <= 0 || boxHeight <= 0) {
			boxWidth = initialwidth;
			boxHeight = initialheight;
		}

		window.document.getElementById("contentBox").src = url;
		boxObj.display = '';

//		boxObj.width = boxWidth+"px";
//		boxObj.height = boxHeight+"px";
		boxObj.width = "920px";
		boxObj.height = "490px";
		setContentBoxPos();

		boxObj.zIndex = 2;

		window.document.getElementById("contentBox").style.border = "0px";



	}
}

function setContentBoxPos() {

	boxObj = window.document.getElementById("contentWindow").style;

	topGap = -55;
	leftGap = -2;

	if(document.getElementById("contentBox").src != '') {
		boxObj.top = (document.body.offsetHeight - parseInt(boxObj.height))/2 - topGap + "px";
		boxObj.left = (document.body.offsetWidth - parseInt(boxObj.width))/2 - leftGap + "px";
	}
}


function closeContentWin() {

	// 플래쉬에서 호출되는 함수, div를 닫고 iframe의 src를 비운다.
	if(ie5) {
		window.document.getElementById("contentBox").src = 'about:blank';
		window.document.getElementById("contentWindow").style.display = 'none';
	}
	else{
		window.document.getElementById("contentWindow").style.display = 'none';
		window.document.getElementById("contentBox").src = 'about:blank';
	}
}



function closeContentWindowJS() {
	window.document.mainSWF.setVariable("closeContentWindowJS", "true");
}



function fullSizeWindow() {
	window.resizeTo(window.screen.availWidth,window.screen.availHeight);
	window.moveTo(0,0);
}


function OSDetect() {
	if(navigator.appVersion.indexOf("Windows")>(-1)) {
		// this is Windows
		OS = "Windows";
	}
	else { 
		OS = "notWindows";
	}

	return OS;

}


function startFlashMovie() {
	OS = OSDetect();

	var detectedStr;

	if(OS == "Windows") {
		detectedStr = "?dynamicBoxisEnable=true";
	}
	else {
		detectedStr = "?dynamicBoxisEnable=false";
	}

	window.document.writeln("      <OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" WIDTH=\"100%\" HEIGHT=\"100%\" id=\"mainSWF\">");
	window.document.writeln("        <PARAM NAME=movie VALUE=\"index.swf" + detectedStr + "\">");
	window.document.writeln("        <PARAM NAME=loop VALUE=false>");
	window.document.writeln("        <PARAM NAME=menu VALUE=false>");
	window.document.writeln("        <PARAM NAME=quality VALUE=high>");
	window.document.writeln("        <PARAM NAME=scale VALUE=noscale>");
	window.document.writeln("        <PARAM NAME=wmode VALUE=transparent>");
	window.document.writeln("        <PARAM NAME=swLiveConnect VALUE=true>");
	window.document.writeln("        <PARAM NAME=allowScriptAccess VALUE=sameDomain>");
	window.document.writeln("        <EMBED src=\"index.swf"+ detectedStr +"\" loop=false menu=false quality=high wmode=transparent scale=noscale WIDTH=\"100%\" HEIGHT=\"100%\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"  name=\"mainSWF\" swLiveConnect=\"true\" allowScriptAccess=\"sameDomain\">");
	window.document.writeln("        </EMBED>");
	window.document.writeln("      </OBJECT>");

}


window.onResize = setContentBoxPos;
window.onLoad = OSDetect;