﻿// JScript File

function IsComboValid(source, arguments) {
    var dropdown = document.getElementById(source.controltovalidate);
    var selIndex = dropdown.selectedIndex;
    if (selIndex == 0 || dropdown.options[selIndex].text == "") {
        arguments.IsValid = false;
    }
    else {
        arguments.IsValid = true;
    }
}

function autoscroll() {
    setTimeout(function () {
        $('html,body').scrollTo("[name*='appForm']", 500);
    }, 500);
}

function toggleDiv(tagName, val) {
    if (document.getElementById) {
        // this is the way the standards work
        var tagStyle = document.getElementById(tagName).style;
        tagStyle.display = val;
    }
    else if (document.all) {
        // this is the way old msie versions work
        var tagStyle = document.all[tagName].style;
        tagStyle.display = val;
    }
    else if (document.layers) {
        // this is the way nn4 works
        var tagStyle = document.layers[tagName].style;
        tagStyle.display = val;
    }
}

/*iagto.caption.js*/

$(window).load(function () {
    putCaptions();
});

function putCaptions() {
    //for each description div...  
    $('div.description').each(function () {
        //...set the opacity to 0...  
        $(this).css('opacity', 0);
        //..set width same as the image...  
        $(this).css('width', $(this).siblings('img').width());
        //$(this).css('height', $(this).siblings('img').height() - $(this).siblings('img').height()/2);
        //...get the parent (the wrapper) and set it's width same as the image width... '  
        $(this).parent().css('width', $(this).siblings('img').width());
        //...set the display to block  
        $(this).css('display', 'block');
    });

    $('div.wrapper').hover(function () {
        //when mouse hover over the wrapper div  
        //get it's children elements with class description '  
        //and show it using fadeTo  
        $(this).children('.description').stop().fadeTo(500, 0.9);
    }, function () {
        //when mouse out of the wrapper div  
        //use fadeTo to hide the div  
        $(this).children('.description').stop().fadeTo(500, 0);
    });
}

/*iagto.news.js*/

(function ($) {
    $.fn.extend({
        SpotlightNews: function (options) {

            function runAfterAnimation(index) {
            }

            function reset() {
            }

            function completedAll(clickedOn) {
            }

            var defaults = {
                height: 378,
                numberOfNewsItems: 14,
                initialImagePath: 'Images/News/news-welcome.jpg',
                animationPostMethod: runAfterAnimation,
                reset: reset,
                allAnimationsCompleted: completedAll
            }

            var options = $.extend(defaults, options);
            var NewsDivObject = $(this);
            var NewsContentItems = $(this).find("div.news-content-item");

            $("div.news-headers").height($(this).height() - 2);

            var newsItemHeight = (NewsDivObject.height() / options.numberOfNewsItems); //height of a single news header item

            $(".active-news-content-item").css("background", "url('" + options.initialImagePath + "')");

            $("div.news-headers > div").height(newsItemHeight);

            $(this).find("div.news-headers > div").click(function () {
                if ($(this).is(".active-news-header")) {  //If it's already active, then...
                    return false; // Don't click through
                }
                else {
                    var clickedOn = $(this);
                    var index = $("div.news-headers > div").index(clickedOn) + 1;

                    $("div.news-headers > div").removeClass("active-news-header")
                    $(clickedOn).removeClass("header-item-hover");
                    $(clickedOn).removeClass("hover");
                    $(clickedOn).addClass("active-news-header");
                    

                    $("div.active-news-content-item").animate({ opacity: 0 }, 250, null, function () {//hide the current active news content
                        options.reset();
                        $(".active-news-content-item").removeClass("active-news-content-item").animate({ opacity: 0 }, 250); //remove active content class from all
                        $($("div.news-content-item")[index]).addClass("active-news-content-item").animate({ opacity: 1.0 }, 250, null, function () {
                            options.animationPostMethod(index);
                        });

                        options.allAnimationsCompleted(clickedOn);
                        //alert($(".ActiveNewsContentItem").children(".image").size());

                    });
                }

            }).hover(function () {
                $(this).not(".active-news-header").addClass("hover");
            }, function () {
                $(this).removeClass("hover");
            });
        }
    });
})(jQuery);

/*iagto.scroller.js*/

function videoNavigator() {
    //set height of prev and next buttons
    $("#prev").height($("#NavigationContainer").height());
    $("#next").height($("#NavigationContainer").height());
    //set classes of preve and next buttons
    $("#prev").addClass("prev");
    $("#prev").addClass("browsed");
    
    $("#next").addClass("next");
    $("#next").addClass("browsed");

    //set the class for slider
    $("#VideoSlider").addClass("video-slider");

    //set navigator class
    $("#Navigator").addClass("navigator");

    //set width and height of the navigator
    $("#Navigator").width($("#NavigationContainer").width() - ($("#prev").width() + $("#next").width() + 18));
    $("#Navigator").height($("#NavigationContainer").height());
    $("#Navigator").css("padding-left", 5);
    $("#Navigator").css("padding-right", 5);

    //set width and height of the sliders
    $("#VideoSlider").height($("#NavigationContainer").height());
    $("#VideoSlider").width(($(".video-item").width() + parseInt($(".video-item").css("padding-left")) + parseInt($(".video-item").css("padding-right")) + parseInt($(".video-item").css("margin-right")) + parseInt($(".video-item").css("margin-left"))) * $(".video-item").size() + (5 * ($(".video-item").size() - 1)));

    var pageWidth = $("#Navigator").width();

    var numberOfElemsInOnePage = parseInt((pageWidth / $(".video-item").width()) + "");

    var indexOfItem = numberOfElemsInOnePage;

    var remainderForPadding = pageWidth % $(".video-item").width();

    var paddingForRight = (remainderForPadding / numberOfElemsInOnePage) +  2;

    //set padding of the top and bottom for item
    var margin = ($("#VideoSlider").height() - $(".video-item").height()) / 2;
    $(".video-item").css("padding-top", margin);
    $(".video-item").css("padding-right", paddingForRight / 2);
    $(".video-item").css("padding-left", paddingForRight / 2);

    $("#VideoSlider").width(($(".video-item").width() + parseInt($(".video-item").css("padding-left")) + parseInt($(".video-item").css("padding-right")) + parseInt($(".video-item").css("margin-right")) + parseInt($(".video-item").css("margin-left"))) * $(".video-item").size() + (5 * ($(".video-item").size() - 1)) - 1);

    //size of one item
    var pxR = $(".video-item").css("padding-right").replace("px", "");

    var pxL = $(".video-item").css("padding-left").replace("px", "");

    var itemWidth = $(".video-item").width() + parseInt(pxR) + parseInt(pxL);

    pageWidth = itemWidth * numberOfElemsInOnePage;

    var amountToMove = 0;

    $("#next").click(function () {
        moveNext();
        $("#VideoSlider").animate({
            left: "-=" + amountToMove + "px"
        }, 90 * (amountToMove/itemWidth));
    });

    $("#prev").click(function () {
        movePrev();
        $("#VideoSlider").animate({
            left: "+=" + amountToMove + "px"
        }, 90 * (amountToMove / itemWidth));
    });

    function moveNext() {
        if ($(".video-item").size() - indexOfItem >= numberOfElemsInOnePage) {
            amountToMove = itemWidth * numberOfElemsInOnePage;
            indexOfItem += numberOfElemsInOnePage;
        }
        else {
            amountToMove = itemWidth * ($(".video-item").size() - indexOfItem);
            if (amountToMove < 0) {
                amountToMove = 0;
            }
            indexOfItem = $(".video-item").size();
        } 
    }
    function movePrev() {
        if ((indexOfItem - numberOfElemsInOnePage) >= numberOfElemsInOnePage) {
            amountToMove = itemWidth * numberOfElemsInOnePage;
            indexOfItem -= numberOfElemsInOnePage;
        }
        else {
            amountToMove = itemWidth * (indexOfItem - numberOfElemsInOnePage);
            if (amountToMove < 0) {
                amountToMove = 0;
            }
            indexOfItem = numberOfElemsInOnePage;
        }      
    }
}

function changeLinks() {
    $("#agtcSubMenu").prev("a").attr("href", "/Public/TravelIndustry/AsiaConvention12-MGTA/Public.aspx");
    $("#theEvent").attr("href", "/Public/TravelIndustry/AsiaConvention12-MGTA/Public.aspx");
    $("#venue").attr("href", "/Public/TravelIndustry/AsiaConvention12-MGTA/Venue.aspx");
    $("#destination").attr("href", "/Public/TravelIndustry/AsiaConvention12-MGTA/Destination.aspx");
    $("#program").attr("href", "/Public/TravelIndustry/AsiaConvention12-MGTA/Program.aspx");
    $("#registration").attr("href", "/Public/TravelIndustry/AsiaConvention12-MGTA/RegistrationDescription.aspx");
    $("#attendingBuyers").attr("href", "/Public/TravelIndustry/AsiaConvention12-MGTA/AttendingOperators.aspx");
    $("#iagto").attr("href", "/Public/TravelIndustry/AsiaConvention12-MGTA/PublicIagto.aspx");
}

; (function (d) { var k = d.scrollTo = function (a, i, e) { d(window).scrollTo(a, i, e) }; k.defaults = { axis: 'xy', duration: parseFloat(d.fn.jquery) >= 1.3 ? 0 : 1 }; k.window = function (a) { return d(window)._scrollable() }; d.fn._scrollable = function () { return this.map(function () { var a = this, i = !a.nodeName || d.inArray(a.nodeName.toLowerCase(), ['iframe', '#document', 'html', 'body']) != -1; if (!i) return a; var e = (a.contentWindow || a).document || a.ownerDocument || a; return d.browser.safari || e.compatMode == 'BackCompat' ? e.body : e.documentElement }) }; d.fn.scrollTo = function (n, j, b) { if (typeof j == 'object') { b = j; j = 0 } if (typeof b == 'function') b = { onAfter: b }; if (n == 'max') n = 9e9; b = d.extend({}, k.defaults, b); j = j || b.speed || b.duration; b.queue = b.queue && b.axis.length > 1; if (b.queue) j /= 2; b.offset = p(b.offset); b.over = p(b.over); return this._scrollable().each(function () { var q = this, r = d(q), f = n, s, g = {}, u = r.is('html,body'); switch (typeof f) { case 'number': case 'string': if (/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)) { f = p(f); break } f = d(f, this); case 'object': if (f.is || f.style) s = (f = d(f)).offset() } d.each(b.axis.split(''), function (a, i) { var e = i == 'x' ? 'Left' : 'Top', h = e.toLowerCase(), c = 'scroll' + e, l = q[c], m = k.max(q, i); if (s) { g[c] = s[h] + (u ? 0 : l - r.offset()[h]); if (b.margin) { g[c] -= parseInt(f.css('margin' + e)) || 0; g[c] -= parseInt(f.css('border' + e + 'Width')) || 0 } g[c] += b.offset[h] || 0; if (b.over[h]) g[c] += f[i == 'x' ? 'width' : 'height']() * b.over[h] } else { var o = f[h]; g[c] = o.slice && o.slice(-1) == '%' ? parseFloat(o) / 100 * m : o } if (/^\d+$/.test(g[c])) g[c] = g[c] <= 0 ? 0 : Math.min(g[c], m); if (!a && b.queue) { if (l != g[c]) t(b.onAfterFirst); delete g[c] } }); t(b.onAfter); function t(a) { r.animate(g, j, b.easing, a && function () { a.call(this, n, b) }) } }).end() }; k.max = function (a, i) { var e = i == 'x' ? 'Width' : 'Height', h = 'scroll' + e; if (!d(a).is('html,body')) return a[h] - d(a)[e.toLowerCase()](); var c = 'client' + e, l = a.ownerDocument.documentElement, m = a.ownerDocument.body; return Math.max(l[h], m[h]) - Math.min(l[c], m[c]) }; function p(a) { return typeof a == 'object' ? a : { top: a, left: a} } })(jQuery);
