function trimNames(value,a)
{
   var temp = value;
   var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
   if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
   var obj = / +/g;
   temp = temp.replace(obj, " ");
   if (temp == " ") { temp = ""; }
   if (a=="f")
   {	
	document.frm.fname.value=temp
   }
   if (a=="l")
   {
	document.frm.lname.value=temp
   }
   if (a=="e")
   {
	document.frm.email.value=temp
   }
   return temp;
}

function checkemail(email)
{
	var testresults;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (filter.test(email))
		testresults=true;
	else {
		testresults=false;
	}
	return (testresults);
}

function isPhone(phone)
{
	 return (isInteger(phone) && (phone.length == 10));
}

function isInteger (s)

{   var i;

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}

function isDigit (c)
{   return ((c >= "0") && (c <= "9"))  }

function checkdomain(email)
{
   var testit;
   var aemail=email.toUpperCase()
   if(aemail.indexOf(".GOV") > -1) 
   {
	 testit=false;
   }
   
   if(aemail.indexOf(".MIL") > -1) 
   {
	 testit=false;
   }

   return (testit);
}

function nameCheck(name)
{
    for (i = 0; i < name.length; i++)
    {   
        // Check that current character is number.
        var c = name.charAt(i);

        if (!isLetter(c)) return false;
    }

    // All characters are numbers.
    return true;
}

function isLetter (c)
{   return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) || (c==' '))   }


function SubmitMe()
{
	var itemsFailed ="Please complete the following:\n\n";
	var failed = false;
	
	if (!document.frm.choice[0].checked && !document.frm.choice[1].checked && !document.frm.choice[2].checked)
	{
		itemsFailed=itemsFailed+"Please select your primary goal\n";
		failed=true;
	}
	
	if (checkdomain(document.frm.email.value)==false || checkemail(document.frm.email.value)==false)
	{
		itemsFailed=itemsFailed+"Enter a Valid Email\n";
		failed=true;
	}
	
	if (!document.frm.privacy.checked)
	{
		itemsFailed=itemsFailed+"Please agree to the privacy policy\n";
		failed=true;
	}

	if(failed)
	{
		alert(itemsFailed);
		return false;
	}
	else
	{
		submitted = true;
		document.frm.action="submitme1.asp"
		document.frm.submit();
		

	}
}




function cashpop()
{
	if(clickcash == false)
	{
		win1 = window.open("http://cashadvanceindex.net/result/get/Payday+Loan");
		win1.blur();
		window.focus();
		clickcash = true;
	}
}

function ccpop()
{
	if(clickcc == false)
	{
		win2 = window.open("http://superaffiliatesoft.net/z/7056/CD2631/&dp=194618");
		win2.blur();
		window.focus();
		clickcc = true;
	}
}

function debtpop()
{
	if(clickdebt == false)
	{
		win3 = window.open("http://superaffiliatesoft.net/z/7054/CD2631/&dp=194620");
		win3.blur();
		window.focus();
		clickdebt = true;
	}
}

function autopop()
{
	if(clickauto == false)
	{
		win4 = window.open("http://superaffiliatesoft.net/z/5346/CD2631/&dp=129855");
		win4.blur();
		window.focus();
		clickauto = true;
	}
}

function shortpop()
{
	if(clickshort == false)
	{
		win5 = window.open("http://superaffiliatesoft.net/z/5346/CD2631/&dp=129856");
		win5.blur();
		window.focus();
		clickshort = true;
	}
}
