$().ready(function() {
	$("#query").autocomplete('/proc?r=j&s=autocomplete', {
		max: 12,
		autoFill: false,
		multiple: false,
		matchContains: true,
//		multipleSeparator: " ",
//		formatResult: formatResult,
		minChars: 2
	});

	function trimItem(row) {
		return row[0].replace(/^\s*|\s*$/g, "");
	}

	function formatItem(row) {
		return row[0] + " (<strong>id: " + row[1] + "</strong>)";
	}
	function formatResult(row) {
		return row[0].replace(/(<.+?>)/gi, '');
	}


	function smartInit() {
//		$("div.#wrapper").css({ 'width' : '960px'});

//		var screenWidth = $("div.#nav").width();

//		var leftPanelWidth = $("div.#panel_left").width();
//		var rightPanelWidth = $("div.#panel_right").width();
//		var centerPanelWidth = screenWidth - leftPanelWidth - rightPanelWidth-8;


		// Central Panel Width
//		$("div.#panel_center").css({ 'width' : centerPanelWidth});

		// Search Input Width
//		var inputWidth = Math.floor(screenWidth -480);
//		$("div.#nav #query").css({ 'width' : inputWidth});

		// Hot Keyword Display
//		var kwLength = $("div.#search_label_pre").width()+$("div.#search_label").width();
//		$('div.#searched_keyword a').each(function() {  
//			kwLength = kwLength + $(this).width()+18;
//			if (kwLength > centerPanelWidth){
//				$(this).hide();
//			} else {
//				$(this).show();
//			}
//		});

		// Brand Banner Width
//		var mainXPWidth= $("div.#xp_home").width();
//		var brandWidth = centerPanelWidth-mainXPWidth;

//		$("#xp_brands").css({ 'width' : brandWidth});

//		$("#xp_brands ul.column").css({ 'width' : brandWidth});
//		var colNum = Math.floor(brandWidth / 110);
//		var brandColWidth = Math.floor(brandWidth / colNum) -5;

//		var rowNum = 3;
//
//		$(".xp_brand_block").css({ 'width' : brandColWidth});
//		$(".xp_brand_block a img").css({'display': 'block'});
//
//		var cnt=1;
//		var msize = colNum * rowNum;
//		$('.xp_brand_block').each(function() {  
//			if (cnt > msize) {
//				$(this).hide();
//			} else {
//				$(this).show();
//			}
//			cnt++;
//		}); 
//
//
//		// New DATA  Width
//		colNum = Math.floor(centerPanelWidth / 130);
//		rowNum = 1;
//		msize = colNum * rowNum;
//		var colWidth = Math.floor(100/ colNum)-1;
//		cnt = 1;
//		$('.new_data_1 ul li').each(function() {  
//			$(this).css({'width':colWidth+'%'});
//			if (cnt > msize) {
//				$(this).hide();
//			} else {
//				$(this).show();
//			}
//			cnt++;
//		}); 
//
//		cnt = 1;
//		$('.new_data_2 ul li').each(function() {  
//			$(this).css({'width':colWidth+'%'});
//			if (cnt > msize) {
//				$(this).hide();
//			} else {
//				$(this).show();
//			}
//			cnt++;
//		}); 
//
//		cnt = 1;
//		$('.new_data_3 ul li').each(function() {  
//			$(this).css({'width':colWidth+'%'});
//			if (cnt > msize) {
//				$(this).hide();
//			} else {
//				$(this).show();
//			}
//			cnt++;
//		}); 
//
//		// Instant Kill Items
//
//		var ikPanelWidth = $("#tabbed_area").width();
//		$('div.content ul li').each(function() {  
//			if (ikPanelWidth < 600) {
//				$(this).css({'width': '50%'});
//			} else if (ikPanelWidth < 900) {
//				$(this).css({'width': '33%'});
//			} else if (ikPanelWidth < 1200) {
//				$(this).css({'width': '25%'});
//			} else {
//				$(this).css({'width': '20%'});
//			}
//		});
//
//		colNum = Math.floor(centerPanelWidth / 138);
//		cnt=1;
//		var msize = colNum * 2;
//		$('div.#new_items li').each(function() {  
//			if (cnt > msize) {
//				$(this).hide();
//			} else {
//				$(this).show();
//			}
//			cnt++;
//		}); 
//
//		cnt=1;
//		$('div.#promotion_items li').each(function() {  
//			if (cnt > msize) {
//				$(this).hide();
//			} else {
//				$(this).show();
//			}
//			cnt++;
//		}); 

	
	}

	function initHintHelp(c) {
		var activeHint = 1;
		if (c >= 1){
			activeHint = c;
		}
		var cnt = 1;
		$('div.#hint_n_help .hint_content').each(function() {  
			if (cnt==activeHint) {
				$(this).show();
			} else {
				$(this).hide();
			}
			cnt++;
		});
	}




	function initHintHelpHeader () {
			$('div.#hint_n_help .accordion_headings').each(function() {  
				$(this).removeClass().addClass("accordion_headings");
			});
	}


	$('div.#hint_n_help .accordion_headings').click(function() {
		initHintHelpHeader();
		$(this).removeClass().addClass("accordion_headings header_highlight");
		initHintHelp($(this).attr('id').split('-')[2]);
	});



	initHintHelp(1);


	
//	smartInit();
//	$(window).resize(function () {
//		smartInit();
//	});

});

