var isNav = (navigator.appName.indexOf("Netscape") != -1);
var myBrowser = window.name;
var isPrerelease = false;
navigator.storedvariable = "notdefined";

function goBack() {
 //If user has blank page as browser default
 if ((!isNav && history.length == 0) || (isNav && history.length == 1)) {
 document.location = "about:blank"
 } 
 else {history.back(-1);}
 window.blur();
} 

//If user has bookmark the login page then spawn a new window with no menus, toolbars etc....
if (myBrowser != 'WPTFinancialServices') {
 var width = 788, height = 520;
 if (isNav) {wid = screen.availWidth; hei = screen.availHeight;}
 else {wid = screen.width; hei = screen.height;}
 var top = ((hei - height ) / 2) - 60, left = ((wid - width ) / 2) - 10;
 top = (top < 1) ? 1 : top;
 var aURL = document.location + ' ';
 var aQSLoc = aURL.indexOf ("?");
 var aQueryString = (aQSLoc >-1 ) ? aURL.substring (aQSLoc, aURL.length -1) : "" ;
 
 //Span the new window - force 800x600 for Netscape users
 if (isNav) {aWindow = window.open('../../asp/common/cor_log_in.asp' + aQueryString,'WPTFinancialServices','width=' + width + ',height=' + height + ',toolbar=no,status=yes,scrollbars=yes,resizable=no,menubar=no,top=' + top + ',left=' + left);}
 else {aWindow = window.open('../../asp/common/cor_log_in.asp' + aQueryString,'WPTFinancialServices','width=' + width + ',height=' + height + ',toolbar=no,status=yes,scrollbars=yes,resizable=yes,menubar=no,top=' + top + ',left=' + left);}

 //If IE, navigate current window to previous page
 if (!isNav) {goBack();}
}

//Insert correct stylesheet
if (!isNav) {document.write('<link rel="stylesheet" href="../../css/common/IEstyles.css" type="text/css">');}
else {document.write('<link rel="stylesheet" href="../../css/common/NSstyles.css" type="text/css">');}

//Status bar messages
function showStatus (statusMsg){
 if (statusMsg == "WP") {statusMsg = " ";}
 window.status = statusMsg; return true;
}

//For error message displays
function showAlert (icon, title, msg, buttons, buttonFlag, yesHref, noHref) {
 document.write ('<table border="0" cellspacing="0" cellpadding="0">');
 document.write (' <tr><td valign="middle" class="bevelError1" align="center">');
 document.write (' <table border="0" cellspacing="15" cellpadding="0">');
 document.write (' <tr><td><img src="../../images/Common/icon_error_' + icon + '.gif" border="0" align="absmiddle"></td></tr>');
 document.write (' </table>');
 document.write (' </td>');
 document.write (' <td class="bevelError2"> ');
 document.write (' <table width="470" border="0" cellspacing="10" cellpadding="0">');
 document.write (' <tr><td><span class="errormsgbold">' + title + '</span><br><span class="errormsg">' + msg + '</span></td>');
 if (buttons == 'yes') {
 document.write (' <td valign="bottom" align="right"> ');
 document.write (' <table border="0" cellspacing="0" cellpadding="0" height="11">');
 document.write (' <tr> ');
 switch (buttonFlag) {
 case "close": document.write (' <td class="buttonbg" height="13"><a onMouseOver=" showStatus(\'Close Window\');return true;" onMouseOut=" showStatus(\'WP\');return true;" onFocus="if(this.blur)this.blur()" href="javascript:window.close();" class="button0">&nbsp;&nbsp;CLOSE&nbsp;&nbsp;</a></td>');break;
 case "ok": document.write (' <td class="buttonbg" height="13"><a onMouseOver=" showStatus(\'OK\');return true;" onMouseOut=" showStatus(\'WP\');return true;" onFocus="if(this.blur)this.blur()" href="' + yesHref +'" class="button0">&nbsp;&nbsp;OK&nbsp;&nbsp;</a></td>');break;
 case "yes": document.write (' <td class="buttonbg" height="13"><a onMouseOver=" showStatus(\'Yes\');return true;" onMouseOut=" showStatus(\'WP\');return true;" onFocus="if(this.blur)this.blur()" href="' + yesHref +'" class="button0">&nbsp;&nbsp;YES&nbsp;&nbsp;</a></td>');document.write ('<td height="13"><img src="../../images/common/1x1.gif" width="4" height="13" border="0"></td>');document.write ('<td class="buttonbg" height="13"><a onMouseOver=" showStatus(\'No\');return true;" onMouseOut=" showStatus(\'WP\');return true;" onFocus="if(this.blur)this.blur()" href="' + noHref +'" class="button0">&nbsp;&nbsp;NO&nbsp;&nbsp;</a></td>');break;
 case "back": document.write (' <td class="buttonbg" height="13"><a onMouseOver=" showStatus(\'Back\');return true;" onMouseOut=" showStatus(\'WP\');return true;" onFocus="if(this.blur)this.blur()" href="' + yesHref +'" class="button0">&nbsp;&nbsp;BACK&nbsp;&nbsp;</a></td>');break;
 default:
 }
 document.write (' </tr>');
 document.write (' </table>');
 document.write (' </td>');
 }
 document.write (' </tr>');
 document.write (' </table>');
 document.write (' </td>');
 document.write (' </tr>');
 document.write ('</table>');
}

//Key press events
function netscapeKeyPress(e) {if (e.which == 13) {submitForm();}}
function microsoftKeyPress() {if (window.event.keyCode == 13) {submitForm();}}
if (isNav) {window.captureEvents(Event.KEYPRESS); window.onKeyPress = netscapeKeyPress;}

//Set focus to first form element
function setFocus() {document.forms[0].elements[1].focus();}

//Submit the form
function submitForm() {document.form.action='cor_log_in.asp?Action=Submit'; document.form.submit();}

//Redirect users to correct home and register URL's
if ((document.URL.indexOf("prerelease.", 1) + document.URL.indexOf("uat.", 1)) != -2) {isPrerelease = true;}
function goHomeURL() {
 if (isPrerelease) {document.location = "http://www.prerelease.assirtplanningsoftware.com.au";}
 else {document.location = "http://www.assirtplanningsoftware.com.au/";}
}
function goRegisterURL() {
 if (isPrerelease) {document.location = "http://www.prerelease.assirtplanningsoftware.com.au/cor_member_registration.asp";}
 else {document.location = "http://www.assirtplanningsoftware.com.au/cor_member_registration.asp";}
}
function popUp(url){
sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=720,height=450');
self.name="mainWin";}