//Prompts setup
function popDialog(divname) {
	$j('#'+divname).dialog("open");
	}
	
function preloadDialogs() {
	$j('#modPwdReset').dialog({ height: 310, width: 510, autoOpen: false, modal: true, position: 'center', selection: 'change', closeOnEscape: true,
		buttons: {
			"Cancel": function() { 
				$j(this).dialog("close");
			},
			"Reset Password": function() {
				if (document.forms['frmPwdReset'].txtUserName.value == '' || document.forms['frmPwdReset'].txtClientID.value == '') {
					popDialog('modMsgRequired');
				} else {
					postForm();
					$j(this).dialog("close"); 
				}
			}
		}
	});
	$j('#modMsgSuccess').dialog({autoOpen: false, modal: true, position: 'center', selection: 'change', closeOnEscape: true,
		buttons: {
			"Close": function() { 
				$j(this).dialog("close"); 
			}
		}
	});
	$j('#modMsgFail').dialog({autoOpen: false, modal: true, position: 'center', selection: 'change', closeOnEscape: true,
		buttons: {
			"Close": function() { 
				$j(this).dialog("close"); 
			}
		}
	});
	$j('#modMsgRequired').dialog({autoOpen: false, modal: true, position: 'center', selection: 'change', closeOnEscape: true,
		buttons: {
			"Close": function() { 
				$j(this).dialog("close"); 
			}
		}
	});
	
}

function postForm() {
//debugger;
	var post_to = "/signinactionsV2.asp"
	//if (document.forms['frmPwdReset'].txtClientID.value == 'nccms') post_to = 'http://cms.thinkgate.net/signin/signinactionsV2.asp'
	//if (document.forms['frmPwdReset'].txtClientID.value == 'nccmstraining') post_to = 'http://cmstraining.thinkgate.net/signin/signinactionsV2.asp'
	//if (document.forms['frmPwdReset'].txtClientID.value == 'nccms') { alert('The password reset for CMS is temporarily relocated. You will be redirected when you click Ok.'); window.open('http://cms.thinkgate.net/display.asp', 'win', 'top=0, left=0, location=no, titlebar=yes, menubar=no, resizable=yes, scrollbars=yes, status=yes, toolbar=no'); return false}
	//if (document.forms['frmPwdReset'].txtClientID.value == 'nccmstraining') { alert('The password reset for CMS is temporarily relocated. You will be redirected when you click Ok.'); window.open('http://cmstraining.thinkgate.net/display.asp', 'win', 'top=0, left=0, location=no, titlebar=yes, menubar=no, resizable=yes, scrollbars=yes, status=yes, toolbar=no'); return false}
	$j.post(post_to, { txtUserName: document.forms['frmPwdReset'].txtUserName.value, txtClientID: document.forms['frmPwdReset'].txtClientID.value, resetReq: document.forms['frmPwdReset'].resetReq.value },  
			function(data){
			//debugger;
				//alert(data);
				if (data=='True'){
					popDialog('modMsgSuccess');
				}
				else
				{
					popDialog('modMsgFail');
				}
			}, "Text");
}
