

var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE);
document.onresize		= windowResizeHandler;
 
var clientRectWidth;
var clientRectHeight;
var wstX;
var wstY;
var WSTButtonDown;
var WSTMoved;

var pageTop;
var pageBottom;
var pageLeft;
var pageRight;
var pageHeight;
var pageWidth;

var menuTabsHeight;
var toolWindowWidth;
var toolWindowTop;
var headerEnd;

var mapFrameLeft;
var mapFrameTop;
var mapFrameRight;
var mapFrameBottom;

var regTop;


function pageInitPublic (initFunc)
{	
		
		getClientSize();
		
		pageLeft = 0;
		pageTop = 0;
		pageBottom = clientRectHeight - 0;
		pageRight = clientRectWidth - 5;
		
		headerEnd = pageTop + 72;
		
		theLogin = document.getElementById("NCFirstLogin");
		toolWindowWidth = theLogin.offsetWidth;
		
		mapFrameLeft = pageLeft + toolWindowWidth;
		mapFrameTop  = headerEnd;
		mapFrameRight = pageRight ;
		mapFrameBottom = pageBottom ;
		
	//	theLogin = document.getElementById("headerBox");
		menu = new SDMenu("menuGeneral", mapFrameBottom - mapFrameTop);
		menu.init();
		//resizeToolWindow();
		
		
		resizeInteractiveFrame();
		positionLogin();
}

function positionLogin()
{
	theLogin = document.getElementById("NCFirstLogin");
	theLogin.style.top = pageTop+5;
	if (!IE) 
	{
		theLogin.style.left = (pageRight - theLogin.offsetWidth)-15 +"px";
	}
	else
	{
		theLogin.style.left = (pageRight - theLogin.offsetWidth) +"px";
	}
	//theLogin.style.width = (theLogin.offsetWidth*2) +"px";
	//theLogin.style.height = (theLogin.offsetHeight) +"px";
	
}

function resizeInteractiveFrame()
{
	inter = document.getElementById("interactiveFrame");
	inter.style.left = mapFrameLeft + "px";
	inter.style.top  = mapFrameTop  + "px";
	
	
	if (!IE) 
	{
		inter.style.width  =	(mapFrameRight - mapFrameLeft - 37) + "px" ;
	}
	else
	{
		inter.style.width  =	(mapFrameRight - mapFrameLeft) + "px" ;
	}
	
	toolWindowTop = mapFrameTop;
	toolWin = document.getElementById("toolWindow");
	toolWin.style.top 	= toolWindowTop + "px";
	toolWin.style.left 	= pageLeft + "px";
	toolWin.style.width = (toolWindowWidth ) + "px";
	if ((mapFrameBottom - mapFrameTop) > inter.offsetHeight)
	{
		inter.style.height =	(mapFrameBottom - mapFrameTop) + "px" ;
		toolWin.style.height = (pageBottom - toolWindowTop) + "px";
	}
//	inter.style.height =	(mapFrameBottom - mapFrameTop) + "px" ;
}


function windowResizeHandler()
{
		getClientSize();
		
		pageLeft = 0;
		pageTop = 0;
		pageBottom = clientRectHeight - 0;
		pageRight = clientRectWidth - 5;
		
		headerEnd = pageTop + 72;
		
		theLogin = document.getElementById("NCFirstLogin");
		toolWindowWidth = theLogin.offsetWidth;
		
		mapFrameLeft = pageLeft + toolWindowWidth;
		mapFrameTop  = headerEnd;
		mapFrameRight = pageRight ;
		mapFrameBottom = pageBottom ;
		
		menu = new SDMenu("menuGeneral", mapFrameBottom - mapFrameTop);
		menu.init();
		//resizeToolWindow();
		
		
		resizeInteractiveFrame();
		positionLogin();
}
 
function showFullSize(url)
{
    interFrame = document.getElementById("interactiveFrame");
    interFrame.innerHTML = "&nbsp;";

    var str = interFrame.style.width; 
    var x = str.substring(0,str.indexOf("px"));
    str = interFrame.style.height; 
    var y = str.substring(0,str.indexOf("px"));
    var dx = x - x / 35;
    var dy = y - y / 20;
    if (!(str.substring(0,str.indexOf("?") > 0))) {
        url=url+"?";
    }
    interFrame.innerHTML = "<iframe id='interactiveFrame_iframe' src='"+url+"&x=" + dx + "&y=" + dy 
                         + "' frameborder='0' width='" + x + "' height='" + y + "'></iframe>";
    showInteractive();
}

function showNewsPage(category)
{
    interFrame = document.getElementById("interactiveFrame");
    interFrame.innerHTML = "&nbsp;";
    
    var str = interFrame.style.width; 
    var x = str.substring(0,str.indexOf("px"));
    str = interFrame.style.height; 
    var y = str.substring(0,str.indexOf("px"));
    var dx = x - x / 35;
    var dy = y - y / 20;
 // var dx=x;
 // var dy=y;
   interFrame.innerHTML = "<iframe id='interactiveFrame_iframe' src='news/index.php?category="+category+"&x=" + dx + "&y=" + dy 
                  + "' frameborder='0' width='" + x + "' height='" + y + "'></iframe>";
 //  showInteractive();
}


function getMouseXY(e) {
	if (IE) { // grab the x-y pos.s if browser is IE
		wstX = event.clientX + document.body.scrollLeft;
		wstY = event.clientY + document.body.scrollTop;
	}
	else {  // grab the x-y pos.s if browser is NS
		wstX = e.pageX;
		wstY = e.pageY;
	}  
	//theInput = document.getElementById("inputBox").value = wstX + " " + wstY;
}

function getClientSize(){
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		clientRectWidth = window.innerWidth;
		clientRectHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		clientRectWidth = document.documentElement.clientWidth;
		clientRectHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		clientRectWidth = document.body.clientWidth;
		clientRectHeight = document.body.clientHeight;
	}
}
