﻿// JScript File
$(document).ready(function() {
    $('#horizontalnav .subnav').hide();

    //horizontal navigation sub category alignment
    $('#horizontalnav #navigation li:not(.subnav li)').not('#verticalnav #navigation li').hover(
    function() {
        leftPosition = $(this).position().left;
        // alert(leftPosition);
        objWidth = $(this).outerWidth();
        liWidth = $(this).next().outerWidth();
        //alert(liWidth);
        //objWidth = objWidth/2;
        // leftPosition = leftPosition - objWidth;
        var leftPositionAbs = Math.abs(leftPosition);
        topPosition = $(this).offset().top;
        currSubNav = $(this).find('.subnav '); //IE workaround 
        $('.subnav:visible').hide();
        $(currSubNav).css({ 'position': 'absolute', 'left': leftPositionAbs, 'top': '30px', 'display': 'inline' }); //yet another IE workaround
        $(this).css({ 'border-bottom': '4px solid #193F70', 'border-top': '2px solid #193F70' });
        $(this).next('ul').not(currSubNav).css({ 'position': 'absolute', 'left': leftPositionAbs, 'top': '24px', 'display': 'inline', /*'width': '100%',*/'height': '100%' });

    },
    function() {
        $(this).css({ 'border-top': 'none', 'border-bottom': 'none' })
    }
);


    function verticalCenteringSoloCycleImages() {
        var sponsorWidgetLength = $('.SponsorWidget').children().length;
        var mediaWidgetLength = $('.MediaWidget').children().length;


        if (sponsorWidgetLength == 1) {
            var imgHeight = $('.SponsorWidget img').attr('height');
            var containerHeight = $('.SponsorWidget').css('height');
            containerHeight = containerHeight.split('px');
            containerHeight = containerHeight[0];
            var difference = (containerHeight - imgHeight) / 2;
            $('.SponsorWidget img').css('padding-top', difference);
        }

        if (mediaWidgetLength == 1) {
            var imgHeight = $('.MediaWidget img').attr('height');
            var containerHeight = $('.MediaWidget').css('height');
            containerHeight = containerHeight.split('px');
            containerHeight = containerHeight[0];
            var difference = (containerHeight - imgHeight) / 2;
            $('.MediaWidget img').css('padding-top', difference);
        }
        
    }
 verticalCenteringSoloCycleImages();


    //below adjusts for horizontal templates

    $('#horizontalnav').parent().parent().parent().addClass('h_wrapper');
    $('.h_wrapper #header_top').hide();
    $('.h_wrapper #header').insertBefore('#top_hdr');
    $('.h_wrapper').find('.left_col').remove();

    $('#horizontalnav #navigation li:not(.subnav li)').addClass('mainTabs');

    $('#horizontalnav').parent('div').css('height', '188px');
    $('.h_wrapper .footer').addClass('h_footer').insertAfter('.h_wrapper');

    //$('.h_wrapper div.idga').insertBefore('.maindivbox');

    //$('.h_wrapper div.idga').appendTo('.maindivbox');

    //$('.h_wrapper .maindivbox').insertBefore('.idga');
    $('.h_wrapper .eventpartnerstable').appendTo('.eventsubnavbox');
    $('.h_wrapper .maindivbox, .h_wrapper .idga').wrapAll('<div class="horizontal-wrap" />');

    $('<div class="banner" />').prependTo('.h_wrapper .maindivbox');


    var mainDivHeightSetter = $('.h_wrapper .idga').height();
    $('.h_wrapper .maindivbox').css('height', mainDivHeightSetter);



    //$('.h_nav .footer').insertAfter('.h_wrapper').addClass('h_nav');

    //adds horizontal menu class when hovering menu items
    $('li.mainTabs').hover(
    function() {
        $(this).addClass('mainTabsHover');
    },
    function() {
        $(this).removeClass('mainTabsHover');
    }
);

    $('.mainTabs:last').css({ 'border': 'none' });

    /*split sessions */
    //var sessionWidth = $('.Session').css('width');
    //var splitSessionWidth = sessionWidth/2 +'px';
    //$('div.split').css('width', splitSessionWidth);


    //below sets the div class for the specific section based on the contents of the header
    //$('#Agenda div h2:contains(Session)').parent('div').addClass('Session'); 
    //$('#Agenda div h2:contains(Break), h2:contains(Registration), h2:contains(Coffee),h2:contains(Lunch), h2:contains(End Of)').parent('div').addClass('Break'); 
    //$('#Agenda div h2:last').parent('div').addClass('last');

    //$('.titleChecker :contains(Session)').parent('div').addClass('Session'); 
    //$('.titleChecker :contains(Break), h2:contains(Registration), h2:contains(Coffee),h2:contains(Lunch), h2:contains(End Of)').parent('div').addClass('Break'); 
    //$('.titleChecker :last').parent('div').addClass('last');

    //$('h2 .titleChecker').

    //$('#Agenda div').children().wrap('<span></span>');


    //sets h2 around sponsor priority name section but not other spans
    $('.partner').siblings('span').wrap('<h2>');
    $('.h_nav div.breadcrumb').hide();
    $('.page_body .h_nav ').parent().css({ 'background-color': 'transparent' });


    //pageErrorMsg
    $('.pageErrorMsg').appendTo('.maindivbox');

    $(function() {
        var step = 1;
        var current = 0;
        var maximum = $('#my_carousel ul li').size();
        var visible = 1;
        var speed = 200;
        var liSize = 278;
        var carousel_height = 161;


        var ulSize = liSize * maximum;
        var divSize = liSize * visible;

        $('#my_carousel ul').css("width", ulSize + "px").css("left", -(current * liSize)).css("position", "absolute");

        $('#my_carousel').css("width", divSize + "px").css("height", carousel_height + "px").css("visibility", "visible").css("overflow", "hidden").css("position", "relative");

        $('.btnnext').click(function() {
            if (current + step < 0 || current + step > maximum - visible) { return; }
            else {
                current = current + step;
                $('#my_carousel ul').animate({ left: -(liSize * current) }, speed, null);
            }
            return false;
        });

        $('.btnprev').click(function() {
            if (current - step < 0 || current - step > maximum - visible) { return; }
            else {
                current = current - step;
                $('#my_carousel ul').animate({ left: -(liSize * current) }, speed, null);
            }
            return false;
        });
    });







});

//Start section By Rashmi

   $('.SponsorWidget').cycle({
		fx: 'fade' 
	});
	
	
	   $('.MediaWidget').cycle({
		fx: 'fade' 
	});





  //End Section
  
   
  
  
 
