var j = jQuery.noConflict(); //把$让给第一个实现它的库，用j代替
j(document).ready(function(){

strUrl=location.href.substring(location.href.lastIndexOf("/")+1);//取得URL页面名称    

j("#navbarMain li").each(function(i){
var nav_url=j("#navbarMain li > a").eq(i).attr("href");
if(strUrl===nav_url){                          
j(this).addClass('navItem-on')
.siblings().removeClass('navItem-on');
}                      
});
j("#navbar-notice").click(function () {
j(this).addClass('navItem-on')

if (j("div.navContent").is(":hidden")) {
j("div.navContent").show();

}else { 
j("div.navContent").hide();
}
});

j("div.navContent").hover( function() {},
function() { j("div.navContent").hide();
j("#navbar-notice").removeClass('navItem-on');


}); 

if (j(".noticeList").text()=="" ) { 
j(".noticeList").append("<p>暂时没有新通知<p>");
} else {
j(".noticeList").show();
}	

j('#username').blur(function(){

if (j("div#checkusername").is(".tipsErr")) {
j(this).addClass('textErr');

}else {
j(this).removeClass('textErr');
}

});

j('#password').blur(function(){

if (j("div#checkpassword").is(".tipsErr")) {
j(this).addClass('textErr');

}else {
j(this).removeClass('textErr');
}

});

j('#name').blur(function(){

if (j("div#checkName").is(".tipsErr")) {
j(this).addClass('textErr');

}else {
j(this).removeClass('textErr');
}

});

j('#email').blur(function(){

if (j("div#checkEmail").is(".tipsErr")) {
j(this).addClass('textErr');

}else {
j(this).removeClass('textErr');
}

});

j('#seccode').blur(function(){

if (j("div#checkseccode").is(".tipsErr")) {
j(this).addClass('textErr');

}else {
j(this).removeClass('textErr');
}

});

j(".regCheckBox > a").click(function () {

if (j("#regTxt").is(":hidden")) {
j("#regTxt").show();

}else { 
j("#regTxt").hide("");
}

});

//code to hide topic selection, disable for demo
var regCheck = j("#regCheck");
// newsletter topics are optional, hide at first
var inital = regCheck.is(":checked");
var topics = j("#newsletter_topics")[inital ? "removeClass" : "addClass"]("but-large-disabled");
var topicInputs = topics.find("input").attr("disabled", !inital);
// show when newsletter is checked
regCheck.click(function() {
topics[this.checked ? "removeClass" : "addClass"]("but-large-disabled");
topicInputs.attr("disabled", !this.checked);
});

j("#registersubmit").click(function () {

if (j("#msnRegInfo").is(":hidden")) {
j("#msnRegInfo").show();

}

});

j("#studentWrap1").click(function () {
j("#studentWrap").show();
j("#jobWrap").hide();
j("#otherWrap").hide();
if (j("#oldtbody").is(":hidden")) {
j("#oldtbody").show();

}else { 
j("#oldtbody").show("");
j("#jobWrap").hide();
}
});

j("#jobWrap1").click(function () {
j("#studentWrap").show();
j("#oldtbody").hide();
j("#otherWrap").hide();
j("#jobWrap").show();
});

j("#otherWrap1").click(function () {
j("#studentWrap").show();
j("#otherWrap").show();
j("#oldtbody").hide();
j("#jobWrap").hide();
});
j.ajaxSetup ({
cache: false //关闭AJAX相应的缓存
});
j("#pageHdWeather").load("source/weather.php");

var now = new Date(),hour = now.getHours()
if (hour < 6){
j("#dns").addClass('night-lc');
} 
else if (hour < 9){
j("#dns").addClass('day-am');
} 
else if (hour < 12){
j("#dns").addClass('day-sw');
} 
else if (hour < 14){
j("#dns").addClass('day-zw');
} 
else if (hour < 17){
j("#dns").addClass('day-pm');
} 
else if (hour < 19){
j("#dns").addClass('night-bw');
} 
else if (hour < 22){
j("#dns").addClass('night-yw');
} 
else {
j("#dns").addClass('night-sy');
};

j(".mcAvatar").mouseover(function(){ 
		 j("#homeUploadAvatar").show();
		 
}).mouseout(function(){ 
		 j("#homeUploadAvatar").hide();
		
});

j("#share").click(function(){ 
	     j(".mcLayer").animate({ top: "0px"});
		 j(".mcAttach-share").show();
		 j(".mcAttach-photo").hide();
		 j(".mcAttach-vote").hide();
});
j("#album").click(function(){ 
		 j(".mcLayer").animate({ top: "0px"});
		 j(".mcAttach-share").hide();
		  j(".mcAttach-vote").hide();
		 j(".mcAttach-photo").show();
});
j("#vote").click(function(){ 
		 j(".mcLayer").animate({ top: "0px"});
		 j(".mcAttach-share").hide();
		 j(".mcAttach-photo").hide();
});
j(".mcLayerOpt").click(function () {
         j(".mcLayer").animate({ top: "-100px"});
		 j(".mcAttach-photo").hide();
		 j(".mcAttach-share").hide();
		 j(".mcAttach-vote").hide();

     });

j("#j-appFeedList").click(function () {
	     if (j(".popLayer").is(":hidden")) {
			 j(".popLayer").show("fast");
			 }else { 
				 j(".popLayer").hide("fast");
				 }
     });


j(".optionItem").hover(
  function () {
    j(this).addClass("optionItem-hover");
  },
  function () {
    j(this).removeClass("optionItem-hover");
  });

j("#share_link").click(function(){ 
	 j("#sharegenBox").show();
});

j("#sharesubmit_btn").click(function(){ 
	 j("#sharegenBox").hide();
});

j("#editclass").click(function () {
	     if (j("#bolgHelpBox").is(":hidden")) {
			 j("#bolgHelpBox").show("fast");
			 }else { 
				 j("#bolgHelpBox").hide("fast");
				 }
     });

j("#psmn").click( function () {
   if (j(".popLayer").is(":hidden")) {
			 j(".popLayer").show("fast");
			 }else { 
				 j(".popLayer").hide("fast");
				 }
  });

j(".homeTipClose").click( function () {

	j("#homeTopic").hide("fast");
				
  });

});
