var imageHeight=70;
var imageWidth=97;


function GetScreenSize() {
  if (self.screen) {
    screenWidth = screen.width;
    screenHeight = screen.height;
    }
  else if (self.java) {
    dtk = java.awt.Toolkit.getDefaultToolkit();
    ss = dtk.getScreenSize();
    screenWidth = ss.width;
    screenHeight = ss.height;
    }
  else if (self.theBody) {
    screenWidth = theBody.offsetWidth;
    screenHeight = theBody.offsetHeight;
    }
  else {
    screenWidth = 1000;
    screenHeight = 600;
    }
}

function GetWindowSize() {
  if (typeof(window.innerWidth ) == 'number') {
    screenWidth = window.innerWidth;
    screenHeight = window.innerHeight;
    }
  else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
    screenWidth = document.documentElement.clientWidth;
    screenHeight = document.documentElement.clientHeight;
    }
  else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
    screenWidth = document.body.clientWidth;
    screenHeight = document.body.clientHeight;
    }


  else
    GetScreenSize();
}

function setDimensions(HPercent,WPercent) {
GetWindowSize();
//alert(screenWidth+','+screenHeight+' ('+getXY(this)+')');
  if ((HPercent < 100)||(WPercent<100)) {
    screenWidth = Math.round(screenWidth * WPercent / 100);
    screenHeight = Math.round(screenHeight * HPercent / 100);
  }
}






function writeZoomify(url) {
setDimensions(imageHeight,imageWidth);
//url='zoomifyImagePath=Budapest';
var swfPath='http://images.cch.kcl.ac.uk/Assets/s/cfeoZoomify.swf';
var urlString = document.location.href;
var paramIndex = urlString.indexOf("?")+1;
var paramString = urlString.substring(paramIndex,urlString.length);
/*document.writeln("	<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'");
document.writeln("           codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0'");
document.writeln("           width='" + screenWidth + "'");
document.writeln("           height='" + screenHeight + "'");
document.writeln("           id='theMovie'>");
document.writeln("    		<param name='src' value='Assets/s/cfeoZoomify.swf'>");
document.writeln("		<param name='FlashVars' value='" + url + "' >");
document.writeln("		<embed src='Assets/s/cfeoZoomify.swf'");
document.writeln("		   FlashVars='" + url + "'");
document.writeln("           pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'");
document.writeln("           width='" + screenWidth + "'");
document.writeln("           height='" + screenHeight + "'");
document.writeln("           name='theMovie' >");
document.writeln("    	</embed>");
document.writeln("   </object>");*/
document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="theMovie" height="'+screenHeight+'" width="'+screenWidth+'">'+   
 		'<param name="src" value="'+swfPath+'"><param name="allowScriptAccess" value="always" />'+
'<param name="FlashVars" value="'+url+'">'+		
'<embed src="'+swfPath+'"  allowScriptAccess="always" flashvars="'+url+'" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" name="theMovie" height="'+screenHeight+'" width="'+screenWidth+'">');

}


function getXY(self){
    var frameWidth=0;
    var frameHeight=0;
    if (self.innerWidth)
	{
		frameWidth = self.innerWidth;
		frameHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		frameWidth = document.documentElement.clientWidth;
		frameHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		frameWidth = document.body.clientWidth;
		frameHeight = document.body.clientHeight;
	}
	return [frameWidth,frameHeight];
}


function adjustWindow(wname) {
   // alert(wname);
    if (wname){
        var w=window.open('',wname);        
        if (w){
            var flash=null;
                        if(navigator.appName.indexOf("Microsoft") != -1) {
				flash = w.flashObject;
			}
                        if (!flash) {
				flash = w.document.theMovie;
			}
                        if (flash){
                            var Percent=imageHeight;
                            var dim=getXY(flash);                                             
                            var screenHeight = Math.round(w.document.documentElement.clientHeight * Percent / 100);
                            var screenWidth = Math.round(w.document.documentElement.clientWidth * imageWidth / 100);
                            flash.height=screenHeight;
                            flash.width=screenWidth;
                            
                        }
            }     			
    }
}