// HIDE FROM INCOMPATIBLE BROWSERS

		// If we're in a frameset, bounce us out
		if (self != top) {
			top.location.href = window.location.href;
		}
				// Add Error handler for the javascript errors
		var OLPErrors = [];
		/*var paydateFields = ['biweekly_date','frequency','weekly_day','biweekly_day','twicemonthly_type',
							 'twicemonthly_date1','twicemonthly_date2','twicemonthly_week','twicemonthly_day',
							 'twicemonthly_order','monthly_type','monthly_date','monthly_week','monthly_day',
							 'monthly_after_date','monthly_after_day'];*/
							 
		function OLP_display_errors()
		{
			if(OLPErrors.length == 0) return;
		
			// use this variable to see if we should print the old style errors
			use_js_style_errors = true;

			for(var x in OLPErrors)
			{
				try 
				{
					var fieldName = OLPErrors[x];

					switch(fieldName)
					{
						case 'twicemonthly_day':
						case 'twicemonthly_week':
							fieldName = 'twicemonthly_dw';
							break;

						case 'monthly_day':
						case 'monthly_week':
							fieldName = 'monthly_dw';
							break;

						case 'monthly_after_date':
						case 'monthly_after_day':
							fieldName = 'monthly_after';
							break;

						case 'twicemonthly_date1':
							fieldName = 'twicemonthly_order';
							break;
					}
					
					var l = document.getElementById("label_" + fieldName);
					l.className += " olperroron";
				}
				catch(e) 
				{
					// we need to display the error block
					use_js_style_errors = false;
				}
			}
			// if we were able to highlight all of the fields that
			// are in error then we display the javascript error
			// otherwise show the big red error block
			if(use_js_style_errors)
			{
				//Show error DIV
				document.getElementById("olperrors").style.display = "block";
				hideOldErrorBlock('wf-trunk-errors-container');
			} 

		}
		
		// Test for cookie capability; send to uh-oh page if not
		// ********************************************************
		if (!navigator.cookieEnabled)
		{
			if (!document.cookie || document.cookie == null || document.cookie == "")
			{
								document.location.href="index.php?page=no_unique_id";
			}
		}
	

	/*
	 * GForge #15273 - Popup When Min Loan Amount ... [AuMa]
	 * This function finds the element that is passed into it.
	 * @param string the id of the element to find
	 * @return object handle to the element
	 */
	function findElement(ele)
	{
		if ( document.getElementById )
		{
			elem = document.getElementById (ele );
		}
		else if ( document.all )
		{
			elem = document.all[ele];
		}
		else if ( document.layers )
		{
			elem = document.layers[ele];
		}

		return elem;
	}

	// So we don't show the drop down form multiple times
	loan_info_div_shown = 0;

	/*
	 * GForge #15273 - Popup up when Min Loan Amount ... [AuMa]
	 * This function displays the question on the screen
	 * @param object select box object that is tested
	 */
	function show_loan_info_div(selectBox)
	{
		if (selectBox.options[selectBox.selectedIndex].value >= 600 
			&& loan_info_div_shown == 0)
		{
			toggle_layer ('loan_info', 'show');
			loan_info_div_shown++;
		} 
		else 
		{
			toggle_layer ('loan_info', 'hide');
		}
	}

	/* 
	 * GForge #15273 - Popup When Min Loan Amount ... [AuMa]
	 * This function toggles whether a div is displayed to the
	 * user or not
	 * @param string id of the object controlled
	 * @param string (show or hide) 
	 */
	function toggle_layer(layer, mode)
	{
		ele = findElement(layer);
		vis = ele.style;

		switch (mode)
		{
			case 'show':
				vis.display = 'block';
			break;
			case 'hide':
				vis.display = 'none';
			break;
		}
	}

	/*
	 * GForge #15273 - Popup When Min Loan Amount ... [AuMa]
	 * This function will hide the loan question and depending 
	 * on the mode it will change the value of the select box
	 * @param string ('yes','no')
	 */
	function hide_loan_info(answer, form)
	{
		selectBox = form.loan_amount_desired;
		if (answer == 'yes')
		{
			selectBox.selectedIndex = 2;
		}
		toggle_layer('loan_info', 'hide');
	}


		
		function toggle(name, force_on)
		{
			var element = document.getElementById(name);
			
			if(force_on != null)
			{
				element.style.display = (force_on) ? '' : 'none';
			}
			else if(element.style.display != 'none')
			{
				element.style.display = 'none';
			}
			else
			{
				element.style.display = '';
			}
		}
		
		function toggle_disabled(name, disable)
		{
			var element = document.getElementById(name);
			
			element.disabled = disable;
		}
		

		/**
		  * @see [#18218] [DY]
		  */
		  
		var properClickThrough = false;
		var USItimerID = '';
		var USIdone = false;

		var isXPSP2 = false;
		var isIE7 = false;

		if (typeof(navigator.appMinorVersion) != 'undefined') {
			isXPSP2 = (navigator.appMinorVersion.toLowerCase().indexOf("sp2") != -1);
			isIE7 = (navigator.appVersion.toLowerCase().indexOf("msie 7.0") != -1);
		}

		if(window.addEventListener) {
			window.addEventListener("beforeunload", cancelTimer, false);
		} else {
			window.attachEvent("onbeforeunload", cancelTimer);
		}

		function cancelTimer() {
			USIdone = true;
		    if (USItimerID != '') clearTimeout(USItimerID);
		}

		function TestClick() {
		    properClickThrough = true;
			USItimerID  = setTimeout("usiInterval();", 1000);
		}

		function usiInterval() {
			if(!USIdone){
				properClickThrough = false;
			}
		}

		document.documentElement.onclick = TestClick;
		document.documentElement.onkeypress = TestClick;

		/**
		  * End code [#18218] [DY]
		  */


		// Set exit variable based on page type
		// ********************************************************
			
				var exit = true;
		
		// Set onLoad Pop
		// ********************************************************
		function pop_onLoad()
		{
					}
		
		function pop_formLoad()
		{
					}


		// This is so a page can redirect
		// ********************************************************
		function redirect (target_url, seconds_until)
		{
			script_expression = "document.location.href = '" + target_url + "'";
			msecs = seconds_until * 1000;
			setTimeout(script_expression, msecs);
		}

	// This function will make the window bigger - Mantis 9607/9608 [AuMa]
	function maximize_window()
	{
		window.moveTo(0,0); window.resizeTo(screen.width,screen.height);	
	}
	
	// This function will display the UpSellIt Confirmation tracking pixel. - Mantis 9607/9608 [AuMa]
	// This function is no longer used
	//********************************************* 
	// per instructions - tracking pixel will be made instead
	/*
	function UpSellIt_Confirm(siteID, orderID)
	{
	
		var productID = "77";
		var position = "1";
		var command = "REPORT";
		var upsellit_tag = "<SCRIPT LANGUAGE='JavaScript' " + "SRC=https://www.upsellit.com/upsellitReporting.jsp?command=" + command +"&siteID=" + siteID + "&productID=" + productID + "&position=" + position + "&orderID=" + orderID + " />";
		document.write(upsellit_tag);	
	}
	*/
	


		// Set onUnload popup
		// ********************************************************

		/*function pop_onUnload()
		{
			if (exit)
			{
							}

			
			exit_url = 'http://www.bloxnine.com/?azq=100&bid=198&aid=CD163&dp=36071&cid=51&land=0&opt';

			_pop_onUnload(exit_url, 800, 600);

			
			confirm_url = '';

			_pop_onUnload(confirm_url, 400, 400);

			return true;
		}*/

		function _pop_onUnload(exit_url, width, height)
		{
			if (!properClickThrough && exit_url != '')
			{
				if(!isIE7 && !isXPSP2 && !document.all) {
					window.open(exit_url, 'pm_indexexit', 'width=' + width + ',height=' + height + ',menubar=yes,toolbar=yes,location=yes,status=yes,resizable=yes,scrolling=yes');	
				} else if (!isIE7 && !isXPSP2 && document.all) {
					showModalDialog(exit_url, '', 'dialogTop:150px;dialogLeft:300px;dialogWidth:' + width + 'px;dialogHeight:' + height + 'px;status:yes;scroll:yes');
				} else {
					document.body.innerHTML += "<object id=iie width=0 height=0 classid='CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6'></object>";
					iie.launchURL(exit_url);
				}
			}
		}

		function sub_pop(){
		
		sub_dest = ''
		
		
			 sub_dest='http://click.linkstattrack.com/zoneId/218487?sub=cashpop';
		
		winname = 'i'
		props = 'width=' + screen.width-75 + ',height=' + screen.height-75
		props = props + ',status=yes,toolbar=yes,resizable=yes,'
		props = props + 'titlebar=yes,scrollbars=yes,menubar=yes,location=yes'

			if (sub_dest != '') {
				var d = window.open(sub_dest,winname,props)
				d.blur()
				
				setTimeout("document.forms[0].submit()", "300")
			}
		}
		
		// Set Pop Title
		// ********************************************************
		function set_title (ref, title)
		{
			ref.document.title = title;
		}

		// Pop local window and direct to <a name=""></a> bookmark
		// ********************************************************
		function pop_bookmark(page_req, bookmark)
		{
			if(page_req == "?page=info_faq")
			{
				page_url = "index.php"+page_req+"#"+bookmark;
				win = window.open(page_url,"popwin","width=490,height=420,resizable=no,scrollbars=yes,toolbar=no,menubar=no");
				win.focus ();
			}
			else
			{
				page_url = "index.php"+page_req+"#"+bookmark;
				win = window.open(page_url,"popwin","width=490,height=420,resizable=no,scrollbars=yes,toolbar=no,menubar=no");
				win.focus ();
			}
		}

		// Set ABA POP 
		// ********************************************************
		function pop_help_aba(url)
		{
			info = window.open('http://alamancefinancialapp.com/imgdir/live/media/image/help_aba_check.gif','info',' scrollbars=no, resizable=no, width=477, height=265');
			setTimeout ("set_title(info, 'ABA Number')", 250);
			info.focus();
		}

		// Spawn local pops from drop-down menus
		// ********************************************************
		function pop_dropdown(dropdown_obj)
		{
			page_req = dropdown_obj.options[dropdown_obj.selectedIndex].value;
			switch (page_req)
			{
				// these do nothing:
				case "":
				case "Quick Navigation":
					break;
				//these change location:
				case "?page=home":
				case "?page=cs_login":
					document.location.href = "http://alamancefinancialapp.com/index.php"+page_req;
					break;
				// Enterprise login
				case "?page=ent_cs_login":
					document.location.href = "/index.php"+page_req;
					break;
				// this spawns the popup:
				case "?page=ent_mail_password":
				case "?page=cs_removeme":
				default:
					page_url = "index.php"+page_req;
					window.open(page_url,"popwin","width=490,height=420,resizable=no,scrollbars=yes,toolbar=no,menubar=no");
					break;
			}
		}

		// Spawn external sites in standard sized pop (800x600)
		// ********************************************************
		function pop_newsite(page_url, bookmark)
		{
			if (bookmark)
			{
				page_url = page_url+"#"+bookmark;
			}
			window.open(page_url,"tss_win","width=800,height=600,resizable=yes,scrollbars=yes,location=yes,toolbar=yes,menubar=yes");
		}

		function pop_resizable(page_url, width, height)
		{
			window.open(page_url,'pop_win',"width=" + width + ",height=" + height + ",resizable=no,scrollbars=yes,toolbar=no,menubar=no");
		}
		


		// Spawn local pops from menus
		// ********************************************************
		function pop_menu(page_req)
		{
			switch (page_req)
			{
				// these change location:
				case "":
				case "?page=prequal":
					//document.location.href = "index.php"+page_req;
					document.location.href = "index.php";
					break;
				// this spawns the popup:
				default:
					page_url = page_req;
					window.open(page_url,"popwin","width=490,height=420,resizable=no,scrollbars=yes,toolbar=no,menubar=no");
					break;
			}
		}

		// Redirect links INSIDE of a popup back to parent window
		// ********************************************************
		function back2opener(loc_str)
		{
			opener.location.href = loc_str;
		}

		// Redirect function
		// ********************************************************
		function redirect_link(link)
		{
			document.location.href = link;
		}

		// form button disabling and value rewrite function
		// ********************************************************
		function toggle_agree_deny (obj_ref)
		{
			this_form = obj_ref;
			if (this_form.id == "thumbs_up")
			{
				this_button = this_form.b_legal_agree;
				that_button = document.getElementById ("thumbs_down").b_legal_deny;
			}
			else
			{
				this_button = this_form.b_legal_deny;
				that_button = document.getElementById ("thumbs_up").b_legal_agree;
			}
			this_button.value = "Processing...";
			this_button.disabled = true;
			that_button.style.color = "#666666";
			that_button.style.border = "solid 1px #666666";
			that_button.style.backgroundColor = "#999999";
			that_button.disabled = true;
		}


		
		function _check_state(val)
		{
			hide_div("ca_form");
			switch(val)
			{
				case "CA":
				show_div("ca_form");
				break;
			}
		}

		if (typeof(show_div)=='undefined') {
			function show_div(id)
			{
				div = document.getElementById(id);
				if(div)
				{
					div.style.display = "block";
				}
			}
		}

		if (typeof(hide_div)=='undefined') {
			function hide_div(id)
			{
				div = document.getElementById(id);
				if(div)
				{
					div.style.display = "none";
				}
			}
		}

		// Clears the paydate radios when we change the day.
		// ********************************************************
		function clear_radio (name_fragment)
		{
			button_name = "paydate["+name_fragment+"]";
			radio_buttons = document.getElementsByName(button_name);
			num_buttons = radio_buttons.length;
			if (num_buttons > 0)
			{
				for (i=0; i<num_buttons; i++)
				{
					radio_buttons[i].checked = false;
				}
			}
		}
		
		/**
		 * This function takes the id of any element and hides it.
		 */
		function Hide_Image(id, hide)
		{
			img = document.getElementById(id);
			if(hide == false)
			{
				img.style.visibility = "visible";
			}
			else
			{
				img.style.visibility = "hidden";
			}
		}
		
		// Displays the processing page on submit.
		function Show_Processing_Page(error_id, main_id, process_id)
		{
			var error_div = document.getElementById(error_id);
			
			if(error_div)
			{
				error_div.style.display = "none";
			}
			
			try {
				var main_div = document.getElementById(main_id);
				main_div.style.display = "none";
				var process_div = document.getElementById(process_id);
				process_div.style.display = "block";
			}
			catch(e) {}						
			window.scrollTo(0,0);
		}

		
		/**********************************************************
		 * This function will hide the old error block
		 *
		 * @param error_block_id
		 *********************************************************/
		function hideOldErrorBlock(error_id)
		{
			var error_div = document.getElementById(error_id);
			
			if(error_div)
			{
				error_div.style.display = "none";
			}
		}
		
		// Displays credit card information if the customer selects credit cards as the payment
		// option.
		function Show_CC_Info()
		{
			var cc_info_div = document.getElementById("cc_info");
			var cc_option = document.getElementById("credit_card_option");
			
			if(cc_option.selected) cc_info_div.style.display = "block";
			else cc_info_div.style.display = "none";
		}
