

function popSite(){
	var w = xScreen.getWidth();
	var h = xScreen.getHeight();
	var f = "flashdetect.html";
	if(w > 800){
		xWindow.openCenter(f,"site",800,630);
	}else{
		xWindow.openCenterScroll(f,"site",w,h);
	}
}

function popDownload(id){
	alert("Disabled for this demo");
	//var f = "/mskcc/shared/graphics/AR_2004/"+id;
	//xWindow.openCenterScroll(f,"dl",500,400);
}



//xWindow.openCenter("/virtualtour.php","tourpop",375,400);
//xWindow.openCenterScroll("/supersash.php","ss",650,490);

function popOrder(){
	alert("Disabled for this demo");
	//u = "http://www.mskcc.org/mskcc/html/13836.cfm";
	//xWindow.openCenterScroll(u,"orderwin",460,460);
}

////////////////////
// XSWAP
////////////////////
xSwap = function(name){
	this.name = name;
	this.images = {};
	this.restoresrc = null;
	this.nest = "undefined";
};
xSwap.prototype.add = function(state,src){
	this.images[state] = new Image();
	this.images[state].src = src;
};
xSwap.prototype.swap = function(state){
	var img = this.getImage();
	this.restoresrc = img.src;
	img.src = this.images[state].src;
};
xSwap.prototype.restore = function(){
	if(this.restoresrc){
		this.getImage().src = this.restoresrc;
		this.restoresrc = null;
	}
};
xSwap.prototype.getImage = function(){// Private
	if(document.layers && this.nest == "undefined") this.nest = this.getLayer();
	if(document.layers && this.nest != false){
		return this.nest.document.images[this.name];
	}else{
		return document.images[this.name];
	}
};
xSwap.prototype.getLayer = function(root){// Private
	var i, k, layer, found = false;
	if(!root) root = window;
	for(i = 0; i < root.document.layers.length; i++){
		layer = root.document.layers[i];
		for(k = 0; k < layer.document.images.length; k++){
			if(layer.document.images[k].name == this.name){
				return layer;
			}
		}
		if(layer.document.layers.length) found = this.getLayer(layer);
		if(found) return found;
	}
	return false;
};
////////////////////
// NAVIGATION
////////////////////
// ROLLOVERS
//hom_obj = new xSwap ("hom_btn");
//hom_obj.add ("over","/images/navigation/nav_hom_o.gif");


////////////////////
// xscreen
////////////////////
if(typeof(xScreen) == "undefined") xScreen = {};

xScreen.getWidth = function(){
	return window.screen ? window.screen.availWidth : 0;
};
xScreen.getHeight = function(){
	return window.screen ? window.screen.availHeight : 0;
};



////////////////////
// xwindowopen
////////////////////
// Requires: xscreen.js
if(typeof(xScreen) == "undefined") alert("xScreen Required");

// ||||||||||||||||||||||||||||||||||||||||||||||||||

if(typeof(xWindow) == "undefined") xWindow = {};

xWindow.open = function(url,name,width,height,xpos,ypos,chrome,scroll,fullscreen){
	var x, y, w, h, moveX=0, moveY=0, features="";
	chrome = chrome ? "yes" : "no";
	scroll = scroll ? "yes" : "no";
	features += "toolbar="+chrome;
	features += ",menubar="+chrome;
	features += ",location="+chrome;
	features += ",status="+chrome;
	features += ",scrollbars="+scroll;
	features += ",resizable="+scroll;
	if(width) features += ",width="+width;
	if(height) features += ",height="+height;
	if(fullscreen) features += ",fullscreen=yes";
	if(xpos){
		w = xScreen.getWidth();
		width = parseInt(width);
		switch(xpos){
			case "left": x = 0; break;
			case "center": x = Math.round((w-width)/2); break;
			case "right": x = w-width; break;
			default: x = xpos;
		}
		features += ",screenX="+x+",left="+x;
		var moveX = x;
	}
	if(ypos){
		h = xScreen.getHeight();
		height = parseInt(height);
		switch(ypos){
			case "top": y = 0; break;
			case "middle": y = Math.round((h-height)/2); break;
			case "bottom": y = h-height; break;
			default: y = ypos;
		}
		features += ",screenY="+y+",top="+y;
		var moveY = y;
	}
	xWindowOpenReference = window.open(url,name,features);
	if(moveX || moveY){
		if(xWindowOpenReference != null && !xWindowOpenReference.closed){
			// position the window for browsers that don't recognize screenX, screenY
			xWindowOpenReference.moveTo(moveX,moveY);
		}
	}
};
xWindow.openScroll = function(url,name,width,height){
	this.open(url,name,width,height,false,false,false,"scroll");
};
xWindow.openCenter = function(url,name,width,height){
	this.open(url,name,width,height,"center","middle");
};
xWindow.openCenterScroll = function(url,name,width,height){
	this.open(url,name,width,height,"center","middle",false,"scroll");
};
xWindow.openFull = function(url,name){
	this.open(url,name,xScreen.getWidth(),xScreen.getHeight(),"0","0",false,true);
};
xWindow.openKiosk = function(url,name){
	this.open(url,name,xScreen.getWidth(),xScreen.getHeight(),"0","0",false,false,true);
};




////////////////////
// XBROWSER
////////////////////
xBrowser = function(){
	this.agent = navigator.userAgent.toLowerCase();
	// Platform
	this.mac = this.agent.indexOf("mac")!=-1;
	this.win = this.agent.indexOf("win")!=-1;
	this.win32 = this.win && this.agent.indexOf("16bit")==-1;
	this.unix = this.agent.indexOf("x11")!=-1 || this.agent.indexOf("linux")!=-1;
	// Browser
	this.w3c = document.getElementById ?true:false;
	this.iex = document.all ?true:false;
	this.ie4 = this.iex && !this.w3c;
	this.ie5up = this.iex && this.w3c;
	this.ns4 = document.layers ?true:false;
	this.ns6up = !this.iex && !this.ns4 && this.w3c;
	this.nsx = this.ns4 || this.ns6up;
};
xBrowser.prototype.dump = function(){
	var html = "";
	for(i in this) if(typeof(this[i]) != "function") html += i+" = "+this[i]+"<br>";
	document.write(html);
};
xBrowser = new xBrowser();

