﻿$(document).ready(function () {
    $('#navListRight').hover(
        function () {
            $(this).addClass('hover');
        },
        function () {
            $(this).removeClass('hover');
        });

    $('#navListBenefits').hover(
        function () {
            $(this).addClass('hover');
        },
        function () {
            $(this).removeClass('hover');
        });

    $('#navListWorks').hover(
        function () {
            $(this).addClass('hover');
        },
        function () {
            $(this).removeClass('hover');
        });

    $('#navListProducts').hover(
        function () {
            $(this).addClass('hover');
        },
        function () {
            $(this).removeClass('hover');
        });
    //Define the animation speed for the Carousel
    var speed = 600;
    //        $('#coPrev').click(function () {
    //            $('#calloutLinks ul').animate({ marginLeft: '-321px' }, speed);
    //        });
    //        $('#coNext').click(function () {
    //            //And now lets move back to the start of the Carousel
    //            $('#calloutLinks ul').animate({ marginLeft: '0px' }, speed);
    //        });

    //        $('#carPrev').click(function () {
    //            $('#carouselElements ul').animate({ marginLeft: '-179px' }, speed);
    //        });
    //        $('#carNext').click(function () {
    //            //And now lets move back to the start of the Carousel
    //            $('#carouselElements ul').animate({ marginLeft: '0px' }, speed);
    //        });


    //rotation speed and timer
    //var speed = 5000;

    //grab the width and calculate left value
    var item_width = $('#calloutLinks li').outerWidth();
    var left_value = (item_width * (-1));

    //move the last item before first item, just in case user click prev button
    $('#calloutLinks li:first').before($('#calloutLinks li:last'));

    //set the default item to the correct position 
    $('#calloutLinks ul').css({ 'marginLeft': left_value });

    $('#calloutLinks li').css({ 'color': '#d0d0d0' });
    $('#calloutLinks li').css({ 'border-right': '2px solid' });
    $('#calloutLinks li:first').css({ 'border-right': 'none' });
    $('#calloutLinks li:last').css({ 'border-right': 'none' });
    //if user clicked on prev button
    $('#coNext').click(function () {

        //get the right position            
        var left_indent = (parseInt($('#calloutLinks ul').css('marginLeft')) + item_width);

        //slide the item            
        $('#calloutLinks ul').animate({ 'marginLeft': left_indent }, 500, function () {

            //move the last item and put it as first item            	
            $('#calloutLinks li:first').before($('#calloutLinks li:last'));

            //set the default item to correct position
            $('#calloutLinks ul').css({ 'marginLeft': left_value });

            $('#calloutLinks li').css({ 'color': '#d0d0d0' });
            $('#calloutLinks li').css({ 'border-right': '2px solid' });
            $('#calloutLinks li:first').css({ 'border-right': 'none' });
            $('#calloutLinks li:last').css({ 'border-right': 'none' });
        });
        //cancel the link behavior            
        return false;

    });


    //if user clicked on next button
    $('#coPrev').click(function () {

        //get the right position
        var left_indent = (parseInt($('#calloutLinks ul').css('marginLeft')) - item_width);

        //slide the item
        $('#calloutLinks ul').animate({ 'marginLeft': left_indent }, 500, function () {

            //move the first item and put it as last item
            $('#calloutLinks li:last').after($('#calloutLinks li:first'));

            //set the default item to correct position
            $('#calloutLinks ul').css({ 'marginLeft': left_value });

            $('#calloutLinks li').css({ 'color': '#d0d0d0' });
            $('#calloutLinks li').css({ 'border-right': '2px solid' });
            $('#calloutLinks li:first').css({ 'border-right': 'none' });
            $('#calloutLinks li:last').css({ 'border-right': 'none' });

        });
        //cancel the link behavior
        return false;

    });

    //grab the width and calculate left value
    var prod_item_width = $('#carouselElements li').outerWidth();
    var prod_left_value = ((prod_item_width * (-1)));

    //move the last item before first item, just in case user click prev button
    $('#carouselElements li:first').before($('#carouselElements li:last'));

    //set the default item to the correct position 
    $('#carouselElements ul').css({ 'marginLeft': prod_left_value });

    //if user clicked on prev button
    $('#carNext').click(function () {

        //get the right position
        var prod_left_indent = (parseInt($('#carouselElements ul').css('marginLeft')) + prod_item_width);

        //slide the item
        $('#carouselElements ul').animate({ 'marginLeft': prod_left_indent }, 500, function () {

            //move the first item and put it as last item
            $('#carouselElements li:first').before($('#carouselElements li:last'));

            //set the default item to correct position
            $('#carouselElements ul').css({ 'marginLeft': prod_left_value });

        });

        //cancel the link behavior
        return false;

    });


    //if user clicked on next button
    $('#carPrev').click(function () {

        //get the right position
        var prod_left_indent = (parseInt($('#carouselElements ul').css('marginLeft')) - prod_item_width);

        //slide the item
        $('#carouselElements ul').animate({ 'marginLeft': prod_left_indent }, 500, function () {

            //move the first item and put it as last item
            $('#carouselElements li:last').after($('#carouselElements li:first'));

            //set the default item to correct position
            $('#carouselElements ul').css({ 'marginLeft': prod_left_value });

        });

        //cancel the link behavior
        return false;

    });



});

function navOver(a, src) {
    if (location.hostname == 'localhost')
        a.childNodes[0].src = 'http://' + location.hostname + '/BreatheRight2010/' + src;
    else
        a.childNodes[0].src = 'http://' + location.hostname + '/' + src;
}

function navOut(a, src) {
    if (location.hostname == 'localhost')
        a.childNodes[0].src = 'http://' + location.hostname + '/BreatheRight2010/' + src;
    else
        a.childNodes[0].src = 'http://' + location.hostname + '/' + src;
}

function coOver(div, src) {
    if (location.hostname == 'localhost')
        div.src = 'http://' + location.hostname + '/BreatheRight2010/' + src;
    else
        div.src = 'http://' + location.hostname + '/' + src;
}

function coOut(div, src) {
    if (location.hostname == 'localhost')
        div.src = 'http://' + location.hostname + '/BreatheRight2010/' + src;
    else
        div.src = 'http://' + location.hostname + '/' + src;
}

function coDown(div, src) {
    if (location.hostname == 'localhost')
        div.childNodes[0].src = 'http://' + location.hostname + '/BreatheRight2010/' + src;
    else
        div.childNodes[0].src = 'http://' + location.hostname + '/' + src;
}

function coUp(div, src) {
    if (location.hostname == 'localhost')
        div.childNodes[0].src = 'http://' + location.hostname + '/BreatheRight2010/' + src;
    else
        div.childNodes[0].src = 'http://' + location.hostname + '/' + src;
}

function coArrowDown(div, src) {
    if (location.hostname == 'localhost')
        div.src = 'http://' + location.hostname + '/BreatheRight2010/' + src;
    else
        div.src = 'http://' + location.hostname + '/' + src;
}

function coArrowUp(div, src) {
    if (location.hostname == 'localhost')
        div.src = 'http://' + location.hostname + '/BreatheRight2010/' + src;
    else
        div.src = 'http://' + location.hostname + '/' + src;
}

var BreatheRightApp = {

    GetDocumentTitle: function() {
        if (document.title != null && document.title != "") {
            return document.title;
        }

        return "BreatheRight.com";
    },

    init: function() {
        //  Bind actions to the share control

        $("#share").click(function(event) {
            event.preventDefault();
            $(".shareThisContainer").show();
        });

        $(".shareThisCloseWin").click(function(event) {
            event.preventDefault();
            $(".shareThisContainer").hide();
        });

        return;
    }

};

$(document).ready(function() {
    BreatheRightApp.init();
});

function GetDocumentTitle() {
    if (document.title != null && document.title != "") {
        return document.title;
    }
    return "BreatheRight.com";
}

$(document).ready(function() {
    $("#share > a").click(function(event) {
        event.preventDefault();
        $(".shareThisContainer").show();
    });

    $(".shareThisCloseWin").click(function(event) {
        event.preventDefault();
        $(".shareThisContainer").hide();
    });
});

function popUp(strUrl, strName, strFeatures) {
    if (strUrl == "") { strUrl = ""; }
    if (strName == "") { strName = "default"; }
    if (strFeatures == "") { strFeatures = ""; }

    newwindow = window.open(strUrl, strName, strFeatures);
    newwindow.focus();
}

$(".btnShareThis").ready(function () {
    $(".btnShareThis").click(function (evt) {
        $(".shareThisContainer").css("top", evt.pageY + 20);
        // $(".shareThisContainer").css("left", evt.pageX - ($(".shareThisContainer").css("width").replace("px", "") / 1));
        $(".shareThisContainer").css("left", evt.pageX);
        $(".shareThisContainer").show();
        $(".shareThisCloseWin").click(function (evt) {
            evt.preventDefault();
            $(this).unbind('click');
            $(".shareThisContainer").hide();
        });
    });
});

function noaccordion(obj) {
    $(".inactive").toggleClass("activemin");
    $(".Breathrigh_collaps").toggleClass("Breathrigh_Expand");

}

//if user clicked on next button
$(document).ready(function () {

$('.FirstLeft').click(function () {
    $('#BeliveDo li:first').before($('#BeliveDo li:last'));
});
$('.FirstRight').click(function () {
    $('#BeliveDo li:last').after($('#BeliveDo li:first'));
});

$('.candoLeft').click(function () {
    $('#cando li:first').before($('#cando li:last'));
});
$('.candoright').click(function () {
    $('#cando li:last').after($('#cando li:first'));
});


});

