/*
  jQuery Custom Functions 
  Author: Yahya Mubashir	
  Author URI: http://www.cressettech.com
*/
$(document).ready(function(){
	  	
		$('#slider').nivoSlider({
		effect:'random', //Specify sets like: 'fold,fade,sliceDown'
		slices:15,
		animSpeed:500, //Slide transition speed
		pauseTime:3000,
		startSlide:0, //Set starting Slide (0 index)
		directionNav:false, //Next & Prev
		directionNavHide:true, //Only show on hover
		controlNav:false, //1,2,3...
		controlNavThumbs:false, //Use thumbnails for Control Nav
      controlNavThumbsFromRel:false, //Use image rel for thumbs
		controlNavThumbsSearch: '.jpg', //Replace this with...
		controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
		keyboardNav:true, //Use left & right arrows
		pauseOnHover:false, //Stop animation while hovering
		manualAdvance:false, //Force manual transitions
		captionOpacity:0.8, //Universal caption opacity
		beforeChange: function(){},
		afterChange: function(){},
		slideshowEnd: function(){} //Triggers after all slides have been shown
	});
		
		
		
		
		$('#401k').mouseover(function() {
	  		$('#sub_menu_401k').show(600);
			$('#sub_menu_additional_funding').hide(600);
			$('#sub_menu_equipment_financing').hide(600);
	  	});
		$('#additional_funding').mouseover(function() {
	  		$('#sub_menu_401k').hide(600);
			$('#sub_menu_additional_funding').show(600);
			$('#sub_menu_equipment_financing').hide(600);
	  	});
		$('#equipment_financing').mouseover(function() {
	  		$('#sub_menu_401k').hide(600);
			$('#sub_menu_additional_funding').hide(600);
			$('#sub_menu_equipment_financing').show(600);
	  	});
		
		$('.hide').mouseover(function() {
	  		$('#sub_menu_401k').hide(600);
			$('#sub_menu_additional_funding').hide(600);
			$('#sub_menu_equipment_financing').hide(600);
			$('#sub_menu_check_by_phone').hide(600);
			$('#sub_menu_echeck_online').hide(600);
			$('#sub_menu_check_guarantee').hide(600);
			$('#sub_menu_check_21').hide(600);
			$('#sub_menu_retail_restaurant').hide(600);
			$('#sub_menu_mail_phone_order').hide(600);
			$('#sub_menu_internet_processing').hide(600);
			$('#sub_menu_mobile_wireless').hide(600);
	  	});
		
		// for check processing menu
		$('#check_by_phone').mouseover(function() {
	  		$('#sub_menu_check_by_phone').show(600);
			$('#sub_menu_echeck_online').hide(600);
			$('#sub_menu_check_guarantee').hide(600);
			$('#sub_menu_check_21').hide(600);
	  	});
		$('#echeck_online').mouseover(function() {
	  		$('#sub_menu_check_by_phone').hide(600);
			$('#sub_menu_echeck_online').show(600);
			$('#sub_menu_check_guarantee').hide(600);
			$('#sub_menu_check_21').hide(600);
	  	});
		$('#check_guarantee').mouseover(function() {
	  		$('#sub_menu_check_by_phone').hide(600);
			$('#sub_menu_echeck_online').hide(600);
			$('#sub_menu_check_guarantee').show(600);
			$('#sub_menu_check_21').hide(600);
	  	});
		$('#check_21').mouseover(function() {
	  		$('#sub_menu_check_by_phone').hide(600);
			$('#sub_menu_echeck_online').hide(600);
			$('#sub_menu_check_guarantee').hide(600);
			$('#sub_menu_check_21').show(600);
	  	});
		
		// for merchant services menu
		
		$('#retail_restaurant').mouseover(function() {
	  		$('#sub_menu_retail_restaurant').show(600);
			$('#sub_menu_mail_phone_order').hide(600);
			$('#sub_menu_internet_processing').hide(600);
			$('#sub_menu_mobile_wireless').hide(600);
	  	});
		$('#mail_phone_order').mouseover(function() {
	  		$('#sub_menu_retail_restaurant').hide(600);
			$('#sub_menu_mail_phone_order').show(600);
			$('#sub_menu_internet_processing').hide(600);
			$('#sub_menu_mobile_wireless').hide(600);
	  	});
		$('#internet_processing').mouseover(function() {
	  		$('#sub_menu_retail_restaurant').hide(600);
			$('#sub_menu_mail_phone_order').hide(600);
			$('#sub_menu_internet_processing').show(600);
			$('#sub_menu_mobile_wireless').hide(600);
	  	});
		$('#mobile_wireless').mouseover(function() {
	  		$('#sub_menu_retail_restaurant').hide(600);
			$('#sub_menu_mail_phone_order').hide(600);
			$('#sub_menu_internet_processing').hide(600);
			$('#sub_menu_mobile_wireless').show(600);;
	  	});

// expression check 
/*^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$*/


// store url for current page as global variable
    current_page = document.location.href
 //alert(current_page);
    // apply selected states depending on current page
    if (current_page.match(/index/)) {
		//alert(current_page);
        $("ul.megamenu li:eq(0) a").addClass('selected');
		//$("ul.megamenu li:eq(0)").addClass('selected');
    }/* else if (
			  current_page.match(/business_cash_advance/) || 
			  current_page.match(/business_cash_advance_how_it_works/) ||
			  current_page.match(/business_cash_advance_getting_funded/) ||
			  current_page.match(/business_cash_advance_how_to_qualify/) ||
			  current_page.match(/why_choose_us/)) {
        $("ul.megamenu li:eq(1) a").addClass('selected');
    } else if (
			   current_page.match(/business_loans/) ||
			   current_page.match(/ira_401k_business_financing/) || 
			   current_page.match(/medical_financing/) || 
			   current_page.match(/equipment_leasing/) || 
			   current_page.match(/small_business_loans/) || 
			   current_page.match(/sba_loans/) || 
			   current_page.match(/working_capital/) ||
			   current_page.match(/restaurant_loans/) || 
			   current_page.match(/business_lines_of_credit/) || 
			   current_page.match(/unsecured_loans/) ||
			   current_page.match(/accounts_receivable_financing/) || 
			   current_page.match(/ira_401k_business_financing/) || 
			   current_page.match(/401k_business_financing_advantages/) ||
			   current_page.match(/401k_business_financing_how_it_works/) || 
			   current_page.match(/medical_financing/) || 
			   current_page.match(/minority_business_loans/) ||
			   current_page.match(/franchise_financing/) || 
			   current_page.match(/bad_credit_business_loans/) || 
			   current_page.match(/small_business_funding_other/) ||
			   current_page.match(/home_based_business_loans/) || 
			   current_page.match(/personal_business_loans/) || 
			   current_page.match(/commercial_loans/) ||
			   current_page.match(/small_business_loans_for_women/) || 
			   current_page.match(/canadian_funding/) || 
			   current_page.match(/merchant_check_advance/) ||
			   current_page.match(/new_business_loan/) || 
			   current_page.match(/fast_business_loans/) || 
			   current_page.match(/poor_credit_business_loans/) ||
			   current_page.match(/signature_loans/) || 
			   current_page.match(/venture_capital/) || 
			   current_page.match(/purchase_order_funding/) ||
			   current_page.match(/government_small_business_loan/) || 
			   current_page.match(/secured_loans/) || 
			   current_page.match(/restaurant_equipment_loans/) ||
			   current_page.match(/medical_equipment_loans/)
			   ) {
        $("ul.megamenu li:eq(2) a").addClass('selected');
    } else if (
			   current_page.match(/check_by_phone_group/) ||
			   current_page.match(/check_by_phone/) || 
			   current_page.match(/online_check_overview/) ||
			   current_page.match(/check_guarantee/) || 
			   current_page.match(/check_21/) || 
			   current_page.match(/check_conversion/) || 
			   current_page.match(/check_by_phone/) || 
			   current_page.match(/check_by_phone_how_it_works/) || 
			   current_page.match(/check_by_phone_why_us/) ||
			   current_page.match(/check_by_phone_rates_and_fees/) || 
			   current_page.match(/check_by_phone_frequently_asked_questions/) || 
			   current_page.match(/online_check_overview/) || 
			   current_page.match(/electronic_check_conversion_rates_and_fees/) || 
			   current_page.match(/electronic_check_conversion_payment_gateway/) || 
			   current_page.match(/electronic_check_conversion_check_verification/) ||
			   current_page.match(/electronic_check_conversion_faq/) || 
			   current_page.match(/check_21/) || 
			   current_page.match(/check_guarantee_frequently_asked_questions/) || 
			   current_page.match(/check_21/) || 
			   current_page.match(/check_21_equipment/)
			   ) {
        $("ul.megamenu li:eq(3) a").addClass('selected');
    }else if (
			   current_page.match(/merchant_services_group/) ||
			   current_page.match(/merchant_services/) ||
			   current_page.match(/mail_phone/overview/) ||
			   current_page.match(/merchant_service_moto_internet_overview/) ||
			   current_page.match(/wireless_and_mobile_credit_card_processing/) ||
			   current_page.match(/credit_card_machines/) ||
			   current_page.match(/point_of_sale_equipment/) ||
			   current_page.match(/lower_processing_rate/) ||
			   current_page.match(/merchant_services/) ||
			   current_page.match(/merchant_service_retail_processing_rates_and_fees/) ||
			   current_page.match(/merchant_service_retail_processing_faq/) ||
			   current_page.match(/mail_phone/overview/) ||
			   current_page.match(/merchant_service_moto_rates_and_fees/) ||
			   current_page.match(/merchant_service_moto_virtual_terminal/) ||
			   current_page.match(/merchant_service_moto_frequently_asked_questions/) ||
			   current_page.match(/merchant_service_moto_internet_overview/) ||
			   current_page.match(/merchant_service_internet_payment_gateway/) ||
			   current_page.match(/merchant_service_internet_rates_and_fees/) ||
			   current_page.match(/merchant_service_internet_ecommerce/) ||
			   current_page.match(/merchant_service_internet_faq/) ||
			   current_page.match(/merchant_service_internet_shopping_carts/) ||
			   current_page.match(/wireless_and_mobile_credit_card_processing/) ||
			   current_page.match(/merchant_service_mobile_wireless_rates_and_fees/) ||
			   current_page.match(/merchant_service_mobile_wireless_faq1/)
			   ) {
        $("ul.megamenu li:eq(4) a").addClass('selected');
    }*/

function extendPanel(event) {
    		var thisPanel = $(this).parents('.panel');
    		$('.panel .bar').unbind('click',extendPanel);
			$('.panel .bar').unbind('click',extendPanel);
    		expand.width = "960px"; expand.left = 0;
			collapse.width = + thisPanel.width(); collapse.left = thisPanel.position().left;
		  thisPanel
			.addClass('current')
			.css('zIndex',200)
		    .animate(expand,
		      'normal', function() { $('.panel.current .bar').one('click',returnPanels); $('.panel').not('.current').hide(); } );
		     $('.current .default').hide();
		     $('.current .extended').show('fast');
    	}
    	
    	function returnPanels(event) {
    		var thisPanel = $('.panel.current');
    		$('.panel.current .default').show();
    		$('.panel.current .extended').hide();
    		thisPanel
    			.css('top',0)
    			.animate(collapse,
    		'normal', function() { $('.panel .bar').bind('click',extendPanel); thisPanel.css('zIndex',2); thisPanel.removeClass('current'); });
    		$('.panel').show();
    	}
    	
		var expand = Object();
    	var collapse = Object();
    	
    	$('.changed').hide();
    	$('.panel .bar').bind('click',extendPanel);
    	$('.panel .learnMore').bind('click',extendPanel);
    	$('.panel .back').bind('click',returnPanels);
		
		
		function extendPanel1(event) {
    		var thisPanel1 = $(this).parents('.panel1');
    		$('.panel1 .bar1').unbind('click',extendPanel1);
    		expand.width = "640px"; expand.left = 0;
			collapse.width = + thisPanel1.width(); collapse.left = thisPanel1.position().left;
		  thisPanel1
			.addClass('current')
			.css('zIndex',200)
		    .animate(expand,
		      'normal', function() { $('.panel1.current .bar1').one('click',returnPanels1); $('.panel1').not('.current').hide(); } );
		     $('.current .default1').hide();
		     $('.current .extended1').show('fast');
    	}
    	
    	function returnPanels1(event) {
    		var thisPanel1 = $('.panel1.current');
    		$('.panel1.current .default1').show();
    		$('.panel1.current .extended1').hide();
    		thisPanel1
    			.css('top',0)
    			.animate(collapse,
    		'normal', function() { $('.panel1 .bar1').bind('click',extendPanel1); thisPanel1.css('zIndex',2); thisPanel1.removeClass('current'); });
    		$('.panel1').show();
    	}
    	
		var expand1 = Object();
    	var collapse1 = Object();
    	
    	$('.changed').hide();
    	$('.panel1 .bar1').bind('click',extendPanel1);
    	$('.panel1 .learnMore1').bind('click',extendPanel1);
    	$('.panel1 .back1').bind('click',returnPanels1);



$(function() {
		$("#tabs").tabs();
	});

jQuery(function(){
        var SelfLocation = window.location.href.split('?');
        switch (SelfLocation[1]) {
          case "justify_right":
            jQuery(".megamenu").megamenu({ 'justify':'right' });
            break;
          case "justify_left":
          default:
            jQuery(".megamenu").megamenu();
        }
      });
});

