jQuery(document).ready(function ($) {
		
	// IF JAVASCRIPT ENABLED
	$('body').addClass('js');
	
	// FOOTER PRIMARY MOVES/TABS
	$('#footer-primary').prependTo('#footer');
	
	$('<p><a id="footer-read-more-show">Read More &raquo;</a></p>').insertBefore('#footer-read-more-content');
	$('<p><a id="footer-read-more-hide">Collapse &#94;</a></p>').appendTo('#footer-read-more-content');
	
	$('.footer-tab-control').idTabs();
	$('#footer-read-more-content').hide();
	$('#footer-read-more-show').click(function() {
		$('#footer-read-more-content').toggle();
	});
	$('#footer-read-more-hide').click(function() {
		$('#footer-read-more-content').hide();
	});
	
	//SIGNUP FORM SHOW/HIDE
	//$('<p id="show-signup"><a>Sign Up for Free</a></p>').insertBefore('#signupform');
	//$('#signupform').hide();
	//$('#show-signup').click(function() {
	//	$(this).parent().addClass('contentplus');
	//	$(this).hide();
	//	$('#signupform').show();
	//});
	
	// QUOTES AND NEWS SLIDER
	$('#quotes').bxSlider({auto:true,pause:5000});
	$('.bx-prev').appendTo('#qcontrol');
	$('.bx-next').appendTo('#qcontrol');

	// TWITTER FEED
	$('<div id="twitter-feed-nav"><a class="prev">prev</a><a class="next">next</a></div>').insertAfter('#twitter-feed');

	$('#twitter-feed').jCarouselLite({
		btnNext: '#twitter-feed-nav .next',
		btnPrev: '#twitter-feed-nav .prev',
		vertical: true,
		visible: 1,
		auto: 5000
	});

	// GREAT USES POPUPS
     $('a.nyroModalPro').nyroModal({wrap:{div: '<div class="wrapper"></div>',
        ajax: '<div class="wrapperPro"></div>',
        form: '<div class="wrapper"></div>',
        formData: '<div class="wrapper"></div>',
        image: '<div class="wrapperImg"></div>',
        swf: '<div class="wrapperSwf"></div>',
        iframe: '<div class="wrapperIframe"></div>',
        iframeForm: '<div class="wrapperIframe"></div>',
        manual: '<div class="wrapper"></div>'
    }});

    var USECASEPIDS = {
        uc1pid: 247974654, uc2pid: 569779449, uc3pid: 264936508, uc4pid: 255783194, uc5pid: 860182878,
        uc1img: 'upload-ppt-btn.png', uc2img: 'upload-document-btn.png', uc3img: 'upload-video-btn.png', uc4img: 'upload-photos-btn.png', uc5img: 'produce-podcast-btn.png',
        uc1tab: '#ppt-container', uc2tab: '#document-container', uc3tab: '#video-container', uc4tab: '#photos-container', uc5tab: '#podcast-container'
    };
        
    $('#usecases li').hover(function () {$(this).addClass("hover");
           }, function () {$(this).removeClass("hover");});
           
    $('#usecases li').each(function(i) {
            $(this).click (function(e) {
                e.preventDefault();
                var pid = USECASEPIDS[this.id.replace('li', 'pid')];
                var img = USECASEPIDS[this.id.replace('li', 'img')];
                var tab = USECASEPIDS[this.id.replace('li', 'tab')];
                var title = $(this).find('h3').text();
                
                $.nyroModalManual({
                    title: title,
                    url: '#usecaseplayer',
                    titleFromIframe: false,
                    endFillContent: function(nyro) {
                        nyro.content.find('iframe').attr('src', 'http://www.brainshark.com/brainsharkinc/vu?pi=' + pid + '&pt=15&dm=5&nrs=1');
                        //nyro.content.find('img')
                        //    .attr('src', '/images/mybrainshark/' + img)
                        //    .attr('title', title);
                        //nyro.content.find('a').attr('href', 'http://my.brainshark.com/LoginModal.aspx?returnurl=http://my.brainshark.com/brainshark/brainshark.net/author/Upload.aspx' + escape(tab)).nyroModal();
                    },
                    beforeHideContent: function(nyro, s, cb) { nyro.content.find('iframe').attr('src', 'javascript:\'\''); cb(); }
                });
                
                return false;
            });
     });
     
     $('.viewademo' ).click(function(e) {
        var that = this;
        $.nyroModalManual({
            url: '#demoplayer',
            title: that.title,
            titleFromIframe: false,
            endFillContent: function(nyro) { nyro.content.find('iframe').attr('src', that.href); },
            beforeHideContent: function(nyro, s, cb) { nyro.content.find('iframe').attr('src', 'javascript:\'\''); cb(); }
        });
        
        return false;
     });


});

