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

var boxObj;
var topGap, leftGap;

var windowMaxWidth;
var windowMaxHeight;

document.domain = "limitcut.com";

var innerFrameCall = true;



/*------------------------------ FSCommand Connections ------------------------------*/
var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

// Handle all the FSCommand messages in a Flash movie.
function index_DoFSCommand(command, args) {
	var indexObj = isInternetExplorer ? document.all.index : document.index;

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

	if(command == "closeContentWin") {
		closeContentWin();
	}

	if(command == "setphotoboxposition") {
		setPhotoBoxPos();
	}
}

// Hook for Internet Explorer.
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 index_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call index_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}


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

function contentBoxPopUp(url, boxWidth, boxHeight, boxPosition) {

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

	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.width = boxWidth+"px";
		boxObj.height = boxHeight+"px";
		setContentBoxPos(boxPosition);
		boxObj.zIndex = 2;

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

		window.document.indexSWF.setVariable("contentBoxIsPresent", "true");

	}
}

function showInnerPage() {
	boxObj = document.getElementById("contentWindow").style;
	boxObj.display = '';
}


function setContentBoxPos(boxPosition) {

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

  if(boxPosition == 'up'){
   	topGap = 20;
	  leftGap = 10;
  }
  else if(boxPosition == 'down') {
  	topGap = -75;
	  leftGap = 5;
  }
  else {
  	topGap = -20;
	  leftGap = 5;
	}

	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 = '';
		window.document.getElementById("contentWindow").style.display = 'none';
	}
	else{*/
		window.document.getElementById("contentWindow").style.display = 'none';
		window.document.getElementById("contentBox").src = '';//about:blank';
//	}
	window.document.mainSWF.setVariable("contentBoxIsPresent", "false");
}



function closeContentWindowJS() {
	var indexObj = isInternetExplorer ? document.all.index : document.index;

	closeContentWin();
	indexObj.setVariable("subMovie_mc.closeContentWindowJS", "true");
}



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

}



function setPhotoBoxPos() {
	var indexObj = isInternetExplorer ? document.all.index : document.index;

	var photoWidth = 800;
	var photoHeight = 800;
	var clientWidth = document.body.clientWidth;
	var clientHeight = document.body.clientHeight;

	var photo_x = clientWidth + ((clientWidth-1000)/2);
	var photo_y = clientHeight + ((clientHeight-600)/2);

	indexObj.setVariable("photo_x", photo_x);
	indexObj.setVariable("photo_y", photo_y);
}


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