/** * Management of IE5+ modal windows created by calling showModalDialog() * * This script will instantiate (create) a new object of type ModalWindow  * named 'modalWindow' which you may use in subsequent calls. * * Usage: * 	<script language="JavaScript" src="modalWindow.js"></script> *  <body onload="modalWindow.onLoadHandler();"> *      <form onsubmit="return modalWindow.onSubmitHandler(this);"> *          <!-- your form goes here --> *      </form> *  </body> * * Copyright (c) 2003 Balder Programvare AS, all rights reserved. * * Parts of the code is probably Copyright (c) Danny Goodman as mentioned in  * the code. */function ModalWindow() {    // this.prop = something;    // Saves cookie from currently loaded document    this.cookie = document.cookie;}/* --------------- instance methods ------------------- *//** * When loading the document body inside the modal window, we give the * window a name and save the current cookie. */ModalWindow.prototype.onLoadHandler = function()  {	// Modal Windows in IE6 does not have a name!	if (!window.name) {		window.name = 'SrPopUp';	}	this.myCookie = document.cookie;	// Save current cookie    this.window = window;	return true;}/** Does nada for now... */ModalWindow.prototype.onUnloadHandler = function() {    return true;}/** Handle submission of forms, ensuring that the name of the currentwindow * corresponds to the 'target' property of the form and ensurer that we have * a valid cookie */ModalWindow.prototype.onSubmitHandler = function(form) {    // alert('Submitting with cookie:' + document.cookie);    if (!form)        throw "onSubmitHandler() :- Missing parameter 'form'";    if (!document.cookie) {        alert('Cookie gone, setting cookie to: ' + this.myCookie);        document.cookie = this.myCookie;    }    if (ModalWindow.isModalWindow()) {    } else {		if (form.target != window.name)			form.target = window.name;	}	return true;}/** * Workaround bug in IE6 modal windows when * performing HTTP GET operations. I.e. pressing a link created by <A> tag * will open up a new window unless you visit the link by issuing a HTTP POST */ModalWindow.prototype.doGetUrl = function (url) {    alert('Entering modalWindow.doGetUrl("' + url + '")');	if (ModalWindow.isModalWindow()) {		form = document.createElement("form");		form.setAttribute("target", window.name);		form.setAttribute("action", url);		form.setAttribute("method","POST");		document.appendChild(form);        alert('Performing http get with url=' + url            + '\nwindow.name=' + window.name            + '\nform.target=' + form.target);		form.submit();	} else		location.href=url;}/* --------------- class methods ------------------- *//** * Converts a URL query string into an array * of name=value pairs.  * * Copyright (c) Danny Goodman * * Usage: * 	getSearchAsArray("bla.jsp?a=b&x=2"); * * returns Array: * 	 [a,b], [x,2] */ModalWindow.getSearchAsArray = function (queryString) {	var results = new Array();	var questionMarkPos = queryString.indexOf("?");	var input = unescape(queryString.substr(questionMarkPos+1));	if (input) {		var srchArray = input.split("&");		var tempArray = new Array();		for (i = 0; i < srchArray.length; i++) {			tempArray = srchArray[i].split("=");			results[tempArray[0]] = tempArray[1];		}	}	return results;}/** * @param widthToUse width in pixels * @param heightToUse height in pixels */ModalWindow.resizeModalWindow = function (widthToUse, heightToUse) {    if (window.dialogWidth) {        // Move the dialogWindow to the center        window.dialogLeft = '5cm'; // This @#!!$#@ does not work!        // Change the width and the height of the dialog        window.dialogWidth = widthToUse + 'px';        window.dialogHeight = heightToUse + 'px';    } else {        window.resizeTo(widthToUse, heightToUse);        window.self.moveTo(100, 100);    }    return true;}    /** Returns whether this window is modal or not */ModalWindow.isModalWindow = function() {	if (window.dialogArguments === undefined)		return false;	else		return true;}// Creates instance of the modalWindow object which may be used in the // document which includes this piece of code.var modalWindow = new ModalWindow();