$(document).ready(function(){
	$('DIV.product_item IMG.thumbnail').hover(function(){
		if	($(this).attr('POPUP') != undefined)	{
		}
	},function(){
	}) ;
	$('UL.product_menu LI.lv1').hover(function(){
		if	($(this).attr('mode') != 'o')	$(this).addClass('hover') ;
	},function(){
		if	($(this).attr('mode') != 'o')	$(this).removeClass('hover') ;
	});
	$('UL.product_menu LI.lv1').each(function(){
		if	($(this).find('UL').size() > 0)	{
			$(this).find('UL').hide() ;
			$(this).attr('mode','c') ;
			$('<FONT CLASS="menu_switch o">&nbsp;&nbsp;+</FONT><FONT CLASS="menu_switch c">&nbsp;&nbsp;-</FONT>').insertAfter($(this).find('A:first')) ;
			$(this).find('FONT.c').hide() ;
//			$(this).css('cursor','pointer') ;
			$(this).find('FONT.menu_switch').click(function(){
				var	node	=	$(this).parent().filter('LI.lv1') ;
				if	($(this).parent().filter('LI.lv1').attr('mode') == 'c')	{
					$(node).find('FONT.c').show() ;
					$(node).find('FONT.o').hide() ;
					$(node).find('UL').slideDown(150) ;
					$(node).attr('mode','o').css('padding','10px 0 0 0') ;
					$('<DIV CLASS="delimiter"></DIV>').insertAfter($(node).find('UL.lv2')) ;
				}
				else	{
					$(node).find('FONT.o').show() ;
					$(node).find('FONT.c').hide() ;
					$(node).find('UL').slideUp(50) ;
					$(node).attr('mode','c').css('padding','10px 0 12px 0') ;
					$('UL.product_menu DIV.delimiter').remove() ;
				}
			}) ;
		}
	});
	$('UL.product_menu LI.lv2').each(function(){
		$(this).find('LI:gt(0)').each(function(){
			$(this).html('<NOBR><FONT>/</FONT>' + $(this).html() + '</NOBR>') ;
		}) ; // prepend('<FONT>/</FONT>') ;
	}) ;
	$(function(){
		var	count	=	0 ;
		$("#slide").rolling('left', 157, 170);
		$('#slidebank').find('IMG').each(function(){
			count	+=	1 ;
			if	($('#rollingComment').html() == '')	$("#rollingComment").html('型號:<A HREF="' + $(this).attr("url") + '">' + $(this).attr("NO") + "</A>"
				+ '<BR>'
				+ '品名:<A HREF="' + $(this).attr("url") + '">' + $(this).attr("NAME") + "</A>");
			$("#slide").addRollingItem($(this));
		}) ;
		$("#slide").bindRollingEvent(function(event, currentRollingItem) {
			$("#rollingComment").html(
				'型號:<A HREF="' + $("img", currentRollingItem).attr("url") + '">' + $("img", currentRollingItem).attr("NO") + "</A>"
				+ '<BR>'
				+ '品名:<A HREF="' + $("img", currentRollingItem).attr("url") + '">' + $("img", currentRollingItem).attr("NAME") + "</A>"
			);
		});
		$("#slide").bindStopEvent(function(event) {
			$("#rollingStatus").html("Stop");
		});
		if	(count > 1)	$("#slide").startRolling(100, 3000, 5);
	}) ;
	$('IMG.thumbnail').tagMenu('myTag', {}) ;
	$('UL.product_menu A').each(function(){
		if	($(this).attr('href') == location.pathname) {
			$(this).parents().filter('LI.lv1').addClass('hover').find('FONT.o').click() ;
		}
	}) ;
}) ;
function	act() {
	document.CSI.submit() ;
}

(function($) {
	var menu, content, hash ;
	var defaults = {
		eventPosX: 'pageX',
		eventPosY: 'pageY'
	};
	$.fn.tagMenu = function(id, options) {
		if (!menu) {
			menu = $('<div CLASS="tagStyle"></div>')
				.css({position:'absolute', zIndex:'500'})
				.appendTo('body') ;
		}
		hash = hash || [];
		hash.push({
			id : id,
			bindings: options.bindings || {},
			eventPosX: options.eventPosX || defaults.eventPosX,
			eventPosY: options.eventPosY || defaults.eventPosY
		});

		var index = hash.length - 1;
		$(this).hover(function(e) {
			if	($(this).attr('POPUP') != undefined)	{
				$('div.tagStyle').html('<IMG SRC="/upload_file_2008/ZH/product-image/' + $(this).attr('POPUP') + '" STYLE="border:#888 solid 1px">') ;
			}
		},function(){});
		$(this).mousemove(function(e) {
			if	($(this).attr('POPUP') != undefined)	{
				if		(window.innerWidth > 0)						w =	window.innerWidth ;
				else if	(document.body.clientWidth > 0)				w = document.body.clientWidth ;
				else if	(document.documentElement.clientWidth > 0)	w = document.documentElement.clientWidth ;
				if		(window.innerHeight > 0)					h =	window.innerHeight ;
				else if	(document.body.clientHeight > 0)			h = document.body.clientHeight ;
				else if	(document.documentElement.clientHeight > 0)	h = document.documentElement.clientHeight ;
				var	sh	=	(document.body.scrollTop) ? document.body.scrollTop : 0 ;
				var cur = hash[index] ;
				x	=	(e[cur.eventPosX] > parseInt(w / 2) + 20) ? e[cur.eventPosX] - 380 : e[cur.eventPosX] + 80 ;
				y	=	((e[cur.eventPosY] - sh) > parseInt(h / 2) + 20) ? e[cur.eventPosY] - 350 : e[cur.eventPosY] + 50 ;
				menu.css({'left':x,'top':y}).show() ;
				return false;
			}
		});
		$(this).mouseout(function(e) {
			menu.hide() ;
		}) ;
	};
})(jQuery);

document.ONDRAGSTART	=	function(){
	return	false ;
}
document.oncontextmenu	=	function(){
	return	false ;
}
document.onSelectStart	=	function(){
	return	false ;
}