﻿$(document).ready(function() {   
   
   var pagesCount= $(".footercontent").length;
   var footerPages = $(".footercontent");
   if(pagesCount > 0){
    $(footerPages[0]).addClass('selected');
   }
    
    $( ".footercontent" ).click(function() {
        var id = $(this).attr("id");
        var qstring = id.split('_')[1];
        
        $('#general-content .nav a').removeClass('selected');
        $('#page_' + qstring).addClass('selected');

        loadSchoolContent(qstring); return false;
    });
    
    function loadSchoolContent(pageid) {
        var handlerPath = '/web/handlers/AjaxLoadMenuContent.ashx?tab=' + pageid;
        $.ajax({
            method:"get",
            url: handlerPath,
            dataType: 'html',
            beforeSend: function(XMLHttpRequest) {
                $('#general-content-body').html('<span class=\"loading\"></span>');
            },
            success: function(data) {
                $('#general-content-body').hide();
                $('#general-content-body').html(data);
                $('#general-content-body').fadeIn('normal');
            }
        });
        return false;
    }
    
    //Load YouTube Movies
    $('div[id^="video_"]').each(function() {
        var videoId = $(this).attr('id').replace('video_', '');
        var values = $(this).attr('class').split('_');
        var width = parseInt(values[1]);
        var height = parseInt(values[3]);
        var videoUrl = "http://www.youtube.com/v/" + videoId;
        swfobject.embedSWF(videoUrl, $(this).attr('id'), width, height+25, "9.0.0", "expressInstall.swf");
    });
   
});


