$(function(){
	$('ul.menu').superfish({ 
		delay:       1000,                            // one second delay on mouseout 
		animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
		speed:       'slow',                          // faster animation speed 
		autoArrows:  true,                           // disable generation of arrow mark-up 
		dropShadows: false                            // disable drop shadows 
     }); 
	
	$('#slider').SexySlider({
      width  : 964,
      height : 376,
      navigation    : '#controls', // #id of div to place navigation buttons.
		control       : '#pagination',    // #id of div to place control buttons.
		strips        : 5,   // number of strips
		auto          : true, // autoslider
		autopause     : true, // stop autoslider after click
		delay         : 3000, // delay between images in ms
		stripSpeed    : 500,  // delay beetwen strips in ms
		titleOpacity  : 1,  // opacity of title
		titleSpeed    : 1000, // speed of title appereance in ms
		titlePosition : 'bottom', // top, right, bottom, left
		titleStyle    : false, // 'auto', false 
		direction     : 'alternate', // left, right, alternate, random
		effect        : 'random' // curtain, zipper, wave, fountain, cascade, fade, random
    });
	$('#slider-v2').SexySlider({
      width  : 654,
      height : 256,
      navigation    : '#controls', // #id of div to place navigation buttons.
		control       : '#pagination',    // #id of div to place control buttons.
		strips        : 5,   // number of strips
		auto          : true, // autoslider
		autopause     : true, // stop autoslider after click
		delay         : 3000, // delay between images in ms
		stripSpeed    : 500,  // delay beetwen strips in ms
		titleOpacity  : 1,  // opacity of title
		titleSpeed    : 1000, // speed of title appereance in ms
		titlePosition : 'bottom', // top, right, bottom, left
		titleStyle    : false, // 'auto', false 
		direction     : 'alternate', // left, right, alternate, random
		effect        : 'random' // curtain, zipper, wave, fountain, cascade, fade, random
    });
	
	$('#smlogo').css({ "opacity" : 0.6 });

	$('#smlogo').hover(
	function(){
		$(this).stop().animate({ opacity: 1 }, 150);
	},
	function(){
		$(this).stop().animate({ opacity: 0.6 }, 150);
	
	});
	
// search related
	$(".search_trigger").click(function(){
		$(this).toggleClass("active");
		$('#advanced-search').slideToggle("slow");
		return false;
	});
	
	
//Hide (Collapse) the toggle containers on load
	$(".toggle_container").hide();

	//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
	$("h2.trigger").click(function(){
		$(this).toggleClass("active").next().slideToggle("slow");
		return false; //Prevent the browser jump to the link anchor
	});
	
	
	
// Monthly Payment Calculator

function roundNumber(num, dec) {
    var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
    return result;
}

function getRate(r, l, m) {
    var intRate = (parseFloat(r) / 100) / 12;
    var loan = l;
    var months = parseFloat(m) * 12;
    var bottom = 1 - (1 / Math.pow((1 + intRate), months));
    var top = intRate * loan;

    var t = top / bottom;

    $('#results').html(roundNumber(t, 2));
}

$('input').change(function() {
    getRate($('.rate').val(), $('.loan').val(), $('.months').val());
}).blur(function() {
    $(this).change();
}).focus(function() {
    $(this).change();
});

$('.loan').focus();

$(function(){
    $("form#monthly_cal").validate({
  rules: {
	  
	  
    loan: {
      digits: true
    },
	rate: {
		digits: true
	},
	months: {
		digits: true
	}

	
  }
	});
});



});
