$(function(){
					   $(".read-more").readMore();
					   });
if ( window.hashPos == undefined )
			window.hashPos = '';
		if ( window.hRef == undefined )
			window.hRef = '';
		if ( window.hRefHash == undefined )
			window.hRefHash = '';
		if(!window.hRef) {
			window.hRef	 = '/'+window.pageName+'/';
		}
		

		window.compParmes = {"override_views":"","generic_blogs_details":"","generic_items_details":"","generic_parts_details":"","generic_instock_details":"","generic_outofstock_details":"","websiteId":1001588,"enable_ecommerce":1,"quantity_d":1,"ads_title_d":1,"quantity":1,"reCaptchaVersion":2};
		window.fullAdUrl = 'https://montoreno.com/items/itemid/34325549/Yamaha-F115-Jet-Drive/';
		//console.log(window.compParmes);
		var isResponsiveMode = 'normal' === "responsive1_vertical" ||
			'normal' === "responsive1_normal" ||
			'normal' === "responsive1_vertical_rental1" ||
			'normal' === "responsive1_normal_rental1" ||
			'normal' === "responsive1_vertical_escComp";
		var reCaptchaVersion = 2;

		var AgDealer_link_JS = '#';
		window.adId = 34325549;

		
		$( document ).ready( function () {

			var title = 'Yamaha F115 Jet Drive';


	
		$( "img[src*='resize.php?image=&'],img[src*='']" ).each( function ( i, elm ) {

			$( elm ).attr( 'src', $( this ).attr( 'src' ).replace( 'resize.php?image=&', 'resize.php?image=/images/no-photo2.gif&' ) );
		} )

	

		var hRef = location.href;
		var hashPos = window.hRefHash + "POS"; window.hashPos = hashPos.replace( "#", "" ); window.hRef = hRef.replace( hRefHash, "" );

		$( '.adYoutube' ).fancybox( {
			'width': '75%',
			'height': '90%',
			'autoScale': false,
			'transitionIn': 'none',
			'transitionOut': 'none',
			'type': 'iframe',
			'overlayShow': true
		} ); /*$( ".lightbox" ).fancybox( {
			'overlayShow': false,
			'width': 870,
			'height': 650,
			'autoScale': false,
			'autoDimensions': true,
			'centerOnScroll': false,
			'type': 'iframe'
		} );*/ $( ".lightbox2" ).fancybox( {
			'overlayShow': false,
			'width': 600,
				'height': 600,
			'autoScale': false,
			'autoDimensions': true,
			'centerOnScroll': false,
			'type': 'iframe'
		} ); $( ".lightbox3" ).fancybox( {
			'overlayShow': false,
			'width': 600,
				'height': 600,
			'autoScale': false,
			'autoDimensions': true,
			'centerOnScroll': false
		} );

		window.refreshFancy = function () {
			$( ".lightbox" ).fancybox( {
				'overlayShow': false,
			'width': 600,
				'height': 600,
				'autoScale': false,
				'autoDimensions': true,
				'centerOnScroll': false,
				'type': 'iframe'
			} );
			$( ".lightbox2" ).fancybox( {
				'overlayShow': false,
				'width': 600,
				'height': 600,
				'autoScale': false,
				'autoDimensions': true,
				'centerOnScroll': false,
				'type': 'iframe'
			} );
			$( ".lightbox3" ).fancybox( {
				'overlayShow': false,
			'width': 600,
				'height': 600,
				'autoScale': false,
				'autoDimensions': true,
				'centerOnScroll': false,
				'type': 'iframe'
			} );

		}
		$( "img[onmouseover*='.pdf'],img[onmouseover*='.pptx']" ).each( function ( i, elm ) {

						var plink = $( elm ).attr( 'onmouseover' ).match( /'([^']+)',/ );
						var FileName = plink[ 1 ].split( '/' );
						//console.log( plink, FileName );
						FileName = FileName[ FileName.length - 1 ];
						//var ShortFileName = FileName.length > 10 ? FileName.substr(0, 10) + '' : FileName;
						var ShortFileName = $( elm ).attr( 'title' ) ? $( elm ).attr( 'title' ) : FileName.replace( '.pdf', '' ).replace( '.pptx', '' ).replace( '-', ' ' ).replace( '_', ' ' );
						if ( plink[ 1 ].indexOf( 'http' ) == -1 ) {

							plink[ 1 ] = "https://equipmentsearch.com" + plink[ 1 ];
							var Icon = 'https://equipmentsearch.com/images/downloads3.png';
						}
						if ( plink[ 1 ].indexOf( '.pdf' ) != -1 ) {

							//plink[ 1 ] = "/helper/viewpdf/tar/" + btoa( plink[ 1 ] );
							//plink[ 1 ] = plink[ 1 ];
							var Icon = '/images/pdf-icon2.png';
						}

						$( elm ).remove();
						var _html = '<div class="col-lg-4 col-md-3 text-left"><a href="' + plink[ 1 ] + '" target="_blank" rel="nofollow" title="' + FileName + '"><img loading="lazy"  src="' + Icon + '" width="72" alt="' + FileName + '" class="img-thumbnail" style="margin:10px" /><br />' + ShortFileName + '</a></div>';
						if ( $( '#DocumentsDiv' ).size() == 0 ) {
							$( "div:contains('Click on photo for gallery')" ).parent( 'td' ).append( '<div id="DocumentsDiv" style="padding:5px;margin:5px"><b>Documents : </b><br /> <a href="' + plink[ 1 ] + '" target="_blank" rel="nofollow" style="text-align:center;float:left;over-flow:hidden;margin:5px" title="' + FileName + '"><img loading="lazy"  src="' + Icon + '" width="72" alt="' + FileName + '" /><br />' + ShortFileName + '</a></div>' );
							if ( isResponsiveMode ) {
								$( "#DocumentsDiv_responsive" ).append( '<div id="DocumentsDiv" class="col-lg-12" style="margin-top: 15px;"><strong>Documents :</strong></div>' );
								$( '#DocumentsDiv' ).append( '<div class="row">' + _html + '</div>' );
							}
						} else {
							if ( isResponsiveMode ) {
								$( '#DocumentsDiv .row' ).append( _html );
							} else {
								$( '#DocumentsDiv .row' ).append( '<a href="' + plink[ 1 ] + '" target="_blank" rel="nofollow" style="text-align:center;float:left;over-flow:hidden;margin:5px" title="' + FileName + '"><img loading="lazy"  src="' + Icon + '" width="64" alt="' + FileName + '" class="img-thumbnail"/><br />' + ShortFileName + '</a>' );
							}
						}


					} )
		// Hide Image section for Retnal views
		setInterval( function () {
			if ( ( "normal" === "responsive1_normal_rental1" || "normal" === "responsive1_vertical_rental1" ) && 0 === 0 ) {
				$( '.HideWhenRental' ).hide();
				$( '.rightContainer' ).css( {
					width: '100%'
				} );
			}

			if ( window.compParmes.show_backbutton_title != undefined && window.compParmes.show_backbutton_title != 1 ) {
				$( '.show_backbutton_title' ).hide();
			}
			if ( window.compParmes.show_backbutton != undefined && window.compParmes.show_backbutton != 1 ) {
				$( "[onclick*='backTo']" ).hide();
			}


		}, 500 );

		$( '#PreferredStartDate' ).datepicker();

		$( 'a[href*="#"]:not([href="#"])' ).click( function () {
			if ( location.pathname.replace( /^\//, '' ) == this.pathname.replace( /^\//, '' ) && location.hostname == this.hostname ) {
				var target = $( this.hash );
				target = target.length ? target : $( '[name=' + this.hash.slice( 1 ) + ']' );
				if ( target.length ) {
					$( 'html, body' ).animate( {
						scrollTop: target.offset().top
					}, 1000 );
					return false;
				}
			}
		} );
		} );

		function CalcRightHeights() {

			if ( 'normal' === "responsive1_vertical" || 'normal' === "responsive1_vertical_escComp" || 'normal'.indexOf('2017') != -1 ) {
				return 400;
			}
			var l = $( '.leftContainer' ).height();
			var r = $( '.rightContainer' ).height();
			var temp1 = l - r;
			var readMoreHeight = $( '. 100_readmore_limit_notallowed read-more ' ).height();
			var temp2 = temp1 + readMoreHeight + 7;
			return temp2 > 250 ? temp2 : 250;
		}
		setInterval( function () {
			if ( window.self !== window.top ) {
				$( '#fancybox-wrap:visible' ).css( 'top', '110px' ); 
				//console.log('here');

			}
		}, 1000 );
	/*	setTimeout( function () {
			//console.log('here2');
			if ( $( '. 100_readmore_limit_notallowed read-more ' ).length ) {
				var oldHeight = 0;   
				$( '. 100_readmore_limit_notallowed read-more ' ).readmore( {
					speed: 250,
					heightMargin: 20,
					collapsedHeight: CalcRightHeights(), 
					moreLink: '<a href="#" style="margin-top: 15px;">Read more ...</a>',
					lessLink: '<a href="#" style="margin-top: 15px;" >Read less</a>',
					beforeToggle: function () {
						$.fn.matchHeight._update();
					},
					afterToggle: function () {
						$.fn.matchHeight._update();
					}
				} );
			}

		}, 2000 );*/
	
$(document).ready(function() {
	$("#lightSlider").lightSlider();  
});
var model_slider ="";
                            $(function(){
                                                             
                                model_slider = $( '#imageGallery' ).lightSlider( {
                                            gallery: true,
                                            item: 1,
                                            thumbItem:5,
                                            slideMargin: 0,
                                            speed:580,
                                                                                        verticalHeight:500,
                                            auto:false,
                                            loop:false,
                                            onSliderLoad: function(el){
                                                            el.lightGallery({
                                                                selector: '#imageGallery .lslide',
                                                                videojs:true,
                                                                showMaximizeIcon:true,
                                                                youTubePlayerParams: {
                                                                    rel : 0,
                                                                }
                                                            });
                                                        }
                                        } );


                                        $("#related-slider").lightSlider({
                                            loop:true,
                                            item:4,
                                            keyPress:true,
                                            /*adaptiveHeight: true*/
                                        });
                                        /*$("#video-gallery").lightSlider({
                                            item: 2,
                                            verticalHeight:500,
                                        });

                                        $("#docs").lightSlider({
                                            item: 3,
                                            verticalHeight:500,

                                        });*/

                                   
                                });
$('#videos-btn').click(function(e) {
                    /*$('#collapseOne').collapse('hide');*/
                    $('#model-videos').collapse('toggle');        
                });
function detectMob() {
                        const toMatch = [
                            /Android/i,
                            /webOS/i,
                            /iPhone/i,
                            /iPad/i,
                            /iPod/i,
                            /BlackBerry/i,
                            /Windows Phone/i
                        ];
                        
                        return toMatch.some((toMatchItem) => {
                            return navigator.userAgent.match(toMatchItem);
                        });
                    }
                $(window).on("load", function() { 
                    $('#model-accordion > .panel > .panel-collapse').first().collapse('show');

                    /*Custom script to detect when all images are loaded*/
                        var sticky_height = $('.sticky-header').size()>0? $('.sticky-header').outerHeight(true): 0;
                            
                           
                        $('#right-cta-buttons').css("width",$('#right-cta-buttons').outerWidth());
                        $('#right-cta-buttons').affix({
                              offset: {
                                top:function () {
                                  return (this.top = $("#model-right-content").offset().top)
                                },
                                bottom: function () {
                                  /*return (this.bottom = $('#FooterDiv').outerHeight(true))*/
                                   return (this.bottom = $('body').outerHeight(true)-($('#normal_vdp').offset().top + $('#normal_vdp').outerHeight(true) - sticky_height)+20 )
                                   //return (this.bottom = $('#model-right-content').outerHeight(true) + $('#model-right-content').offset().top  - sticky_height +20 )
                                }
                              }
                        });  
                            

                        /*force acccordion to scroll top */
                        $('#model-accordion').on('shown.bs.collapse', function () {
                         if($('#model-accordion .collapse.in').offset().top < $(document).scrollTop()){
                            //$(document).scrollTop($('#model-accordion .collapse.in').offset().top);
                            $('html, body').animate({
                                scrollTop: $('#model-accordion .collapse.in').offset().top-$('#model-accordion .accord-btn').outerHeight()
                            }, 0);
                         }
                        });

                        $('a[onclick^="showIframeModal"]').click(function( event ) {
                          event.preventDefault();
                        });          
                     });


                     /* Loan calculator*/
                     function calcPayment(price,rate,period,base){
                        if(rate>0)
                        {
                            rate = (rate/base)/100;
                            period = (period/12)*base;
                            x= rate * ((1+rate)**period) ;
                            y= ((1+rate)**period) - 1;
                            monthly = price * (x / y);
                        }
                        else{
                            period = (period/12)*base;
                            monthly = price / period;
                        }
                        return monthly;
                    }
                    function calcInstallment(){
                        let downpayment = document.getElementById('loan-down-payment').value;
                        let price= document.getElementById('loan-amount').value - downpayment;
                        let rate= document.getElementById('loan-interest-rate').value;
                        let period= document.getElementById('loan-term').value;
                        let basis=  document.getElementById('loan-frequency').value;
                        let instalment = [];

                        if(basis == 12){
                        instalment['basis']  = 'Monthly';
                        instalment['amount'] = calcPayment(price,rate,period,12);
                        }
                        if(basis == 24){
                        instalment['basis']  = 'Bi Weekly';
                        instalment['amount'] = calcPayment(price,rate,period,26);
                        }
                        if(basis == 48){
                        instalment['basis']  = 'Weekly';
                        instalment['amount'] = calcPayment(price,rate,period,52);
                        }
                        //return instalment;
                        $('.loan-amount-txt').text(instalment['amount'].toFixed(2)); 
                        $('.loan-basis-txt').text(instalment['basis']);
                        //$('.loan-basis-txt-short').text(instalment['basis'].substring(0,2));
                        $('.loan-basis-txt-short').text(instalment['basis']);
                        $('.amountFinanced').text('$'+price);

                    } 
                    function calc_reset(){
                        $('#loan-amount').val(0);
                        $('#loan-down-payment').val(0);
                        $('#loan-interest-rate').val(0);
                        $('#loan-frequency').val(12);
                        $('#loan-term').val(12);
                    }

                    let loan_frequency = 0 ;
                    let loan_term = 0 ;
                    $(function() {      
                        
                        $("body").addClass("VDP-open");

                        
                        $('#loan-frequency').val(loan_frequency);
                        $('#loan-term').val(loan_term);
                        if(detectMob()){
                            $(".model-tabs").after($(".loan-calculator"));
                        }




                        $('.accord-btn').click(function(event) {
                            event.preventDefault(); // Fix when click on accordion it refresh the page
                        });

                    });
window.WebsiteModal = false;
		window.PageModal = false;
