function UserLogout(){
var hn = window.location.hostname; 
$.cookie('uAdmin', 'False', { expires: 365, path: '/', domain: hn });
window.location="default.asp"; 
}
function UserLogin(gl, cn, cw){
var LOG = $("#txtLGN").val();
var PASS = $("#txtPASS").val();
var username = $('#txtLGN').attr("value");
var password = $('#txtPASS').attr("value");
var remb = $('#remember').attr('checked');
var hn = window.location.hostname; 
$.post("../gfeShared/gfeSCR/gfeDBUtilities.asp",	{ action: 'chkUser', Login: LOG, Password: PASS },
  	function(data){
		if(data=="GUEST"){
			if(gl=="True"){
			//$("#gfeMenu").load("../gfeShared/gfeSCR/gfeMenu.asp");
 			$("#gfeMenu").load("../gfeShared/gfeSCR/gfeMenu.asp", {CoN: cn, CoW: cw});
			$("#gfeMain").text("GFE GUEST Request Form");
			$("#lgnMNU").text("Welcome Guest");
			$.cookie('uGuest', 'True', { expires: 365, path: '/', domain: hn });
			$("#gfeHome").load("../gfeShared/gfeSCR/gfeGFE.asp", {l: "NONE"});
			$.cookie('uAdmin', 'False', { expires: 365, path: '/', domain: hn });
			$("#colorPick").hide();
			}else{
			alert("Invalid Login\n\nGuest logins are not allowed. Please contact " + $.cookie('CompanyContact') + " at " + $.cookie('CompanyContactPhone') + " to establish a login in the proGFE system.");	  
	  
			}
		}else if(data=="Invalid email or password"){
			alert("Invalid Password, Please try again!");
			window.location = "default.asp";
			$.cookie('uAdmin', 'False', { expires: 365, path: '/', domain: hn });
			$.cookie('uGuest', 'True', { expires: 365, path: '/', domain: hn });
			
		}else{
			$.cookie('uGuest', 'False', { expires: 365, path: '/', domain: hn });
			var mySplitResult = data.split("|");
			$("#gfeHome").load("../gfeShared/gfeSCR/gfeGFE.asp", {
							   l: mySplitResult[0],
							   uName: mySplitResult[2],
							   uEmail: mySplitResult[3],
							   uPhone: mySplitResult[4],
							   uAdmin: mySplitResult[5],
							   uCoName: mySplitResult[6],
							   uCompanyName: mySplitResult[7],
							   uCompanyWebsite: mySplitResult[8]
							   });
			$("#gfeMain").text("GFE Request Form");
			$("#lgnMNU").text("Welcome To ProGFE ( " + mySplitResult[2] + " )");
			$.cookie('uAdmin', mySplitResult[5], { expires: 365, path: '/', domain: hn });
			//$("#gfeMenu").load("../gfeShared/gfeSCR/gfeMenu.asp");
			//alert("CoN: "+ cn & " - CoW: "+ cw);
 			$("#gfeMenu").load("../gfeShared/gfeSCR/gfeMenu.asp", {CoN: cn, CoW: cw});
			$("#colorPick").hide();

			if (remb){
				$.cookie('username', username, { expires: 365, path: '/', domain: hn });
				$.cookie('UserCompanyName', mySplitResult[7], { expires: 365, path: '/', domain: hn });
				$.cookie('CompanyWebsite', mySplitResult[8], { expires: 365, path: '/', domain: hn });
				$.cookie('password', password, { expires: 365, path: '/', domain: hn });
				$.cookie('remember', true, { expires: 365, path: '/', domain: hn });
			} else {
				$.cookie('username', null, { path: '/', domain: hn });
				$.cookie('password', null, { path: '/', domain: hn });
				$.cookie('remember', null, { path: '/', domain: hn });
			}
		}
  	}
);
}
function IsItRe(){
if($(".group2:checked").val()=== undefined){
	alert("None Selected");
}else{
	alert($(".group2:checked").val());
}
}
function popFields(){
if ( $.cookie('GFEPro_selPURCREFI') == 'selPUR' ) {
	$("#selPUR").attr("checked", "checked"); 
	
$("#txtSalePrice").val("").removeAttr("readonly"); 
$("#lblSalePrice").css("color","black");
$("#myPUR").show();
$("#ddPages").show();
//$("#docPages").show();	
	
	
}else if( $.cookie('GFEPro_selPURCREFI') == 'selREF' ) {
	$("#selREF").attr("checked", "checked"); 
	
	
$("#txtSalePrice").val("0.00");
$("#txtSalePrice").attr("readonly", true);
$("#lblSalePrice").css("color","gray");
$("#myPUR").hide();
$("#ddPages").hide();
//$("#docPages").show();
	
	
}else if( $.cookie('GFEPro_selPURCREFI') == 'selEQY' ) {
	$("#selEQY").attr("checked", "checked"); 
	
$("#txtSalePrice").val("0.00");
$("#txtSalePrice").attr("readonly", true);
$("#lblSalePrice").css("color","gray");
$("#myPUR").hide();
$("#ddPages").hide();
//$("#docPages").show();	
	
	
}else{
	$("#myPUR").hide();
}
$("#txtPropertyState").selectOptions($.cookie('GFEPro_txtPropertyState'));
TestPopulate();
if($.cookie('GFEPro_txtSenderName') !== null){
$('#txtSenderName').attr("value", $.cookie('GFEPro_txtSenderName'));
}
if($.cookie('GFEPro_txtSenderEmail') !== null){
$('#txtSenderEmail').attr("value", $.cookie('GFEPro_txtSenderEmail'));
}
if($.cookie('GFEPro_txtSenderPhone') !== null){
$('#txtSenderPhone').attr("value", $.cookie('GFEPro_txtSenderPhone'));
}
if($.cookie('GFEPro_txtPropertyAddress') !== null){
$('#txtPropertyAddress').attr("value", $.cookie('GFEPro_txtPropertyAddress'));
}
if($.cookie('GFEPro_txtPropertyCity') !== null){
$('#txtPropertyCity').attr("value", $.cookie('GFEPro_txtPropertyCity'));
}
if($.cookie('GFEPro_txtPropertyState') !== null){
$("#txtPropertyState").selectOptions($.cookie('GFEPro_txtPropertyState'));
}
if($.cookie('GFEPro_txtPropertyZip') !== null){
$('#txtPropertyZip').attr("value", $.cookie('GFEPro_txtPropertyZip'));
}
if($.cookie('GFEPro_txtPropertyCounty') !== null){
$('#txtPropertyCounty').attr("value", $.cookie('GFEPro_txtPropertyCounty'));
}
if($.cookie('GFEPro_txtLoanAmount') !== null){
$('#txtLoanAmount').attr("value", $.cookie('GFEPro_txtLoanAmount'));
}
if($.cookie('GFEPro_txtSalePrice') !== null){
$('#txtSalePrice').attr("value", $.cookie('GFEPro_txtSalePrice'));
}
if($.cookie('GFEPro_txtTemplate') !== null){
$("#txtTemplate").selectOptions($.cookie('GFEPro_txtTemplate'));
}
if($.cookie('GFEPro_txtPPType') !== null){
$("#txtPPType").selectOptions($.cookie('GFEPro_txtPPType'));
}
if($.cookie('GFEPro_txtReCoverage') !== null){
$('#txtReCoverage').attr("value", $.cookie('GFEPro_txtReCoverage'));
}
if($.cookie('GFEPro_txtPPDate') !== null){
$('#txtPPDate').attr("value", $.cookie('GFEPro_txtPPDate'));
}
if($.cookie('GFEPro_txtDeedPages') !== null){
$('#txtDeedPages').attr("value", $.cookie('GFEPro_txtDeedPages'));
}
if($.cookie('GFEPro_txtMortPages') !== null){
$('#txtMortPages').attr("value", $.cookie('GFEPro_txtMortPages'));
}
if($.cookie('GFEPro_DOT1201') !== null){
$('#DOT1201').attr("value", $.cookie('GFEPro_DOT1201'));}
if($.cookie('GFEPro_M1OT1201') !== null){
$('#M1OT1201').attr("value", $.cookie('GFEPro_M1OT1201'));}
if($.cookie('GFEPro_R1BYRPG1201') !== null){
$('#R1BYRPG1201').attr("value", $.cookie('GFEPro_R1BYRPG1201'));}
if($.cookie('GFEPro_R1BYROT1201') !== null){
$('#R1BYROT1201').attr("value", $.cookie('GFEPro_R1BYROT1201'));}
if($.cookie('GFEPro_R2BYRPG1201') !== null){
$('#R2BYRPG1201').attr("value", $.cookie('GFEPro_R2BYRPG1201'));}
if($.cookie('GFEPro_R2BYROT1201') !== null){
$('#R2BYROT1201').attr("value", $.cookie('GFEPro_R2BYROT1201'));}

if($.cookie('GFEPro_txtLendNumber') !== null){
$('#txtLendNumber').attr("value", $.cookie('GFEPro_txtLendNumber'));
}
if ( $.cookie('GFEPro_IsReissue') == 'IsReY' ) {
	$("#IsReY").attr("checked", "checked"); 
	$("#myReissue").show(); 
}else{
	$("#IsReN").attr("checked", "checked"); 
	$("#myReissue").hide(); 
}
popRecording()
}
function myDefaults(){
var hn = window.location.hostname;
$.cookie('myGFEPro_txtSenderName', $('#txtSenderName').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('myGFEPro_txtSenderEmail', $('#txtSenderEmail').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('myGFEPro_txtSenderPhone', $('#txtSenderPhone').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('myGFEPro_txtPropertyAddress', $('#txtPropertyAddress').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('myGFEPro_txtPropertyCity', $('#txtPropertyCity').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('myGFEPro_txtPropertyState', $('#txtPropertyState').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('myGFEPro_txtPropertyZip', $('#txtPropertyZip').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('myGFEPro_txtPropertyCounty', $('#txtPropertyCounty').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('myGFEPro_txtLoanAmount', $('#txtLoanAmount').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('myGFEPro_txtSalePrice', $('#txtSalePrice').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('myGFEPro_txtTemplate', $('#txtTemplate').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('myGFEPro_txtPPType', $('#txtPPType').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('myGFEPro_txtReCoverage', $('#txtReCoverage').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('myGFEPro_txtPPDate', $('#txtPPDate').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('myGFEPro_txtDeedPages', $('#txtDeedPages').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('myGFEPro_txtMortPages', $('#txtMortPages').attr("value"), { expires: 365, path: '/', domain: hn });

	$.cookie('myGFEPro_DOT1201', $('#DOT1201').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('myGFEPro_M1OT1201', $('#M1OT1201').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('myGFEPro_R1BYRPG1201', $('#R1BYRPG1201').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('myGFEPro_R1BYROT1201', $('#R1BYROT1201').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('myGFEPro_R2BYRPG1201', $('#R2BYRPG1201').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('myGFEPro_R2BYROT1201', $('#R2BYROT1201').attr("value"), { expires: 365, path: '/', domain: hn });

	$.cookie('myGFEPro_txtLendNumber', $('#txtLendNumber').attr("value"), { expires: 365, path: '/', domain: hn });
	if ($('#selPUR').attr('checked')) {
		$.cookie('myGFEPro_selPURCREFI', "selPUR", { expires: 365, path: '/', domain: hn });}
	if ($('#selREF').attr('checked')) {
		$.cookie('myGFEPro_selPURCREFI', "selREF", { expires: 365, path: '/', domain: hn });}
	if ($('#selEQY').attr('checked')) {
		$.cookie('myGFEPro_selPURCREFI', "selEQY", { expires: 365, path: '/', domain: hn });}
	if ($('#IsReY').attr('checked')) {
		$.cookie('myGFEPro_IsReissue', "IsReY", { expires: 365, path: '/', domain: hn });}
	if ($('#IsReN').attr('checked')) {
		$.cookie('myGFEPro_IsReissue', "IsReN", { expires: 365, path: '/', domain: hn });}
alert("Defaults Saved!  In the future, use the Load My Defaults menu option to populate fields with your set defaults. ");
}
function myDefaultsRestore(){
if($.cookie('myGFEPro_txtSenderName') !== null){
$('#txtSenderName').attr("value", $.cookie('myGFEPro_txtSenderName'));}
if($.cookie('myGFEPro_txtSenderEmail') !== null){
$('#txtSenderEmail').attr("value", $.cookie('myGFEPro_txtSenderEmail'));}
if($.cookie('myGFEPro_txtSenderPhone') !== null){
$('#txtSenderPhone').attr("value", $.cookie('myGFEPro_txtSenderPhone'));}
if($.cookie('myGFEPro_txtPropertyAddress') !== null){
$('#txtPropertyAddress').attr("value", $.cookie('myGFEPro_txtPropertyAddress'));}
if($.cookie('myGFEPro_txtPropertyCity') !== null){
$('#txtPropertyCity').attr("value", $.cookie('myGFEPro_txtPropertyCity'));}
if($.cookie('myGFEPro_txtPropertyState') !== null){
$("#txtPropertyState").selectOptions($.cookie('myGFEPro_txtPropertyState'));}
if($.cookie('myGFEPro_txtPropertyZip') !== null){
$('#txtPropertyZip').attr("value", $.cookie('myGFEPro_txtPropertyZip'));}
if($.cookie('myGFEPro_txtPropertyCounty') !== null){
$('#txtPropertyCounty').attr("value", $.cookie('myGFEPro_txtPropertyCounty'));}
if($.cookie('myGFEPro_txtLoanAmount') !== null){
$('#txtLoanAmount').attr("value", $.cookie('myGFEPro_txtLoanAmount'));}
if($.cookie('myGFEPro_txtSalePrice') !== null){
$('#txtSalePrice').attr("value", $.cookie('myGFEPro_txtSalePrice'));}
if($.cookie('myGFEPro_txtTemplate') !== null){
$("#txtTemplate").selectOptions($.cookie('myGFEPro_txtTemplate'));}
if($.cookie('myGFEPro_txtPPType') !== null){
$("#txtPPType").selectOptions($.cookie('myGFEPro_txtPPType'));}
if($.cookie('myGFEPro_txtReCoverage') !== null){
$('#txtReCoverage').attr("value", $.cookie('myGFEPro_txtReCoverage'));}
if($.cookie('myGFEPro_txtPPDate') !== null){
$('#txtPPDate').attr("value", $.cookie('myGFEPro_txtPPDate'));}
if($.cookie('myGFEPro_txtDeedPages') !== null){
$('#txtDeedPages').attr("value", $.cookie('myGFEPro_txtDeedPages'));}
if($.cookie('myGFEPro_txtMortPages') !== null){
$('#txtMortPages').attr("value", $.cookie('myGFEPro_txtMortPages'));}

if($.cookie('myGFEPro_DOT1201') !== null){
$('#DOT1201').attr("value", $.cookie('myGFEPro_DOT1201'));}
if($.cookie('myGFEPro_M1OT1201') !== null){
$('#M1OT1201').attr("value", $.cookie('myGFEPro_M1OT1201'));}
if($.cookie('myGFEPro_R1BYRPG1201') !== null){
$('#R1BYRPG1201').attr("value", $.cookie('myGFEPro_R1BYRPG1201'));}
if($.cookie('myGFEPro_R1BYROT1201') !== null){
$('#R1BYROT1201').attr("value", $.cookie('myGFEPro_R1BYROT1201'));}
if($.cookie('myGFEPro_R2BYRPG1201') !== null){
$('#R2BYRPG1201').attr("value", $.cookie('myGFEPro_R2BYRPG1201'));}
if($.cookie('myGFEPro_R2BYROT1201') !== null){
$('#R2BYROT1201').attr("value", $.cookie('myGFEPro_R2BYROT1201'));}


if($.cookie('myGFEPro_txtLendNumber') !== null){
$('#txtLendNumber').attr("value", $.cookie('myGFEPro_txtLendNumber'));}
if ( $.cookie('myGFEPro_selPURCREFI') == 'selPUR' ) {
	$("#selPUR").attr("checked", "checked"); 
	$("#myPUR").show();
}else if ( $.cookie('myGFEPro_selPURCREFI') == 'selREF' ) {
	$("#selREF").attr("checked", "checked"); 
	$("#myPUR").hide();
}else if ( $.cookie('myGFEPro_selPURCREFI') == 'selEQY' ) {
	$("#selEQY").attr("checked", "checked"); 
	$("#myPUR").hide();
}else{
	$("#selREF").attr("checked", "checked"); 
	$("#myPUR").hide();
}
if ( $.cookie('myGFEPro_IsReissue') == 'IsReY' ) {
	$("#IsReY").attr("checked", "checked"); 
	$("#myReissue").show(); 
}else{
	$("#IsReN").attr("checked", "checked"); 
	$("#myReissue").hide(); 
}
popRecording()
}
function isReTrue(){
$("#myReissue").show();
}
function isReFalse(){
$("#myReissue").hide();
}
function checkEmail() {
var email = document.getElementById('txtSenderEmail');
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(email.value)) {
	alert('Please provide a valid email address');
	email.focus;
	return false;
}
}
function ValidateMe(){
// Reset Colors
$("#valError").hide();
$("#lblSenderName").css("background-color","");
$("#lblSenderEmail").css("background-color","");
$("#lblSenderPhone").css("background-color","");
$("#lblPropertyAddress").css("background-color","");
$("#lblPropertyCity").css("background-color","");
$("#lblPropertyCounty").css("background-color","");
$("#lblSalePrice").css("background-color","");
$("#lblLoanAmount").css("background-color","");
$("#lblPPDate").css("background-color","");
$("#lblReCoverage").css("background-color","");	


var hn = window.location.hostname;
if(($("#txtTemplate").val()=="") || ($("#txtTemplate").val()===null)){
alert("System Setup Error\n\nA default template has not been set for the state and order type combination that you have specified. This request CANNOT be completed!\n\nPlease contact " + $.cookie('CompanyContact') + " at " + $.cookie('CompanyContactPhone') + " or your ProGFE administrator to report this problem.");	  
}else{
	
	
var prob = "False";

if($("#txtSenderName").val()==""){
	var prob = "True";
	$("#lblSenderName").css("background-color","#FFFF9D");						
}
if($("#txtSenderEmail").val()==""){
	var prob = "True";
	$("#lblSenderEmail").css("background-color","#FFFF9D");						
}
if($("#txtSenderPhone").val()==""){
	var prob = "True";
	$("#lblSenderPhone").css("background-color","#FFFF9D");						
}
if($("#txtPropertyAddress").val()==""){
	var prob = "True";
	$("#lblPropertyAddress").css("background-color","#FFFF9D");						
}
if($("#txtPropertyCity").val()==""){
	var prob = "True";
	$("#lblPropertyCity").css("background-color","#FFFF9D");						
}
if($("#txtPropertyState").val()==""){
	var prob = "True";
	$("#lblPropertyCity").css("background-color","#FFFF9D");						
}
if($("#txtPropertyZip").val()==""){
	var prob = "True";
	$("#lblPropertyCity").css("background-color","#FFFF9D");						
}
if($("#txtPropertyCounty").val()==""){
	var prob = "True";
	$("#lblPropertyCounty").css("background-color","#FFFF9D");						
}

if($(".group1:checked").val() == "Purchase"){	
	if(($("#txtSalePrice").val()=="")||($("#txtSalePrice").val()==null)||($("#txtSalePrice").val()=="0.00")){
		var prob = "True";
		$("#lblSalePrice").css("background-color","#FFFF9D");						
	}
}
if($(".group1:checked").val() == "Refinance"){	
	if(($("#txtLoanAmount").val()=="")||($("#txtLoanAmount").val()==null)||($("#txtLoanAmount").val()=="0.00")){
		var prob = "True";
		$("#lblLoanAmount").css("background-color","#FFFF9D");						
	}
}
if($(".group1:checked").val() == "Equity"){	
	if(($("#txtLoanAmount").val()=="")||($("#txtLoanAmount").val()==null)||($("#txtLoanAmount").val()=="0.00")){
		var prob = "True";
		$("#lblLoanAmount").css("background-color","#FFFF9D");						
	}
}
if($(".group2:checked").val() == "True"){
	if(($("#txtPPDate").val()=="")||($("#txtPPDate").val()==null)){
		var prob = "True";
		$("#lblPPDate").css("background-color","#FFFF9D");
	}
}
if($(".group2:checked").val() == "True"){
	if(($("#txtReCoverage").val()=="")||($("#txtReCoverage").val()==null)||($("#txtReCoverage").val()=="0.00")){
		var prob = "True";
		$("#lblReCoverage").css("background-color","#FFFF9D");
	}
}

if(prob=="True"){	
$("#valError").show();
}else{
	
$("#valError").hide();

	if($.cookie('uGuest')=='False'){
			$.cookie('GFEPro_txtSenderName', $('#txtSenderName').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('GFEPro_txtSenderEmail', $('#txtSenderEmail').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('GFEPro_txtSenderPhone', $('#txtSenderPhone').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('GFEPro_txtPropertyAddress', $('#txtPropertyAddress').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('GFEPro_txtPropertyCity', $('#txtPropertyCity').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('GFEPro_txtPropertyState', $('#txtPropertyState').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('GFEPro_txtPropertyZip', $('#txtPropertyZip').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('GFEPro_txtPropertyCounty', $('#txtPropertyCounty').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('GFEPro_txtLoanAmount', $('#txtLoanAmount').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('GFEPro_txtSalePrice', $('#txtSalePrice').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('GFEPro_txtTemplate', $('#txtTemplate').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('GFEPro_txtPPType', $('#txtPPType').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('GFEPro_txtReCoverage', $('#txtReCoverage').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('GFEPro_txtPPDate', $('#txtPPDate').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('GFEPro_txtDeedPages', $('#txtDeedPages').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('GFEPro_txtMortPages', $('#txtMortPages').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('GFEPro_DOT1201', $('#DOT1201').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('GFEPro_M1OT1201', $('#M1OT1201').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('GFEPro_R1BYRPG1201', $('#R1BYRPG1201').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('GFEPro_R1BYROT1201', $('#R1BYROT1201').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('GFEPro_R2BYRPG1201', $('#R2BYRPG1201').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('GFEPro_R2BYROT1201', $('#R2BYROT1201').attr("value"), { expires: 365, path: '/', domain: hn });
	$.cookie('GFEPro_txtLendNumber', $('#txtLendNumber').attr("value"), { expires: 365, path: '/', domain: hn });
	if ($('#selPUR').attr('checked')) {
		$.cookie('GFEPro_selPURCREFI', "selPUR", { expires: 365, path: '/', domain: hn });}
	if ($('#selREF').attr('checked')) {
		$.cookie('GFEPro_selPURCREFI', "selREF", { expires: 365, path: '/', domain: hn });}
	if ($('#IsReY').attr('checked')) {
		$.cookie('GFEPro_IsReissue', "IsReY", { expires: 365, path: '/', domain: hn });}
	if ($('#IsReN').attr('checked')) {
		$.cookie('GFEPro_IsReissue', "IsReN", { expires: 365, path: '/', domain: hn });}
	}else{
			$.cookie('GFEPro_txtSenderName', null, { path: '/', domain: hn });
			$.cookie('GFEPro_txtSenderEmail', null, { path: '/', domain: hn });
			$.cookie('GFEPro_txtSenderPhone', null, { path: '/', domain: hn });
			$.cookie('GFEPro_txtPropertyAddress', null, { path: '/', domain: hn });
			$.cookie('GFEPro_txtPropertyCity', null, { path: '/', domain: hn });
			$.cookie('GFEPro_txtPropertyState', null, { path: '/', domain: hn });
			$.cookie('GFEPro_txtPropertyZip', null, { path: '/', domain: hn });
			$.cookie('GFEPro_txtPropertyCounty', null, { path: '/', domain: hn });
			$.cookie('GFEPro_txtLoanAmount', null, { path: '/', domain: hn });
			$.cookie('GFEPro_txtSalePrice', null, { path: '/', domain: hn });
			$.cookie('GFEPro_txtTemplate', null, { path: '/', domain: hn });
			$.cookie('GFEPro_txtPPType', null, { path: '/', domain: hn });
			$.cookie('GFEPro_txtReCoverage', null, { path: '/', domain: hn });
			$.cookie('GFEPro_txtPPDate', null, { path: '/', domain: hn });
			$.cookie('GFEPro_txtDeedPages', null, { path: '/', domain: hn });
			$.cookie('GFEPro_txtMortPages', null, { path: '/', domain: hn });
			$.cookie('GFEPro_DOT1201', null, { path: '/', domain: hn });
			$.cookie('GFEPro_M1OT1201', null, { path: '/', domain: hn });
			$.cookie('GFEPro_R1BYRPG1201', null, { path: '/', domain: hn });
			$.cookie('GFEPro_R1BYROT1201', null, { path: '/', domain: hn });
			$.cookie('GFEPro_R2BYRPG1201', null, { path: '/', domain: hn });
			$.cookie('GFEPro_R2BYROT1201', null, { path: '/', domain: hn });
			$.cookie('GFEPro_txtLendNumber', null, { path: '/', domain: hn });
	} //end save cookies if not a guest

$("#valBODY").hide();
$("#valWait").show();
PREorderGFE();
	
	
}//end of no validation errors found
}//end of template if
}//end of validation	



function PREorderGFE(){
$.post("../gfeShared/gfeSCR/gfeDBUtilities.asp", { action: "getHeadFoot" },
  function(data){
	var a = data;
	var b = a.split("|");
	PREorderGFE2(b[0], b[1], b[2], b[3]);	
   });
}
function PREorderGFE2(mHead, mFoot, sA, sPoll){
$.post("../gfeShared/gfeSCR/gfeDBUtilities.asp", { action: "getOcList", mdl: $('#txtTemplate option:selected').text(), Recs: $("#OCArray").val() },
	function(data){
		var ocA = data;
		PREorderGFE3(mHead, mFoot, sA, sPoll, ocA);
});	
}
function PREorderGFE3(mHead, mFoot, sA, sPoll, ocA){
if($("#EndArray").val() === undefined){
//Get the IsDefault Endorsements
$.post("../gfeShared/gfeSCR/gfeDBUtilities.asp", { action: "getDefaultEnd", mdl: $('#txtTemplate option:selected').text() },
function(data){
var endA = data;
PREorderGFE4(mHead, mFoot, sA, sPoll, ocA, endA);
});	
}else{
var endA = "";
PREorderGFE4(mHead, mFoot, sA, sPoll, ocA, endA);
}
}
function PREorderGFE4(mHead, mFoot, sA, sPoll, ocA, endA){

//Get the Custom Formula Groups
$.post("../gfeShared/gfeSCR/gfeDBUtilities.asp", { action: "getCF", mdl: $('#txtTemplate option:selected').text() },
function(data){
	var a = data;
	var b = a.split("|");
	var cf1 = b[0];
	var cf2 = b[1];
orderGFE(mHead, mFoot, sA, sPoll, ocA, endA, cf1, cf2);
});	

}

function orderGFE(mHead, mFoot, sA, sPoll, ocA, endA, cf1, cf2){
$.post("../gfeShared/gfeSCR/gfeDBUtilities.asp", { action: "getLookup", PFT: $("#txtTemplate").val() },
  function(data){
	var myModel = data;
if($(".group1:checked").val()== "Purchase"){
	var ot = "Purchase";
	var tDP = $("#txtDeedPages").val();
	var tDP2 = $("#DOT1201").val();
}else{
	var ot = "Refinance";
	var tDP = "";
	var tDP2 = "";
}
if($(".group2:checked").val()== "True"){
	var ri = "True";
}else{
	var ri = "False";
}
if($("#EndArray").val() === undefined){
	var eA = "";
}else{
	var eA = $("#EndArray").val();
}
var ucn = $.cookie('UserCompanyName');
var str=$("#txtTemplate").val();
var mySplitResult = str.split("|");
var tplID = mySplitResult[0]; 
var tplFile = mySplitResult[1]; 
var myCODir = $.cookie('c');
$.post("../gfeShared/gfeSCR/gfeSend.aspx", { 
	myCODir: myCODir,
	txtSenderName: $("#txtSenderName").val(), 
	txtSenderEmail: $("#txtSenderEmail").val(), 
	txtSenderPhone: $("#txtSenderPhone").val(), 
	selPURCREFI: ot,  
	txtLendNumber: $("#txtLendNumber").val(), 
	txtPropertyAddress: $("#txtPropertyAddress").val(), 
	txtPropertyCity: $("#txtPropertyCity").val(), 
	txtPropertyState: $("#txtPropertyState").val(), 
	txtPropertyZip: $("#txtPropertyZip").val(), 
	txtPropertyCounty: $.trim($("#txtPropertyCounty").val()), 
	txtLoanAmount: $("#txtLoanAmount").val(), 
	txtSalePrice: $("#txtSalePrice").val(),
	txtTemplate: tplFile,
	txtTemplateDescription: $('#txtTemplate option:selected').text(),
	txtEndArray: eA,
	txtOCArray: $("#OCArray").val(),
	txtOCFinalArray: ocA,
	txtENDFinalArray: endA,
	txtCF1: cf1,
	txtCF2: cf2,
	END1_Final: $("#END1_Final").val(),
	END2_Final: $("#END2_Final").val(),
	END3_Final: $("#END3_Final").val(),
	END31_Final: $("#END31_Final").val(),
	END4_Final: $("#END4_Final").val(),
	END41_Final: $("#END41_Final").val(),
	END5_Final: $("#END5_Final").val(),
	END51_Final: $("#END51_Final").val(),
	END6_Final: $("#END6_Final").val(),
	END61_Final: $("#END61_Final").val(),
	END62_Final: $("#END62_Final").val(),
	END7_Final: $("#END7_Final").val(),
	END81_Final: $("#END81_Final").val(),
	END9_Final: $("#END9_Final").val(),
	END91_Final: $("#END91_Final").val(),
	END92_Final: $("#END92_Final").val(),
	END10_Final: $("#END10_Final").val(),
	END101_Final: $("#END101_Final").val(),
	END11_Final: $("#END11_Final").val(),
	END12_Final: $("#END12_Final").val(),
	ENDJR1_Final: $("#ENDJR1_Final").val(),
	ENDJR2_Final: $("#ENDJR2_Final").val(),
	ENDX1_Final: $("#ENDX1_Final").val(),
	ENDX2_Final: $("#ENDX2_Final").val(),
	ENDX3_Final: $("#ENDX3_Final").val(),
	ENDX4_Final: $("#ENDX4_Final").val(),
	txtTemplateLookup: myModel,
	txtDeedPages: tDP, 
	txtMortPages: $("#txtMortPages").val(), 
	DOT1201: tDP2, 
	M1OT1201: $("#M1OT1201").val(), 
	R1BYRPG1201: $("#R1BYRPG1201").val(), 
	R1BYROT1201: $("#R1BYROT1201").val(), 
	R2BYRPG1201: $("#R2BYRPG1201").val(),
	R2BYROT1201: $("#R2BYROT1201").val(), 	
	OTH1DESC1201: $("#OTH1DESC1201").val(), 
	OTH1TYP1201: $('#OTH1TYP1201 option:selected').text(),
	OTH1PG1201: $("#OTH1PG1201").val(), 
	OTH1OT1201: $("#OTH1OT1201").val(), 	
	OTH2DESC1201: $("#OTH2DESC1201").val(), 
	OTH2TYP1201: $('#OTH2TYP1201 option:selected').text(),
	OTH2PG1201: $("#OTH2PG1201").val(), 
	OTH2OT1201: $("#OTH2OT1201").val(), 	
	OTH3DESC1201: $("#OTH3DESC1201").val(), 
	OTH3TYP1201: $('#OTH3TYP1201 option:selected').text(),
	OTH3PG1201: $("#OTH3PG1201").val(), 
	OTH3OT1201: $("#OTH3OT1201").val(), 	
	isReissue: ri, 
	txtPPType: $("#txtPPType").val(), 
	txtReCoverage: $("#txtReCoverage").val(), 
	Polling: sPoll,
	txtPPDate: $("#txtPPDate").val(),
	txtRequesterCompany: $("#CoNm").val(),
	txtUserCompanyName: ucn,
	myHeader: mHead,
	myFooter: mFoot,
	sAck: sA,
	CompanyMarketingContact: $("#CompanyMarketingContact").val(),
	CompanyMarketingEmail: $("#CompanyMarketingEmail").val(),
	CompanyNotifyMarketerOf: $("#CompanyNotifyMarketerOf").val()
	},
   function(data){
	 $("#valWait").hide();
	 $("#valDone").show();
	$("#gfeMenu").load("../gfeShared/gfeSCR/gfeMenu.asp", {aa: 'MD'});
  });
  });
}
function AnotherRequest(){
$("#valWait").hide();
$("#valDone").hide();
$("#valBODY").show();
if($("#lc").val()=="NONE"){
$("#gfeHome").load("../gfeShared/gfeSCR/gfeGFE.asp",{
l: "NONE", 
uCoName: $("#CoNm").val(),
uName: $("#txtSenderName").val(),
uEmail: $("#txtSenderEmail").val(),
uPhone: $("#txtSenderPhone").val()
});
}else{
$("#gfeHome").load("../gfeShared/gfeSCR/gfeGFE.asp",{
l: $("#lc").val(),
uCoName: $("#CoNm").val(),
uName: $("#uN").val(),
uEmail: $("#uE").val(),
uPhone: $("#uP").val()
});
}
$("#gfeMenu").load("../gfeShared/gfeSCR/gfeMenu.asp");
}
function itRefi(){
$("#txtSalePrice").val("0.00");
$("#txtSalePrice").attr("readonly", true);
$("#lblSalePrice").css("color","gray");
$("#myPUR").hide();
$("#ddPages").hide();
//$("#docPages").show();
}
function itEqu(){
$("#txtSalePrice").val("0.00");
$("#txtSalePrice").attr("readonly", true);
$("#lblSalePrice").css("color","gray");
$("#myPUR").hide();
$("#ddPages").hide();
//$("#docPages").show();
}
function itPur(){
$("#txtSalePrice").val("").removeAttr("readonly"); 
$("#lblSalePrice").css("color","black");
$("#myPUR").show();
$("#ddPages").show();
//$("#docPages").show();
}
function resetAllCK(){
var hn = window.location.hostname; 	
$.cookie('uAdmin', null, { path: '/', domain: hn });
$.cookie('uGuest', null, { path: '/', domain: hn });
$.cookie('uAdmin', null, { path: '/', domain: hn });
$.cookie('username', null, { path: '/', domain: hn });
$.cookie('password', null, { path: '/', domain: hn });
$.cookie('remember', null, { path: '/', domain: hn });
$.cookie('UserCompanyName', null, { path: '/', domain: hn });
$.cookie('CompanyWebsite', null, { path: '/', domain: hn });
$.cookie('GFEPro_selPURCREFI', null, { path: '/', domain: hn });
$.cookie('myGFEPro_txtSenderName', null, { path: '/', domain: hn });
$.cookie('myGFEPro_txtSenderEmail', null, { path: '/', domain: hn });
$.cookie('myGFEPro_txtSenderPhone', null, { path: '/', domain: hn });
$.cookie('myGFEPro_txtPropertyAddress', null, { path: '/', domain: hn });
$.cookie('myGFEPro_txtPropertyCity', null, { path: '/', domain: hn });
$.cookie('myGFEPro_txtPropertyState', null, { path: '/', domain: hn });
$.cookie('myGFEPro_txtPropertyZip', null, { path: '/', domain: hn });
$.cookie('myGFEPro_txtPropertyCounty', null, { path: '/', domain: hn });
$.cookie('myGFEPro_txtLoanAmount', null, { path: '/', domain: hn });
$.cookie('myGFEPro_txtSalePrice', null, { path: '/', domain: hn });
$.cookie('myGFEPro_txtTemplate', null, { path: '/', domain: hn });
$.cookie('myGFEPro_txtPPType', null, { path: '/', domain: hn });
$.cookie('myGFEPro_txtReCoverage', null, { path: '/', domain: hn });
$.cookie('myGFEPro_txtPPDate', null, { path: '/', domain: hn });
$.cookie('myGFEPro_txtDeedPages', null, { path: '/', domain: hn });
$.cookie('myGFEPro_txtMortPages', null, { path: '/', domain: hn });

$.cookie('myGFEPro_DOT1201', null, { path: '/', domain: hn });
$.cookie('myGFEPro_M1OT1201', null, { path: '/', domain: hn });
$.cookie('myGFEPro_R1BYRPG1201', null, { path: '/', domain: hn });
$.cookie('myGFEPro_R1BYROT1201', null, { path: '/', domain: hn });
$.cookie('myGFEPro_R2BYRPG1201', null, { path: '/', domain: hn });
$.cookie('myGFEPro_R2BYROT1201', null, { path: '/', domain: hn });

$.cookie('myGFEPro_txtLendNumber', null, { path: '/', domain: hn });
$.cookie('myGFEPro_selPURCREFI', null, { path: '/', domain: hn });
$.cookie('myGFEPro_IsReissue', null, { path: '/', domain: hn });
$.cookie('ServerVersion', null, { path: '/', domain: hn });
$.cookie('fST', null, { path: '/', domain: hn });
$.cookie('fCO', null, { path: '/', domain: hn });
$.cookie('CompanyCode', null, { path: '/', domain: hn });
$.cookie('CompanyContact', null, { path: '/', domain: hn });
$.cookie('CompanyContactPhone', null, { path: '/', domain: hn });
$.cookie('ProGFEPollingEmail', null, { path: '/', domain: hn });
$.cookie('GFEPro_txtSenderName', null, { path: '/', domain: hn });
$.cookie('GFEPro_txtSenderEmail', null, { path: '/', domain: hn });
$.cookie('GFEPro_txtSenderPhone', null, { path: '/', domain: hn });
$.cookie('GFEPro_txtPropertyAddress', null, { path: '/', domain: hn });
$.cookie('GFEPro_txtPropertyCity', null, { path: '/', domain: hn });
$.cookie('GFEPro_txtPropertyState', null, { path: '/', domain: hn });
$.cookie('GFEPro_txtPropertyZip', null, { path: '/', domain: hn });
$.cookie('GFEPro_txtPropertyCounty', null, { path: '/', domain: hn });
$.cookie('GFEPro_txtLoanAmount', null, { path: '/', domain: hn });
$.cookie('GFEPro_txtSalePrice', null, { path: '/', domain: hn });
$.cookie('GFEPro_txtTemplate', null, { path: '/', domain: hn });
$.cookie('GFEPro_txtPPType', null, { path: '/', domain: hn });
$.cookie('GFEPro_txtReCoverage', null, { path: '/', domain: hn });
$.cookie('GFEPro_txtPPDate', null, { path: '/', domain: hn });
$.cookie('GFEPro_txtDeedPages', null, { path: '/', domain: hn });
$.cookie('GFEPro_txtMortPages', null, { path: '/', domain: hn });
$.cookie('GFEPro_DOT1201', null, { path: '/', domain: hn });
$.cookie('GFEPro_M1OT1201', null, { path: '/', domain: hn });
$.cookie('GFEPro_R1BYRPG1201', null, { path: '/', domain: hn });
$.cookie('GFEPro_R1BYROT1201', null, { path: '/', domain: hn });
$.cookie('GFEPro_R2BYRPG1201', null, { path: '/', domain: hn });
$.cookie('GFEPro_R2BYROT1201', null, { path: '/', domain: hn });

$.cookie('GFEPro_txtLendNumber', null, { path: '/', domain: hn });
$.cookie('GFEPro_selPURCREFI', null, { path: '/', domain: hn });
$.cookie('GFEPro_IsReissue', null, { path: '/', domain: hn });
$.cookie('c', null, { path: '/', domain: hn });
$.cookie("css", null, { path: '/', domain: hn });
alert("Stored Settings Removed\n\nSettings stored by ProGFE have been removed from your system.  You will now be redirected to the ProGFE login screen.");
window.location.reload();
}
// gfeGFE.asp page functions
function ourWeb(){
window.location = 'http://<% = request("uCompanyWebsite")%>';
}
function getSTInfo(){
$.post("../gfeShared/gfeSCR/gfeDBUtilities.asp",{ action: 'getDocSet', st: $("#txtPropertyState").val() },
  function(data){
	var mySplitResult = data.split("|");
	if(mySplitResult[0]=="False"){
		$("#docPages").show();
		$("#docPagesReq").val("False");
		$("#txtDeedPages").val(mySplitResult[1]);
		$("#txtMortPages").val(mySplitResult[2]);
		$("#DOT1201").val(mySplitResult[3]);
		$("#M1OT1201").val(mySplitResult[4]);
		$("#R1BYRPG1201").val(mySplitResult[5]);
		$("#R1BYROT1201").val(mySplitResult[6]);
		$("#R2BYRPG1201").val(mySplitResult[7]);
		$("#R2BYROT1201").val(mySplitResult[8]);
		popRecording();
	}else{
		$("#docPages").hide();
		$("#docPagesReq").val("True");
		$("#txtDeedPages").val(mySplitResult[1]);
		$("#txtMortPages").val(mySplitResult[2]);
		$("#DOT1201").val(mySplitResult[3]);
		$("#M1OT1201").val(mySplitResult[4]);
		$("#R1BYRPG1201").val(mySplitResult[5]);
		$("#R1BYROT1201").val(mySplitResult[6]);
		$("#R2BYRPG1201").val(mySplitResult[7]);
		$("#R2BYROT1201").val(mySplitResult[8]);
		popRecording();
	}
  });
}
function popRecording(){
		var dc = "";
		if($(".group1:checked").val() == "Purchase"){
			if($("#txtDeedPages").val()!=""){
				dc=dc+"Deed: " + $("#txtDeedPages").val() + ",  "
			}
		}
		if($("#txtMortPages").val()!=""){
		dc=dc+"MTG: " + $("#txtMortPages").val() + ",  "
		}
		if($("#R1BYRPG1201").val()!=""){
		dc=dc+"REL 1: " + $("#R1BYRPG1201").val() + ",  "
		}
		if($("#R2BYRPG1201").val()!=""){
		dc=dc+"REL 2: " + $("#R2BYRPG1201").val() + ",  "
		}
		$("#txtRecording").val(dc);
}
function ENDlist(){
var choice = "Selected Endorsement Array:\n\n ";
var x = new Array();
var Endorsements = document.frmGFE.ENDs;
for ( i = 0; i < Endorsements.length; i++ ) {
if ( Endorsements[i].checked ) {
x.push(Endorsements[i].value);
}
}
if($(".ends:checked").length==1){
document.frmGFE.EndArray.value = document.frmGFE.ENDs.value;
}else{
document.frmGFE.EndArray.value = (x.length == 0 ? 'NONE' : x.join('|'));
}
} 
function getSEL_END(){
try
  {
if($("#txtTemplate").val()==""){
alert("The Calculation Model is missing");
}else{
$('ul#selENDList li').remove();
var x = new Array();
var Endorsements = document.frmGFE.ENDs;
for ( i = 0; i < Endorsements.length; i++ ) {
if ( Endorsements[i].checked ) {
x.push(Endorsements[i].value);
}
}
var dc = (x.length == 0 ? 'NONE' : x.join('|'));
if(x.length == 0){
if($(".ends:checked").length==1){
document.frmGFE.EndArray.value = document.frmGFE.ENDs.value;
var endD = '#'+document.frmGFE.ENDs.value + '_Description'
var endDesc = $(endD).val();
$('<li>' + endDesc + '</li>').appendTo('ul#selENDList');
$(".endLoaderE").show();
$(".endLoader").hide();
$("#selEnd").show();
}else{
$('<li><strong>Default endorsements will be included.</strong> To view the defaults, click the SHOW icon, you may then EDIT the list to remove or include other endorsements as necessary!</li>').appendTo('ul#selENDList');
$("#endLoader").show();
$("#endLoaderE").hide();
}
}else{//Items are selected
var col_array=dc.split("|");
var part_num=0;
while (part_num < col_array.length)
{
var endD = '#'+col_array[part_num] + '_Description';
var endDesc = $(endD).val();
$('<li>' + endDesc + '</li>').appendTo('ul#selENDList');
part_num+=1;
}
$("#endLoaderE").show();
$("#endLoader").hide();
$("#selEnd").show();
ENDlist();  
}//End items are selected
}
}
catch(err)
{
alert("System Setup Error\n\nDefault Endorsements have not been correctly configured for the currently selected calculation module which covers the order type and state you have selected.\n\nPlease contact " + $.cookie('CompanyContact') + " at " + $.cookie('CompanyContactPhone') + " or your ProGFE administrator to report this problem.");
}
}
function getOCsVisible(){
var theAry = "";
var theREL = "";
$('.OCsD:checkbox:checked').each(function(i) { 
theAry = theAry + this.value + "|";
theREL = theREL + $(this).attr('rel') + "|"; 
}); 
$("#OCArrayV").val(theAry);
$("#OCDescArrayV").val(theREL);
}
function getOCs(){
var theAry = "";
var theREL = "";
$('.OCs:checkbox:checked').each(function(i) { 
theAry = theAry + this.value + "|";
theREL = theREL + $(this).attr('rel') + "|"; 
}); 
$("#OCArray").val(theAry);
$("#OCDescArray").val(theREL);
getOCsVisible();
}
function popList(){
$('ul#selOCList li').remove();
var mystring = $("#OCDescArrayV").val();
if(mystring==""){
$('<li><strong>No Items have been included by default.</strong> Click EDIT to select other items which you would like included.</li>').appendTo('ul#selOCList');	
}else{
                $.each( mystring.split("|"), function(){ 
					if(this != ""){
						$('<li>' + this + '</li>').appendTo('ul#selOCList');
					}
                }) 
}
}
function popfXML(theEND){
var mych = "#"+theEND;
var mychF = "#"+theEND+"_Final";
var mychD = "#"+theEND+"_Description";
var mychC = "#"+theEND+"_Cost";
var mychH = "#"+theEND+"_HUDLine";
var mychA = "#"+theEND+"_ApplyToPolicy";
var mychI = "#"+theEND+"_InvoiceLine";
if($(mych).attr('checked')==false){
$(mychF).val("");
}else{
var fc = $(mych).val();
var d = $(mychD).val();
var c = $(mychC).val();
var h = $(mychH).val();
var a = $(mychA).val();
var i = $(mychI).val();
var fXML = fc + "|" + d + "|" + c + "|" + h + "|" + a + "|" + i;
$(mychF).val(fXML);
}
}
function loadEND(cMod){
if($("#txtTemplate").val()==""){
alert("Missing Calculation Model\n\nPlease select an order type, Purchase/Refinance/Equity, then verify that the colculation model pulldown contains your desired model.");
}else{
$("#innerEND").load("../gfeShared/gfeSCR/gfeEND.asp", {mdl: cMod}, function(){
getSEL_END();
$("#endLoaderE").show('slow');
$("#endLoader").hide();
});
}
}
function loadOC(cMod){
if($("#txtTemplate").val()==""){
alert("Missing Calculation Model\n\nPlease select an order type, Purchase/Refinance/Equity, then verify that the colculation model pulldown contains your desired model.");
}else{
	$("#innerOC").load("../gfeShared/gfeSCR/gfeOC.asp", {action: "getTBL", mdl: cMod}, function(){
		popList();
		$("#ocLoaderE").show('slow');
		$("#ocLoader").hide();
	});
}
}
function clearTest(){
// Reset Endorsements
$('#innerEND').html('');
$("#endLoader").show();
$("#endLoaderE").hide();
$('ul#selENDList li').remove();
$('<li id=myID><strong>Default endorsements will be included.</strong> To view the defaults, click the SHOW icon, you may then EDIT the list to remove or include other endorsements as necessary!</li>').appendTo('ul#selENDList');
// Reset Other Charges
$('#innerOC').html('');
$("#ocLoader").show();
$("#ocLoaderE").hide();
$('ul#selOCList li').remove();
$('<li><strong>Default charge items, if any, will be included.</strong> To view the default items click the SHOW icon, you may then EDIT the list to remove or include other optional items, as necessary!!</li>').appendTo('ul#selOCList');
testEndOc();
}
function chgType(){
if($("#hld").val()=="none"){
// Do not reset as it is the first run
$("#hld").val("set");
}else{ // The type is being changed so clear_reset everything
// Reset Endorsements
$('#innerEND').html('');
$("#endLoader").show();
$("#endLoaderE").hide();
$('ul#selENDList li').remove();
$('<li id=myID><strong>Default endorsements will be included.</strong> To view the defaults, click the SHOW icon, you may then EDIT the list to remove or include other endorsements as necessary!</li>').appendTo('ul#selENDList');
// Reset Other Charges
$('#innerOC').html('');
$("#ocLoader").show();
$("#ocLoaderE").hide();
$('ul#selOCList li').remove();
$('<li><strong>Default charge items, if any, will be included.</strong> To view the default items click the SHOW icon, you may then EDIT the list to remove or include other optional items, as necessary!!</li>').appendTo('ul#selOCList');
$("#btnSelEnd").click(function () { 
	loadEND($('#txtTemplate option:selected').text());
});
$("#btnSelOc").click(function () { 
	loadOC($('#txtTemplate option:selected').text());
});
$("#hld").val("set");
} 
}
function nyFieldTest(){
if($("#nyTest").val()=="DOC"){
popRecording();
}else if($("#nyTest").val()=="END"){
getSEL_END();
}else if($("#nyTest").val()=="OC"){
popList();
}
}
function testEndOc(){
//See if ends or ocs have been set up
$.post("../gfeShared/gfeSCR/gfeDBUtilities.asp", { action: "chkEndOc", mdl: $('#txtTemplate option:selected').text() },
   function(data){
		var b = data.split("|");
		if(b[0]=="Yes"){
			$("#endVER2").show();
		}else{
			$("#endVER2").hide();
		}
		if(b[1]=="Yes"){
			$("#chgVER2").show();
		}else{
			$("#chgVER2").hide();
		}
   });
}

//DEFAULT.asp page functions

function loadAdminSetup(){
window.location = "../gfeShared/gfeSetup/gfeSetup.asp";
}
function clearit(){
var sn = $("#txtSenderName").val();
var se = $("#txtSenderEmail").val();
var sp = $("#txtSenderPhone").val();
document.frmGFE.reset();
$("#txtSenderName").val(sn);
$("#txtSenderEmail").val(se);
$("#txtSenderPhone").val(sp);
}
function clearLoginCookies(){
var hn = window.location.hostname; 
$.cookie('remember', null, { path: '/', domain: hn });
$.cookie('username', null, { path: '/', domain: hn });
$.cookie('password', null, { path: '/', domain: hn });
$.cookie('CompanyCode', null, { path: '/', domain: hn });
$.cookie('CompanyContact', null, { path: '/', domain: hn });
$.cookie('CompanyContactPhone', null, { path: '/', domain: hn });
$.cookie('ProGFEPollingEmail', null, { path: '/', domain: hn });
$("#txtLGN").val("");
$("#txtLGN").Watermark("Guest");
$("#txtPASS").val("");
$("#remember").attr("checked", false);
}
function clearCookies(){
var hn = window.location.hostname; 
	$.cookie('GFEPro_txtSenderName', null, { path: '/', domain: hn });
	$.cookie('GFEPro_txtSenderEmail', null, { path: '/', domain: hn });
	$.cookie('GFEPro_txtSenderPhone', null, { path: '/', domain: hn });
	$.cookie('GFEPro_txtPropertyAddress', null, { path: '/', domain: hn });
	$.cookie('GFEPro_txtPropertyCity', null, { path: '/', domain: hn });
	$.cookie('GFEPro_txtPropertyState', null, { path: '/', domain: hn });
	$.cookie('GFEPro_txtPropertyZip', null, { path: '/', domain: hn });
	$.cookie('GFEPro_txtPropertyCounty', null, { path: '/', domain: hn });
	$.cookie('GFEPro_txtLoanAmount', null, { path: '/', domain: hn });
	$.cookie('GFEPro_txtSalePrice', null, { path: '/', domain: hn });
	$.cookie('GFEPro_txtTemplate', null, { path: '/', domain: hn });
	$.cookie('GFEPro_txtPPType', null, { path: '/', domain: hn });
	$.cookie('GFEPro_txtReCoverage', null, { path: '/', domain: hn });
	$.cookie('GFEPro_txtPPDate', null, { path: '/', domain: hn });
	$.cookie('GFEPro_txtDeedPages', null, { path: '/', domain: hn });
	$.cookie('GFEPro_txtMortPages', null, { path: '/', domain: hn });
	$.cookie('GFEPro_txtLendNumber', null, { path: '/', domain: hn });
	$.cookie('GFEPro_selPURCREFI', null, { path: '/', domain: hn });
	$.cookie('GFEPro_IsReissue', null, { path: '/', domain: hn });

	alert("ProGFE Default Cookies Removed\n\nAll cookies set as user defaults have been removed from your system.");
}
function checkEnter(e){ //Submit is enter is pressed in password field
var characterCode;
if(e && e.which){
e = e;
characterCode = e.which;
}
else{
e = event;
characterCode = e.keyCode;
}
if(characterCode == 13){
UserLogin();
return false 
}
else{
return true 
}

}
function FP(thePoll){
//	alert(thePoll);
if (confirm("Request For Password Reminder\n\nClick OK below to have your password sent to your email account.  The email address you enter must be a valid ProGFE email/login account.\n\nContinue?")) { 
if($("#txtLGN").val()==""){
alert("Missing Login\n\nIn order for us to send you your password, we need you to enter your email address in the email or login entry field.  Enter your email address, and then try again.");
}else{
// Code to get and send the password
$.post("../gfeShared/gfeSCR/gfeDBUtilities.asp",
  	{ action: 'getPWord', lg: $("#txtLGN").val() },
  function(data){
//    alert("Data Loaded: " + data);
	if(data=="Error"){
		alert("Invalid Email Address\n\nThe email address login that you have entered is not a valid ProGFE email address.\n\nPlease reenter the email address and try again, or contact the system administrator.")
	}else{
	//place code to send email
	$.post("../gfeShared/gfeSCR/gfeRemind.aspx",
  		{ txtPass: data, txtEmail: $("#txtLGN").val(), txtPoll: thePoll },
  function(data){
  	if(data=="SENT"){
    	alert("Password Sent\n\nYour ProGFE login and password has been sent to your email address.");
	
	}else{
    	alert("PROBLEM\n\nThere was a problem sending your login and password to the email address specified.  Please verified the entered email address and then try again.");
	}
  }
);//End second ajax post
	}// end if password is returned
  }// end first function
);// end first post
}// end if email address is entered
}// end confirm
}
function config_split(str, typ){
var hn = window.location.hostname;
var config_str=str;
var config_array=config_str.split("|");
if(typ=="gfeDir" || typ=="gfeCookie"){
$.cookie(config_array[0], config_array[1], { expires: 365, path: '/', domain: hn });
}else if(typ=="gfeSession"){
$.cookie(config_array[0], config_array[0], { path: '/', domain: hn });
}
}
