$(document).ready(function(){    
    var lcol = $('#left-col'), rcol = $('#right-col'), ccol = $('#center-col');
    
    /**
     * Tabs
     */
    $('div.tabs div[rel].tab').each(function(i){        
        $(this).unbind('click').bind('click',function(){
            $(this).parent().find('div.tabactive').removeClass('tabactive');
            $(this).addClass('tabactive');

            //find direct div children and hide it
            $($(this).attr('rel')).parent().find('div.active').removeClass('active');
            $($(this).attr('rel')).addClass('active');

            window.location.hash = $(this).attr('rel');
        });
    });
    
    //get current tab name from hash
    var current_tab = window.location.hash;
    
    if(current_tab == ''){
        //active first tab 
        $("div.tabs div[rel]:first-child").addClass('tabactive');
    }else{
        $("div.tabs div[rel=" + current_tab +"]").addClass('tabactive').trigger('click');
    }

    $('button').click(function(){
       if ($(this).attr('action')){
           document.location.href = $(this).attr('action');
           return false;
       }
    });
    
    
    $('input:submit.ui').button({
        icons : {
            primary: "ui-icon-unlocked"
        }
    });
    
	
	Cufon.replace('.cufon, .menu li a', {fontFamily: 'Myriad Pro Regular', hover: true}); 
	
	$("input.datepicker").datepicker({changeMonth: true, changeYear: true});
    
    /*
	$('div[rel].tab').click(function(){
		$('.tabcontent>div').hide();
		$($(this).attr('rel')).show();
		$('.tabactive').removeClass('tabactive');
		$(this).addClass('tabactive');
	});
    */
    $('.servicetabs li').click(function(){
		$('.servicewrapper>div.servicecontent').css('display', 'none');
		$($(this).attr('rel')).css('display', 'block');
		$('.servicetabs li.serviceactive').removeClass('serviceactive');
		$(this).addClass('serviceactive');
	});    
});

(function($){
    $.fn.disable = function(){
        return this.each(function(){
            // add  some stuff here
            $(this).attr('disabled',true).css({
                'opacity' : 0.4
            });
        });
    };
    
    $.fn.enable = function(){
        return this.each(function(){
            // add some stuff here
            $(this).attr('disabled',false).css({
                'opacity' : 1
            });
        });
    };
})(jQuery);
