window.onresize = function() {
  checkForScrollbars();
}
window.onload = function() {
  checkForScrollbars();
  writeShadowPages();
  checkPage();
}

var popup = null;

function flashMovie(movieName) {

    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}

function checkForScrollbars()   {

       var min_width = swf_width;
       var min_height = swf_height;
	   
	   if (forced_width > 0) min_width = forced_width;
	   if (forced_height > 0) min_height = forced_height;

       var width = windowWidth();
       var height = windowHeight();
       
       if (width && height) {
		   
          var new_width = width;
          var new_height = height;
          if (width < min_width) new_width = min_width;
          if (height < min_height) new_height = min_height;

		  
		  
          var flash_object = flashMovie("myFlashContent");
		 
		  if (flash_object) {
			flash_object.width = new_width;
			flash_object.height = new_height;
		  }

       } else {
       
          window.setTimeout("checkForScrollbars()", 1000);
       
       }

}

function windowWidth () {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && document.documentElement.clientWidth ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && document.body.clientWidth ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}

function windowHeight () {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && document.documentElement.clientHeight) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && document.body.clientHeight) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}

function openPopup(url, options) {
	
	if (popup) popup.close();
	popup = null;
	
	if (options == undefined) options = "";
	options = options.replace(/ /g,"");
	
	var my_options = options.split(",");
	var values = new Array();
	for (var i=0; i<my_options.length; i++) {
		var value = my_options[i].split("=");
		values[value[0].toLowerCase()] = value[1];
	}
	
	if (values["width"] == undefined) values["width"] = 400;
	if (values["height"] == undefined) values["height"] = 500;
	if (values["location"] == undefined) values["location"] = "no";
	if (values["menubar"] == undefined) values["menubar"] = "no";
	if (values["resizable"] == undefined) values["resizable"] = "no";
	if (values["scrollbars"] == undefined) values["scrollbars"] = "yes";
	if (values["status"] == undefined) values["status"] = "no";
	if (values["toolbar"] == undefined) values["toolbar"] = "no";
	
	if (values["left"] == undefined && values["screenX"] == undefined) values["left"] = (screen.width-values["width"])/2;
	if (values["top"] == undefined && values["screenY"] == undefined) values["top"] = (screen.height-values["height"])/2;
	
	var new_options = "";
	for (var key in values) {
		new_options += key+"="+values[key]+",";
	}
	new_options = new_options.substr(0, new_options.length-1);
	
	popup = window.open(url, "flashpopup", new_options);
	
}

var forced_width = 0;
var forced_height = 0;

function setDimensions(width, height) {
	
	forced_width = width;
	forced_height = height;
	
	if (width < windowWidth()) width = windowWidth();
	if (height < windowHeight()) height = windowHeight();
	
	var flash_object = flashMovie("myFlashContent");
			
	if (flash_object) {
		if (width && width > 0) flash_object.width = width;
		if (height && height > 0) flash_object.height = height;		
	}	
	
}