﻿var transitionTime = 5000;
var getTimeout = 5000;
var rotationTime = 5000; /*artf1212946 Added by Durgesh to control the rotation time of Slides*/
var langApply = "Apply";

var countryName = "United States/Canada";
var localeURL = "http://www.deere.com/"; /*DD artf1221188 : Configure different links for different locales*/

/*DD artf1254378 Added Image Gallery Variable*/
/** Used text to show Image text  */
langIMAGE = "Image";

/** Variable used in case of translation of "OF" word */
langOF = "of";

/* Variables used in the Image Gallery (Small, Medium & Large) */
langPrev = "Previous";
langNext = "Next";
langNextLine = "Next Line";
langPrevLine = "Previous Line";
langLoading = "Loading...";
langCancel = "Cancel";
langPlay = "Play again";
langPause = "Stop it";
langClose = "Shut this down";

/** Used in ACM page */
closeValue = "close";


$(document).ready(function () {

	$('.MOD_GC_12_5 #product-navigation').append('<div class="overlay_illusion" style="display:none;"><img src="../img/blank.gif" /></div>');

    $('.MOD_FO_6b table tbody > tr:nth-child(even)').addClass('bg');
    //DD Commented out as this not required now. $('.alphabet li:nth-child(10)').css({'visibility' : 'hidden'});
    persistlang();

    $('.MOD_GC_4 a').each(function () {
        $(this).click(function () {
            var relDia = $(this).attr('rel');
            var modalWidth = parseInt(relDia.substring(0, relDia.indexOf("|")))
            var ModalHeight = parseInt(relDia.substring(relDia.indexOf("|") + 1, relDia.length))

            setInterval(function () {
                $('#nyroModalWrapper').width(modalWidth);
                $('#nyroModalContent').width(modalWidth);
                $('#nyroModalWrapper').height(ModalHeight);
                $('#nyroModalContent').height(ModalHeight);
                //$('#nyroModalWrapper').css("top", ( $(window).height() - ModalHeight ) / 2+$(window).scrollTop() + "px");
                //$('#nyroModalWrapper').css("left", ( $(window).width() - modalWidth ) / 2+$(window).scrollLeft() + "px");
            }, 1000)
        })
    })

    $('#utilityNav .lang').mouseenter(function () {
        $(this).prev().addClass('on');
    });

    $('#utilityNav .lang').mouseleave(function () {
        $(this).prev().removeClass('on');
    });

    tallest = 0;
    $('.MOD_GC_14_2').each(function () {
        thisHeight = $(this).find('div').height();
        if (thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    $('.MOD_GC_14_2 div').height(tallest);
    $('.MOD_GC_14_2:lt(2) div').css('paddingTop', '0');

    $('img[align="left"]').addClass('imageLeft');
    $('img[align="right"]').addClass('imageRight');

    $('.carousel-pagination span').hover(function () {
        $(this).addClass('hover');
    }, function () {
        $(this).removeClass('hover');
    });

    $('#utilityNav .lang').click(function () {
        $(this).parent().find('.submenu').show();
    });
	
	$("#utilityNav li:first a").before("<span>" + countryName + "</span>");

    $('#close_lang').click(function () {
        $(this).parent().hide();
    });

    $('.MOD_NO_2_S li').click(function () {
        if (!$(this).hasClass('on')) {
            var onClass = $(this).attr('class');
            $('.MOD_NO_2_S li, .tabContent').removeClass('on');
            $('.MOD_NO_2_S .' + onClass + ', .' + onClass).addClass('on');
        }
    });

    /*DD Removed hierarchy as per Dax (.feature .inner) as seeallfeatures and specs was required through Content as well.*/
    $('a#seeallfeatures').click(function () {
        $('.MOD_NO_2_S li, .tabContent').removeClass('on');
        $('.MOD_NO_2_S .' + 'features' + ', .' + 'features').addClass('on');
    });
    $('a#seeallspecs').click(function () {
        $('.MOD_NO_2_S li, .tabContent').removeClass('on');
        $('.MOD_NO_2_S .' + 'specifications' + ', .' + 'specifications').addClass('on');
    });
	
	


    // MOD_GC_12_5
    // cta does not work with overlay, so it's commented out for now. Remove the comment as it was changing the behaviour Piyush
    var point;
	
    /* Drop down product nav */
	$('.MOD_GC_12_5 #product-navigation-trigger a').mouseenter(function(e){
            e.stopPropagation();
            // Pause the banner slideshow
            $('.MOD_GC_12_5 #banner').cycle('pause');
            $(document.getElementById('product-navigation').getElementsByTagName('ul')).css('display', 'block');
            document.getElementById('slideShowOverlay').className = '';
            $('.pause-resume').removeClass('pause').addClass('resume');
            $(this).removeClass('open').addClass('close');
    });
	
	/*DD artf1255036 Conditional click event for Link*/
	$('.MOD_GC_12_5 #product-navigation-trigger a').click(function(e){
		if($(this).hasClass("close")){
			e.preventDefault();
            e.stopPropagation();
            $(document.getElementById('product-navigation').getElementsByTagName('ul')).css('display', 'none');
            document.getElementById('slideShowOverlay').className = 'hideOverlay';
            $('.MOD_GC_12_5 #product-navigation-trigger a').removeClass('close').addClass('open');
            // Resume the banner slideshow
            $('.MOD_GC_12_5 #banner').cycle('resume');
            $('.pause-resume').removeClass('resume').addClass('pause');
		}else{
			e.stopPropagation();
            // Pause the banner slideshow
            $('.MOD_GC_12_5 #banner').cycle('pause');
            $(document.getElementById('product-navigation').getElementsByTagName('ul')).css('display', 'block');
            document.getElementById('slideShowOverlay').className = '';
            $('.pause-resume').removeClass('pause').addClass('resume');
            $(this).removeClass('open').addClass('close');		
		}
    });
	
	/*DD artf1255036 When mouse leave the banner area*/
	$('#hero-banner').mouseleave(function(e){
		e.preventDefault();
		e.stopPropagation();
		$(document.getElementById('product-navigation').getElementsByTagName('ul')).css('display', 'none');
		document.getElementById('slideShowOverlay').className = 'hideOverlay';
		$('.MOD_GC_12_5 #product-navigation-trigger a').removeClass('close').addClass('open');
		
		$('#slideShowOverlay').mouseleave(function() {
			// Resume the banner slideshow
			$('.MOD_GC_12_5 #banner').cycle('resume');
			$('.pause-resume').removeClass('resume').addClass('pause');
		});
    });
	
	/*DD artf1255036*/
	$('#product-navigation').mouseleave(function(e){
		// Resume the banner slideshow
		$('.MOD_GC_12_5 #banner').cycle('resume');
		$('.pause-resume').removeClass('resume').addClass('pause');
    });
	
	/*DD artf1255036*/
	$('#slideShowOverlay, #product-navigation').mouseenter(function(e){
		// Pause the banner slideshow
		$('.MOD_GC_12_5 #banner').cycle('pause');
		$('.pause-resume').removeClass('pause').addClass('resume');
    });
	
	/*DD artf1255036 When we click on the overlay or the navigation icon.*/
	$('.MOD_GC_12_5 #slideShowOverlay').click(function(e){
			e.preventDefault();
            e.stopPropagation();
            $(document.getElementById('product-navigation').getElementsByTagName('ul')).css('display', 'none');
            document.getElementById('slideShowOverlay').className = 'hideOverlay';
            $('.MOD_GC_12_5 #product-navigation-trigger a').removeClass('close').addClass('open');

            // Resume the banner slideshow
            $('.MOD_GC_12_5 #banner').cycle('resume');
            $('.pause-resume').removeClass('resume').addClass('pause');
    });
	
	
    // Image Popup
    $(".MOD_GC_12_5 #product-navigation ul li a").hover(function (e) {
        var msie = $.browser == 'msie' && $.browser.version < 7; // target ie6
        var placement = {
            x: 219,
            y: 0
        }; // top of zero and a left value equal to the width of the list item
        var pointPlacement = {
            x: -15,
            y: 0
        }; // top absolute default positioning of the popup tip
        // CALCULATED Y (TOP) POSITION
        var flyoutHeight = $(e.target).find('.flyout').outerHeight();
        var positionsY = $(e.target).parent().position(),
            positionY = positionsY.top + flyoutHeight; //The number + the height of the popup block.
        if (positionY > 420) {
            placement.y = 420 - positionY; //height of the banner container - the height of the list item - positionY
            pointPlacement.y = flyoutHeight + positionsY.top - 420;
        }

        // CALCULATED X (LEFT) POSITION
        var positionsX = $(e.target).parent().position(),
            positionX = positionsX.left;
        if ($(this).parent().parent().hasClass('col-4')) {
            if (msie) {
                placement.x = -220;
            } else {
                placement.x = -219;
            }

            point = '<span class="point_left">&nbsp;</span>';

            //point = '<img class="point" src="/common/deere-resources/img/arrows-r.png" />';
            pointPlacement.x = 212;
            $('.col-4').css('z-index', '5');
        } else {
            $('.col-4').css('z-index', '1');
        }

        // (K) modified as per artf1162987
        if (placement.x == 219) {
            point = '<span class="point arrow_left">&nbsp;</span>';
			//point = '<img class="point" src="/common/deere-resources/img/arrows-l.png" />';
            pointPlacement.x = -15;
        } else if (placement.x == -219) {
            point = '<span class="point arrow_right">&nbsp;</span>';
			//point = '<img class="point" src="/common/deere-resources/img/arrows-r.png" />';
            pointPlacement.x = 212;
        }



        //		if (positionX >= 500) {
        //	      	if (msie) {
        //				placement.x = -220; // If the left position touches the outside container (set at 500) go the opposite direction
        //	    	  	$('.MOD_GC_12_5 #product-navigation ul').css('position', 'static');
        //			} else {
        //				placement.x = -219; // If the left position touches the outside container (set at 500) go the opposite direction
        //			}
        //			point = '<img class="point" src="/common/deere-resources/img/arrows-r.png" />';
        //			pointPlacement.x = 212;
        //		} else {
        //			point = '<img class="point" src="/common/deere-resources/img/arrows-l.png" />';
        //		}
        // (K) modified as per artf1162987		
        $(this).find('.flyout').prepend(point).find('span.point').css({
            top: pointPlacement.y,
            left: pointPlacement.x
        });
        $(this).find('.flyout').css({
            top: placement.y,
            left: placement.x
        }).show();
    }, function () {
        $(this).find('.flyout').find('.point').remove();
        $(this).find('.flyout').hide();
    });

    // MOD_GC_12_2
    $('.MOD_GC_12_2 .item').mouseenter(function () {
        $(this).addClass('on');
        $('.nav + .MOD_GC_13').hide();
        $(this).find('.subItem').show();
    });
    $('.MOD_GC_12_2 .item').mouseleave(function () {
        $(this).removeClass('on');
        $('.nav + .MOD_GC_13').show();
        $(this).find('.subItem').hide();
    });
    $('.MOD_GC_12_2 .item > a').focus(function () {
        $(this).parent().addClass('on');
        $('.nav + .MOD_GC_13').hide();
        $(this).next().show();
    });
    $('.MOD_GC_12_2 .item > a').blur(function () {
        $(this).parent().removeClass('on');
        $('.nav + .MOD_GC_13').show();
        $(this).next().hide();
    });

    $('.MOD_FO_4').mouseenter(function () {
        if (!$(this).hasClass('off')) {
            // add blank li to keep stuff beneath from moving
            /* DD Commented the below code for artf1218172
			if ($(this).is(':last-child')) {
                $(this).parent().append('<li> </li>').css("display", "block");
            }*/

            $(this).addClass('oon');
            //$(this).next().css('margin-top','25px');/*(K) as per artf1164296 */
        }
    }).mouseleave(function () {
        $(this).removeClass('oon');
        //$(this).next().css('margin-top','0px');/*(K) as per artf1164296 */
    });

    $('.MOD_FO_6d h3').click(function () {
        if (!$(this).hasClass('open')) {
            $('.MOD_FO_6d h3').removeClass('open').next().hide();
            $(this).next().show();
            $(this).addClass('open');
        } else {
            $('.MOD_FO_6d h3').removeClass('open').next().hide();
        }
    });

/*$('.MOD_FO_6a h3, .MOD_FO_6b h3, .MOD_FO_6c h3, .MOD_GC_23a h3, .MOD_GC_22a h3, .MOD_FO_7a h3, .MOD_FO_13 h3').toggle(function() {
		$(this).next().show();
		$(this).addClass('open');
	}, function() {
		$(this).next().hide();
		$(this).removeClass('open');
	});*/
    $('.MOD_FO_6a h3, .MOD_FO_6b h3, .MOD_FO_6c h3, .MOD_GC_23a h3, .MOD_GC_22a h3, .MOD_FO_7a h3, .MOD_FO_13 h3').click(function () {
        if ($(this).next().is(':hidden')) {
            $(this).next().show();
            $(this).addClass('open');
        } else {
            $(this).next().hide();
            $(this).removeClass('open');
        }
    });

    $('.MOD_GC_22a div').css('display', 'none');

    $('.MOD_FO_6a a').click(function () {
        $('.collapse_all').removeClass('disabled');
        $('.expand_all').removeClass('disabled');
    });

    $('.collapse_all').addClass('disabled');

    $(".expand_all").click(function () {
        $(this).parent().parent().find('h3').next().show();
        $(this).parent().parent().find('h3').addClass('open');
        $('.collapse_all').removeClass('disabled');
        $('.expand_all').addClass('disabled');
    });

    $(".collapse_all").click(function () {
        $(this).parent().parent().find('h3').next().hide();
        $(this).parent().parent().find('h3').removeClass('open');
        $('.collapse_all').addClass('disabled');
    });

    $('.itemContent .item').each(function () {
        $('.modal .paginator').append('<li><a href="javascript:void(0)">&nbsp;</a></li>');
    });

    $('.modal .paginator li:first-child').children('a').addClass('on');
    $('.itemContent .item:first-child').addClass('on');

    $('.modal .next, .modal .prev').click(function () {

        obj = $(this).attr('class');
        var ttl = ($('.itemContent .item').length) - 1;
        var ind = 0;

        for (i = 0; i <= ttl; i++) {
            indice = $('.itemContent .item').eq(i).hasClass('on')
            if (indice == true) {
                active = i;
            }
        }

        switch (obj) {
        case "prev":
            if (active == 0) {
                $('.modal .paginator li').eq(0).find('a').removeClass('on');
                $('.modal .paginator li').eq(ttl).find('a').addClass('on');
                $('.itemContent .item').eq(0).removeClass('on');
                $('.itemContent .item').eq(ttl).addClass('on');
            } else {
                $('.modal .paginator li').eq(active).find('a').removeClass('on');
                $('.modal .paginator li').eq(active - 1).find('a').addClass('on');
                $('.itemContent .item').eq(active).removeClass('on');
                $('.itemContent .item').eq(active - 1).addClass('on');
            }
            break;
        case "next":
            if (active == ttl) {
                $('.modal .paginator li').eq(ttl).find('a').removeClass('on');
                $('.modal .paginator li').eq(0).find('a').addClass('on');
                $('.itemContent .item').eq(ttl).removeClass('on');
                $('.itemContent .item').eq(0).addClass('on');
            } else {
                $('.modal .paginator li').eq(active).find('a').removeClass('on');
                $('.modal .paginator li').eq(active + 1).find('a').addClass('on');
                $('.itemContent .item').eq(active).removeClass('on');
                $('.itemContent .item').eq(active + 1).addClass('on');
            }
            break;
        }
    });

    $('.listItems .ctItem').hide();

    $('.listItems h3').click(function () {
        $(this).toggleClass('on');
        $(this).next().toggle();
    });


    // MOD_GC_23a
    $('.rTable').attr('style', 'position: relative;');
    $('.rTable:first').show();

    $('.rTable .tablepag .prev_column').hide();
    $('.rTable .tablepag .next_column').hide();

    var ttl_columns = $('.rTable table:first thead th').length - 1;

    var ttl_page = 0;
    if (ttl_columns % 3 == 0) {
        ttl_page = ttl_columns / 3
    } else {
        ttl_page = parseInt(ttl_columns / 3) + 1
    }

    for (i = 0; i < ttl_page; i++) {
        if (i == 0) {
            $('.rTable .tablepag span').append('<a rel=' + i + ' class="p' + i + ' on">' + (i + 1) + '</a>');
        } else {
            $('.rTable .tablepag span').append('<a rel=' + i + ' class="p' + i + '">' + (i + 1) + '</a>');
        }
    }

    $('.rTable .tablepag span a').click(function () {
        // Click function for little yellow paging buttons
        $('.rTable .tablepag span a').removeClass('on');
        var index = $(this).attr('rel');
        paging_columns(index);
        $(this).addClass('on');
    });

    function paging_columns(page) {
        // called by paging buttons to move table to approproate position
        $('.rTable div:not(".fixed") table').each(function () {
            $(this).animate({
                left: (-(482) * page) - 121
            }, 300, showhide_buttonnav(page));
            $('.p' + page).addClass('on');
        });
    }

    if (ttl_columns > 3) {
        // if enough columns to scroll, show scroll button
        $('.rTable .tablepag .next_column').show();
    }

    $('.rTable div:not(".fixed") table').width((186 * ttl_columns) - 14);

    $('.rTable table').each(function () {
        $(this).parent().before('<div class="fixed" style="position:absolute;width:162px;overflow:hidden"></div>');
        $(this).clone().appendTo($(this).parent().prev());
    });
    $('.rTable .fixed th:first').attr('style', 'width:142px !important');

    //$('.rTable .fixed table tr th').css('backgroundColor','#f1f1f1')
/*$('.rTable div:not(".fixed") tr').each(function() {
		$(this).find('th:first, td:first').remove();
	});
	$('.rTable .fixed tr').each(function() {
		$(this).find('th:last, td:last').remove();
	});*/
    //.before('<div class="scroll" style="display: block; position: relative; left: 162px; width: 502px; overflow: hidden;">')
/*$('.rTable table').each(function() {
        var column_title = null;
        var column_body = null;
        $(this).find('thead tr').each(function() {
            column_title = '<tr><th style="height:'+($(this).height()+10)+'px;background:none">&nbsp;</th></tr>';
            $(this).parent().parent().before('<div style="position:absolute; display: block; width: 164px;"><table class="fixed"><thead>' + column_title + '<tbody>');
            $(this).find('th:first').remove();
        });
        $(this).find('tbody tr').each(function() {
            column_body = '<tr><td style="height:'+($(this).height()+10)+'px">' + $(this).find('td:first').html() + '</td></tr>';
            $(this).parent().parent().prev().find('tbody').append(column_body);
            $(this).parent().parent().prev().find('tbody tr:even').addClass('bg');
            $(this).find('td:first').remove();
        });
    }).before('<div class="scroll" style="display: block; position: relative; left: 162px; width: 502px; overflow: hidden;">');*/



    $('.rTable div:not(".fixed") table').each(function () {
        $(this).attr('style', 'position: relative;');
        $(this).appendTo($(this).prev());
        $(this).width(184 * ttl_columns);
    });
    var current = 0;

    $('.rTable .next_column').click(function () {
        $('.rTable .tablepag span a').removeClass('on');
        var el = $('.rTable div:not(".fixed") table');
        var position = el.position();
        current = 0;
        $('.rTable div:not(".fixed") table').animate({
            left: position.left - 482
        }, 300, function () {
            var e = $('.rTable div:not(".fixed") table');
            var f = e.position()
            current = (f.left * -1) / 486; //
            $('.p' + Math.round(current)).addClass('on');
            showhide_buttonnav(Math.round(current));
        });
        $('.rTable .tablepag .prev_column').show();
    });

    $('.rTable .prev_column').click(function () {
        // left scroll button clicked
        $('.rTable .tablepag span a').removeClass('on');
        var el = $('.rTable div:not(".fixed") table');
        var position = el.position()
        $('.rTable div:not(".fixed") table').animate({
            left: position.left + 482
        }, 300, function () {
            var e = $('.rTable div:not(".fixed") table');
            var f = e.position()
            current = (f.left * -1) / 485;
            $('.p' + Math.round(current)).addClass('on');
            showhide_buttonnav(Math.round(current));
        });
        $('.rTable .tablepag .next_column').show();
    })

    function showhide_buttonnav(pos) {
        // called ten times when scrolled?
        $('.rTable .prev_column, .rTable .next_column').show();
        if (pos == 0) {
            $('.rTable .prev_column').hide();
        }
        if (pos == (ttl_page - 1)) {
            $('.rTable .next_column').hide();
        }
    }

    $('.chooseModels').click(function () {
        var pos = $(this).offset();
        var postab = $('.tabContent').parent().offset();
        $('.addRemoveModel').hide().css('top', pos.top - (postab.top + 100));
        $('.addRemoveModel').css('left', pos.left - (postab.left + 20)).show();
    });
    $('.addRemoveModel a').click(function () {
        $('.addRemoveModel').hide();
    });

    $('.chooseModels').click(function () {
        // Called from clicking 'add/remove models', opens add/remove model box.
        var pos = $(this).offset();
        var postab = $('.tabContent').parent().offset();
        if (postab) {
            $('.addRemoveModel').hide().css('top', pos.top - (postab.top + 100));
            $('.addRemoveModel').css('left', pos.left - (postab.left + 20)).show();
        } else {
            // if not being loaded within a tab
            $('.addRemoveModel').hide().css('top', pos.top + 20);
            $('.addRemoveModel').css('left', pos.left - 20).show();
        }
    });

    $('.addRemoveModel a').click(function () {
        // closes the add/remove model box
        $('.addRemoveModel').hide();
    });


    $('#checkAllAutoLeft').click(function () {
        $(".checkLeft").attr('checked', $('#checkAllAutoLeft').is(':checked'));
    });

    $('#checkAllAutoRight').click(function () {
        $(".checkRight").attr('checked', $('#checkAllAutoRight').is(':checked'));
    });

    $('.listCompare li input, .listCompare2 li input, .topCompare input').click(function () {
        var a = 0;
        var b = 0;
        $('.listCompare li input').each(function () {
            if ($(this).attr('checked')) {
                a++;
            }
        });
        $('.listCompare2 li input').each(function () {
            if ($(this).attr('checked')) {
                b++;
            }
        });
        if (a >= 1 && b >= 1) {
            $('.MOD_FO_10 .header a').removeClass('noCompareModels').addClass('compareModels')
        } else {
            $('.MOD_FO_10 .header a').removeClass('compareModels').addClass('noCompareModels')
        }
        a = 0;
        b = 0;
    });

    $('.listType a').click(function () {
        $('.listType a').removeClass('on');
        $(this).addClass('on')
        $(this).parent().next().next().removeClass('list, grid');
        $(this).parent().next().next().addClass($(this).attr('rel'));
        $('.MOD_GC_18 .grid li:nth-child(3n)').css('marginRight', '0');
    });

    // adv search
    $(".UTIL_1_1_menu ul li").toggle(function () {
        $(this).children().next().css('display', 'block');
        $(this).addClass('open');
        $(this).addClass('on');
    }, function () {
        //$(this).css('display','none');
        $(this).removeClass('open');
        $(this).removeClass('on');
        $(".UTIL_1_1_menu > ul > li > ul").css('display', 'none');
    });

    $(".UTIL_1_1_menu ul li ul li ul li").click(function () {
        $(this).removeClass('open');
        $(this).removeClass('on');
    });

    $(".UTIL_1_1_menu ul li span").click(function () {
        $(this).removeClass('on');
        $(this).removeClass('open');
    });

    // pag reg-homepage
    $('.homepage-slide-op li:first').show();
    $('.homepage-slide-thumblist li:first').addClass('curr');


    $('.MOD_GC_12_2b *').bind({
        mouseover: function () {
            clearInterval(intervalo2);
        },
        mousemove: function () {
            clearInterval(intervalo2);
        }
    });

    $('.MOD_GC_12_2b').bind('mouseout', function (evt) {
        evt.stopPropagation();
        timeIntervalo2();
    });

    $('.homepage-slide-op li').each(function (i) {
        $(this).attr('id', 'homepage-slide-' + ++i + '');
    });
    $('.homepage-slide-thumblist li').each(function (i) {
        $(this).find('a').attr('href', '#homepage-slide-' + ++i + '');
    });

    function timeIntervalo2() {
        intervalo2 = setInterval(function () {
            //alert('enter');
            var curr = $('.homepage-slide-op li:visible');
            var currTumb = $('.homepage-slide-thumblist li.curr');
            curr.hide();
            if (curr.is(':last-child')) {
                $('.homepage-slide-op li:first').show();
                $('.homepage-slide-thumblist li:first').addClass('curr');
            } else {
                curr.next().show();
                currTumb.next().addClass('curr');
            }
            currTumb.removeClass('curr');
        }, getIntervalTime());
    }

    function getIntervalTime() {
        return transitionTime;
    }

    function timeIntervalo3() {
        intervalo2 = setInterval(function () {
            var curr = $('.homepage-slide-op li:visible');
            var currTumb = $('.homepage-slide-thumblist li.curr');
            curr.hide();
            if (curr.is(':last-child')) {
                $('.homepage-slide-op li:first').show();
                $('.homepage-slide-thumblist li:first').addClass('curr');
            } else {
                curr.next().show();
                currTumb.next().addClass('curr');
            }
            currTumb.removeClass('curr');
        }, 3000);
    }
    timeIntervalo2();

    $('.homepage-slide-thumblist li').click(function (event) {
        event.preventDefault();
        var openImg = $('a', this).attr('href');
        $('' + openImg + '').show();
        $('' + openImg + '').siblings('.homepage-slide-op li').hide();
        $(this).addClass('curr');
        $(this).siblings().removeClass('curr');
        clearInterval(intervalo2);
        //timeIntervalo3();
    });

    $('#homepage-slide-op-next').click(function () {
        var curr = $('.homepage-slide-op li:visible');
        var currTumb = $('.homepage-slide-thumblist li.curr');
        curr.hide();
        if (curr.is(':last-child')) {
            $('.homepage-slide-op li:first').show();
            $('.homepage-slide-thumblist li:first').addClass('curr');
        } else {
            curr.next().show();
            currTumb.next().addClass('curr');
        }
        currTumb.removeClass('curr');
        clearInterval(intervalo2);
        //timeIntervalo3();
    });

    $('#homepage-slide-op-prev').click(function () {
        var curr = $('.homepage-slide-op li:visible');
        var currTumb = $('.homepage-slide-thumblist li.curr');

        curr.hide();
        if (curr.is(':first-child')) {
            $('.homepage-slide-op li:last-child').show();
            $('.homepage-slide-thumblist li:last-child').addClass('curr');
        } else {
            curr.prev().show();
            currTumb.prev().addClass('curr');
        }
        currTumb.removeClass('curr');
        clearInterval(intervalo2);
        //timeIntervalo3();
    });

	/*DD artf1232530*/	
	$('#homepage-slide-op-prev a span, #homepage-slide-op-next a span').hover(function () {
		$(this).addClass("hover");
	}, function () {
		$(this).removeClass("hover");
	});
	
	// end pag reg-homepage

    // slide MOD_GC_12_2a
    var slideTag = ".slide-op li";
    var slideNavTag = ".slide-nav li";
    var intervalo;
    var timeI = 1000;
    var currNav = 0;
    var slideLength = $(slideTag).length - 1;

    $('.slide-op').parent().append('<div class="slide-navigation"></div>');

    $('' + slideTag + ':first').show();
    $('<ul class="slide-nav"></ul>').appendTo('.slide-navigation');
    $('.slide-navigation').append('<a href="" class="slide-pause">Pause</a>').click(function (event) {
        event.preventDefault();
        clearInterval(intervalo);
    });

    $(slideTag).each(function (qnt) {
        var qnt = ++qnt;
        $(this).attr('id', 'slide-' + qnt + '');
        $('<li><a href="javascript:void(0)" targetId="#slide-' + qnt + '">' + qnt + '</a></li>').appendTo('.slide-nav');
    });

    $('' + slideNavTag + ':first').addClass('curr');

    function timeIntervalo() {
        intervalo = setInterval(function () {
            var curr = $('.slide-op li:visible');
            curr.hide();
            $(slideNavTag).removeClass('curr');
            if (currNav >= slideLength) {
                currNav = 0;
            }
            if (curr.is(':last-child')) {
                $('' + slideTag + ':first').show();
                $('' + slideNavTag + ':first').addClass('curr');
            } else {
                curr.next(slideTag).show();
                $('' + slideNavTag + ':eq(' + ++currNav + ')').addClass('curr');
            }
        }, timeI);
    }
    timeIntervalo();

    $('' + slideNavTag + ' a').click(function (event) {
        event.preventDefault();
        var openId = $(this).attr('targetId');
        $('' + openId + '').show();
        $('' + openId + '').siblings(slideTag).hide();

        $('#debug').text(openId);
        $(this).parents('li').addClass('curr');
        $(this).parents('li').siblings().removeClass('curr');
        clearInterval(intervalo);
    });
    // end 
    // caption
/*
	$(".MOD_GC_3 img").each(function(){
		var alt = $(this).attr("alt"); 
		var imgsize = $(this).width();
		if(alt){
			$(this).wrap("<div class='caption'></div>");
			$(this).parent('.caption').width(imgsize);	
			$(this).parent('.caption').append("<p>"+alt+"</p>");
			$(".MOD_GC_3 img[align='left']").parent('.caption').addClass('imageLeft');
			$(".MOD_GC_3 img[align='right']").parent('.caption').addClass('imageRight');
		}		
	});
	*/

    // tab_module	
    $('.tab_module_content.on').show();

    $('.MOD_NO_2_S li').click(function () {
        if (!$(this).hasClass('on')) {
            $(this).siblings().removeClass('on');
            var openClass = $(this).attr('class');
            $('.tabContent').hide();
            $('.' + openClass + '').addClass('on').show();
            $('.' + openClass + '').siblings().removeClass('on');
            $('#mainNav .on').hide();
            $(this).addClass('on');
            //alert($('.'+openClass+'').find('.carousel-viewport').length);
            if (!$('.' + openClass + '').find('.carousel-viewport')[0]) { /* Carousel the thumbnails*/
                $('.' + openClass + '').find('.MOD_GC_6 .list ul').tileCarousel({
                    increment: 4,
                    loop: false,
                    pagination: true
                });
                //alert("INNNN");
            }

        } else {
            $('.tabContent.on .MOD_GC_6 .list ul.thumbs').tileCarousel({
                increment: 4,
                loop: false,
                pagination: true
            });
        }
    });




    /*(K) added to make the worldwide tabs working*/
    $('.tab_module li').click(function () {
        if (!$(this).hasClass('on')) {
            $(this).siblings().removeClass('on');
            var openClass = $(this).attr('class');
            $('.tab_module_content').hide();
            $('.' + openClass + '').addClass('on').show();
            $('.' + openClass + '').siblings().removeClass('on');
            $('#mainNav .on').hide();
            $(this).addClass('on');
            //alert($('.'+openClass+'').find('.carousel-viewport').length);
        }
    });

    /*(K) added to make the worldwide tabs working*/

/*DD 07-Dec-11 Added the below codes.

.MOD_NO_4 li.nvl_2 h3:last-child span
.MOD_NO_4 li.nvl_3 ul:last-child h3:last-child span

*/
    // MOD_NO_4
    $('.MOD_NO_4 li.nvl_2 ul li:last-child, .MOD_NO_4 li.nvl_2 h3:last-child span, .MOD_NO_10 li.nvl_2 ul li:last-child').css('border', 'none');
    $('.MOD_NO_4 li.nvl_2_1 ul li:last-child, .MOD_NO_10 li.nvl_2_1 ul li:last-child').css('border', 'none');
    
	$('.MOD_NO_4 li.nvl_3 ul li:last-child a, .MOD_NO_10a li.nvl_3 ul li:last-child a, .MOD_NO_10b li.nvl_3 ul li:last-child a, .MOD_NO_10a li.nvl_3 ul h3:last-child a, .MOD_NO_10b li.nvl_3 ul h3:last-child a, .MOD_NO_4 li.nvl_3 ul:last-child h3:last-child span').css('border', 'none');

	$('.MOD_NO_4 li.nvl_3_1 ul li:last-child a, .MOD_NO_4 li.nvl_3_1 ul li:last-child h3 a, .MOD_NO_4 li.nvl_3_1 ul h3:last-child a, .MOD_NO_4 li.nvl_3_1 ul li:lastchild h3:last-child a').css('border', 'none'); /*DD artf1215990 / artf1219101 .MOD_NO_4 li.nvl_3_1 ul h3:last-child a*/
	
	$('.ie7 .MOD_NO_4 li.nvl_3_1 ul li:last-child a, .ie7 .MOD_NO_4 li.nvl_3_1 ul li:last-child h3 a, .ie7 .MOD_NO_4 li.nvl_3_1 ul h3:last-child a').css('border-bottom','1px dotted #9b9b9b');/*DD artf1254228*/
	$('.MOD_NO_4 li.nvl_3_1 ul li:last-child a, .ie7 .MOD_NO_4 li.nvl_3_1 ul > h3:last-child a').css('border', 'none'); /*DD Specifically for IE7*/
	$('.MOD_NO_4 li.nvl_3_1 ul li:last-child h3:last-child a').css('border-top', '1px dotted #9b9b9b'); /*DD Specifically for IE7 | artf1254228*/
	$('.MOD_NO_4 li.nvl_4 ul li:last-child a, .MOD_NO_10a li.nvl_4 ul li:last-child a, .MOD_NO_4 li.nvl_4 ul h3:last-child a').css('border', 'none'); /*DD artf1224315, artf1246893*/
	
	$('.MOD_NO_10a li.nvl_3 ul li:last-child, .MOD_NO_10b li.nvl_3 ul li:last-child').addClass('last_item');


    //Added by Vikas Khera for Artifact artf1163280
    //$('.MOD_NO_4 li.nvl_2').css('border','none'); 
    var foundLI = $('MOD_NO_4 li.nvl_3 ul').find("li");
    if (foundLI.length == 0) {
        $('.MOD_NO_4 li.nvl_3 ul h3 a').css('border', 'none')
    }


    var foundLI2 = $('MOD_NO_4 li.nvl_2').find("ul");
    if (foundLI2.length == 0) {
        //$('.MOD_NO_4 li.nvl_2 h3').css('border-bottom','1px solid #ccc')  Commented by Swarn
        $('.MOD_NO_4 li.nvl_2 h3 a').css('border', 'none')
    }

    // new lightbox
    if ($.nyroModalSettings) {
        $.nyroModalSettings({
            // debug: true,
            processHandler: function (settings) {
                var url = settings.url;
                if (url && url.indexOf('http://www.deere.com/media/player/playerdata/Player.swf') == 0) {
                    $.nyroModalSettings({
                        // john deere video player default width & height
                        height: 480,
                        width: 720
                    })
                }
                if (url && url.indexOf('http://www.deere.com/en_US/ProductCatalog/HO/media/flash') == 0) {
                    $.nyroModalSettings({
                        // john deere 360 player default width & height
                        height: 460,
                        width: 614
                    })
                } else {
                    $.nyroModalSettings({
                        // john deere 360 player default width & height
                        minHeight: 100,
                        minWidth: 220
                    })
                }
            },
            endShowContent: function (elts, settings) {
                $('.resizeLink', elts.contentWrapper).click(function (e) {
                    e.preventDefault();
                    $.nyroModalSettings({
                        width: Math.random() * 1000,
                        height: Math.random() * 1000
                    });
                    return false;
                });
                $('.bgLink', elts.contentWrapper).click(function (e) {
                    e.preventDefault();
                    $.nyroModalSettings({
                        bgColor: '#' + parseInt(255 * Math.random()).toString(16) + parseInt(255 * Math.random()).toString(16) + parseInt(255 * Math.random()).toString(16)
                    });
                    return false;
                });
            }
        });
        $('#manual').click(function (e) {
            e.preventDefault();
            var content = 'Content wrote in JavaScript<br />';
            jQuery.each(jQuery.browser, function (i, val) {
                content += i + " : " + val + '<br />';
            });
            $.fn.nyroModalManual({
                bgColor: '#3333cc',
                content: content
            });
            return false;
        });
        $('#manual2').click(function (e) {
            e.preventDefault();
            $('#imgFiche').nyroModalManual({
                bgColor: '#cc3333'
            });
            return false;
        });
        $('#myValidForm').submit(function (e) {
            e.preventDefault();
            if ($("#myValidForm :text").val() != '') {
                $('#myValidForm').nyroModalManual();
            } else {
                alert("Enter a value before going to " + $('#myValidForm').attr("action"));
            }
            return false;
        });
        $('#block').nyroModal({
            'blocker': '#blocker'
        });

        function preloadImg(image) {
            var img = new Image();
            img.src = image;
        }

        //preloadImg('img/ajaxLoader.gif');
        //preloadImg('img/prev.gif');
        //preloadImg('img/next.gif');
    }

    $('.MOD_GC_12_1 .icons li a').hover(function () {
        $(this).addClass('hover');
    }, function () {
        $(this).removeClass('hover');
    });

    //added by vikash
    $('.MOD_GC_12_1 .icons li a').bind('click', function () {
        if ($(this).hasClass('on')) {
            if ($($(this).parents('.MOD_GC_12_1')[0]).find('div[class~="' + $($(this).parents('li')[0]).attr('class') + '_Cont"]')[0]) {
                $($(this).parents('ul.icons')[0]).find('li a').removeClass('on');
                $($(this).parents('.MOD_GC_12_1')[0]).find('div[class~="' + $($(this).parents('li')[0]).attr('class') + '_Cont"]').hide();
                $($(this).parents('.MOD_GC_12_1')[0]).find('.defaultView').show();
            }
        } else {
            if ($($(this).parents('.MOD_GC_12_1')[0]).find('div[class~="' + $($(this).parents('li')[0]).attr('class') + '_Cont"]')[0]) {
                $($(this).parents('ul.icons')[0]).find('li a').removeClass('on');
                $(this).addClass('on');
                $($(this).parents('.MOD_GC_12_1')[0]).find('.view').hide();
                $($(this).parents('.MOD_GC_12_1')[0]).find('div[class~="' + $($(this).parents('li')[0]).attr('class') + '_Cont"]').show();
            }
        }
    });

/*artf1212946 Added by Durgesh to control the rotation time of Slides*/
    if ($('.MOD_GC_12_5 #banner').cycle) {

        $('.MOD_GC_12_5 #banner').cycle({
            speed: 800,
            timeout: rotationTime,
            pager: '#pager-numbers',
            pagere: 'mouseover',
            pauseOnPagerHover: true
        });

        $('.MOD_GC_12_5 .pause').toggle(function () {
            $('.MOD_GC_12_5 #banner').cycle('pause');
            $(this).removeClass('pause').addClass('resume');
        }, function () {
            $('.MOD_GC_12_5 #banner').cycle('resume');
            $(this).removeClass('resume').addClass('pause');
        });
    }
	
/*artf1212946 Added by Durgesh to control the rotation time of Slides*/
    if ($('.MOD_GC_12_5a #banner').cycle) {

        $('.MOD_GC_12_5a #banner').cycle({
            speed: 800,
            timeout: rotationTime,
            pager: '#pager-numbers',
            pagere: 'mouseover',
            pauseOnPagerHover: true
        });

        // KARAN Artifact artf1164079 : Play button disappears on hover 
        //if($('#pager-numbers'== 0)){
        //$('#pager').hide();
        //}
        // KARAN Artifact artf1164079 : Play button disappears on hover 
        $('.MOD_GC_12_5a .pause').toggle(function () {
            $('.MOD_GC_12_5a #banner').cycle('pause');
            $(this).removeClass('pause').addClass('resume');
        }, function () {
            $('.MOD_GC_12_5a #banner').cycle('resume');
            $(this).removeClass('resume').addClass('pause');
        });
    }


    if ($('.MOD_GC_12_2a #banner-small').cycle) {

        $('.MOD_GC_12_2a #banner-small').cycle({
            speed: 800,
            timeout: getTimeout,
            pager: '#pager-numbers',
            pagere: 'mouseover',
            pauseOnPagerHover: true
        });

        $('.MOD_GC_12_2a .pause').toggle(function () {
            $('.MOD_GC_12_2a #banner-small').cycle('pause');
            $(this).removeClass('pause').addClass('resume');
        }, function () {
            $('.MOD_GC_12_2a #banner-small').cycle('resume');
            $(this).removeClass('resume').addClass('pause');
        });
    }

    if ($('.MOD_GC_12_2a_green #banner-small').cycle) {

        $('.MOD_GC_12_2a_green #banner-small').cycle({
            speed: 800,
            timeout: getTimeout,
            pager: '#pager-numbers',
            pagere: 'mouseover',
            pauseOnPagerHover: true
        });

        $('.MOD_GC_12_2a_green .pause').toggle(function () {
            $('.MOD_GC_12_2a_green #banner-small').cycle('pause');
            $(this).removeClass('pause').addClass('resume');
        }, function () {
            $('.MOD_GC_12_2a_green #banner-small').cycle('resume');
            $(this).removeClass('resume').addClass('pause');
        });
    }


    //VIEW OTHER OPTIONS POPUP
    $('.buying_options .bg_btn').click(function () {
        var nextNode = $(this).next();
        var url = $(nextNode).text();
        //changed the code to handle opening in defined target: Moiz.
        var target = $(nextNode).attr('target');
        window.open(url, target);
        //window.open(url);
        return false;
    });
    $('.buying_options .btn').click(function () {
        //Removed code in this method as it was not needed: Pradeep
        return false;
    });

    $('#jdnpfhfl-en-us-row-1').parent().css('background', 'none')


    $('.MOD_GC_25 table tbody > tr:nth-child(even)').addClass('bg');






/* DD artf1213653 : Wrong style coming from js 
    if ($('.MOD_GC_3').length > 1) {
        $('.MOD_GC_3:last p:last').css('margin', '0px');
    }
*/

    $('.MOD_GC_6 .list a.nextFrame').hover(function () {
        $(this).addClass('nextHover');
    }, function () {
        $(this).removeClass('nextHover');
    });

    $('.MOD_GC_6 .list a.prevFrame').hover(function () {
        $(this).addClass('prevHover');
    }, function () {
        $(this).removeClass('prevHover');
    });

    /*DD - To make the tab text vertically middle*/
    $('.MOD_NO_2_S li a span, .tab_module li a span').vAlign();
	
	
	/*DD Vertical Align Button*/
	$('.MOD_FO_10 .header .noCompareModels').verticalAlign();


    /*DD - Tweek to make gallery work within tab.*/
    //$("div.gallery_tab").addClass($("gallery_tab_disabled").hasClass("selected").toString());
    if ($("div.gallery_tab").hasClass('on')) {
        $("div.gallery_tab").removeClass('gallery_tab_disabled');
    } else {
        $("div.gallery_tab").addClass('gallery_tab_disabled');
    }

    $('.MOD_NO_2_S li').click(function () {
        $("div.gallery_tab").addClass('on');
        $("div.gallery_tab").addClass('gallery_tab_disabled');
    });

    $('.MOD_NO_2_S li.gallery_tab').click(function () {
        $("div.gallery_tab").removeClass('gallery_tab_disabled');
        $("div.gallery_tab").addClass('on');
    });

    /*DD Custom Select Menu*/
    //$('#Category, #Subcategory, #Series ,#Subseries').ieSelectStyle();

    $('.generic_table tbody > tr:nth-child(even)').addClass('bg');

	
	/*DD artf1221188 : Configure different links for different locales*/
	$('#Ghid000001').attr('href', localeURL);

}); // end ready


$(window).scroll(function () {
    var box = $('.MOD_FO_9').position();
    var scrollbar = $(window).scrollTop();
    if (scrollbar >= 150) {
        $('.MOD_FO_9').css('top', (scrollbar + 2));
    } else {
        $('.MOD_FO_9').css('top', 'auto');
    }
});

// this method shows the tab module (Features/Specifications/compare/CompatibleEquipment/Overview)
// @ param  tabValue :  This contains the tab to be highlighted

function onProductTab(tabValue) {
    $('.MOD_NO_2_S li, .tabContent').removeClass('on');

    $('.MOD_NO_2_S .' + tabValue + ', .' + tabValue).addClass('on');
}

function viewOtherOption_Click($this) {
    $($this).next('.buying_options').show();
    $($this).next().next('.buying_options').show();
}

function divPopHeaderClose_Click($this) {
    $($this).parent().parent('.buying_options').hide();
}

function buyOptionBtn_Click($this) {
    //Removed code in this method as it was not needed: Pradeep
    return false;
}

function buyOptionBgBtn_Click($this) {
    var nextNode = $($this).next();
    var url = $(nextNode).text();
    window.open(url);
    return false;
}

function expandAll_Click($this) {
    $($this).parent().parent().find('h3').next().show();
    $($this).parent().parent().find('h3').addClass('open');
}

function collapseAll_Click($this) {
    $($this).parent().parent().find('h3').next().hide();
    $($this).parent().parent().find('h3').removeClass('open');
}

function expandAllSpecSeries_Click($this) {
    $($this).parent().parent().parent().find('h3').next().show();
    $($this).parent().parent().parent().find('h3').addClass('open');
}

function collapseAllSpecSeries_Click($this) {
    $($this).parent().parent().parent().find('h3').next().hide();
    $($this).parent().parent().parent().find('h3').removeClass('open');
}

function tabHeaders_Click($this) {
    if ($($this).hasClass('open')) {
        $($this).next().hide();
        $($this).removeClass('open');
    } else {
        $($this).next().show();
        $($this).addClass('open');
    }
}

function openCompEquipmentAccordion_Click($this) {
    if ($('.MOD_FO_6d h3').hasClass('open')) {
        $('.MOD_FO_6d h3').removeClass('open').next().hide();
    }

    if ($($this).hasClass('open')) {
        $($this).next().hide();
        $($this).removeClass('open');
    } else {
        $($this).next().show();
        $($this).addClass('open');
    }
}

function tabFeatureSpec_Click($this) {
    if ($($this).hasClass('open')) {
        $($this).next().hide();
        $($this).removeClass('open');
    } else {
        $($this).next().show();
        $($this).addClass('open');
    }
}

// old lightbox (deprecated)

function showHidePop(obj) {
    var e = document.getElementById(obj);
    var valScroll = document.documentElement.scrollTop;
    if (document.all) {
        var displayReal = e.currentStyle.display;
    } else {
        var cs = document.defaultView.getComputedStyle(e, null);
        var displayReal = cs.getPropertyValue('display');
    }
    if (displayReal == 'block') {
        document.getElementById('bkgPop').style.display = 'none';
        document.getElementById('frm').style.display = 'none';
        document.getElementById(obj).style.display = 'none';
    } else {
        resizePop();
        document.getElementById('bkgPop').style.display = 'block';
        document.getElementById('frm').style.display = 'block';
        document.getElementById(obj).style.display = 'block';
        document.getElementById(obj).style.top = (valScroll + 50) + 'px';
    }
}

function resizePop() {
    if (!document.all) {
        document.getElementById('bkgPop').style.height = (window.innerHeight + 10) + 'px';
        document.getElementById('frm').style.height = (window.innerHeight + 10) + 'px';
        if (window.innerHeight < document.body.clientHeight) {
            document.getElementById('bkgPop').style.height = (document.body.clientHeight + 10) + 'px';
            document.getElementById('frm').style.height = (document.body.clientHeight + 10) + 'px';
        }
    } else {
        if (document.documentElement.clientHeight < document.body.clientHeight) {
            document.getElementById('bkgPop').style.height = (document.body.clientHeight + 10) + 'px';
            document.getElementById('frm').style.height = (document.body.clientHeight + 10) + 'px';
        } else {
            document.getElementById('bkgPop').style.height = (document.documentElement.clientHeight + 10) + 'px';
            document.getElementById('frm').style.height = (document.documentElement.clientHeight + 10) + 'px';
        }
    }
}

function changeLanguage(locale) {
    var url = window.location.href;
    var appName = url.indexOf('/wps/PA_jd_crp/');
    if (appName != -1) {
        optionParam = fetchParam('option');
        target = "/wps/PA_jd_crp/" + locale + "/Home.page?option=" + optionParam + "&locale=" + locale;
        window.location.href = target;
    }
    appName = url.indexOf('/wps/PA_jd_crp_preview/');
    if (appName != -1) {
        optionParam = fetchParam('option');
        target = "/wps/PA_jd_crp_preview/" + locale + "/Home.page?option=" + optionParam + "&locale=" + locale;
        window.location.href = target;
    }
}

function fetchParam(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null) return "";
    else {
        return results[1];
    }
}

function persistlang() {
    var locale = fetchParam('locale');
    var selectObj = document.getElementById("langSelect");
    if (selectObj != null) {
        for (i = 0; i < selectObj.length; i++) {
            if (locale == selectObj.options[i].value) {
                selectObj.selectedIndex = i;
            }
        }
    }
}

function filterProducts(type) {
    if (type) {
        $('.MOD_FO_4:not(".off")').addClass('off');
        $('.' + type).removeClass('off');
    } else {
        $('.MOD_FO_4.off').removeClass('off');
    }
}
// SiteMap even li margin


//equalheight for MOD_GC_14_2
jQuery.fn.equalHeight = function (columnNum) {
    var height = 0;
    var maxHeight = 0;

    if (columnNum) {
        totalRowsCount = Math.ceil(this.length / columnNum);

        for (var i = 1; i <= totalRowsCount; i++) {
            var startNum = (i * columnNum) - columnNum;
            // Store the tallest element's height
            for (var j = startNum; j < startNum + columnNum; j++) {
                if (jQuery(this.eq(j))[0]) {
                    height = jQuery(this.eq(j)).outerHeight();
                    maxHeight = (height > maxHeight) ? height : maxHeight;
                } else {
                    break;
                }
            }
            //set t.css(property, minHeight + 'px');
            for (var k = startNum; k < startNum + columnNum; k++) {
                if (jQuery(this.eq(k))[0]) {
                    var t = jQuery(this.eq(k));
                    var minHeight = maxHeight - (t.outerHeight() - t.height());
                    var property = 'height';

                    t.css(property, minHeight + 'px');
                } else {
                    break;
                }
            }
            maxHeight = 0;
        }
    } else {
        // Store the tallest element's height
        this.each(function () {
            height = jQuery(this).outerHeight();
            maxHeight = (height > maxHeight) ? height : maxHeight;
        });

        // Set element's min-height to tallest element's height
        return this.each(function () {
            var t = jQuery(this);
            var minHeight = maxHeight - (t.outerHeight() - t.height());
            var property = 'height';

            t.css(property, minHeight + 'px');
        });
    }
};
//jQuery.each(jQuery.browser, function(i, val) {
//	if(i=="mozilla" && jQuery.browser.version.substr(0,3)=="1.9")
//	alert("Do stuff for firefox 3")
window.onload = function () {
    //setTimeout(function() {
    if ($('.MOD_GC_14_2')[0]) $('.MOD_GC_14_2').equalHeight(2);
    //}, 1500)
}

//});
//equalheight for MOD_GC_14_2
$(document).ready(function () {
    if ($('#grey_bg_layout')[0]) {
        var a = $('.bt .btn_primary span').width(),
            b = 84;
        //alert(a);
        if (a > b) {
            $('div.Fo1_content').addClass(' big_btn');
        }
    }
    $('.MOD_NO_19 ul li:nth-child(even)').addClass('noMargin');
    $('.MOD_GC_12_5a #banner').css('height', '458px');
    //(K) added to add grey BG in Mod FO 2
    //if ($('div').hasClass('MOD_FO_1')){
    //	$('#content table .ls-canvas').addClass('greybg');
    //}
    //(K) added to add grey BG in Mod FO 2
    $('.buyingOption').click(function () {
        $('#buying').show();
        $('.feature').hide();
    });
    $('#buying .close').click(function () {
        $('#buying').hide();
        $('.feature').show();
    });
    //$('.Mod_GC_14_panel').height($('.MOD_GC_14_2_left').outerHeight())
    //$('.Mod_GC_14_panel').height($('.MOD_GC_14_2_right').outerHeight())
    $('.MOD_GC_12_5 #product-navigation-trigger a').width($('.MOD_GC_12_5 #product-navigation-trigger a span').outerWidth());

    $('.MOD_GC_12_5 #product-navigation-trigger a span').width($('.MOD_GC_12_5 #product-navigation-trigger a span').outerWidth() - 10);

    //(VK)artf1180188
    var explorespan = $('.MOD_GC_12_5 #product-navigation-trigger a span').outerHeight();
    if (explorespan < 30) {
        $('.MOD_GC_12_5 #product-navigation-trigger span').height(30);
    }
    $('.agree').click(function () {
        $('.terms').hide();
        $('.terms_agree').show();
    });
});

/*Flash Detection*/

var MM_contentVersion = 6;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if (plugin) {
    var words = navigator.plugins["Shockwave Flash"].description.split(" ");
    for (var i = 0; i < words.length; ++i) {
        if (isNaN(parseInt(words[i]))) continue;
        var MM_PluginVersion = words[i];
    }
    var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
} else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE") >= 0 && (navigator.appVersion.indexOf("Win") != -1)) {
    document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
    document.write('on error resume next \n');
    document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
    document.write('</SCR' + 'IPT\> \n');
}
//alert(MM_FlashCanPlay);

function flashDetect() {
    if (MM_FlashCanPlay == true) {
        //document.getElementById(manual).write('Flash is installed');
        //document.getElementById('manual1').innerHTML="<a href=\"test.html\" title=\"Flash is installed\"> Flash is installed </a>";
        //alert("Flash Installed");
    } else {
        document.getElementById('degreelink').href = "/common/deere-resources/html/flashNotInstalled.html";
        //alert("Flash Installed");
    }
}



//PNG FIX JS INCLUDE

function loadScript(src, f) {
    var head = document.getElementsByTagName("head")[0];
    var script = document.createElement("script");
    script.src = src;
    var done = false;
    script.onload = script.onreadystatechange = function () {
        // attach to both events for cross browser finish detection:
        if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) {
            done = true;
            if (typeof f == 'function') f();
            // cleans up a little memory:
            script.onload = script.onreadystatechange = null;
            head.removeChild(script);
        }
    };
    head.appendChild(script);
}

if ($.browser.msie && $.browser.version == "6.0")
// example:
loadScript('/common/deere-resources/js/DD_belatedPNG.js');
//PNG FIX JS INCLUDE
/*DD - To make the tabs text vertically middle*/
$.fn.vAlign = function () {
    return this.each(function (i) {
        var ah = $(this).height();
        var ph = $(this).parent().height();
        var mh = Math.ceil((ph - ah) / 2) - 2;
        var ih = Math.ceil((ph - mh) - 2);
		
		/*DD artf1226921*/
        if (mh>0){
			$(this).css('padding-top', mh);
		}
        $(this).css('height', ih);
    });
};

/*DD Vertical Align for button*/
$.fn.verticalAlign = function () {
    return this.each(function (i) {
			var ah = $(this).height();
			var ph = $(this).parent().height();
			var mh = Math.ceil((ph - ah) / 2) - 5;
			$(this).css('margin-top', mh);
		});
	};


/*Browser Detection Script - DD artf1189723 : Header Nav */

function css_browser_selector(u) {
    var ua = u.toLowerCase(),
        is = function (t) {
            return ua.indexOf(t) > -1
        },
        g = 'gecko',
        w = 'webkit',
        s = 'safari',
        o = 'opera',
        m = 'mobile',
        h = document.documentElement,
        b = [(!(/opera|webtv/i.test(ua)) && /msie\s(\d)/.test(ua)) ? ('ie ie' + RegExp.$1) : is('firefox/2') ? g + ' ff2' : is('firefox/3.5') ? g + ' ff3 ff3_5' : is('firefox/3.6') ? g + ' ff3 ff3_6' : is('firefox/3') ? g + ' ff3' : is('gecko/') ? g : is('opera') ? o + (/version\/(\d+)/.test(ua) ? ' ' + o + RegExp.$1 : (/opera(\s|\/)(\d+)/.test(ua) ? ' ' + o + RegExp.$2 : '')) : is('konqueror') ? 'konqueror' : is('blackberry') ? m + ' blackberry' : is('android') ? m + ' android' : is('chrome') ? w + ' chrome' : is('iron') ? w + ' iron' : is('applewebkit/') ? w + ' ' + s + (/version\/(\d+)/.test(ua) ? ' ' + s + RegExp.$1 : '') : is('mozilla/') ? g : '', is('j2me') ? m + ' j2me' : is('iphone') ? m + ' iphone' : is('ipod') ? m + ' ipod' : is('ipad') ? m + ' ipad' : is('mac') ? 'mac' : is('darwin') ? 'mac' : is('webtv') ? 'webtv' : is('win') ? 'win' + (is('windows nt 6.0') ? ' vista' : '') : is('freebsd') ? 'freebsd' : (is('x11') || is('linux')) ? 'linux' : '', 'js'];
    c = b.join(' ');
    h.className += ' ' + c;
    return c;
};
css_browser_selector(navigator.userAgent);


/*Added Function for Popup Lavina/Vaibhav*/

function openDeerecomPopup(url) {
    //var winDims = 'width=600,height=500';
    var newWindow = window.open(url, "deerecompopupwindow", ',resizable=yes,scrollbars=yes,menubar=yes,toolbar=yes,directories=yes,location=yes,status=yes,copyhistory=yes');
}


/*DD Added the review link.*/
function showtabsreview(){
	//$('.BVRRRatingSummaryLinks a').click(function () {
	$('.MOD_NO_2_S li, .tabContent').removeClass('on');
	$('.MOD_NO_2_S .' + 'reviews' + ', .' + 'reviews').addClass('on');
};
