/******************************************************************
	JAVASCRIPT - WINDOWS
	(c) Copyright 2005 Focus Computers
******************************************************************/

/* Open URL in Modal Window */
function openModalWindow(url, w, h){
	return window.showModalDialog(url,"","dialogHeight: " + h + "px; dialogWidth: " + w + "px; edge: Raised; center: Yes; help: No; resizable: No; status: Yes; scroll: No;");
}

/* Open URL in Modal Window with exact position*/
function openModalWindow(url, w, h, t, l){
	return window.showModalDialog(url,"","dialogHeight: " + h + "px; dialogWidth: " + w + "px; dialogTop: " + t + "; dialogLeft: " + l + "; edge: Raised; center: No; help: No; resizable: No; status: Yes; scroll: No;");
}

/* Open URL and Maximise Window */
function openMax(url){
	try{
		windowHandle = window.open(url,'myWindow',"resizable=yes,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=auto,copyhistory=0,top=0,left=0");
		maximiseWindow(windowHandle);
		if (!windowHandle.opener) windowHandle.opener=self;
		windowHandle.focus();
	} catch(ex){
	}
}

/* New Window */
function newWindow(url,w,h){
	try{
		windowHandle=window.open(url,'','width='+w+',height='+h+',toolbar=yes,location=yes,directories=yes,status=no,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');
		windowHandle.resizeTo(w,h);
		if (!windowHandle.opener) windowHandle.opener=self;
		centerOnScreen(windowHandle,w,h);
		windowHandle.focus();
	} catch(ex){
	}
}

/* New Window with specific position */
function newWindow(url,w,h,t,l){
	try{
		windowHandle=window.open(url,'','width='+w+',height='+h+',top='+t+',left='+l+',toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');
		if (!windowHandle.opener) windowHandle.opener=self;
		windowHandle.focus();
	} catch(ex){
	}
}

/* Open New Window */
function openWindow(url,w,h){
	try{
		l = ((screen.availWidth / 2) - (w / 2));
		t = ((screen.availHeight / 2) - (h / 2));
		windowHandle=window.open(url,"myWindow","resizable=yes,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,copyhistory=0,top=" + t + ",left=" + l + ",width=" + w + ",height=" + h);
		if (!windowHandle.opener) windowHandle.opener=self;
		windowHandle.focus();
	} catch(ex){
	}
}

/* Open Dialog Window */
function openDialog(url,w,h,t,l){
	try{
		windowHandle=window.open(url,"myDialog","resizable=no,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,copyhistory=0,top=" + t + ",left=" + l + ",width=" + w + ",height=" + h);
		if (!windowHandle.opener) windowHandle.opener=self;
		windowHandle.focus();
	} catch(ex){
	}
}

/* Open New Window */
function openWindow(url,w,h,windowName){
	try{
		l = ((screen.availWidth / 2) - (w / 2));
		t = ((screen.availHeight / 2) - (h / 2));
		windowHandle=window.open(url,windowName,"resizable=yes,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,copyhistory=0,top=" + t + ",left=" + l + ",width=" + w + ",height=" + h);
		if (!windowHandle.opener) windowHandle.opener=self;
		windowHandle.focus();
	} catch(ex){
	}
}

/* Center new Window on screen */
function centerOnScreen(winRef,w,h){
	xW = w / 2;
	xH = h / 2;
	w = screen.availWidth / 2;
	h = screen.availHeight / 2;
	winRef.moveTo(w-xW,h-xH);
}

/* Maximise Window */
function maximiseWindow(winRef){
	if (window.screen) {
		winRef.moveTo(-5,-5);
		winRef.resizeTo(screen.availWidth+10,screen.availHeight+10);
	}
}

