
// Set thickbox loading image
tb_pathToImage = "../NewDesign/FooterImageGalleryScripts/images/loading-thickbox.gif";

function mycarouselInitCallback(carousel) {
    // Disable autoscrolling if the user clicks the prev or next button.
    reloadCarousel = carousel;
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });
    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
    carousel.buttonNext.disableTextSelect();
    carousel.buttonPrev.disableTextSelect();
    //$(".jcarousel-prev, .jcarousel-next").disableTextSelect();
}

/**
* Item html creation helper.
*/
function mycarousel_getItemHTML(item) {
    try {
        var url_m = item.url.replace(/_s.jpg/g, '_m.jpg');
        return '<a href="' + url_m + '" title="' + item.title + '"><img src="' + item.url + '" width="138" height="105" border="0" alt="' + item.title + '" /></a>';
    } catch (e) {
        //alert(e);
    }
};


function mycarousel_itemLoadCallback(carousel, state) {
    try {
        for (var i = carousel.first; i <= carousel.last; i++) {
            if (carousel.has(i)) {
                continue;
            }

            if (i > mycarousel_itemList.length) {
                break;
            }

            // Create an object from HTML
            var item = jQuery(mycarousel_getItemHTML(mycarousel_itemList[i - 1])).get(0);

            // Apply thickbox
            tb_init(item);

            carousel.add(i, item);
        }
    } catch (e) {
    }
};

function Carousel_BeforeStart() {
    try {
        $('.JcarouselContainer').each(function() {
            $(this).css('display', 'none');
        });
        $('#JcarouselContentLoading').css('display', 'block');
    } catch (e) {
        //alert(e);
    }
}

function Carousel_Start() {
    try {
        $('.JcarouselContainer').each(function() {
            $(this).css('display', 'block');
        });
        $('#JcarouselContentLoading').css('display', 'none');
        //mycarousel_itemList = null;
        /*
        Commented By : Kumarchand R. Tripathi
        Commented On : 08 Apr 2011
        Purpose      : To resolve the carisol related issue within update panel
        jQuery('#mycarousel').jcarousel({
        auto: 6,
        wrap: 'last',
        visible: 6,
        size: mycarousel_itemList.length,
        initCallback: mycarouselInitCallback,
        itemLoadCallback: { onBeforeAnimation: mycarousel_itemLoadCallback }
        });
        */
        jQuery('#mycarousel').jcarousel({
            auto: 6,
            //wrap: 'last',
            //wrap: null,
            //scroll:3,
            wrap: 'circular',
            visible: 6,
            //size: mycarousel_itemList.length,
            initCallback: mycarouselInitCallback,
            itemLoadCallback: { onBeforeAnimation: mycarousel_itemLoadCallback }
        });
        effects("#mycarousel");
        $(".gallery:first a[rel^='prettyPhoto']").prettyPhoto({ animationSpeed: 'slow', theme: 'light_square', slideshow: 2000, autoplay_slideshow: false });
        $(".gallerytwo:first a[rel^='prettyPhoto']").prettyPhoto({ animationSpeed: 'slow', theme: 'light_square', slideshow: 2000, autoplay_slideshow: false });
    } catch (e)
                { alert(e); }
}
var version = navigator.appVersion;
function effects(id) {
    id = id + " li"
    $(id).hover(function() {

        if (version.indexOf('MSIE 6.0') > 0) {
            $(this).find('div:first').css({ 'border': '2px solid #59b600' });
        } else {
            $(this).children().css({ 'position': 'relative', 'z-index': '10000', 'display': 'inline-block' });

            $(this).children().animate({
                width: 155, height: 122, left: -9, top: -8
            }, 500);
            $(this).find('img').animate({
                width: 155, height: 122
            }, 500);
        }
    });

    $(id).mouseleave(function() {
        if (version.indexOf('MSIE 6.0') > 0) {
            $(this).find('div:first').css({ 'border': '2px solid #FFFFFF' });
        } else {
            $(this).children().css({ 'position': 'relative', 'border': '2px solid #FFF', "top": -8, 'left': -9, 'z-index': '0' });
            $(this).children().width(155);
            $(this).children().height(122);
            $(this).children().animate({
                width: 138, height: 105, left: 0, top: 0
            }, 500);
            $(this).find('img').animate({
                width: 138, height: 105
            }, 500);

        }
    })
}

function DispalyAlert() {
    alert("This feature will be available shortly");
}

///Increase and Decrease font size --Added by Chaitanya

function zoomIn(fontSiz) {

    try {
            document.body.style.fontSize = fontSiz + 'px';
            $('div').css("fontSize", fontSiz + 'px');
            $('p').css("fontSize", fontSiz + 'px');
            $('a').css("fontSize", fontSiz + 'px');
            $('li').css("fontSize", fontSiz + 'px');
            $('img').css("fontSize", fontSiz + 'px');
            $('input').css("fontSize", fontSiz + 'px');
            $('strong').css("fontSize", fontSiz + 'px');
            $('table').css("fontSize", fontSiz + 'px');
            $('td').css("fontSize", fontSiz + 'px');

    }
    catch (e) {
    }
}

function DisableContextMenu(selector) {
    $(selector).each(function() {
        $(this).bind("contextmenu", function(e) {
            e.preventDefault();
        });
    });
}

jQuery(document).ready(function() {
    DisableCarouselContextMenu();
    //Carousel_Start();
    //Sys.WebForms.PageRequestManager.getInstance().add_endRequest(Carousel_Start);
    JCarouselLite_Start();
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(JCarouselLite_Start);
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(Carousel_BeforeStart);
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(DisableCarouselContextMenu);
});

function DisableCarouselContextMenu() {
    DisableContextMenu('.JQjcarousel-container');
}

function JCarouselLite_Start() {
    try {
        $('.JcarouselContainer').each(function() {
            $(this).css('display', 'block');
        });
        $('#JcarouselContentLoading').css('display', 'none');
        //alert($('.JCarousolLite ul li').length);
        //$('.jcarousel-next,.jcarousel-prev').css('background', 'none');
        if ($('.JCarousolLite ul li').length > 6) {
            $(".JCarousolLite").jCarouselLite({
                btnNext: ".jcarousel-next",
                btnPrev: ".jcarousel-prev",
                speed: 400,
                //easing: "easeinout",
                auto: 8000,
                circular: true,
                visible: 6,
                scroll: 3,
                //mouseWheel: true,
                mouseWheel: false,
                pauseOnHover: true,
                start: 0
            });
        }
        else {
            $('.jcarousel-next,.jcarousel-prev').css('background', 'none');
            $(".JCarousolLite").jCarouselLite({
                btnNext: ".jcarousel-next",
                btnPrev: ".jcarousel-prev",
                speed: 400,
                //easing: "easeinout",
                auto: 8000,
                circular: false,
                visible: 6,
                scroll: 3,
                //mouseWheel: true,
                mouseWheel: false,
                pauseOnHover: true,
                start: 0
            });
        }
        $('.jcarousel-next,.jcarousel-prev').disableTextSelect();
        effects(".JCarousolLite");
        $(".gallery:first a[rel^='prettyPhoto']").prettyPhoto({ animationSpeed: 'slow', theme: 'light_square', slideshow: 2000, autoplay_slideshow: false });
        $(".gallerytwo:first a[rel^='prettyPhoto']").prettyPhoto({ animationSpeed: 'slow', theme: 'light_square', slideshow: 2000, autoplay_slideshow: false });

    } catch (e) {
        alert(e);
    }
}

var JcarouselLiteStart = function(carousel) {
    //debugger;
    carousel.buttonNext.disableTextSelect();
    carousel.buttonPrev.disableTextSelect();
}
