// SeViR Simple Horizontal Accordion @2007
// http://letmehaveblog.blogspot.com
//
// Modified by Nate for use on the Insyt New Media website

jQuery.fn.extend({
  haccordion: function(params){
    var jQ = jQuery;
    var open_at_start = 'card_web';
    var opened = false;
    var in_progress = false;
    var params = jQ.extend({
      speed: 250,
      headerclass: "card", // *
      contentclass: "content",
      contentwidth: 407
    },params);
    
    return this.each(function(){
    	
      jQ("."+params.headerclass,this).mousemove(function(){
        var p = jQ(this).parent()[0];
        var t = this;
        var hac = opened;
        
        if( (hac != this || hac == false) && (in_progress == false)) {
	      in_progress = true;
	      if (p.opened != "undefined" && hac != false) { 
	          var nx = jQ(p.opened);
	          var wdth = false;
	          if(p.opened.id == "card_av") {
	          		wdth = "31px";
	          }
	          nx.animate({
	            width: wdth || "40px"
	          },params.speed,'swing');
	          jQ(' div.'+params.contentclass,nx).hide();
	      }
	        
	    	p.opened = this;
	        
	     	var nx = $(t);//jQ(this).next("div."+params.headerclass);
	        	nx.animate({
			width: params.contentwidth + "px"
		}, params.speed,'swing',function() { in_progress = false;});
		jQ(' div.'+params.contentclass,nx).show();
		   
        	opened = this;
        }
      });
      
    });
    
  }
});

// --- End horizontal accordion code --//
$(function() {
	$("#cards").haccordion();
	$("#card_web").trigger("mousemove");
});