<!-- // hide this script from non-javascript-enabled browsers

function addhost(url) {
	if (window.location.hostname && window.location.hostname == "www.floodinsurancehelp.com") { 
			return url+"&referer=help";
	} else if (window.location.hostname && window.location.hostname == "www.bancinsurefloodhelp.com") {
			return url+"&referer=bancinsure";
	} else {
		return url; 
	}	
}

function MM_findObj(n, d) { //v3.0
    var p, i, x;
    if(!d)
	d = document;
    if((p = n.indexOf("?")) > 0 && parent.frames.length) {
	d = parent.frames[n.substring(p+1)].document;
	n = n.substring(0,p);
    }
    if(!(x = d[n]) && d.all)
	x = d.all[n];
    for (i = 0 ; !x && i < d.forms.length ; i++)
	x = d.forms[i][n];
    for(i = 0 ; !x && d.layers && i < d.layers.length ; i++)
	x = MM_findObj(n, d.layers[i].document);
    return x;
}

/* Functions that swaps images. */
function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments;
    document.MM_sr = new Array;
    for(i = 0 ; i < (a.length-2) ; i += 3)
	if ((x = MM_findObj(a[i])) != null){
	    document.MM_sr[j++]=x;
	    if(!x.oSrc)
		x.oSrc = x.src; x.src = a[i+2];
	}
}

function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr;
    for(i = 0 ; a && i < a.length && (x = a[i]) && x.oSrc ; i++)
	x.src = x.oSrc;
}

/* Functions that handle preload. */
function MM_preloadImages() { //v3.0
    var d = document;
    if(d.images) {
	if(!d.MM_p)
	    d.MM_p=new Array();
	var i, j = d.MM_p.length, a = MM_preloadImages.arguments;
	for(i = 0; i < a.length; i++)
	    if (a[i].indexOf("#")!=0) {
		d.MM_p[j]=new Image;
		d.MM_p[j++].src=a[i];
	    }
    }
}

function Get_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

function Set_Cookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}

function Delete_Cookie(name,path,domain) {
    if (Get_Cookie(name)) document.cookie = name + "=" +
       ( (path) ? ";path=" + path : "") +
       ( (domain) ? ";domain=" + domain : "") +
       ";expires=Thu, 01-Jan-70 00:00:01 GMT";
}

/* show/hide form elements: */
var ie4 = (document.all) ? true : false;
var ns6 = (!document.all && document.getElementById) ? true : false;

function toggle( targetId ){
    if (ie4){
	target = document.all[targetId];
	if (target.style.display == "none"){
	    target.style.display = "";
	} 
	else {
	    target.style.display = "none";
	}
    }
    else if (ns6){
	target = document.getElementById(targetId);
	if (target.style.display == "none"){
	    target.style.display = "";
	} 
	else {
	    target.style.display = "none";
	}
    }
}

function show( targetId ){
    if (ie4){
	target = document.all[targetId];
	target.style.display = "";
    }
    else if (ns6){
	target = document.getElementById(targetId);
	target.style.display = "";
    }
}

function hide( targetId ){
    if (ie4){
	target = document.all[targetId];
	target.style.display = "none";
    }
    else if (ns6){
	target = document.getElementById(targetId);
	target.style.display = "none";
    }
}

function y2k(number) { return (number < 1000) ? number + (number < 70 ? 2000 : 1900) : number; }
function y2kjs(number) { return number < 1900 ? number + 1900 : number; }

function isDate (day, month, year) {
    var today = new Date();
    year = y2k(year);
    month = month - 1;
    if (!day)
	return false;

    var test = new Date(year, month, day);
    if ( (y2kjs(test.getYear()) == year) &&
	 (month == test.getMonth()) &&
	 (day == test.getDate()) )
	return test;
    else
        return false;
}

function check_date(form, name) {

    var d = eval("form['" + name + "_dd']");
    if(d) {
        d = parseInt(eval("form['" + name + "_dd'].value"), 10);
    } else { d = 1; }
    var m = parseInt(eval("form['" + name + "_mm'].value"), 10);
    var y = eval("form['" + name + "_yyyy'].value");

    if (y == "00") {
	y = "2000";
    }
    y = parseInt(y, 10);

    if(isNaN(y) || isNaN(m) || isNaN(d)){
	return false;
    }

    var test;
    if(test = isDate(d, m, y)) {
 	eval("form['" + name + "_dd'].value = test.getDate()");
	eval("form['" + name + "_mm'].value = test.getMonth() + 1");
 	eval("form['" + name + "_yyyy'].value = y2kjs(test.getYear())");
	return true;
    } else if (y < 1902) {
        return true;
    }
    return false;
}

var showWhy = 1;
var showSearch = 0;

var loggedIn = 0;
var isMpppflood = 0;
if (location.hostname.indexOf("mpppflood") >= 0) {
	isMpppflood = 1;
}
function link(htmpage) {
	if (isMpppflood) {
		document.location = htmpage + "_mppp.htm";
	} else {
		document.location = htmpage + ".htm";
	}
	
}
function fixupNav() {

    var showLogin = parseInt(Get_Cookie("showlogin"));
    var isVisitor = parseInt(Get_Cookie("visitor"));
    var cType = parseInt(Get_Cookie("ctype")); //customer type: mppp lender(7), insurance agency(1)..
    loggedIn = parseInt(Get_Cookie("loggedin"));
	
	if (isMpppflood == 1) {
		document.title = "MPPPFlood.com - Your Online Source for Lender Placed Flood Insurance Premiums - Brought to you by The Flood Insurance Agency";
	}
    if(isNaN(isVisitor)) {
        isVisitor = 0;
    }
    if(isNaN(cType)) {
        cType = 0;
    }
    if(isNaN(showLogin)) {
        showLogin = 0;
    }

	var def;
    	var tfia_all_a;
	var tfia_agent_a;
	var tfia_all_b;
	var mppp_all_a;
	var mppp_visitor_a;
	var mppp_agent_a;
	var mppp_all_b;
	var mppp_bottom;
	var tfia_bottom;
	    
    if(ie4) {
		//vis = document.all["visitor"];
		def = document.all["def"];
		tfia_all_a = document.all["tfia_all_a"];
		tfia_agent_a = document.all["tfia_agent_a"];
		tfia_all_b = document.all["tfia_all_b"];
		tfia_bottom = document.all["tfia_bottom"];
		mppp_bottom = document.all["mppp_bottom"];
		mppp_all_a = document.all["mppp_all_a"];
		mppp_visitor_a = document.all["mppp_visitor_a"];
		mppp_agent_a = document.all["mppp_agent_a"];
		mppp_all_b = document.all["mppp_all_b"];
	} else if (ns6) {
		//vis = document.getElementById("visitor");
		def = document.getElementById("def");
		tfia_all_a = document.getElementById("tfia_all_a");
		tfia_agent_a = document.getElementById("tfia_agent_a");
		tfia_all_b = document.getElementById("tfia_all_b");
		tfia_bottom = document.getElementById("tfia_bottom");
		mppp_bottom = document.getElementById("mppp_bottom");
		mppp_all_a = document.getElementById("mppp_all_a");
		mppp_visitor_a = document.getElementById("mppp_visitor_a");
		mppp_agent_a = document.getElementById("mppp_agent_a");
		mppp_all_b = document.getElementById("mppp_all_b");
    }
    if(isMpppflood == 1) {
    	if (mppp_bottom && tfia_bottom) {
    		tfia_bottom.style.display = "none";
    		mppp_bottom.style.display = "";
    	}
    } else {
	if (mppp_bottom && tfia_bottom) {
		tfia_bottom.style.display = "";
    		mppp_bottom.style.display = "none";
	}
    }
    if (def) {
		def.style.display = "";
		if(isMpppflood == 1) {
			mppp_all_a.style.display = "";
			mppp_all_b.style.display = "";
			
			tfia_all_a.style.display = "none";
			tfia_all_b.style.display = "none";
			tfia_agent_a.style.display = "none";
			if(loggedIn == 1) {
				mppp_agent_a.style.display = "";
				if(mppp_visitor_a) {
					mppp_visitor_a.style.display = "none";
			        }
			} else {
				mppp_agent_a.style.display = "none";
				if(mppp_visitor_a) {
					mppp_visitor_a.style.display = "";
			        }
			}
		} else {
			tfia_all_a.style.display = "";
			tfia_all_b.style.display = "";
			mppp_all_a.style.display = "none";
			mppp_all_b.style.display = "none";
			mppp_agent_a.style.display = "none";
			if(loggedIn == 1) {
				tfia_agent_a.style.display = "";
			} else {
				tfia_agent_a.style.display = "none";
			}
		}
	}


    

    showlogin(loggedIn);
}

function showlogin(loggedIn) {

    if (ie4) {
	limg = document.all["loginimg"];
	lhref = document.all["loginhref"];
    } else if (ns6) {
	limg = document.getElementById("loginimg");
	lhref = document.getElementById("loginhref");
    }

    if(limg && lhref) {
	if(loggedIn) {
	    document.links[0].href = "https://" + location.hostname + "/cgi-bin/tfia.cgi?control=1";
	    limg.src = "images/n-logout.gif";
	    lhref.href = "/cgi-bin/tfia.cgi?logout=1";
	} else {
	    limg.src = "images/n-login.gif";
	    lhref.href = "/cgi-bin/tfia.cgi?showlogin=1";
	}
    }
}

function referral() {
    var name;
    var under;

    name = Get_Cookie("referral");
    under = Get_Cookie("underwriter");
       
    if(under && name) {
        document.write("<h1 align='center'>" + under + " welcomes " + name + " Insurance Agents to The Flood Insurance Agency</h1>");
    } else if(name) {
	document.write("<h1 align='center'>Welcome customers of<br>" + name + "</h1>");
    }
}

function errwin(left, top) {

    if (document.all) {
        document.all["errwin"].style.posLeft = left;
        document.all["errwin"].style.posTop = top;
    } else if (document.layers) {
        document["errwin"].left = left;
        document["errwin"].top = top;
    }

    show("errwin");
}

function DL_GetElementLeft(eElement)
{
   if (!eElement && this)                    // if argument is invalid
   {                                         // (not specified, is null or is 0)
      eElement = this;                       // and function is a method
   }                                         // identify the element as the method owner

   if(!eElement) { return null; }

   var DL_bIE = document.all ? true : false; // initialize var to identify IE

   var nLeftPos = eElement.offsetLeft;       // initialize var to store calculations
   var eParElement = eElement.offsetParent;  // identify first offset parent element

   while (eParElement != null)
   {                                         // move up through element hierarchy

      if(DL_bIE)                             // if browser is IE, then...
      {
         if( (eParElement.tagName != "TABLE") && (eParElement.tagName != "BODY") )
         {                                   // if parent is not a table or the body, then...
            nLeftPos += eParElement.clientLeft; // append cell border width to calcs
         }
      }
      else                                   // if browser is Gecko, then...
      {
         if(eParElement.tagName == "TABLE")  // if parent is a table, then...
         {                                   // get its border as a number
            var nParBorder = parseInt(eParElement.border);
            if(isNaN(nParBorder))            // if no valid border attribute, then...
            {                                // check the table's frame attribute
               var nParFrame = eParElement.getAttribute('frame');
               if(nParFrame != null)         // if frame has ANY value, then...
               {
                  nLeftPos += 1;             // append one pixel to counter
               }
            }
            else if(nParBorder > 0)          // if a border width is specified, then...
            {
               nLeftPos += nParBorder;       // append the border width to counter
            }
         }
      }
      nLeftPos += eParElement.offsetLeft;    // append left offset of parent
      eParElement = eParElement.offsetParent; // and move up the element hierarchy
   }                                         // until no more offset parents exist
   return nLeftPos;                          // return the number calculated
}

function DL_GetElementTop(eElement)
{
   if (!eElement && this)                    // if argument is invalid
   {                                         // (not specified, is null or is 0)
      eElement = this;                       // and function is a method
   }                                         // identify the element as the method owner

   if(!eElement) { return null; }

   var DL_bIE = document.all ? true : false; // initialize var to identify IE

   var nTopPos = eElement.offsetTop;         // initialize var to store calculations
   var eParElement = eElement.offsetParent;  // identify first offset parent element

   while (eParElement != null)
   {                                         // move up through element hierarchy
      if(DL_bIE)                             // if browser is IE, then...
      {
         if( (eParElement.tagName != "TABLE") && (eParElement.tagName != "BODY") )
         {                                   // if parent a table cell, then...
            nTopPos += eParElement.clientTop; // append cell border width to calcs
         }
      }
      else                                   // if browser is Gecko, then...
      {
         if(eParElement.tagName == "TABLE")  // if parent is a table, then...
         {                                   // get its border as a number
            var nParBorder = parseInt(eParElement.border);
            if(isNaN(nParBorder))            // if no valid border attribute, then...
            {                                // check the table's frame attribute
               var nParFrame = eParElement.getAttribute('frame');
               if(nParFrame != null)         // if frame has ANY value, then...
               {
                  nTopPos += 1;              // append one pixel to counter
               }
            }
            else if(nParBorder > 0)          // if a border width is specified, then...
            {
               nTopPos += nParBorder;        // append the border width to counter
            }
         }
      }

      nTopPos += eParElement.offsetTop;      // append top offset of parent
      eParElement = eParElement.offsetParent; // and move up the element hierarchy
   }                                         // until no more offset parents exist
   return nTopPos;                           // return the number calculated
}


// End hiding -->
