﻿$(document).ready(function() {
    setUpPage();
    
});

function setUpPage()
{
    $("#tabs li").hover(function() { if (!$(this).hasClass("hold")) $(this).addClass("hover"); }, function() { $(this).removeClass("hover"); });
    $("#tabs li").click(function() {
        var url = $(this).children("a").attr("href");
        window.location = url;
    });

    $(".orange_button").validate();

    $("#map").click(function() {
        tb_show("205 Ellis St, Frankton", "popMap.aspx?&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=315&width=390");
    });


    $("#catagoryBar div").hover(function() { $(this).addClass("hover"); }, function() { $(this).removeClass("hover"); });
    $("#catagoryBar div").click(function() {
        var id = $(this).attr("id");
        $(this).addClass("hold");
        $(".txtCategoryID").val(id);
        $(".btnGetProducts").click();
    });

    $("#subcatagorybar span").hover(function() { $(this).addClass("hover"); }, function() { $(this).removeClass("hover"); });
    $("#subcatagorybar span").click(function() {
        var id = $(this).attr("id");
        $(this).addClass("hold");
        $(".txtSubCategoryID").val(id);
        $(".btnGetProducts2").click();
    });

    $("#subcatagorybar span").each(function() {
        if ($(this).attr("id") == $("#ctl00_ContentPlaceHolder1_txtSubCategoryID").val()) {
            $(this).addClass("hold");
        }
    });

    $(".orange_button_quote").click(function() {
        var id = $(this).siblings(".hide").html();
        window.location = "Order.aspx?type=1&cat=" + id;
    });

    $(".orange_button_view").click(function() {
        var id = $(this).siblings(".hide").html();
        tb_show("View Product on Car", "popOnCar.aspx?id=" + id + "&keepThis=true&TB_iframe=true&height=270&width=320", 'false');
    });

    $("#rOrder").click(function () { $("#rQuote")[0].checked = false; $(".radiobutton").val("1"); });
    $("#rQuote").click(function () { $("#rOrder")[0].checked = false; $(".radiobutton").val("2"); });

    $(".orderchecks").click(function () {
        $(".orderchecks").each(function () { $("input", this)[0].checked = false; });
        $("input", this)[0].checked = true;
    });

    $("#mycarousel li").click(function() {
        $(".contentIDhidden").val($(this).children(".hide").html());
        $(".btnviewcat").click();
    });

    $("#mycarousel2 li").click(function () {
        $(".contentIDhidden").val($(this).children(".hide").html());
        $(".btnviewcat").click();
    });

    $("#lowerhome").css("display", "block");
    $("#mycarousel").jcarousel();
    $("#mycarousel li:first").click();

    $("#mycarousel2").jcarousel();
    /*$("#mycarousel2 li:first").click();*/

    $("#hotproducts div").click(function() {
        var cat = $(this).children().children(".category").html();
        window.location = "Order.aspx?cat=" + cat;
    });

    $(".ddlproducts").change(function () {
        if ($(".txttick").val() != "") {
            var answer = confirm("One order per vehicle type can be stored at one time. Do you wish to start a new order?");
            if (answer) {
            
            } else {
                return false;
            }
        }
    });

    $(".orange_button_longer_ab").click(function() {

        var cats = "";
        var x = 0;
        $("#cats input").each(function() {
            if (x == 0) {
                if ($(this)[0].checked) cats = $(this).attr("id");
                x++;
            }
            else {
                if ($(this)[0].checked) cats = cats + "|" + $(this).attr("id");
            }

        });

        $(".tickedcats").val(cats);
    });
}

function setUpOrdering() {

    $(".gvhomeproducts input").click(function () {

    });
    
}
