﻿$(document).ready(function() {

$('.block').equalHeights();
var height = $('.block').height() + 105;
$('.block').height(height);

var $li = $("#right-banner .sf_simpleList li").hide();
	var len = $li.length;
	var counter = 1; // how many items to display
	var randomnumber;

	if (len > 0) {
		randomnumber = Math.floor(Math.random() * (len));
		if ($li.eq(randomnumber).is(":hidden")) {
			$li.eq(randomnumber).show();
			counter -= 1;
		}
	}	
	
});





$(document).ready(function() {

//var $sf = $(".sf_wrapper").value;
//alert($sf);
//if ($sf == "") {

			var $li = $("#feature .scroll-wrap .no-scroll li").hide();			
			var len = $li.length;
			var counter = 6; // how many items to display
			var randomnumber;

			if(len > 0) {
				while (counter > 0) {
					randomnumber = Math.floor(Math.random() * (len));
					if ($li.eq(randomnumber).is(":hidden")) {
						$li.eq(randomnumber).show();
						counter -= 1;
					}
				}	
			}

		});


//}
(function(j$) {
    j$(document).ready(function() {
		Cufon.replace('#subnav-heading, h1, .project-type, .scroll-title');
		Cufon.replace('#ctas a', { hover:true, textShadow: '#777 1px 1px' });
		
		// Based on neogisme code from http://flowplayer.org/tools/forum/35/41619
		var scrollSize = 5;
		j$("div.scrollable").scrollable({ items: ".sf_simpleList", size: 1, 
			onBeforeSeek: function(evt,index) {
				var i = index-1;
				var s = this.getSize() - scrollSize;
				
				if(i >= s) return false;
			},
			onSeek: function() {				
				var i = this.getIndex();
				var s = this.getSize() - scrollSize;
				
				if (i >= s) {
					this.seekTo(s);
				}
				
				if(i == s) {
					j$('a.nextPage').addClass('disabled');
				} else {
					j$('a.nextPage').removeClass('disabled');
				}
			}
		});
		j$("div.scrollable ul.sf_simpleList li:first").addClass("first-child");		
		j$("div.scrollable ul.sf_simpleList li:last").addClass("last-child");
		j$("div.no-scroll ul.sf_simpleList li:first").addClass("first-child");		
		j$("div.no-scroll ul.sf_simpleList li:last").addClass("last-child");				

		j$("div.scrollable ul.sf_simpleList li a img").parent().addClass("thumb-wrap");
		j$("div.no-scroll ul.sf_simpleList li a img").parent().addClass("thumb-wrap");

		ScrollListCopy('div.scrollable ul.sf_simpleList');
		ScrollListCopy('div.no-scroll ul.sf_simpleList');
		
		if(j$("div.scrollable ul.sf_simpleList") != null) {
			var s = j$("div.scrollable").scrollable().getSize() - scrollSize;
			if(s <= 0) j$('a.nextPage').addClass('disabled');
		}
		
		j$('a[rel=shadowbox]').fancybox();
	});

	// Copy Sitefinity list items to single ul.sf_simpleList.  This prevents lists from being layed one on top of the other
	function ScrollListCopy(ulToCopy) {
		var i = 0;
		j$(ulToCopy).each(function() {
			if(i > 0) {
				var liToCopy = j$(this).find('li');
				j$(ulToCopy + ':first li:last').after(liToCopy);
				j$(this).remove(liToCopy);
			}
			i++;
		});
	}

// Right side banner

/*$('#right-banners').randomClass( [ 'right-banner1', 'right-banner2', 'right-banner3', 'right-banner4', 'right-banner5', 'right-banner7' ] );*/



        //Popup window code
        j$('a').each(function() {
            var popupWindowRegex = /\{[\w\d\s:,&;/\."\[\]\-]*\}/g;
            if (j$(this).attr('class').match('popUp')) {
                var paramsJson = j$(this).attr('class').match(popupWindowRegex); 
                j$(this).click(function() {
                    popUp(paramsJson);
                    return false;
                });
            }
        });	    
//		j$('.main-nav ul.L1').superfish({
//			delay: 500,                            // one second delay on mouseout 
//			animation: { opacity: 'show' },  // fade-in and slide-down animation 
//			speed: 'fast',                          // faster animation speed 
//			autoArrows: false,
//			dropShadows: false
//		});		
})(jQuery);




