// JavaScript Document
function hoverButton(imgDir){
	jQuery(".hoverbutton").hover(			   
      function () {
        jQuery(this).attr({ 
		src: imgDir + "/images/" + this.id + "-on.jpg"
		});

      }, 
      function () {
        jQuery(this).attr({ 
		src: imgDir + "/images/" + this.id + "-off.jpg"
		});
      }
    );
}

function hoverBackground(imgDir){
	
	jQuery(".hoverbackground").hover(			   
      function () {
        jQuery(this).attr({ 
		src: imgDir + "/images/" + this.id + "-on.jpg"
		});

      }, 
      function () {
        jQuery(this).attr({ 
		src: imgDir + "/images/" + this.id + "-off.jpg"
		});
      }
    );
}

function handleAds(currItem){
	var currID = currItem.attr('id');
	var iLength = currID.length -1;

	

	if (! (currItem.hasClass('current')) && currID.substr(iLength) != 'adcontent') {
  	  jQuery('#companyads li').addClass('current');
	//  currItem.addClass('current');	  
	  
	switch(currItem.attr('id'))
    {
      case 'ad1':
        //ad 1 is always on the left
		jQuery('#companyads #ad2').removeClass('current');
		jQuery('#companyads #ad3').removeClass('current');
	    currItem.addClass('current');
		jQuery('#companyads #ad2').removeClass('onleft');
		jQuery('#companyads #ad2').addClass('onright');
		//jQuery('#companyads #ad2').hide();
        jQuery('#companyads #ad2').animate({
			left:'426px'
	
		  }, "slow");
        
		if (jQuery('#companyads #ad3').hasClass('onleft')) {
			jQuery('#companyads #ad3').removeClass('onleft');
		    jQuery('#companyads #ad3').addClass('onright');;
		//	jQuery('#companyads #ad3').hide();
    		jQuery('#companyads #ad3').animate({
			left:'460px'

					  
		  }, "slow");		
		  
		}
		
          jQuery('#companyads #adcontent2').css('display', 'none');
		  jQuery('#companyads #adcontent3').css('marginLeft', '368px');
		  jQuery('#companyads #adcontent3').css('display', 'none');
		 
		  jQuery('#companyads #adcontent1').animate({ width: 'show' });

		  

        break;
      case 'ad2':
	    jQuery('#companyads #ad1').removeClass('current');
		jQuery('#companyads #ad3').removeClass('current');
	    currItem.addClass('current');
        if (currItem.hasClass('onleft')) {
		  jQuery('#companyads #ad3').removeClass('onleft');	
		  jQuery('#companyads #ad3').addClass('onright');
		//  jQuery('#companyads #ad3').hide();
		  jQuery('#companyads #ad3').animate({
			left:'460px'
	
		  }, "slow");		
		  
		}
		else {//ad 2 is on the right
		  jQuery('#companyads #ad2').removeClass('onright');	
		  jQuery('#companyads #ad2').addClass('onleft');
		//  jQuery('#companyads #ad2').hide();
		  jQuery('#companyads #ad2').animate({
			left:'34px'
           }, "slow");
		  
		}
	 	jQuery('#companyads #adcontent3').css('display', 'none');
		jQuery('#companyads #adcontent1').css('display', 'none');
		
		jQuery('#companyads #adcontent2').animate({ width: 'show' });
		
   
		break;
	  case 'ad3':
	    jQuery('#companyads #ad1').removeClass('current');
		jQuery('#companyads #ad2').removeClass('current');
	    currItem.addClass('current');
       //only moves when on the right otherwise its current
		  jQuery('#companyads #ad2').removeClass('onright');	
		  jQuery('#companyads #ad2').addClass('onleft');
		//  jQuery('#companyads #ad2').hide();
		  jQuery('#companyads #ad2').animate({
			left:'34px'
		  }, "slow");
		  jQuery('#companyads #ad2').animate({ width: 'show' });
		  if (jQuery('#companyads #ad3').hasClass('onright')) {
            jQuery('#companyads #ad3').removeClass('onright');	
		    jQuery('#companyads #ad3').addClass('onleft');
		 //   jQuery('#companyads #ad3').hide();
		    jQuery('#companyads #ad3').animate({
			  left:'68px'

		    }, "slow");
		    
		  }
		 jQuery('#companyads #adcontent1').css('display', 'none');
    	  jQuery('#companyads #adcontent2').css('display', 'none');
		  
		  jQuery('#companyads #adcontent3').animate({width: 'show', left: parseInt(jQuery('#companyads #adcontent3').css('marginLeft'),10) != 0 ? -jQuery('#companyads #adcontent3').outerWidth() :   0 });
		  
		break;
      default:
	    break;
	
	}
} 

}
function setupTabs(activeTab) {
 var $tabs = jQuery("#tabs").tabs({ selected: activeTab });
 try {
 var selected = $tabs.tabs('option', 'selected');
 jQuery(".tabsidebar").addClass("hide");
 jQuery(".side" + selected).removeClass("hide");
 
 $tabs.bind('tabsselect', function(event, ui) {  
         // Objects available in the function context:  
   //     alert(ui.tab);     // anchor element of the selected (clicked) tab  
  //      alert(ui.panel);   // element, that contains the selected/clicked tab contents  
   //     alert(ui.index);   // zero-based index of the selected (clicked) tab  
           jQuery(".tabsidebar").addClass("hide");
		  jQuery(".side" + ui.index).removeClass("hide");
    }); 
 }
 catch(err){}//in case there are no tabs
}
	
function allDone(currItem) {
alert (currItem.attr('id'));
if (!currItem.is(":animated")) {
switch(currItem.attr('id'))
    {
      case 'ad1':
        jQuery('#companyads #ad2').removeClass('current');
		jQuery('#companyads #ad3').removeClass('current');
		break;
	  case 'ad2':
        jQuery('#companyads #ad1').removeClass('current');
		jQuery('#companyads #ad3').removeClass('current');
		break;	
	  case 'ad3':
        jQuery('#companyads #ad1').removeClass('current');
		jQuery('#companyads #ad2').removeClass('current');
		break;	
	  default:
	    break;
  }
  
}
else {
return allDone(currItem);
}

}
// SeViR Simple Horizontal Accordion @2007
// http://letmehaveblog.blogspot.com
jQuery.fn.extend({
  haccordion: function(params){
    var jQ = jQuery;
    var params = jQ.extend({
      speed: 500,
      headerclass: "header",
      contentclass: "content",
      contentwidth: 391
    },params);
    return this.each(function(){

      jQ("."+params.headerclass,this).click(function(){
         var currItem = jQ(this).children('a');	
		if (! (currItem.hasClass('current'))) {  
        var p = jQ(this).parent()[0];
		jQ("div."+params.contentclass).removeClass("opened");
		
        if (p.opened != "undefined"){
	      
          jQ(p.opened).next("div."+params.contentclass).animate({
            width: "0px"
          },'slow').removeClass("opened");
        }
       p.opened = this;
	  	
	  
	// p.opened = jQ(this).children('a');
		
		
		switch(currItem.attr('id'))
       {
		   case 'ad1':
		     jQ('#companyads #ad2').removeClass('current');
		     jQ('#companyads #ad3').removeClass('current');
	          currItem.addClass('current');
		      jQ('#companyads #ad2').removeClass('onleft');
		     jQ('#companyads #ad2').addClass('onright');
			 if (jQ('#companyads #ad3').hasClass('onleft')) {
			  jQ('#companyads #ad3').removeClass('onleft');
		      jQ('#companyads #ad3').addClass('onright');
			 }
		   break;
		   case 'ad2':
		     jQ('#companyads #ad1').removeClass('current');
		     jQ('#companyads #ad3').removeClass('current');
	       currItem.addClass('current');
           if (currItem.hasClass('onleft')) {
		      jQ('#companyads #ad3').removeClass('onleft');	
		      jQ('#companyads #ad3').addClass('onright');
		   }
		   else {//ad 2 is on the right
		    jQ('#companyads #ad2').removeClass('onright');	
		    jQ('#companyads #ad2').addClass('onleft');
		  }
		   break;
		   case 'ad3':
		     jQ('#companyads #ad1').removeClass('current');
		     jQ('#companyads #ad2').removeClass('current');
	         currItem.addClass('current');
       //only moves when on the right otherwise its current
		     jQ('#companyads #ad2').removeClass('onright');	
		     jQ('#companyads #ad2').addClass('onleft');
			 if (jQ('#companyads #ad3').hasClass('onright')) {
              jQ('#companyads #ad3').removeClass('onright');	
		      jQ('#companyads #ad3').addClass('onleft');
			 }
		   break;
		   case 'default':
		   break;
	   }
        
        jQ(this).next("div."+params.contentclass).animate({	 										  
          width: params.contentwidth + "px"
        }, 'slow');
		 	}					 
      });  
    });  
  }   
});  
function blogHideShow(bShow)
{
   if (bShow) {
	  jQuery("#usersignedin").show();
	  jQuery("#homesignin").hide();	  
  }
  else {
	  jQuery("#usersignedin").hide();
	  jQuery("#homesignin").show();	  	
  }  
}
