

$(document).ready(function()
{

var $redirect = 1;

$('#mainnav li ul').pngFix( );
$('div.a').pngFix( );
$(document).pngFix( );
	
$('#tellfriend').hide();


$('#footernav li a.tellfriend').click(function(e){
	$('ul#footernav li a.tellfriend').addClass('active');
	e.preventDefault();
	$('#tellfriend').show();
	
	});

$('#tellfriend img.close').click(function(e){
	$('ul#footernav li a.tellfriend').removeClass('active');
	$('div#tellfriend').hide();
	 });
	
var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);

if (jQuery.browser.msie && (ie55 || ie6)) 
	{
	$('#mainnav li div.sub').append('<iframe></iframe>');
	}
	
/* ------------------------ submitted forms ------------------------  */

	$("#loanfinder").submit(function(e){
		$redirect = $red11;
		
		var $red11 = "11";  $red11 = "apply-for-personal-loan.html";
		var $red13 = "13";
		var $red14 = "14";
		var $red15 = "16";		
		var $red16 = "16";

		var $red21 = "21";	$red21 ="apply-for-installment-loan.html";
		var $red23 = "23";			

		var $red31 = "31";	$red31 = "apply-for-cash-advance.html";
		var $red34 = "33";		
		var $red34 = "34";

		var  $red41 = "41"; $red41 ="apply-for-auto-loan.htm";
		var  $red42 = "42";		

		var  $red51 = "51"; $red51 ="apply-for-student-loans.html";
		
		var  $red94 = "94";
		var  $red95 = "95";


		
		
		
		
		var $loantype = $("#loanfinder #floantype").val();
		var $floanamount = $("#loanfinder #floanamount").val();		
		var $fcreditestimation = $("#loanfinder #fcreditestimation").val();	
		
	/*
            	<select name="floantype" id="floantype">
                	<option value="personal">Personal loans</option>
                	<option value="cash">Cash Advance</option>
                	<option value="student">Student Loans</option>
                	<option value="car">Car Loans</option> 
                	<option value="home">Home Loans </option>
                    <option value="business">Business Loans </option>					
                </select>	
	          
            <select name="floanamount" id="floanamount">
                	<option value="1">100-500</option>
                	<option value="2">500-1,000</option>
                	<option value="3">1,000-1,500</option>    
              		<option value="4">1,500-2,500</option>
                	<option value="5">2,500-5,000</option>    
              		<option value="6">5,000-10,000</option>
              		<option value="7">10,000-25,000</option>
              		<option value="8">25,000-1,000,000</option>  					
             </select>
	
	
	         <select name="fcreditestimation" id="fcreditestimation">
                	<option value="1">No Credit</option>
                	<option value="2">Very Bad credit</option>
                	<option value="3">Bad</option>   
                	<option value="4">Fair</option>
                	<option value="5">Good</option>                                                           
                	<option value="6">Excellent</option>                
                </select>
	
	*/	

switch ($loantype) {
case "personal": 
	if (  ($floanamount==7 || $floanamount==8)  && ($fcreditestimation == 1 || $fcreditestimation == 2 || $fcreditestimation == 3 || $fcreditestimation == 4)  )
				$redirect = $red16;
				
	if ( $fcreditestimation == 5 ||   $fcreditestimation == 6 )
				$redirect = $red14;
				
	if (  ($floanamount==3 || $floanamount==4 || $floanamount==6)  && ($fcreditestimation == 2 || $fcreditestimation == 3)  )
				$redirect = $red21;		
				
	if (  (($floanamount==4 || $floanamount==5 || $floanamount==6)  && ($fcreditestimation == 1))  || ($fcreditestimation == 1 || $fcreditestimation == 2) )
				$redirect = $red31;	
				
	if (  ($floanamount==5 || $floanamount==6)  && ($fcreditestimation == 4)  )
				$redirect = $red13;						
				
	if (  ($floanamount==5)  && ($fcreditestimation == 2 || $fcreditestimation == 3)  )
				$redirect = $red23;	
				
	if (  ($floanamount==3 || $floanamount==4 )  && ($fcreditestimation == 4)  )
				$redirect = $red11;					
			/*end personal*/
	break;
case "cash": 
	if (  ($floanamount==7 || $floanamount==8)  && ($fcreditestimation == 1 || $fcreditestimation == 2 || $fcreditestimation == 3 || $fcreditestimation == 4)  )
				$redirect = $red16;
				

				
	if (  ($floanamount==4 || $floanamount==5 || $floanamount==6)  || ($floanamount==3 && ($fcreditestimation == 1 || $fcreditestimation == 2 || $fcreditestimation == 3 || $fcreditestimation == 4 || $fcreditestimation == 5))  || ($floanamount==2 && ($fcreditestimation==5 || $fcreditestimation==6)))
				$redirect = $red21;		


	if ( $fcreditestimation == 1 || ($fcreditestimation == 3 && $fcreditestimation==6)|| ($fcreditestimation == 2 && ($fcreditestimation==1 || $fcreditestimation==2 || $fcreditestimation==3 || $fcreditestimation==4)))
				$redirect = $red31;

			
	if (  ($floanamount==7 || $floanamount==8)  && ($fcreditestimation == 5 || $fcreditestimation == 6))
				$redirect = $red34;	
	break;
case "student": 
	$redirect = $red51;
	break;
case "car": 
	if ($fcreditestimation == 1 || $fcreditestimation == 2 || $fcreditestimation == 3)
			$redirect = $red42;	
	else 
			$redirect = $red41;	
	break;
case "home": 
	if (  ($floanamount==1 || $floanamount==2 || $floanamount==3 || $floanamount==4 || $floanamount==5 || $floanamount==6)  && ($fcreditestimation == 1 || $fcreditestimation == 2) )
				$redirect = $red15;
	else if (  ($floanamount==1 || $floanamount==2 || $floanamount==3 || $floanamount==4 || $floanamount==5 || $floanamount==6)  && ($fcreditestimation == 4 || $fcreditestimation == 5 || $fcreditestimation == 6) )
						$redirect = $red94;
	
	if (  (($floanamount==1 || $floanamount==2 || $floanamount==3 || $floanamount==4 || $floanamount==5 || $floanamount==6)  && $fcreditestimation == 3) || ($floanamount==8  && ($fcreditestimation == 2 || $fcreditestimation == 3)))
				$redirect = $red95;
	if ( $floanamount==8  && ($fcreditestimation == 4 || $fcreditestimation == 5 || $fcreditestimation == 6))
		$redirect = $red95;	
	else if ( $floanamount==8  && $fcreditestimation == 1)
			$redirect = $red11;	
	break;
case "business": 
	if ($floanamount==1 || $floanamount==2 || $floanamount==3)
		$redirect = $red34;
	else if ($floanamount==5 || $floanamount==6)
		$redirect = $red33;
		else 
			$redirect = $red11;
	break;	
default: $redirect = $red11;
}

/*		
		if ($loantype=="personal")
			{
	
			}
	*/		
			
		e.preventDefault();
		window.location=$redirect;
		
		//alert ($redirect);
									 
		 });
	
	
/* ------------------------ validation ------------------------  */	
	// if needed add validation by following the example
	$("#formcontactus").validate({
		rules: {
			"First Name": "required",
			"Last Name": "required",
			"Email": {
				required: true,
				email: true
			}
		},
		messages: {
			"First Name": "Please enter your first name.",
			"Last Name": "Please enter your last name.",
			"Email": "Please enter your email."	
		}
	});

/*
	$("#formcontactus").validate({
		rules: {
			"ftname": "required",
			"ftsmonth": "required",
			"ftsyear": "required",			
			"ftmessage": "required"
		},
		messages: {
			"ftname": "Please enter your name.",
			"ftsmonth": "Please enter the month of your surgery.",
			"fmlname": "Please enter the year of your surgery.",
			"ftmessage": "Please write a testimonial."			
		}
	});
	*/
	
	
});

