﻿var siteOverview;
var querylimit = 200;
$(document).ready(function() {

    $("#mytabset").semantictabs({
        panel: '.panel',            //-- Selector of individual panel body
        head: 'h3',             //-- Selector of element containing panel header, i.e. h3
        active: ':first'                         //-- Which panel to activate by default
    });
    $("#mytabset h3").addClass("hidden")



    // set active class on navigation for the current page context
    $("#nav_" + RootPageID).parent().addClass("active");
    $("#sln__" + PageLevel2ID).addClass("active");
    $("#apl__" + PageID).addClass("active");
    $(PageIDNavPath).addClass("active");

    //set collapsor for 3rd level nav
    $("div.left-nav ul a").collapsor({ speed: 500 });

    //set collapsor for locations
    $("div.location div.header").collapsor({ speed: 500, sublevelElement: "div.detail" });
    $("div.location div.header").each(function() {
        $(this).attr("title", "Click here to view details for " + $(this).text());
    });
    //set collapsor for accordians
    $("div.accordian div.a-folder div.a-header").collapsor({ speed: 500, sublevelElement: "div.a-content" });

    //set collapsor for car in rent a car
    $("div.carclass").collapsor({ speed: 500, sublevelElement: "div.carclassdetail" });
    $("div.carclass").each(function() {
        $(this).attr("title", "Click here to view the cars in the " + $(this).text() + " class");
    });
    //set mouse-over for 2nd level
    siteOverview = $("div.itemdescription").html();
    var tid = 0;
    $("div.sec-nav-content li a").hover(function() {
        var newOverview = "<strong>" + $(this).text() + "</strong> - " + $(this).attr("title");
        tid = setTimeout(function() { $("div.itemdescription").html(newOverview) }, 100);
    }, function() {
        clearTimeout(tid);
        $("div.itemdescription").html(siteOverview);
    });

    //set search default values
    $("#searchinput").blur(function() {
        if ($(this).val().trim() == "") $(this).val("search ...");
    }).focus(function() {
        if ($(this).val() == "search ...") $(this).val("");
    });

    //search check
    $("#search-form").submit(function() {
        if ($("#searchinput").val() == "search ...") {
            return false;
        }
    });

    // treeview for sitemap
    $("ul.sitemap").treeview();

    // set form values to values passed in querystring

    var names = jQuery.url.paramNames();
    for (var i = 0; i < names.length; i++) {
        if (names[i].toLowerCase() != "id") {
            var parm = jQuery.url.param(names[i]);
            if (parm) {
                $("select[name='" + names[i] + "'] option[value='" + parm.Replace("+", " ") + "']").attr("selected", "selected");
                $("input[name='" + names[i] + "']").val(parm.Replace("+", " "));
                $("textarea[name='" + names[i] + "']").val(parm.Replace("+", " "));
            }
        }
    }
});