var doResetMenuState = true;
var resetMenuTimer = 750;

// for collapsing 2nd level menu
var menuTrigger = null;

$(document).ready(function() {



    $('#submenu-c').html($('#submenu-placeholder').html());
    $('#submenu-placeholder').html('&nbsp;');

    $('#navigation').append($('#tertiairmenu-content').html());

    $("#search").click(function() { $(this).addClass("active"); })
						.blur(function() { if ($("#search").attr("value") == "") { $(this).removeClass("active"); }; })
						.attr("value", "");
    $("#btn-search").click(function() { submit_onclick("frm_search", true); return false; });


    // Display helptext in the keywords input field in the search control.
    $("INPUT#keywords").focus(
							function() {
							    if ($(this).val() == "keywords...") {
							        $(this).val("");
							        $(this).removeClass("help");
							    }
							})
						.blur(
							function() {
							    if ($(this).val() == "") {
							        alert('a');
							        $(this).addClass("help");
							        $(this).val("keywords...");
							    }


							});

    doTransforms();
    doPostTransforms();

    //Controleren of cufonenables true is anders niet gebruiken i.v.m. russische taal
    if (cufonEnabled) {
        /* cufon replace tekst */
        Cufon.replace('#menu li a', { hover: true });
        Cufon.replace('#downloads-search .custom', { hover: true });
        Cufon.replace('.moodboard .lbl_jobs', { hover: true });
    }

    // Reset menu state when the mouse leaves the menu to reflect your current location in the navigation menu.
    $("#navigation").mouseover(function() { doResetMenuState = false; })
						.mouseout(function() { doResetMenuState = true; setTimeout(function() { resetMenuState(); }, resetMenuTimer); });

    // Tertiair menu mouse-overs.
    $("#tertiairmenu LI").hover(
        function() {

            var sub = $(this).find("UL");

            $(this).addClass("active");
            if ($('.lelysite11').size() > 0) {
                sub.stop(true, true).slideDown('slow');
            } else {
                sub.show();
            }
            if (sub.length == 1 && sub.hasClass("tertiairmenu-bg")) {
                $(this).addClass("sprite tertiairmenu-tab");
            }
        },
         function() {
             var sub = $(this).find("UL");

             if (!$(this).hasClass("current"))
                 $(this).removeClass("active");
             sub.stop(true, true).hide();
             if (sub.hasClass("tertiairmenu-bg")) {
                 $(this).removeClass("sprite tertiairmenu-tab");
             }

         });

    $('#tertiairmenu').hover(
        function() { },
        function() { $(this).find('ul').not('ul ul').slideUp('slow'); }
    );

    // Choose your language dropdown.
    $(".languagebar").mouseover(function() { $(this).addClass("active"); $("#languages").removeClass("hidden"); })
						.mouseout(function() { $(this).removeClass("active"); $("#languages").addClass("hidden"); });

    $(".nav .tab").mouseover(function() { $(this).addClass("hover"); })
						.mouseout(function() { $(this).removeClass("hover"); });

    //default tekst van tab activeren wanneer er een subcontainer is geactiveerd.
    //    $(".nav .tab.active").click(function() {
    //        if (($("#details-body-intro").length > 0 && !$("#details-body-intro").hasClass("hidden")) || ($("#product-details-intro").length > 0 && !$("#product-details-intro").hasClass("hidden")) || $("#product-details-default").length > 0) return;
    //        $(this).parent().parent().parent().find(".content").find(".container").addClass("hidden");

    //        if ($("#details-body-intro").length > 0) $("#details-body-intro").removeClass("hidden");
    //        if ($("#product-details-intro").length > 0) $("#product-details-intro").removeClass("hidden");
    //    })

    // Request more info pops a highslide with contact information.
    $(".moodboard .request-more-info").mouseover(function() { $(this).addClass("active"); })
									  .mouseout(function() { $(this).removeClass("active"); });

    // Handle product buttons.
    $(".buttons DIV").mouseover(function() { if (!$(this).hasClass("current")) $(this).addClass("active"); })
						.mouseout(function() { if (!$(this).hasClass("current")) $(this).removeClass("active"); })
						.click(function() {

						    if ($(this).hasClass("unclickable")) return;
						    // toggle button
						    $(this).parent().find("DIV").removeClass("current active");
						    $(this).addClass("current active");

						    // toggle container
						    var container = $("#" + $(this).attr("id").replace("btn-", ""));
						    $(this).parent().parent().find(".container").addClass("hidden");
						    //$(this).parent().parent().find(".container").addClass("invisible");
						    $(container).removeClass("hidden");
						    //$(container).removeClass("invisible");
						});


    //
    $(".textlinks a").click(function() {

        //reset current textlinks
        $(this).parent().parent().find('a').each(function() {
            $(this).removeClass('active current');
        })

        $(this).addClass("active current");


        // toggle container
        var container = $("#" + $(this).attr("id").replace("btn-", ""));
        var c = $(this).parent().parent().parent().parent().attr("id");
        $("#" + c + " > .container").addClass("hidden");
        $(container).removeClass("hidden");
        $(this).addClass('active');
        return false;
    });


    // Handle the mouse-over and click events of the thumbnails on the product details page.
    $("#product-viewer .thumbs IMG").mouseover(function() { if (!$(this).hasClass("current")) $(this).addClass("active"); })
									.mouseout(function() { if (!$(this).hasClass("current")) $(this).removeClass("active"); })
									.click(function() {
									    $("#product-viewer .container").addClass("hidden");
									    $("#product-viewer .buttons DIV").removeClass("current active");
									    $("#product-viewer .bigimage").css("background-image", "url('" + $(this).attr("longdesc") + "')");
									});

    // Downloads listing - Harmonica effect
    $("#downloads-listing LI").click(function() {
        var sender = $(this);
        var thisId = $(this).attr('id');

        var isSenderActive = $(sender).hasClass("active");
        var dontclose = $(sender).hasClass("dontclose");

        // close other items
        $("#downloads-listing LI").each(function() {
            if (!dontclose && !isSenderActive) {
                $(this).removeClass("active");
                $(this).find(".btn").removeClass("active");
                $(this).find(".details").slideUp();
                if ($(this).find('.btn-opengallery').size() > 0) {
                    $(this).find('.greyarrow-down').show();
                    $(this).find('.btn-opengallery').hide();
                }
            }
        });

        // open selected item
        if (!isSenderActive) {
            $(this).find(".btn").addClass('active');
            $(this).find(".details").slideDown();
            $(this).addClass("active")
            if ($(this).find('.btn-opengallery').size() > 0) {
                $(this).find('.greyarrow-down').hide();
                $(this).find('.btn-opengallery').show();
            }

        }

        if ($(this).hasClass('hassocial')) {
            loadSocial($('#socialKey').val(), thisId);
        }
    });


    // Downloads listing - Harmonica effect
    function openDonwloadList(object) {
        var sender = $(object);

        var isSenderActive = $(sender).hasClass("active");
        var dontclose = $(sender).hasClass("dontclose");

        // close other items
        $("#downloads-listing LI").each(function() {
            if (!dontclose && !isSenderActive) {
                $(this).removeClass("active");
                $(this).find(".btn").removeClass("active");
                $(this).find(".details").slideUp();
                if ($(this).find('.btn-opengallery').size() > 0) {
                    $(this).find('.greyarrow-down').show();
                    $(this).find('.btn-opengallery').hide();
                }

            }
        });

        // open selected item
        if (!isSenderActive) {
            $(object).find(".btn").addClass('active');
            $(object).find(".details").slideDown('fast', function() { window.scrollTo($(object).position().left, $(object).position().top - 100); });
            $(object).addClass("active")
            if ($(object).find('.btn-opengallery').size() > 0) {
                $(object).find('.greyarrow-down').hide();
                $(object).find('.btn-opengallery').show();
            }

            if ($(object).hasClass('hassocial')) {
                loadSocial($('#socialKey').val(), $(object).attr('id'));
            }
        }

    };



    //Latest Downloads listing - Harmonica effect
    $("#downloads-latestMedia A").click(function() {
        // var id = $(this).attr('id').replace("link_", "")


        var str = $(this).attr('id');
        var params = str.split(",");
        var id = params[0].replace("link_", "")

        var sender = $('#' + id);

        if (sender.length == 0) {
            var perma = params[1];

            //alert(PROJECT_URL + LANG);
            //var selected = $('#docSelected').attr('value')
            if (perma == null || perma == "") {
                window.location.replace(window.location.pathname + "?tagId=&tagId=&keywords=&docSelected=" + id);
            }
            else {
                window.location.replace(PROJECT_URL + LANG + "/" + perma + "?tagId=&tagId=&keywords=&docSelected=" + id);
            }
        }
        else {
            openDonwloadList(sender);
        }

        return false
    });

    //Latest video,picture.. selected from intro page
    var selected = $('#docSelected').attr('value')
    if (selected) {
        openDonwloadList($("#" + selected));

    }


    // (De)activate picture download buttons
    $("#downloads-listing LI LI").mouseover(function() { $(this).addClass("active").find(".btn").addClass("active"); })
									.mouseout(function() { $(this).removeClass("active").find(".btn").removeClass("active"); });

    // Homepage banners - Vertical Sliding
    //    $('.boxgrid.slideup').hover(function() {
    //        $(".cover", this).stop().animate({ bottom: '0px' }, { queue: false, duration: 100 });
    //    }, function() {
    //        $(".cover", this).stop().animate({ bottom: '-45px' }, { queue: false, duration: 400 });
    //    });

    // Set the width of the UL that holds the images.
    $("#homepage_banners UL").css("width", ($("#homepage_banners UL LI").length + 1) / 2 * (140 + 22) - 22);

    $('.extended-search').hover(
        function() { $(this).addClass('hover'); },
        function() { $(this).removeClass('hover'); }
     )
    // Enable horizontal scrolling of the banners.
    $(".scroll-pane").jScrollHorizontalPane({
        showArrows: true,
        scrollbarMargin: 0,
        scrollbarHeight: 15,
        arrowSize: 20,
        dragMinWidth: 490,
        dragMaxWidth: 490,
        wheelSpeed: 100
    });

    // Enable horizontal scrolling of the banners.
    $(".gallery-scroll-pane").jScrollHorizontalPane({
        showArrows: true,
        scrollbarMargin: 0,
        scrollbarHeight: 15,
        arrowSize: 20,
        dragMinWidth: 490,
        dragMaxWidth: 490,
        wheelSpeed: 100,
        reset: true
    });

    $('.btn_previous, .btn_next').click(function() {
        var the_current_possition = $('.mainimageblock').attr('id');
        the_current_possition = the_current_possition.replace('image_', '');
        the_current_possition = parseFloat(the_current_possition);
        var goto_position;
        if ($(this).hasClass('btn_next')) {
            goto_position = the_current_possition + 1;
        } else {
            goto_position = the_current_possition - 1;
        }
        $('.gallery #item_' + goto_position).click();
    })

    if ($('.gallery').size() > 0) {
        var goto_position = $('#goto_position').val();

        showImage($('#item_' + goto_position, 0, 0));
    }

    //Printen
    $('.btn-print').click(function() {
        printme();
        return false;
    })

    $('.hidewhileloaded').removeClass('hidewhileloaded').addClass('hidden');

    $('.submenu a').hover(
		function() {

		    var the_id = $(this).parent().attr('id');
		    the_id = the_id.replace('submenu-', 'tertiairmenu-');

		    // uitzondering voor animatie lely.com
		    if ($('.lelysite1 #' + the_id + ',.lelysite11 #' + the_id).size() > 0) {
		        if (!$('#' + the_id).is(':visible')) {
		            $('.lelysite1 #tertiairmenu ul, .lelysite11 #tertiairmenu ul').stop(true, true).hide();
		            if ($('#' + the_id).size() > 0) {
		                $('#' + the_id).slideDown('slow');
		            }
		        }
		    } else {
		        if ($('#' + the_id).size() > 0) {
		            $('#' + the_id).show();
		        } else {
                    $('.lelysite1 #tertiairmenu ul, .lelysite11 #tertiairmenu ul').stop(true, true).hide();
		        }
		    }
		    $('.submenu .hover').removeClass('hover');
		    $(this).parent().addClass("hover");
		    $(this).parent().find("IMG").addClass("hover");

		},
		function() {
		}
	)

    $('#navigation').hover(
		function() { },
		function() {
		    $('#submenu-c .hover').removeClass('hover');
		    $('#submenu-c').find('.hidden').hide();
		    $('#submenu-c').find('.active').show().addClass('hover');
		}
	)

    $('#tertiairmenu li').hover(
		function() {
		    $('#tertiairmenu li').removeClass('hover')
		    $(this).addClass('hover')
		},
		function() { }
	)

    $('#sitemap a:not(#sitemap .nochilds a, #sitemap li li a)').click(function() {
        var sublist = $(this).parent().find('ul:first');
        var parentlist = $(this).closest('li');
        if (!sublist.is(":visible")) {
            $('#sitemap .sublist').slideUp()
            $('#sitemap .actlink').removeClass('actlink')
            $('#sitemap .act').removeClass('act');

            sublist.slideDown().addClass('sublist');
            $(parentlist).addClass('act');
            $(this).addClass('actlink');
            return false;
        } else if ($(this).hasClass('actlink')) {
            $('#sitemap .sublist').slideUp()
            $('#sitemap .actlink').removeClass('actlink')
            $('#sitemap .act').removeClass('act');
            return false;
        }
    })

    $('#sitemap a:not(#sitemap .nochilds a)').hover(
        function() { $(this).parent().addClass('hover') },
        function() { $(this).parent().removeClass('hover') }
    )
});

function doTransforms() {
	// jqTransform makes the form controls looks nice.
	$('#footer').jqTransform({imgPath:PROJECT_URL + 'js/img/'});
	$("#product-finder").jqTransform({imgPath:PROJECT_URL + 'js/img/'});
	$("#downloads-search").jqTransform({imgPath:PROJECT_URL + 'js/img/'});
	$("#frmRequestMoreInfo").jqTransform({ imgPath: PROJECT_URL + 'js/img/' });
	$("#news-events").jqTransform({imgPath:PROJECT_URL + 'js/img/'});
}

function doPostTransforms() {
	$(".postTransform").css("visibility", "visible").addClass("hidden");
}

function showTertiairMenu(sender) {
    /*
	var subId = $(sender).parent().attr("id").split("-")[1];
	var tertiairId = $(sender).parent().attr("id").split("-")[2];

	// deactivate all submenu items
	$(sender).parent().parent().find("LI").each(function() { $(this).removeClass("active"); $(this).find("IMG").removeClass("active"); });
	$("UL[id^=tertiairmenu-]").each(function() { $(this).addClass("hidden"); });

	// activate submenu item
	$(sender).parent().addClass("active").find("IMG").addClass("active");
	$("UL#tertiairmenu-" + subId + "-" + tertiairId).removeClass("hidden");
	*/
}

function resetMenuState() {
	if (!doResetMenuState)
		return;

	var currentSubmenuId, currentTertiairmenuId;
    /*
	// activate current submenu
	$(".submenu LI").each(function() {
		if (!$(this).hasClass("current") || $(this).parent().hasClass("hidden")) {
			$(this).removeClass("active");
			$(this).find("IMG").removeClass("active");
		} else {
			$(this).addClass("active");
			$(this).find("IMG").addClass("active");
			currentSubmenuId = $(this).attr("id").split("-")[1];
			currentTertiairmenuId = $(this).attr("id").split("-")[2];
		}
	});

	// show current tertiairmenu
	$("UL[id^=tertiairmenu]").each(function() {
		var subId = $(this).attr("id").split("-")[1];
		var tertiairId = $(this).attr("id").split("-")[2];
		if (subId == currentSubmenuId && tertiairId == currentTertiairmenuId) {
			$(this).removeClass("hidden");
		} else {
			$(this).addClass("hidden");
		}
	});

	// activate the current menu item in the tertiairmenu
	$("#tertiairmenu LI").each(function() {
		if (!$(this).hasClass("current")) {
			$(this).removeClass("sprite tertiairmenu-tab active");
		} else {
			$(this).addClass("active");
		}
	});

	// menu is eligible for a reset again
	doResetMenuState = true;
	*/
}

function showTab(li, startId, activeId) {
	// deactivate all tabs
	$(".nav .tab").each(function() { $(this).removeClass("current active"); });
	$("DIV[id^=" + startId + "]").each(function() { $(this).addClass("hidden"); });

	// activate selected tab
	$("DIV[id^=" + startId + activeId + "]").removeClass("hidden");
	$(li).addClass("current active");
	doTransforms();
}

function showListingDiv(sender, divStartId, div) {
	// deactivate listing items
	$(sender).parent().parent().find("A").each(function() { $(this).removeClass("active"); });
	$("DIV[id^=" + divStartId + "]").each(function() { $(this).addClass("hidden"); });

	// activate selected item
	$(sender).addClass("active");
	$("#" + divStartId + div).removeClass("hidden");
}

function showContactDetails(select) {
	$("DIV[id^=contact-details-]").addClass("hidden");
	$("#contact-details-" + select.value).removeClass("hidden");

}

function getFooterCountry(select) {

  $.ajax({
    async: true,
    url: SITE_URL + LANG + '/xml/getFooterCountryLocations?permalink=' + select,
    success: function(data) {
      $("#subLocations").html(data);
      if (data.indexOf("<!-- -->") == -1) {
        //alert('haal eerste result op!');
        //getFooterCountryFirstLocation(select);
        //alert('haal niets op');
      } else {
        //alert('haal default result op!');
        getFooterCountryLocation(select);
      }
      $('.subLocationSelector').jqTransform({ imgPath: PROJECT_URL + 'js/img/' });
    }
  });

}

function getFooterCountryLocation(select) {
  if (select !== 'NON') {
    $.ajax({
      url: SITE_URL + LANG + '/xml/getFooterCountry?permalink=' + select,
      success: function(data) {
        $('.contact').html(data);
      }
    });
  }
}

function getFooterCountryFirstLocation(select) {
  $.ajax({
    url: SITE_URL + LANG + '/xml/getFooterCountryFirstLocation?permalink=' + select,
    success: function(data) {
      $('.contact').html(data);
    }
  });
}


function pagingGotoImg(sender, imageIdPrefix, imageId) {
	var activePage = $(sender).parent();
	var pagingLIs = $("#" + imageIdPrefix + "-container").find("IMG");
	var maxImages = pagingLIs.length;
	//var pagingLIs = $(sender).parent().parent().find("LI");
	//var maxImages = (pagingLIs.length - 3) / 2;

	
    
	$("IMG[id^=" + imageIdPrefix + "]").each(function() {
		if (isNaN(imageId) && !$(this).hasClass("hidden")) {
			// imageId = 'next' or 'prev'
			imageId = parseInt($(this).attr("id").replace(imageIdPrefix + "-", "")) + (imageId == "next" ? 1 : -1);
			
			// check bounds
			if (imageId < 1) imageId = maxImages; //if lower bound is reached goto upperbound
			if (imageId > maxImages) imageId = 1; //if upper bound is reached goto lowerbound

			// calculate new page
			activePage = $(pagingLIs)[imageId * 2];
		}
           
		// hide old image
		$(this).addClass("hidden");
	});

	// show new image
	$("#" + imageIdPrefix + "-" + imageId).removeClass("hidden");
	
	
	//$(pagingLIs).removeClass("active");
	//$(activePage).addClass("active");
}

function ajaxSearch(form) {

}

function display(id, arr) {
    if (arr != undefined) {
        var a = arr.split(',')
        for (i = 0; i < a.length; i++) {
            $('#' + a[i]).css('display', 'none');
        }
    }
    var style = $('#' + id).css('display');
    if (style == 'none') {
        $('#' + id).css('display', 'block');
    }
    return false
}

function showResultMailFriend() {
    display('cont-mailfriend-result', 'cont-mailfriend');
}

function doProductFinder(currentElement, oCategory, oGroup, oModel) {


    $.ajax({
        type: "POST",
        url: PROJECT_URL + LANG + "/xml/UpdateProductFinder/?productCategory=" + oCategory.val() + "&productGroup=" + oGroup.val() + "&productModel=" + oModel.val() + "&level1=" + $("#level1").val(),
        dataType: "html",
        success: function(txt) {
            $('#container-product-finder').html(txt);
            $("#product-finder form").jqTransform({ imgPath: PROJECT_URL + 'js/img/' });
        }
    });

    return false;
}

function printme() {
    var objOut = document.getElementById("toprint");
    var out = objOut.innerHTML;

    var wh = window.open("", "wh", "width=640px,height=480px,scrollbars=yes");
    wh.document.open();
    var stylesheet = '<link href="' + PROJECT_URL + 'Content/css/print.css" rel="stylesheet" type="text/css" />';
    var output = '<html><head>' + stylesheet + '</head><body>' + out.replace('<object', '<!--object').replace('/object>', '/object-->') + '</body></html>';
    output += '<' + 'script type="text/javascript">';
    output += 'setTimeout("window.print()",2000);';
    output += '</' + 'script>';
    wh.document.writeln(output);
    wh.document.close();
}

function DoAjaxPagingCall(id, action, page){
    var url = PROJECT_URL + action.replace('page=','');
    url += 'page=' + page
    $.ajax({
        type: "GET",
        url: url,
        dataType: "html",
        success: function(html) {
            $('#'+ id).html(html);
        }
    });
}

// functie voor bij tips, zodat niet dichtklapt
function gotoUrl(obj, url) {
    location.href = url;
    $(obj).parents('li').addClass('dontclose');
    return false;
}

function extendSearch() {
    $('.extended-search').toggleClass('hidden');
    if ($('.extended-search').is(':visible')) { $('#useExtendedSearch').val('1'); } else { $('#useExtendedSearch').val('0'); }
  }

  function addChildregistrationLAC() {
    $("#counter").val(parseFloat($("#counter").val()) + 1)

    //for (i = 1; i < $("#counter").val(); i++) {
      //alert(i);
      //alert($("#extrainfo" + i).attr("id"));
      //$("#extrainfo" + i).hide();
    //}
    
    var t = $('#addChild:last').last().clone();
    t.html(t.html().replace('childfirstName1', 'childfirstName' + $("#counter").val()).replace('childfirstName1', 'childfirstName' + $("#counter").val()));
    t.html(t.html().replace('childdateofbirth1', 'childdateofbirth' + $("#counter").val()).replace('childdateofbirth1', 'childdateofbirth' + $("#counter").val()));
    t.html(t.html().replace('childgender1', 'childgender' + $("#counter").val()).replace('childgender1', 'childgender' + $("#counter").val()).replace('childgender1', 'childgender' + $("#counter").val()).replace('childgender1', 'childgender' + $("#counter").val()));
    t.html(t.html().replace('extrainfo', 'extrainfo' + $("#counter").val()));
    t.html(t.html().replace('ammount', $("#counter").val()));
    t.html(t.html().replace('replacedClass', 'extrainfo'));
    t.prependTo('#childContainer');
}

function changePersonsRegistrationAgritechna() {
    var count = parseFloat($('#Visitors_NumberOfPersons').val());
    var PersonTranslated = $('#addPersonName').val();
    var CompanyTranslated = $('#addPersonCompany').val();
    var WhenOnExhibitionTranslated = $('#addPersonWhenOnExhibition').val();
    var html = $('#addPersonIntro').html()
    var t = $("#addPerson").html()
    if (count > 50) {
        $('#Visitors_NumberOfPersons').attr('value', '50');
        count = 50;
    }
    
    if (count > 0) {

        for (i = 0; i < count; i++) {
            var strPerson = PersonTranslated + (i + 1);
            if (i > 0) {
                //Name
                html += '<div class="label">&nbsp;</div>';
                html += '<div class="input-container" style="">';
                html += '   <div class="sprite input-left"><!-- --></div>';
                html += '   <input type="text" id="Visitors_NameOfPersons_" name="Visitors_NameOfPersons_' + (i + 1) + '" maxlength="50" value="' + strPerson + '" title="" />';
                html += '   <div class="sprite input-right"><!-- --></div>';
		        html += '</div>';
		        html += '<div class="clear"><!-- --></div>';
		        
		        //Company
		        html += '<div class="label">&nbsp;</div>';
		        html += '<div class="input-container" style="">';
		        html += '   <div class="sprite input-left"><!-- --></div>';
		        html += '   <input type="text" id="Visitors_CompanyOfPersons_' + (i + 1) + '" name="Visitors_CompanyOfPersons_' + (i + 1) + '" maxlength="50" value="' + CompanyTranslated + '" title="" />';
		        html += '   <div class="sprite input-right"><!-- --></div>';
		        html += '</div>';
		        html += '<div class="clear"><!-- --></div>';

            }
            else {

                //Name
                html += '<div class="input-container" style="">';
                html += '   <div class="sprite input-left"><!-- --></div>';
                html += '   <input type="text" id="Visitors_NameOfPersons_' + (i + 1) + '" name="Visitors_NameOfPersons_' + (i + 1) + '" maxlength="50" value="' + strPerson + '" title="" />';
                html += '   <div class="sprite input-right"><!-- --></div>';
                html += '</div>';
                html += '<div class="clear"><!-- --></div>';

                //Company
                html += '<div class="label">&nbsp;</div>';
                html += '<div class="input-container" style="">';
                html += '   <div class="sprite input-left"><!-- --></div>';
                html += '   <input type="text" id="Visitors_CompanyOfPersons_' + (i + 1) + '" name="Visitors_CompanyOfPersons_' + (i + 1) + '" maxlength="50" value="' + CompanyTranslated + '" title="" />';
                html += '   <div class="sprite input-right"><!-- --></div>';
                html += '</div>';
                html += '<div class="clear"><!-- --></div>';
            }
        }

        html += '<div class="label" style="width:217px;">' + WhenOnExhibitionTranslated + '</div>'
        html += '<div class="clear"><!-- --></div> '

        html += '<div class="chckblabel"><input type="checkbox"  id="Visitors_Exhibition_13-11" name="Visitors_Exhibition" value="13.11."  /></div><div class="chckbtextvisitors" style="width:60px;">13.11.</div>'
        html += '<div class="chckblabel"><input type="checkbox" id="Visitors_Exhibition_14-11" name="Visitors_Exhibition"  value="14.11." /></div><div class="chckbtextvisitors" style="width:60px;">14.11.</div>'
        html += '<div class="chckblabel"><input type="checkbox"  id="Visitors_Exhibition_15-11" name="Visitors_Exhibition" value="15.11." /></div><div class="chckbtextvisitors" style="width:60px;">15.11.</div>'
        html += '<div class="chckblabel"><input type="checkbox"  id="Visitors_Exhibition_16-11" name="Visitors_Exhibition" value="16.11." /></div><div class="chckbtextvisitors" style="width:60px;">16.11.</div>'
        html += '<div class="clear"><!-- --></div> '
        html += '<div class="chckblabel"><input type="checkbox"  id="Visitors_Exhibition_17-11" name="Visitors_Exhibition" value="17.11." /></div><div class="chckbtextvisitors" style="width:60px;">16.11.</div>'
        html += '<div class="chckblabel"><input type="checkbox"  id="Visitors_Exhibition_18-11" name="Visitors_Exhibition" value="18.11." /></div><div class="chckbtextvisitors" style="width:60px;">18.11.</div>'
        html += '<div class="chckblabel"><input type="checkbox"  id="Visitors_Exhibition_19-11" name="Visitors_Exhibition" value="19.11." /></div><div class="chckbtextvisitors" style="width:60px;">19.11.</div>'
        html += '<div class="clear"><!-- --></div> '
        
        $('#personContainer').html(html);
    }else {
        $('#personContainer').html('');
    }
}

function TransferRequiredRegistrationAgritechna(sender) {
    if ($(sender).attr("id") == 'Arrival_TransferYes') {

        //Check if Div exists
        if ($('#Arrival_TransferRequired').length > 0) {
            $('#Arrival_TransferRequired').show()
        }

        if ($('#Arrival_FlightTrainId').length > 0) {
            $('#Arrival_FlightTrainId').attr('title', 'FlightTrainId');
        }
    }
    else if ($(sender).attr("id") == 'Arrival_TransferNo') {

        //Check if Div exists
        if ($('#Arrival_TransferRequired').length > 0) {
            $('#Arrival_TransferRequired').hide()
        }

        if ($('#Arrival_FlightTrainId').length > 0) {
            $('#Arrival_FlightTrainId').attr('title', '');
        }
    }
    else if ($(sender).attr("id") == 'Departure_TransferYes') {
        //Check if Div exists
        if ($('#Departure_TransferRequired').length > 0) {
            $('#Departure_TransferRequired').show()
        }

        if ($('#Departure_FlightTrainId').length > 0) {
            $('#Departure_FlightTrainId').attr('title', 'FlightTrainId');
        }
        
        
    }
    else if ($(sender).attr("id") == 'Departure_TransferNo') {
        //Check if Div exists
        if ($('#Departure_TransferRequired').length > 0) {
            $('#Departure_TransferRequired').hide()
        }

        if ($('#Departure_FlightTrainId').length > 0) {
            $('#Departure_FlightTrainId').attr('title', '');
        }
    }

}

function BookHotelRegistrationAgritechna(sender) {
    if ($(sender).attr("id") == 'Hotel_Yes') {

        //Check if Div exists
        if ($('#Hotel_rooms').length > 0) {
            $('#Hotel_rooms').show()
        }
    }
    else {

        //Check if Div exists
        if ($('#Hotel_rooms').length > 0) {
            $('#Hotel_rooms').hide()
        }
    }
}

function PresentationRegistrationAgritechna(sender) {

    if ($(sender).attr("id") == 'JoinPresentation_Yes') {

        //Check if Div exists
        if ($('#Agritechnica_Languages').length > 0) {
            $('#Agritechnica_Languages').show()
        }
    }
    else {

        //Check if Div exists
        if ($('#Agritechnica_Languages').length > 0) {
            $('#Agritechnica_Languages').hide()
        }
    }
}

  function openExtraInfo(ammount) {
    $("#extrainfo" + ammount).toggle();
}

function showImage(obj, width, height) {

    var the_image = $(obj).attr('href');
    var totalItems = parseFloat($('#totalitems').val());

    if (width > 0 && height > 0) {
        $('#mainimage').removeAttr("style").attr('src', the_image);

        var marginTop = 0;
        var marginLeft = 0;
            
        marginTop = 480 - height;
        if (marginTop > 0){
            marginTop = marginTop / 2
        }

        marginLeft = 640 - width;
        if (marginLeft > 0) {
            marginLeft = marginLeft / 2
        }
        $('#mainimage').attr('style', 'margin:' + marginTop + 'px 0 ' + marginTop + 'px ' + marginLeft + 'px');
    }

    var pos = $(obj).attr('id').replace('item_', '');
    pos = parseFloat(pos);
    $('.mainimageblock').attr('id', 'image_' + pos);
    
    if (pos == totalItems) {
        $('.btn_next').hide();
    } else {
        $('.btn_next').show();
    }

    var bigimage = $('#bigimage_' + pos).val();
    $('.download-image').attr('href', bigimage);

    var nextpost = pos - 3;
    var c = $(".gallery-scroll-pane");
    c[0].scrollTo("li:eq(" + nextpost + ")");
}

function loadSocial(key, id) {

    $.ajax({
        type: "POST",
        url: PROJECT_URL + LANG + '/Xml/Social?key=' + key + '&id=' + id,
        data: {},
        cache: false,
        dataType: "html",
        success: function(html) {
            $('#social-' + id).html(html);
        }
    });

}

function resetMenu() {
    $('.lelysite1 #tertiairmenu ul, .lelysite11 #tertiairmenu ul').stop(true, true).hide();
}
