//$j = jQuery.noConflict();
$(document).ready(function(){
	
	/* Drop Down Menu */
	var offenses = $("#offenses");
	var subMenu	 = $("#sub-nav-container");
	
	offenses.hover(function(){
	
		subMenu.show();
		
	}, function(){
	
		subMenu.hide();
	
	});
	
	/* Input Value */
	$('input').each(function() {
        var default_value = this.value;
        if( $(this).is('.submit') ){
        	// Do Nothing
        }else{
	        $(this).focus(function() {
	            if(this.value == default_value) {
	                this.value = '';
	            }
	        });
	        $(this).blur(function() {
	            if(this.value == '') {
	                this.value = default_value;
	            }
	        });
		}
    });
    
    /* Textarea Value */
    $('textarea:not(#bankruptcy-facts)').each(function() {
    	var default_value = this.value;
    	$(this).focus(function() {
    		if(this.value == default_value) {
                    this.value = '';
             }
    	});
    	$(this).blur(function() {
    		if(this.value == '') {
    			this.value = default_value;
    		}
    	});
    });
		
		$("#bankruptcy-facts").click(function(){
			$(this).focus();
			$(this).select();
		});
    
	/* Misdemeanor List Action */
	$('#misdemeanors li').click(function() {
		var $temp = $j(this);
		$('#misdemeanors li').each(function() {
			$(this).css('background', 'none');
		});
		$('#misdemeanors li li').each(function() {
			$(this).css('background', 'url("/wp-content/themes/criminallaw/images/list-arrow.png") no-repeat scroll left 7px transparent');
		});
		$temp.css('background', 'url(/wp-content/themes/criminallaw/images/misdlist.png) right -1px no-repeat');
		if($temp.children('ul').html() != null)
			$('table .misdright').html('<ul>'+$temp.children('ul').html()+'</ul>');
		else
			$('table .misdright').html('');
	});
	
	/* Bankruptcy Popup */
	// if ($.readCookie('bankruptcy-popup') != 'true') {
	// 		setTimeout(function() { 
	//       var cookie;
	//       $("a#inline").fancybox({ 
	// 					'onComplete' : function(){
	// 						cookie = $.setCookie('bankruptcy-popup', 'true', { duration: 1 });
	// 					}
	// 			}).trigger('click'); 
	// 	  }, 30000);
	//   }

	if ($('#tabs').length){
		console.log('test');
		$.getScript("http://www.jacksonwhitelaw.com/wp-content/themes/bankruptcy/scripts/jquery-ui-1.8.16.custom.min.js", function() {
		console.log('test2');

			$( "#tabs" ).tabs();

		});

	}
		
});
