function customise() {
	document.location.href='DesktopServlet?action=edit&provider=rheCustomisePortal';
}

function closeWindow() {
	window.close()
}
function printWindow() {
	window.print()
}
function focusWindow() {
	window.focus()
}


/**/
function launchWithRewriteToolbars(URL, width, height, windowName) {
	launchNoRewriteToolbars(URL, width, height, windowName)
}

function launchNoRewriteToolbars(URL, width, height, windowName) {
	var addFeatures = 'toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizeable=1';
	new popupWindow(windowName, width, height, addFeatures).launch(URL);
}
/**/
function launchWithRewrite(URL, width, height, windowName, addFeatures) {
	launchNoRewrite(URL, width, height, windowName, addFeatures);
}

function launchNoRewrite(URL, width, height, windowName, addFeatures) {
	new popupWindow(windowName, width, height, addFeatures).launch(URL);
}
/**/
function launchRemote(URL, width, height, windowName, addFeatures) {
	if(URL.indexOf('/zportal/cs/')==0) URL='http://www.zurich.com.au'+URL;
	launchRemoteNoRewrite(URL, width, height, windowName, addFeatures)
}

function launchRemoteNoRewrite(URL, width, height, windowName, addFeatures) {
	new popupWindow(windowName, width, height, addFeatures).launch(URL);
}
/**/
function launch(URL,windowName,addFeatures) {
	return launchPopup(URL,windowName,addFeatures)
}

function launchPopup(URL,windowName,addFeatures) {
	return new popupWindow(windowName, null, null, addFeatures).launch(URL);
}
/**/
function popupWindow(windowName, width, height, addFeatures) {
	this.setWindowName = function (windowName) {if (windowName) {this.windowName = windowName;}}
	this.setWidth = function (width) {
		if (width) {
			if (width>screen.availWidth) width = screen.availWidth;
			this.features.width = width;
			this.setDftLeft()
		}
	}
	this.setHeight = function (height) {
		if (height) {
			if (height>screen.availHeight - 28) height = screen.availHeight - 28;
			this.features.height = height;
			this.setDftTop()
		}
	}
	this.setFeatures = function (addFeatures) {if (addFeatures) {this.addFeatures = addFeatures;}}
	this.setLeft = function(left) {this.features.left = left;this.features.screenX = left}
	this.setTop = function(top) {this.features.top = top;this.features.screenY = top}	

	this.windowName = (windowName)?windowName:"_blank";
	this.features = new Array();
	this.features.width = (width)?width:780;
	this.features.height = (height)?height:550;
	this.features.scrollbars = 1;
	this.features.resizable = 1;
	this.features.channelmode=0;
	this.features.dependent=0;
	this.features.directories=0;
	this.features.fullscreen=0;
	this.features["location"]=0;
	this.features.menubar=0;
	this.features.status=1;
	this.features.toolbar=0;
			
//- SetWindow to be Centred
	this.setDftLeft = function () {
		var dftLeft = (screen.availWidth - this.features.width) / 2;
		if (dftLeft<0) dftLeft=0;
		this.setLeft(dftLeft);
	}
	this.setDftLeft();
	
	this.setDftTop = function () {
		var dftTop  = (screen.availHeight - this.features.height - 28) / 2;
		if (dftTop<0) {dftTop=0;}
		this.setTop(dftTop);
	}
	this.setDftTop();
	this.addFeatures = addFeatures

	this.launch = function (URL) {
		this.URL = (URL)?URL:"";
		var features = "";
		for (feature in this.features) {features += feature + "=" + this.features[feature] + ",";}
		if (this.addFeatures) features += this.addFeatures;
		var remote = open(this.URL, this.windowName, features);
		remote.focus()
		if (remote.opener == null)remote.opener = window;
		this.remote=remote;
		return remote;
	}
}
