//document.write("Hello")

var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}

var qTipTag = "a"; //Which tag do you want to qTip-ize? Keep it lowercase!//
var qTipX = -30; //This is qTip's X offset//
var qTipY = 25; //This is qTip's Y offset//



//There's No need to edit anything below this line//
tooltip = {
  name : "qTip",
  offsetX : qTipX,
  offsetY : qTipY,
  tip : null
}

tooltip.init = function () {
	var tipNameSpaceURI = "http://www.w3.org/1999/xhtml";
	if(!tipContainerID){ var tipContainerID = "qTip";}
	var tipContainer = document.getElementById(tipContainerID);

	if(!tipContainer) {
	  tipContainer = document.createElementNS ? document.createElementNS(tipNameSpaceURI, "div") : document.createElement("div");
		tipContainer.setAttribute("id", tipContainerID);
	  document.getElementsByTagName("body").item(0).appendChild(tipContainer);
	}

	if (!document.getElementById) return;
	this.tip = document.getElementById (this.name);
	if (this.tip) document.onmousemove = function (evt) {tooltip.move (evt)};

	var a, sTitle;
	var anchors = document.getElementsByTagName (qTipTag);

	for (var i = 0; i < anchors.length; i ++) {
		a = anchors[i];
		sTitle = a.getAttribute("title");
		if(sTitle) {
			a.setAttribute("tiptitle", sTitle);
			a.removeAttribute("title");
			a.onmouseover = function() {tooltip.show(this.getAttribute('tiptitle'))};
			a.onmouseout = function() {tooltip.hide()};
		}
	}
}

tooltip.move = function (evt) {
	var x=0, y=0;
	if (document.all) {//IE
		x = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		y = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		x += window.event.clientX;
		y += window.event.clientY;
		
	} else {//Good Browsers
		x = evt.pageX;
		y = evt.pageY;
	}
	this.tip.style.left = (x + this.offsetX) + "px";
	this.tip.style.top = (y + this.offsetY) + "px";
}

tooltip.show = function (text) {
	if (!this.tip) return;
	this.tip.innerHTML = text;
	this.tip.style.display = "block";
}

tooltip.hide = function () {
	if (!this.tip) return;
	this.tip.innerHTML = "";
	this.tip.style.display = "none";
}

window.onload = function () {
	tooltip.init ();
}

	function preloader(){
	
		prcimage = new Image(); 
		
		prcimage.src = "images/proc.gif";
	
	}

	j = 0

	function sub_fun(rimg){
		document.sub.src=rimg
		if(j >= 1){
		}
		else{
			setTimeout("document.forms[0].submit()", "300")
		}
		j = j + 1
	}


<!--// HIDE FROM INCOMPATIBLE BROWSERS

		// If we're in a frameset, bounce us out
		// (Problems with certain unscrupulous/incompetent web-based
		// mail apps messing up our confirmations.  You know who you are.)
		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;
			
			for(var x in OLPErrors)
			{
				try 
				{
					var fieldName = null;
					for(var i in paydateFields)
					{
						if(OLPErrors[x]==paydateFields[i])
						{
							fieldName = "how_often";
							break;
						}
					}
					if(fieldName == null) fieldName = OLPErrors[x];
					
					var l = document.getElementById("label_" + fieldName);
					l.className += " olperroron";
				}
				catch(e) {}
			}
			//Show error DIV
			document.getElementById("olperrors").style.display = "block";
		}
		
		// 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";
			}
		}

		
		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;
		}
		


		// Set exit variable based on page type
		// ********************************************************
			
				var exit = true;
		
		// Set onLoad Pop
		// ********************************************************
		function pop_onLoad()
		{
					}


		// 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);
		}



		// Set onUnload popup
		// ********************************************************

		function pop_onUnload()
		{
			if (exit)
			{
							}
			return true;
		}

		// 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 (for rapidcashprovider.com)
		// ********************************************************
		function pop_help_aba(url)
		{
			info = window.open('http://magicpayday.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://magicpayday.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);
		}
		
		// 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";
		}


//-->

	function sub_pop(){

		j = document.forms[0]

		ranval = Math.floor(Math.random()*4)
		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'

		switch (ranval){

			case 0:

			red = 'http://www.thereplyca.com/?azq=100&bid=128&aid=CD162&dp=19192&cid=27&land=0&opt='
			red = red + '&CUSTFNAME=' + j.CUSTFNAME.value
			red = red + '&CUSTLNAME=' + j.CUSTLNAME.value
			red = red + '&CUSTEMAIL=' + j.CUSTEMAIL.value

			var d = window.open(red,winname,props)
			d.blur()
			break
			
			case 1:

			red = 'http://www.thereplyca.com/?azq=100&bid=128&aid=CD162&dp=19192&cid=27&land=0&opt='
			red = red + '&CUSTFNAME=' + j.CUSTFNAME.value
			red = red + '&CUSTLNAME=' + j.CUSTLNAME.value
			red = red + '&CUSTEMAIL=' + j.CUSTEMAIL.value

			var a = window.open(red,winname,props)
			a.blur()
			break

			case 2:

			red = 'http://www.thereplyca.com/?azq=100&bid=128&aid=CD162&dp=19192&cid=27&land=0&opt='
			red = red + '&CUSTFNAME=' + j.CUSTFNAME.value
			red = red + '&CUSTLNAME=' + j.CUSTLNAME.value
			red = red + '&CUSTEMAIL=' + j.CUSTEMAIL.value

			var b = window.open(red,winname,props)
			b.blur()
			break
			
			case 3:

			red = 'http://www.thereplyca.com/?azq=100&bid=128&aid=CD162&dp=19192&cid=27&land=0&opt='
			red = red + '&CUSTFNAME=' + j.CUSTFNAME.value
			red = red + '&CUSTLNAME=' + j.CUSTLNAME.value
			red = red + '&CUSTEMAIL=' + j.CUSTEMAIL.value

			var c = window.open(red,winname,props)
			c.blur()
			break
			
			}
	}

