﻿//jQuey 
//会员状态
var userName = GetCookie("usernameJS");

//缩放图片
$(".imgResize").each(function(i){
	var imgObj = $(this).children("img").get(0);
	var width = $(this).css("width").replace("px","");
	var height = $(this).css("height").replace("px","");
	if (!width && $(imgObj).attr("title")) {
		var midNum = $(imgObj).attr("title").indexOf("*");
		width = $(imgObj).attr("title").substr(0,midNum); 
		height = $(imgObj).attr("title").substr(midNum+1);
	}
	if(imgObj.complete || imgObj.readyState =="complete") { DrawImage(imgObj,width,height);}
	else {
		imgObj.onreadystatechange = function(){ 
			if(imgObj.readyState =="complete") { DrawImage(imgObj,width,height); }
		} 
	}
});
$(".imgResize2").each(function(i){
	var imgObj = $(this).children("img").get(0);
	var width = $(this).css("width").replace("px","");
	var height = $(this).css("height").replace("px","");
	if (!width && $(imgObj).attr("title")) {
		var midNum = $(imgObj).attr("title").indexOf("*");
		width = $(imgObj).attr("title").substr(0,midNum); 
		height = $(imgObj).attr("title").substr(midNum+1);
	}
	if(imgObj.complete || imgObj.readyState =="complete") { DrawImage2(imgObj,width,height);}
	else {
		imgObj.onreadystatechange = function(){ 
			if(imgObj.readyState =="complete") { DrawImage2(imgObj,width,height); }
		} 
	}
});
	//目录点击展开#category
	function showHideMenu(jObj) { //jObj:list1
		var catStatus = jObj.children("a.aNext").children("div").attr("class");
		if (catStatus=="catNextOpen"){
			jObj.children("a.aNext").children("div").attr("class","catNextClose");
			jObj.css("background-color","#F8F8F8");
			jObj.siblings(".list2").slideUp();
		} else {
			jObj.children("a.aNext").children("div").attr("class","catNextOpen");
			jObj.css("background-color","#EEE");
			jObj.siblings(".list2").slideDown();
		}
	}
	$(".list1 a.aNext").click(function(){
		showHideMenu($(this).parent(".list1"));
		return false;
	});
	$(".list1 a.showNext").click(function(){
		showHideMenu($(this).parent(".list1"));
		return false;
	});
	$(".list2 a").click(function(){
		$(this).parent(".list2").addClass("listOn");
		$(this).parent(".list2").siblings(".list2").removeClass("listOn");
	});
	//默认关闭的子目录[-]
	$(".catNextClose").each(function(){
		$(this).parents(".list1").siblings(".list2").hide();
		$(this).parents(".list1").css("background-color","#F8F8F8");
	});
	$(".catNextOpen").each(function(){
		$(this).parents(".list1").css("background-color","#EEE");
	});


//邀请好友
$("a.yaoqingClick").click(function(){
	$($(".yaoqingClickHandle").html()).dialog({bgiframe:true, width:300, height:'auto', modal:true,
		title: '邀请朋友加入',
		buttons: {
			'发送邀请': function (){
				var theForm = $(this);//alert(theForm.html());
				if (!theForm.find("input[name='mEmail']").val().isEmail()) {
					alert("请正确填写Email地址");
				} else if (!theForm.find("input[name='mFromName']").val()) {
					alert("请填写您的称呼");
				} else {
					var args = "mEmail="+ encodeURIComponent(theForm.find("input[name='mEmail']").val()) +"&mToName="+ encodeURIComponent(theForm.find("input[name='mToName']").val()) +"&mMsg="+ encodeURIComponent(theForm.find("input[name='mMsg']").val()) +"&mFromName="+ encodeURIComponent(theForm.find("input[name='mFromName']").val()) +"";
					theForm.html("<br /><br /><center><img src='/images/loading.gif' alt='' /></center>");
					$.post("/members/yaoqing.asp", args,
					function (data){
						//theForm.html(data);
						theForm.dialog('close');
						if (data) $("<div>"+data+"</div>").dialog({bgiframe:true, title:"发送成功", buttons:{"确认":function(){$(this).dialog("close");}}});
					});
				}
			},
			'取消': function(){ $(this).dialog('close');}
		},
		open: function(){ $(this).dialog('moveToTop'); },
		close: function(){ $(this).dialog('destroy');}
	});
	return false;
});

//栏目收起
if ($(".win_head .close a")) {
	$(".win_head .close a").toggle(function(){
		$(this).parent().css("background","url(../images/icn_doShow.gif) no-repeat center").parents(".win_head").siblings(".win_body").hide();
	},function(){
		$(this).parent().css("background","url(../images/icn_doHide.gif) no-repeat center").parents(".win_head").siblings(".win_body").show();
	});
}

//表格鼠标效果
$("table.tableTrOn tr").not(".head").mouseover(function(){
	$(this).css({'background':'#F7FFE8'});
}).mouseout(function(){
	$(this).css({'background':'none'});
});


//jQuey End

