(function($) {
    $.fn.oldButtonClickEvent = function(){
        var e = $(this);
        /*if($("#slide-out-form").css("bottom")=='-350px') {
		    $("#page").val($(this,"a").attr("title"));
            $("#fade-controls").animate({left:"-380"},400);
            $("#slide-out-form").animate({bottom:"0px"},700);
            $("#slide-out-form").queue(function(){
                e.animate({right:"-55px"},400);
            $(this).dequeue();
            });
        }*/
		
		if($("#calculator-slideout").css("bottom")=='-350px') {
            $("#page").val($(this,"a").attr("title"));
            $("#fade-controls").animate({left:"-380"},400);
            $("#calculator-slideout").animate({bottom:"0px"},700);
            $("#calculator-slideout").queue(function(){
                e.animate({right:"-55px"},400);
            $(this).dequeue();
            });
        }

    }
})(jQuery);
function move_image(){if(zindex>3){zindex=0;}
var link=$("#fadeimg-"+current_stage).attr("href");var title=$("#fadeimg-"+current_stage).attr("title");if(link){$("#apply-now-button-link").attr("href",link);$("#apply-now-button-link").attr("title",title);$(".fade-link a").removeClass("fade-link-active");$("#fadeimg-"+current_stage).addClass("fade-link-active");$(".fade-link a").each(function(){if($(this).attr("class")!='fade-link-active'){$(this).addClass("fade-link-notactive");}});}
if($("#image-fading-div").css("display")=='none'){$("#image-fading-div").css("backgroundPosition","0px -"+top_side+"px");$("#image-fading-div").css("z-index",zindex);$("#image-fading-div").fadeIn(600);$("#image-fading-div2").fadeOut(800);}else{$("#image-fading-div2").css("backgroundPosition","0px -"+top_side+"px");$("#image-fading-div2").css("z-index",zindex);$("#image-fading-div2").fadeIn(600);$("#image-fading-div").fadeOut(800);}
top_side=(top_side+pre_img_height)-0;current_stage=(current_stage+1)-0;if(top_side>=img_height){current_stage=start_stage;top_side=start_pos;}
zindex++;setTimeout(function(){move_image();},3500);}
function update_loan_month(){var amount=$("#amount").val();var years=$("#period").val();var apr=$("#apr").val();var apr=((amount/100)*apr)*years;amount=(amount-0)
var total=(amount+apr)/(12*years);var de_s=total;var de_e=total;var total=total.toFixed(0);var total_interest=(total*12)*years;$("#total_amount").html(total_interest);var total_charge=(total_interest-amount);$("#total_interest").html(total_charge);$("#monthly_pay").html(total);}
$(function(){update_loan_month();$("#slider-range-min").slider({range:"min",value:5000,min:5000,max:100000,step:500,slide:function(event,ui){var amount=ui.value;var amount=amount.toFixed(0);$("#amount").val(amount);update_loan_month();}});$("#slider-range-min-period").slider({range:"min",value:5,min:5,max:25,slide:function(event,ui){$("#period").val(ui.value);update_loan_month();}});$("#slider-range-apr").slider({range:"min",value:15.9,min:7.9,max:29.9,step:0.1,slide:function(event,ui){$("#apr").val(ui.value);update_loan_month();}});$(".form-apply-button").click(function(){var formd=$("#apply").serialize();$.ajax({type:"POST",url:"/apply",data:formd,success:function(msg){msg.replace('\n',"\n");if(msg){alert(msg);}else{$(".loan-form-hold").fadeOut(400);$(".loan-form-copy").fadeOut(400);$("#form-complete").fadeIn(400);setTimeout(function(){$("#sendfriend-slideout").animate({bottom:"-350px"},0);$("#calculator-slideout").animate({bottom:"-350px"},0);$("#slide-out-form").animate({bottom:"-350px"},500);$("#slide-out-form").queue(function(){$("#apply-now-button").animate({right:"0px"},400);$("#fade-controls").animate({left:"0"},400);$(this).dequeue();});},3000);}}});return false;});$(".form-apply-button-friend").click(function(){var formd=$("#friend").serialize();$.ajax({type:"POST",url:"/friend",data:formd,success:function(msg){msg.replace('\n',"\n");if(msg){alert(msg);}else{$("#friends-wrapper").css("display","none");$("#friend-complete").fadeIn(400);setTimeout(function(){$("#sendfriend-slideout").animate({bottom:"-350px"},500);$("#slide-out-form").queue(function(){$("#apply-now-button").animate({right:"0px"},400);$("#fade-controls").animate({left:"0"},400);$("#friends-form").fadeIn(200);$("#friend-complete").fadeOut(400);$("#friends-wrapper").css("display","");$(this).dequeue();});},9000);}}});return false;});$("#close-form").click(function(){close_apply(true);});$(".apply-button, #appnow, .apply-action").click(function(){$('html,body').animate({scrollTop:0},1000);close_apply(false);$("#fade-controls").animate({left:"-380"},400);$("#page").val($(this,"a").attr("title"));$("#slide-out-form").animate({bottom:"0px"},700);$("#slide-out-form").queue(function(){$("#apply-now-button").animate({right:"-55px"},400);$(this).dequeue();});return false;});$("#apply-now-button").click(function(){var e=$(this);if($("#slide-out-form").css("bottom")=='-350px'){$("#page").val($(this,"a").attr("title"));$("#fade-controls").animate({left:"-380"},400);$("#slide-out-form").animate({bottom:"0px"},700);$("#slide-out-form").queue(function(){e.animate({right:"-55px"},400);$(this).dequeue();});}
if($("#slide-out-form").css("bottom")=='0px'){$("#slide-out-form").animate({bottom:"-350px"},500);e.addClass("apply-now-button");e.removeClass("apply-now-button-close");}
return false;});$('.text-content').jScrollPane({showArrows:true});$("#social-tab").animate({right:"-50px"},300);$("#social-tab1").click(function(){$("#social-tab1").animate({right:"-50px"},300);$("#social-tab1").queue(function(){$("#social-tab").animate({right:"0px"},300);});});});function start_scroll(){img.src='/templates/images/image-roll.jpg';img_height=img.height;setTimeout(function(){move_image();},3500);}
function fav_hit(type){$.post("/scripts/fav_hit.php?type="+type,function(data){});}
$(document).ready(function(){if(window.opera){if(!$("a.jqbookmark").attr("rel")){$("a.jqbookmark").attr("rel","sidebar");}}
$(".add-faves").click(function(event){fav_hit('fav');if(!window.opera)
event.preventDefault();var url=this.href;var title=this.title;if(window.sidebar){window.sidebar.addPanel(title,url,"");}else if(window.external){window.external.AddFavorite(url,title);}else if(!window.opera){alert('Unfortunately, this browser does not support the requested action,'+' please bookmark this page manually.');}});$("#add-calc").click(function(){$('html,body').animate({scrollTop:0},600);fav_hit('calc');close_apply(false);$("#fade-controls").animate({left:"-380"},400);$("#calculator-slideout").animate({bottom:"0px"},700);$("#calculator-slideout").queue(function(){$("#apply-now-button").animate({right:"-55px"},400);$(this).dequeue();});});$("#calc-close").click(function(){fader_reset();});$("#calc-proceed").click(function(){var amount=$("#amount").val();$("#loan_amount").val(amount);$("#fade-controls").animate({left:"-380"},400);$("#page").val($(this,"a").attr("title"));close_apply(false);$("#slide-out-form").animate({bottom:"0px"},700);$("#slide-out-form").queue(function(){$("#apply-now-button").animate({right:"-55px"},400);$(this).dequeue();});});$("#calc-close").click(function(){fader_reset();});$("#send-friend").click(function(){$('html,body').animate({scrollTop:0},600);close_apply(false);$("#fade-controls").animate({left:"-380"},400);$("#sendfriend-slideout").animate({bottom:"0px"},700);$("#sendfriend-slideout").queue(function(){$("#apply-now-button").animate({right:"-55px"},400);$(this).dequeue();});});$("#friend-close").click(function(){fader_reset();});$("#watch-video").click(function(){fav_hit('video');var f=document.getElementById('iframe_move');f.contentWindow.location.reload(true);$("#lightbox-bg").slideDown(600);var pos_height=($(window).height()/2)-150;$("#video-placeholder").css("margin",pos_height+"px auto 0px auto");});$("#video-placeholder-close").click(function(){$("#lightbox-bg").css("display","none");});$(".top-contact").click(function(){$('html,body').animate({scrollTop:600},1000);});var margin=125/2;var height=125;var width=590;$("#image2").stop().css({height:'0px',width:''+width+'px',marginTop:''+margin+'px'});setTimeout(function(){domoveimage()},8000);function domoveimage(){setTimeout(function(){domoveimage();moveimage();},8000);}
function moveimage(){if($("#image1").css("height")=='125px'){$("#image2").stop().css({height:'0px',width:''+width+'px',marginTop:''+margin+'px'});$("#image1").stop().animate({height:'0px',width:''+width+'px',marginTop:''+margin+'px'},{duration:400});$("#image1").queue(function(){$("#image2").stop().animate({height:''+height+'px',width:''+width+'px',marginTop:'0px'},{duration:400});$(this).dequeue();});}else{$("#image2").stop().animate({height:'0px',width:''+width+'px',marginTop:''+margin+'px'},{duration:400});$("#image1").stop().css({height:'0px',width:''+width+'px',marginTop:''+margin+'px'});$("#image2").queue(function(){$("#image2").css("height","0px");$("#image1").stop().animate({height:''+height+'px',width:''+width+'px',marginTop:'0px'},{duration:400});$(this).dequeue();});}}
$(".top-contact").mouseenter(function(){moveimage();}).mouseleave(function(){moveimage();});});function close_apply(move_in){$("#slide-out-form").animate({bottom:"-350px"},500);$("#calculator-slideout").animate({bottom:"-350px"},500);$("#sendfriend-slideout").animate({bottom:"-350px"},500);if(move_in){$("#slide-out-form").queue(function(){$("#apply-now-button").animate({right:"0px"},400);$("#fade-controls").animate({left:"0"},400);$(this).dequeue();});}}
function fader_reset(){$("#slide-out-form").animate({bottom:"-350px"},500);$("#slide-out-form").queue(function(){$("#apply-now-button").animate({right:"0px"},400);$("#fade-controls").animate({left:"0"},400);$(this).dequeue();});$("#calculator-slideout").animate({bottom:"-350px"},500);$("#calculator-slideout").queue(function(){$("#apply-now-button").animate({right:"0px"},400);$("#fade-controls").animate({left:"0"},400);$(this).dequeue();});$("#sendfriend-slideout").animate({bottom:"-350px"},500);$("#sendfriend-slideout").queue(function(){$("#apply-now-button").animate({right:"0px"},400);$("#fade-controls").animate({left:"0"},400);$(this).dequeue();});}
