
$(function(){
	
	$("#nav ul li:last-child").addClass('last-child');
	
	$('ul.sf-menu').superfish();
		
	$('#page-slides').slides({
			//preload: true,
			preloadImage: '/images/template/hb-loading.gif',
			play: 0,
			pagination: false
			/*pause: scrollSpeed,
			hoverPause: true
			effect: 'fade',
			crossfade: true*/
	});
		
	if ($('#slides').length > 0) { 
		$('#slides').slides({
			preload: true,
			preloadImage: '/images/template/hb-loading.gif',
			play: 5000,
			pause: 6000,
			hoverPause: true,
			effect: 'fade',
			crossfade: true
		});
	}
	$( "#tabs" ).tabs();
	
	$('#archive').accordion();

	$(".vimeo").colorbox({iframe:true, innerWidth:640, innerHeight:360});

	/* TIMELINE */
	/*if ($('#timelineLimiter').length > 0) {
		var tot=$('.event').length;
		
		$('.eventList li').click(function(e){
				showWindow('<div>'+$(this).find('div.timeline-content').html()+'</div>');
		});
		
		var timelineWidth = 320*tot;
		//var screenWidth = $(document).width();
		var screenWidth = 950;
		
		$('#timelineScroll').width(timelineWidth);
		if(timelineWidth > screenWidth)
		{
			$('#timeline-scroll,#timeline-slider').show();
			//$('#timeline-centered,#timeline-slider').width(66*tot);
			$('#timeline-centered,#timeline-slider').width(950);
			$('#timeline-bar').width((66/320)*screenWidth).draggable({
				containment: 'parent',
				drag: function(e, ui) {
		
					if(!this.elem)
					{
						this.elem = $('#timelineScroll');
						this.maxSlide = ui.helper.parent().width()-ui.helper.width();
						this.cWidth = this.elem.width()-this.elem.parent().width();
						this.highlight = $('#timeline-highlight');
					}
					this.elem.css({marginLeft:'-'+((ui.position.left/this.maxSlide)*this.cWidth)+'px'});
					this.highlight.css('left',ui.position.left)
				}
			});
			
			$('#timeline-highlight').width((66/320)*screenWidth-3);
		}
	}*/
	
	$('.zoom').miniZoomPan({
			sW: 668,
			sH: 430,
			lW: 1336,
			lH: 860
	}
	
	);   
	
	$("#project-images").idTabs(function(id,list,set){ 
	    $("a",set).removeClass("selected") 
	    .filter("[href='"+id+"']",set).addClass("selected"); 
	    for(i in list) 
	      $(list[i]).hide(); 
	    $(id).fadeIn(); 
	    return false; 
	  });
	  
	/* project pyramid */
	
	   $('div.not-current[title]').qtip({
		    position: {
               my: 'left center',
               at: 'right center'
            },
            style: {
            	classes: 'ui-tooltip-shadow ui-tooltip-rounded'
            }
	   });
	   $('.project-current[title]')
         .qtip({
            //content: $(this[title]),
            position: {
               my: 'left center',
               at: 'right center'
            },
            show: {
               event: false, // Don't specify a show event...
               ready: true // ... but show the tooltip when ready
            },
            hide: false, // Don't specify a hide event either!
            style: {
               classes: 'ui-tooltip-light ui-tooltip-shadow ui-tooltip-rounded'
            }
         });
		/*$(".not-current").css({ opacity: 0.25 });
		$(".project-current").css({ opacity: 1 });
		$(".not-current").hover(function(){
			    $(this).stop().animate({"opacity": 1});
			},function(){
			    $(this).stop().animate({"opacity": 0.25});
		});  */
	  
	  
		$('.project-nav td a').equalHeights();
	
	$('a.vidload').live("click",function() 
    {
	    var vidID = $(this).attr("id");
	    var modalID = $(this).attr("data-reveal-id");
	    $('#'+modalID).reveal({
		     animation: 'fade',
		     animationspeed: 300,
		     closeonbackgroundclick: false,
		     dismissmodalclass: 'close-reveal-modal'
		});
    	//alert(vidURL);
		$.ajax({
		    url: "http://vimeo.com/api/oembed.json?format=jsonp&url=http%3A%2F%2Fvimeo.com%2F"+vidID+"&byline=0&title=0&portrait=0&autoplay=1&callback=?",
		    dataType: "jsonp",
		    success: function(data) {
		        //$('#playerdiv').html(JSON.stringify(data.html));
		        $('#playerdiv').html(data.html);
		    },  
		    error: function(errorSender, errorMsg) {
		        $('#playerdiv').text(errorSender + ' ' + errorMsg);
		    } 
		});
        return false;
    });
    
    $('.close-reveal-modal').click( function() {
    	$('#playerdiv').empty();
    });	
	if ($('#subForm').length > 0) {
	$('#bhuddk-bhuddk').valid8({
					regularExpressions: [
						{expression: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(aero|asia|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|pro|tel|travel.ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|er|es|et|eu|fi|fj|fk|fm|.fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|.il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)\b$/, errormessage: 'Please make sure this is valid in order to receive our updates.'}
					]
				});
		$('#mailingsub').bind('click', function(){
			if($('#bhuddk-bhuddk').isValid()){
				
			} else {
				return false
			}
		});
    }
    
	if ($('#contact_form').length > 0) {
		$('#subject, #message').valid8();
		$('#from').valid8({
					regularExpressions: [
						{expression: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(aero|asia|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|pro|tel|travel.ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|er|es|et|eu|fi|fj|fk|fm|.fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|.il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)\b$/, errormessage: 'Please make sure this is valid as we will use it to respond to you.'}
					]
				});
	}

	
	
});
