$(document).ready(function(){

//enticer hover effect
	$(".enticer").click(function(){
	  window.location=$(this).find("a").attr("href"); return false;
	});
	$(".studio").click(function(){
	  window.location=$(this).find("a").attr("href"); return false;
	});

// control hover in/out fade speed
	var hoverSpeed = 600;
	var hoverOut = 200;

// toggle colour bar shift on hover of nav items
//	attachImgEvents("left");
//	attachImgEvents("center");
//	attachImgEvents("right");

//function attachImgEvents(id) {
//$("." + id).mouseover(function() {
     $(".enticer.left").hover(
      function () {
        $(this).contents(".excerptImage").append('<span></span>');
		$(".enticer.left .excerptImage span").css({display:"none"}).fadeIn(hoverSpeed);
      }, 
      function () {
        $(".enticer.left .excerptImage span").fadeOut(hoverOut, function() {
			$(this).remove();
		});
      }
    );

    $(".enticer.center").hover(
      function () {
        $(this).contents(".excerptImage").append('<span></span>');
		$(".enticer.center .excerptImage span").css({display:"none"}).fadeIn(hoverSpeed);
      }, 
      function () {
        $(".enticer.center .excerptImage span").fadeOut(hoverOut, function() {
			$(this).remove();
		});
      }
    );

    $(".enticer.right").hover(
      function () {
        $(this).contents(".excerptImage").append('<span></span>');
		$(".enticer.right .excerptImage span").css({display:"none"}).fadeIn(hoverSpeed);
      }, 
      function () {
        $(".enticer.right .excerptImage span").fadeOut(hoverOut, function() {
			$(this).remove();
		});
      }
    );

     $(".studio.left").hover(
      function () {
        $(this).contents(".studioImage").append('<span></span>');
		$(".studio.left .studioImage span").css({display:"none"}).fadeIn(hoverSpeed);
      }, 
      function () {
        $(".studio.left .studioImage span").fadeOut(hoverOut, function() {
			$(this).remove();
		});
      }
    );

    $(".studio.center").hover(
      function () {
        $(this).contents(".studioImage").append('<span></span>');
		$(".studio.center .studioImage span").css({display:"none"}).fadeIn(hoverSpeed);
      }, 
      function () {
        $(".studio.center .studioImage span").fadeOut(hoverOut, function() {
			$(this).remove();
		});
      }
    );

    $(".studio.right").hover(
      function () {
        $(this).contents(".studioImage").append('<span></span>');
		$(".studio.right .studioImage span").css({display:"none"}).fadeIn(hoverSpeed);
      }, 
      function () {
        $(".studio.right .studioImage span").fadeOut(hoverOut, function() {
			$(this).remove();
		});
      }
    );



//accordion
  // hide all ULs inside LI.drawer except the first one
//  $('li.drawer ul:not(:first)').slideUp(); 
  
  // apply the open class
//  $('li.drawer ul:first').addClass('open');
  
//  $('h4.drawer-handle').click(function () {
    // hide the currently visible drawer contents
//    $('li.drawer ul:visible').slideUp();
    
    // remove the open class from the currently open drawer
//    $('h4.open').removeClass('open');
    
    // show the associated drawer content to 'this' (this is the current H2 element)
    // since the drawer content is the next element after the clicked H2, we find
    // it and show it using this:
//    $(this).next().slideDown();
    
    // set a class indicating on the H2 that the drawer is open
//    $(this).addClass('open');
//  });

//accordion
  $('ul.drawers').accordion({
    // the drawer handle
    header: 'h4.drawer-handle',
    
    // our selected class
    selectedClass: 'open',
    
    // match the Apple slide out effect
    event: 'click'
  });
  
//global contact form validation
function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }



});
