$(document).ready(function(){

	$('#debugwc_close').click(function(){
		try{
			debugwc_count++;
		}
		catch(e){
			debugwc_count = 0;
		}
		if(debugwc_count > 0){
			$('#debugwc').remove();
			return false;
		}

		$('#debugwc_output').text(' ');
		set_cookie('debug_action', '', '', '', '' , '/');
		debugSetCurrentItem('#noElement');
		return false;
	});

	$('#wcShowVars').click(function(){
		wcShowVars();
		set_cookie('debug_action', 'wcShowVars', '', '', '' , '/');
		debugSetCurrentItem('#wcShowVars');
		return false;
	});

	$('#wcShowPageVars').click(function(){
		wcShowPageVars();
		set_cookie('debug_action', 'wcShowPageVars', '', '', '' , '/');
		debugSetCurrentItem('#wcShowPageVars');
		return false;
	});

	$('#wcShowCategories').click(function(){
		wcShowCategories();
		set_cookie('debug_action', 'wcShowCategories');
		debugSetCurrentItem('#wcShowCategories');
		return false;
	});


	function debugSetCurrentItem(e){
		$('#debugwc .current').removeClass('current');
		$(e).addClass('current');
	}

	function wcShowVars(){
		$('#debugwc_output').load((template_path + '/ajax.php'), { ajax : 1, action : 'wcShowVars'} );
	}

	function wcShowPageVars(){
		var temp = $('#wcShowPageVars_data').html()
		
		temp += "\nbody: ";
		temp += ($('body').attr('class'));
		temp += "\npage: ";
		temp += ($('#page').attr('class'));

		
		$('#debugwc_output').html(temp);
	}

	function wcShowCategories(){
		$('#debugwc_output').load((template_path + '/ajax.php'), { ajax : 1, action : 'wcShowCategories'} );
	}

	function do_debug_action(){
		var temp = get_cookie('debug_action');
		if((temp != '') && (temp != undefined)){
			debugSetCurrentItem('#'+temp);
			temp += '()';
//			console.log(temp);
			eval(temp);
		}
	}
	do_debug_action();

	$('#wc_li_id').text( $('#wc_id').text() );


});
