$(document).ready(function () {


    //   Overlay2
    if ($(".overlay2").length) {
        $(".overlay2").css("width", $(document).width() + "px");
        $(".overlay2").css("height", $(document).height() + "px");
        $(".overlay2").click(function () {
            $(this).hide();
            $("#pop-Subscription").removeClass("on");
            $("#pop-Error").removeClass("on");
            $(".pop-data .close").hide();
            $(".pop").fadeOut();
            return false;
        });
    }


    // Subscription Close
    $(".pop-data .close").click(function () {
        $(".overlay2").hide();
        $("#pop-Subscription").removeClass("on");
        $("#pop-Error").removeClass("on");
        $(".pop-data .close").hide();
        $(".pop").fadeOut();
        return false;
    });



    // Footer slider
//    if ($(".footer-slider").length) {
//        $('.footer-slider').bxSlider({
//            mode: 'horizontal', 		//Type of transition between each slide
//            auto: true, 				//Make slide transitions occur automatically
//            speed: 500, 				//In ms, duration of time slide transitions will occupy
//            pause: 4000, 			//In ms, the duration between each slide transition
//            pager: true, 			//Display a numeric pager
//            controls: false, 		//Display previous and next controls
//            displaySlideQty: 5, 		//Number of slides to display at once
//            moveSlideQty: 5				//Number of slides to move at once
//        });
//    }

    // Header slider
    if ($(".home-slider").length) {
        $('.home-slider').bxSlider({
            mode: 'fade', 		//Type of transition between each slide
            auto: true, 			//Make slide transitions occur automatically
            speed: 1000, 		//In ms, duration of time slide transitions will occupy
            pause: 4000, 		//In ms, the duration between each slide transition
            pager: true, 		//Display a numeric pager
            controls: false			//Display previous and next controls
        });
    }

    // Product tabs
    if ($(".prod-slider").length) {
        $('.prod-slider').each(function () {
            $(this).bxSlider({
                mode: 'horizontal', 	//Type of transition between each slide
                auto: false, 		//Make slide transitions occur automatically
                speed: 1000, 		//In ms, duration of time slide transitions will occupy
                pause: 4000, 		//In ms, the duration between each slide transition
                pager: true, 		//Display a numeric pager
                controls: true //Display previous and next controls
                // captions: true
                //startingSlide: 3

            });
        });
    }


    // Overlay
    if ($(".overlay").length) {
        $(".overlay").css("width", $(document).width() + "px");
        $(".overlay").css("height", $(document).height() + "px");
        $(".overlay").click(function () {
            $(this).hide();
            $(".inf").fadeOut(400);
            return false;
        });
    }
    


    // Tooltip
    if ($(".prod-info").length) {

        $(".prod-info").click(function () {

            $(".overlay").show(0);
        
            var currentTab = $(".tabs a.active");
            var TabNumber = currentTab.attr("id").charAt(3);

            //    debugger;
    
            var ActiveSubTabId = $(".boxes .active").attr("id");
            var SubProductNo = ActiveSubTabId.charAt(7);

            $(".product-pic div." + ActiveSubTabId + "inf" + SubProductNo).fadeIn(400);
       
            return false;
        });
        $(".inf .close").click(function () {
            $(".inf").fadeOut(400);
            $(".overlay").hide(0);         
            return false;
        });
    }    



    if ($(".tabs").length) {

        $(".tabs a").click(function () {
       //      debugger;

            if (!$(this).hasClass("active")) {

                ActivateProductPanel($(this).attr("id"));
            }
            return false
        });
    }


    // If URL contains tab number then Activate respective product panel      

    var hash = window.location.hash;
    if (hash.length) {
        //    debugger;
        var tabno = hash.charAt(hash.length - 1);
        ActivateProductPanel("tab" + tabno);
    }


});


function SubscriptionPopUp(popType) {

    $(document).ready(function () {

        var v = $("#pop-" + popType).attr("id");

        $(v).addClass("on");
        $(".overlay2").show(0);
        $(".pop").fadeIn("slow");
        $('#' + v).fadeIn("slow");
        $('#' + v).addClass("active");
        $(".pop-data .close").css("display", "block");

    });
}


function ActivateProductPanel(Tabid) {

    $(".tabs a").removeClass("active");

    $(".product-pic div").removeClass("active");

    $(".boxes a").removeClass("active");

    $(".boxes div").removeClass("currentbox");

    $("#" + Tabid).addClass("active");

    $(".boxes").slideUp(400);

    $("." + Tabid + "box").slideDown(400);

    var CurrentTabId = $(".tabs a.active").attr("id");
    var TabNo = CurrentTabId.charAt(3);

    // tab1product
    $("." + CurrentTabId + "product").addClass("active");


}

function textboxblur(obj, txt) {
    var t = $.trim(obj.value);

    if (t == "")
        obj.value = txt;
}
