/**
 * @author jQuery extenstions
 */

//function to switch tabs, you have to pass it a jQuery object of a tab and it will do the trick
jQuery.fn.switchTabs = function() {
	jQuery(this).click(function(){
		var id = jQuery(this).attr('id').replace("tab","");
		jQuery(this).addClass("active");
		jQuery(this).parents(".tabs").children("ul").children('li').each(function(){
			jQuery(this).children('a').removeClass('active');
			});
		jQuery(this).addClass('active');
		jQuery(this).parents(".tabs-container").children(".tab-content").removeClass('active');
		jQuery(this).parents(".tabs-container").children("#tab-content"+id).addClass('active');
		return false;	
	})
	return false;
}

jQuery(document).ready(function(){

	
	jQuery('a.tab').switchTabs();
	/*this is for showing loading div on every ajax call...need to test it and then apply*/
	jQuery("#admin-loader").ajaxSend(function(){
		var doc_height = jQuery(document).height();	
		jQuery(this).css('height',doc_height/6);
		jQuery(this).show();
	});
	jQuery("#admin-loader").ajaxComplete(function(){
		jQuery(this).hide();
	});

	Ajax.Responders.register({
	  onCreate: function(){
	    jQuery("#admin-loader").css("top", ( jQuery(window).height() - jQuery("#admin-loader").height() ) / 2+jQuery(window).scrollTop() + "px");
	    jQuery("#admin-loader").css("left", ( jQuery(window).width() - jQuery("#admin-loader").width() ) / 2+jQuery(window).scrollLeft() + "px");
		jQuery("#admin-loader").show();
	  }, 
	  onComplete: function(){
		jQuery("#admin-loader").hide();
	  }
	});
	if(typeof document.body.style.maxHeight === "undefined") {
		jQuery('input:text, input:password').addClass('ie6-input-text');
		jQuery('.has-form input:text, .has-form input:password').css({"float":"left","margin-bottom":"5px","width":"140px"})
	}

})
