﻿var resolutionWidth;
var resolutionHeight;

var browserWidth;
var browserHeight;

var maxWidth;
var maxHeight;

var resizeWidth;
var resizeHeight;

maxWidth = 1152;
maxHeight = 900;
adjustRatio = 0.2;

resolutionWidth = screen.width;
resolutionHeight = screen.height;

function activateResizer() {
//    setSize();
}

function getSize() {
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		browserWidth = window.innerWidth;
		browserHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		browserWidth = document.documentElement.clientWidth;
		browserHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		browserWidth = document.body.clientWidth;
		browserHeight = document.body.clientHeight;
	}
}

function setSize() {
	getSize();

    window.moveTo(0, 0);

    if(resolutionHeight > maxHeight) {
        resizeWidth = maxWidth;
        resizeHeight = maxHeight;
    } else {
        resizeHeight = resolutionHeight - parseInt((resolutionHeight * adjustRatio));
        resizeWidth = parseInt(resizeHeight * 1.28);
    }
	
    try {
		setInnerWidth(resizeWidth, resizeHeight);

        if (screen.width) {
            window.moveTo((screen.width-resizeWidth) / 2, 0);
        } else {
            window.moveTo(0, 0);
        }
    } catch(Error) {;}

    //window.onresize = cancelEvent; 
    //window.setTimeout(setSize, 500);
}

function cancelEvent() {
	event.cancelBubble;
}

function getResizeWidth() {
	return resizeWidth;
}

function getResizeHeight() {
	return resizeHeight;
}

function reportSize() {
  myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else {
    if( document.documentElement &&
        ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
      //IE 6+ in 'standards compliant mode'
      myWidth = document.documentElement.clientWidth;
      myHeight = document.documentElement.clientHeight;
    } else {
      if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
      }
    }
  }
}

function setInnerWidth(w,h){
	window.resizeTo(400,400);
	reportSize();
	var oX = 400-myWidth;
	var oY = 400-myHeight;
	window.resizeTo( (w+oX) , (h+oY) );
}

