/**
 * @author katewykes
 * this instatiates all of the drop-downs and View all work/Flip buttons
 * the banner rotation is decalared  at the bottom
 */
$(document).ready(function(){
		/*drop-downs*/		
		$('#oddis').hover(function() {
			if ($('#oddis ul.subnav').css('display') == 'none') {
				$('#oddis ul').slideDown(200);
			}
		}, function() {
			$('#oddis ul').slideUp(10);
		});
		
		/*discipline*/
		$('#discipline').click(function() {
			if ($('#discipline ul.subnav').css('display') == 'none') {
				$('#discipline ul').slideDown(100);
			}else{
				$('#discipline ul').hide();				
			}
		});
		/*client*/
		$('#client').click(function () {
    	  if ($("#client ul").css('display') == 'none') {
    	    $("#client ul").slideDown(100);
    	  } else {
    	    $("#client ul").hide();
    	  }
    	});

		/*$('#client').click(function() {
			if ($('#client ul.subnav').css('display') == 'none') {
				$('#client ul').slideDown(100);
			}else{			
				$('#client ul').slideUp();
			}
		});*/
		/*end drop-downs*/
		
		$("#searchform form input").click(function(){
			$(this).attr("value", "");
		});
		$("#searchform form input").blur(function(){
			$(this).attr("value", "Search");
		});


		/* the fact that the .image has focus overrides the mouseover and out*/
		$(".mask_slide").mouseover(function(){
			$(this).find(".image").css({
				'opacity': '1'
			})
		});
		$(".mask_slide").mouseout(function(){
			if ($(this).attr("selected") != "1") {
				$(this).find(".image").css({
					'opacity': '0.5'
				})
			}
		});

		//absolutely brilliantly written
		$(function() {
		    $('#bannerimage').cycle({
				delay: 2000,
        		speed: 500,
				before: onBefore,
				pager:  '#nav'
    		});				
			function onBefore() {
				//all show through the mask
				$(".mask_slide").find(".image").css({
					'opacity': '0.5'
				})
				$(".mask_slide").attr("selected", "0");
		       	var imageid = $(this).attr("id"); //this is slide1, slide2, etc
		       	var thumbstring = "#thumb";
				var thumbid = thumbstring.concat(imageid.substr(5,1));
				$(thumbid).attr("selected", "1");
				$(thumbid).find(".image").css({
					'opacity': '1'
				})
			}
		});
	
});
