﻿$(document).ready(function() {

    var navlead = $("#logo a").attr("href");
    var themepath = navlead + "themes/Harlan.Themes.Default";
    $("#HTML1_plcContent1 a").append("<img src=\"" + themepath + "/images/Har_ArrowRightGreen1.png\" alt=\"more\"/>");
    $("#HTML2_plcContent1 a").append("<img src=\"" + themepath + "/images/Har_ArrowRightGrnblue.png\" alt=\"more\"/>");
    $("#HTML3_plcContent1 a").append("<img src=\"" + themepath + "/images/Har_ArrowRightGreen2.png\" alt=\"more\"/>");

    // indents links on RMS page
    var $indents = $('.relatedlinks ul li a').filter(function() {
        return this.innerHTML.indexOf('..') == 0;
    });
    $indents.each(function() {
        $(this).parent().addClass('indent').end().text($(this).text().replace(/\.\./, '')).before('<span class="divider">&#8226;</span>');
    });

    if ($('body.edit-mode').length) {
        $("#Background-Image").css("position", "relative");
    }

    

    //for admin tools only.
    if ($(".menuGlider-error").text().length > 0) {
        alert("You have a problem with the Menu Sliding Widget.  The path you entered is not correct. Please correct it below.");
    }

	// products and services landing page
    if (/products_and_services$/.test(document.location)) {
		// disable the rms menu so we can add the product types
		var $rms = $('.menuGlider:first').addClass('disabled');
        $rms.addClass("rms");
        $(".freeform p").addClass("ProSerPWidth");
        
		$.getJSON(navlead + 'ModelsJSON.aspx?method=producttypes', function(data) {
			var $rm = $rms.find('a[title=Research Models]'),
				href = $rm.attr('data-url'),
				$li = $rm.parent(),
				$ul = $('<ul></ul>').appendTo($li);
			
			for (var x = 0; x < data.length; x++) {
				var t = data[x];
				$ul.append('<li><a href="' + href + '-' + t.urlname + '">' + t.name + '</a></li>');
			}
			$rms.removeClass('disabled').menuglider();
		});
    }
    
    $(".menuGlider:not(.disabled)").menuglider();
});
