﻿var curId = "";
 
function category_menu_open(){
	$(".secnav").each(function(){
		$(this).hide()
	});

	curId = $(this).attr("fid");
	curDisp = $(this).attr("fdisplay");

	if (curDisp != "no")
	{
		$("#secnav_" + curId).show();
	}
}

function category_menu_close(){
	var lastId = $(this).attr("fid");
	if (curId != lastId)
	{
		$("#secnav_" + curId).hide();
	}else{
		try{
			setInterval($("#secnav_" + curId).hide(),1000);
		}catch(e){;}
	}
}

$(document).ready(function()
{
	$('#nav > a').bind('mouseover', category_menu_open);
	//$('#nav > a').bind('mouseout',  category_menu_close);

	$('#menu_fav').click(function(){
		window.external.AddFavorite(window.location.toString(),window.document.title);
		return false;
	});

	$('.zoom').click(function(){
		var pid = $(this).attr('pid');
		if ($(this).attr("class") == 'zoom zoom_l')
		{
			$(this).removeClass("zoom_l");
			$(this).addClass("zoom_2");
			$('#goodspro_list' + pid).height('64px');
		}else{
			$(this).removeClass("zoom_2");
			$(this).addClass("zoom_l");
			$('#goodspro_list' + pid).height('32px');
		}

		return false;
	});

	$('.secnav').bind('mouseover', category_menu_open);
	$('.secnav').bind('mouseout',  category_menu_close);

	$("#divBasketItemText").hover(
		function(){
			$.post(uri + "api/c_shoppingbag.asp",{"txt":"123"},
				function(data)
				{
					$("#shopform").html(data);
				}
			);

			$("#sec_menus_shopping").show();
		},
		function(){
			//$("#sec_menus_shopping").hide();
		}
	);

	$("#homes3_notice > ul > li").hover(
		function(){
			$("#homes3_notice > ul > li").each(function(){
				$(this).attr("class","");
			});

			$(this).attr("class","m2_cur");
		}
	);

	$("#leftmenu > dl > dt").hover(
		function(){
			$("#leftmenu > dl > dt").each(function(){
				$(this).addClass("posdiv");
				$(this).children(".childbox").hide();
			});

			$(this).children(".childbox").show();
		},
		function(){
			$(this).children(".childbox").hide();
		}
	);

	$("#shopform").hover(
		function(){
		},
		function(){
			$("#sec_menus_shopping").hide();
		}
	);

//		top.location.href = uri + '?search?ref=search&k='+encodeURI(form.s.value);

	$("#btn_query_keyword").click(function(){
		alert ("test");
		return false;
	});

	$("#btn_friend").click(function(){
		var clipBoardContent=''; 
		$.ajax({ 
			type:"GET", 
			url: "api/myfriend.asp", 
			data:"tmp=" + Math.random(), 
			success:function(data)
			{

				if (data == '')
				{
					location.replace(uri + '?notes-38.html');
				}else{
						clipBoardContent = uri + "?m=" + data;

						window.clipboardData.setData("Text",clipBoardContent);
						window.alert("邀请朋友代码复制成功。\n\n请粘贴(Ctrl+V)到你的QQ/MSN上推荐给好友。");

						if (window.clipboardData){
							window.clipboardData.setData("Text",clipBoardContent);
						}else if(window.netscape){
							try{
								netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
							}catch(e){
								alert("你使用的浏览器是FireFox，此功能不能正常使用，请你拷贝地址栏的地址粘贴给好友。") 
								return false;
							}
							netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
							var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
							if (!clip) return;
							var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
							if (!trans) return;
							trans.addDataFlavor('text/unicode');
							var str = new Object();
							var len = new Object();
							var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
							var copytext = CopyData;
							str.data=copytext;
							trans.setTransferData("text/unicode",str,copytext.length*2);
							var clipid=Components.interfaces.nsIClipboard;
							if (!clip) return false;
							clip.setData(trans,null,clipid.kGlobalClipboard);
						}else{
							window.alert("你当前浏览器不支持剪切板操作，非常抱歉。");
							return false;
						}
					}
				}

		});

		
	});
});
