﻿$(function() {
	$('a.blank').attr('target', '_blank');
	$('.navMenu > li:not(.active)').hover(function() {
		$(this).addClass('hover');
	}, function() {
		$(this).removeClass('hover');
	});
	$('.fcktext table>tbody>tr:odd, table.data>tbody>tr:odd, table.group>tbody>tr:odd, table.result>tbody>tr:even, table.spec tr:even').addClass('even');
	$('.faqList>li:nth-child(3n), .productList > li:nth-child(3n)').after('<li class="separator"></li>');
	$('#localNav a:not(.title)').each(function() {
		if (this.href.toLowerCase() == String(window.location.href).toLowerCase()) {
			return !$(this).addClass('active');
		}
	});
	$('#tabNav li a').each(function() {
		if (this.href.toLowerCase() == String(window.location.href).toLowerCase()) {
			return !$(this).parent().addClass('active');
		}
	});
	$('#repairItem').change(function() {
		$('.note.r').removeClass('r');
		$('.hidden').hide();
		$('#' + $('#repairItem').val()).show();
	});
	var WATERMARK = '請輸入產品型號';
	var WATER_CLASS = 'onfocus';
	$('input.prod-search').focus(function() {
		var j = $(this);
		j.val() == WATERMARK && j.val('').addClass(WATER_CLASS);
	}).blur(function() {
		var j = $(this); var v = $.trim(j.val()); j.val(v);
		(v == WATERMARK || v == '') && j.val(WATERMARK).removeClass(WATER_CLASS);
	}).keyup(function(e) {
		if (e.which==13) $(this).next().click();
	}).val(WATERMARK).next().click(function() {
		var j = $(this).prev();
		if (!j.is('.' + WATER_CLASS)) return !!alert(WATERMARK);
		var v = j.val();
		if (v.length < 3) return j.focus() && !!alert('請至少輸入三個字');
		location.href = '/search/' + encodeURIComponent(v);
	});
	// fix ie6 Flickering Background Images
	if (!$.boxModel)try{document.execCommand("BackgroundImageCache",!1,!0);}catch(e){}
});

