/*
display: block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;
 * */
jQuery(function(){
	var limgpath="/Portal/images/floatImg_left.jpg";
	var rimgpath="/Portal/images/floatImg_right.jpg";
	//$.floatDiv("百度","http://www.baidu.com");
	//jQuery.floatDiv("google","http://www.google.com");
	try {
	//显示首页浮动
	var url="/Portal/portal/resources/resources_manage.htm?getResources";
	jQuery.post(url,{"type":"10013","webId":"0001"},function(data){
		var json = eval(data);
		if(json.length==1){
			if(json[0].imgUrl){
				rimgpath="/Portal/"+json[0].imgUrl;
			}
			$.floatDiv(json[0].name,json[0].url,limgpath,rimgpath);
		} 
		else
		return;
	})
	//获取首页样式
	var url = "/Portal/indexStyleOfMaster.htm";
	jQuery.post(url,function(data){
		var json = eval("["+data+"]");
		var style = json[0].thisWebsite;
		
		var nowStyle = jQuery('link:eq(0)').attr('href');
		if(nowStyle.indexOf('css')!=-1) {
			nowStyle = nowStyle.substring(0,nowStyle.indexOf('css')+4)+style+nowStyle.substring(nowStyle.indexOf('css')+3);
		}
		//jQuery('link:eq(0)').attr('href',nowStyle);
		//jQuery("body").show();
	});
	
	//获取首页导航菜单
	var url="/Portal/portal/section/section_manage.htm?indexSectionTitle";
	jQuery.post(url,function(data){
		var newsHtml = "";
		var json= eval("["+data+"]");
		json = eval(json[0].newsJson);
		for(var i=0; i<json.length; i++) {
			if(i>9) break;
			newsHtml = "";
			stylestr = "";
			if(json[i].name=='专题导航1'){
				stylestr="style='color:#fa8b53;'"
			}
			newsHtml += "<li class='liaClass' lid="+json[i].id+">";
			newsHtml += "<a hidefocus='true' "+stylestr+"  target='_blank' href='"+json[i].url+"'>"+json[i].name+"</a>";
			newsHtml += "</li>";
			jQuery('.indexSectionTitle').append(newsHtml);
		}
		
		json= eval("["+data+"]");
		json = eval(json[0].childJson);
		jQuery('.liaClass').hover(function(e){
			var countChar = 0;
			var jsonLength=json.length;
			var parentId = jQuery(this).attr('lid');
			var tempHtml = "";
			var limit = 0;
			for(var i=0; i<json.length; i++) {
				if(json[i].parentId==parentId) {
					if(limit<8) {
						countChar += json[i].name.length;
						if(json[i].url!=null && json[i].url.length>0) {
							tempHtml += "<li><a target='_blank' href='"+json[i].url+"'>"+json[i].name+"</a></li>"
						} else if(json[i].haveContent=='1') {
							tempHtml += "<li><a target='_blank' href='/Portal/portal/section/section_manage.htm?showSectionContent&id="+json[i].id+"'>"+json[i].name+"</a></li>";
						} else {
							tempHtml += "<li><a target='_blank' href='/Portal/portal/news/news_manage.htm?p=newsBySectionId&id="+json[i].id+"'>"+json[i].name+"</a></li>"
						}
					}
					limit++;
				}
			}
			jQuery('.section2ndUl').html(tempHtml);
			if(typeof jQuery('.new_nav2 ul li:first')[0] == 'undefined')
				return;
			jQuery('.new_nav2 ul').css('padding-left','');
			jQuery('.new_nav2 ul').css('width','auto');
			var left = getAbsLeft(jQuery(this)[0]);
			var liFirst = getAbsLeft(jQuery('.new_nav2 ul li:first')[0]);
			//var doc = jQuery(document.body).width();
			var doc = jQuery('#main').css('width');
			doc = doc.replace('px','');
			var liWidth = doc-liFirst*2+20;
			jQuery('.new_nav2 ul').css('width',liWidth);
			var tempPadding = left-liWidth/2;
			if(tempPadding<0)
				tempPadding=20;
			else if(tempPadding+liWidth>doc)
				tempPadding = doc - liWidth - 30;
			jQuery('.new_nav2 ul').css('padding-left',tempPadding);
		});
	});
	
	//生成首页学院新闻
	var url="/Portal/portal/news/news_manage.htm?kanameNews";
	jQuery.post(url,function(data){
		var newsHtml = "";
		var json= eval("["+data+"]");
		json = eval(json[0].newsJson);
		var limit = json.length;
		if(limit>12)
			limit=12;
		for(var i=0; i<limit; i++) {
			newsHtml += "<li style='width:97%;'>";
			var name = json[i].name;
			newsHtml += "<span>"+json[i].addTime+"&nbsp;</span>";
			var top = "";
			var newImg = "";
			var a_width = "300px";
			if(json[i].top=='true') {
				top="<img style='display:block;float:left;padding-left:5px;padding-top:0px;' src='images/topImg.gif' width='25px' height='28px' />";
			}
			if(json[i].isnew=='true') {
				a_width='280px';
				newImg="<img style='display:block;float:left;padding-left:2px;padding-top:10px;' src='images/new.gif' width='25px' height='9px' />";
			}
			if(json[i].isnew=='true' && json[i].top=='true')
				a_width='260px';
			if(json[i].name.length>18 && json[i].hot=='true' && json[i].top=='true') {
				json[i].name = json[i].name.substring(0,18)+"...";
			} else if(json[i].name.length>20 && (json[i].hot=='true' || json[i].top=='true')) {
				json[i].name = json[i].name.substring(0,18)+"...";
			} else if(json[i].name.length>20) {
				json[i].name = json[i].name.substring(0,20)+"...";
			}
			if(top.length==0){
				newsHtml += top+"<a style=display:block;float:left;' target='_blank' cursor='pointer' title='"+name+"' href='/Portal/portal/news/news_manage.htm?showNewDetails&id="+json[i].id+"'>"+json[i].name+"</a>"+newImg;
			}else{
				newsHtml += top+"<a style='text-indent:0' style=display:block;float:left;' target='_blank' cursor='pointer' title='"+name+"' href='/Portal/portal/news/news_manage.htm?showNewDetails&id="+json[i].id+"'>"+json[i].name+"</a>"+newImg;
			}
			newsHtml += "</li>";
		}
		jQuery('.index_news_div').html(newsHtml);
	});
	
	
	var noticeId = "";
	var	adviceId = "";
	//生成首页公告和通知
	var url="/Portal/portal/news/news_manage.htm?indexNotice";
	jQuery.post(url,function(data){
		var json = eval("["+data+"]");
		json = eval(json[0].sectionJson3);
		noticeId = json[0].notice;
		adviceId = json[0].advice;
		jQuery('.notice').append(json[0].noticeName);
		jQuery('.active').append(json[0].adviceName)
		var newsHtml = "";
		json= eval("["+data+"]");
		json = eval(json[0].newsJson);
		if(typeof json != 'undefined') {
			for(var i=0; i<json.length; i++) {
				newsHtml = "";
				newsHtml += "<li style='width:320px;float:left;'>";
				var name = json[i].name;
				var newImg="";
				newsHtml += "<span style='float:right;display:block;'>"+json[i].addTime+"&nbsp;</span><b style='float:left;display:block;'>&gt;&gt;&nbsp;</b>";
				if(json[i].isnew=='true') {
					newImg="<img style='float:left;display:block;padding-top:7px;' src='images/new.gif' width='25px' height='9px' />";
				} 
				if(json[i].isnew=='true' && json[i].name.length>13){
					json[i].name = json[i].name.substring(0,13)+"...";
				} else if(json[i].name.length>17) {
					json[i].name = json[i].name.substring(0,17)+"...";
				}
				newsHtml += "<a style='float:left;display:block;' target='_blank' href='/Portal/portal/news/news_manage.htm?showNewDetails&id="+json[i].id+"' title='"+name+"'>"+json[i].name+"</a>"+newImg;
				newsHtml += "</li>";
				jQuery('.index_notice_div').append(newsHtml);
			}
		}
		
		var newsHtml = "";
		json= eval("["+data+"]");
		json = eval(json[0].newsJson2);
		if(typeof json != 'undefined') {
			for(var i=0; i<json.length; i++) {
				newsHtml = "";
				newsHtml += "<li style='width:320px;float:left;'>";
				var name = json[i].name;
				newsHtml += "<span style='float:right;display:block;'>"+json[i].addTime+"&nbsp;</span><b style='float:left;display:block;'>&gt;&gt;&nbsp;</b>";
				var newImg = "";
				if(json[i].isnew=='true') {
					newImg="<img style='float:left;display:block;padding-top:7px;' src='images/new.gif' width='25px' height='9px' />";
				}
				if(json[i].isnew=='true' && json[i].name.length>13){
					json[i].name = json[i].name.substring(0,13)+"...";
				} else if(json[i].name.length>17) {
					json[i].name = json[i].name.substring(0,17)+"...";
				}
				newsHtml += "<a style='float:left;display:block;' target='_blank' href='/Portal/portal/news/news_manage.htm?showNewDetails&id="+json[i].id+"' title='"+name+"'>"+json[i].name+"</a>"+newImg;
				newsHtml += "</li>";
				jQuery('.index_advice_div').append(newsHtml);
			}
		}
		jQuery('#notive_a').attr('href','/Portal/portal/news/news_manage.htm?p=newsBySectionId&id='+adviceId);
	});
	
	 $('#jp_hl_tab li').click(function(){
        $('#jp_hl_tab li').removeClass('active');
        $(this).addClass('active');
        $('div.jp_hl_tabs').hide();
        $('#tabs-' + $('#jp_hl_tab li').index(this)).show();
        if($('#jp_hl_tab li').index(this)=='0') {
        	jQuery('#notive_a').attr('href','/Portal/portal/news/news_manage.htm?p=newsBySectionId&id='+adviceId);
        } else {
        	jQuery('#notive_a').attr('href','/Portal/portal/news/news_manage.htm?p=newsBySectionId&id='+noticeId);
        }
    });
	
	//生成首页专题新闻
	var url="/Portal/portal/section/section_manage.htm?indexWEM";
	jQuery.post(url,function(data){
		var newsHtml = "";
		var json= eval("["+data+"]");
		json = eval(json[0].newsJson);
		for(var i=0; i<json.length; i++) {
			newsHtml = "";
			newsHtml += "<li>";
			if(json[i].url!=null) {
				newsHtml += "<a target='_blank' href='"+json[i].url+"'>";
			} else {
				newsHtml += "<a target='_blank' href='/Portal/portal/news/news_manage.htm?p=newsBySectionId&id="+json[i].id+"'>";
			}
			newsHtml += "<img border='0' width='187px' height='51px' src='"+json[i].imgPath+"' />";
			newsHtml += "</a></li>";
			jQuery('.index_image_div').append(newsHtml);
		}
	});
	
	//生成图片新闻
	var url="/Portal/portal/news/news_manage.htm?indexImageNews";
	jQuery.post(url,function(data){
		var newsHtml = "";
		var FocusPic_01 = new FocusPic("BigPic", "SmallPics", "TitleBox", "Discription");
		FocusPic_01.type = 1;
		var json= eval("["+data+"]");
		json = eval(json[0].newsJson);
		var limit = json.length;
		if(limit>5)limit=5;
		for(var i=0; i<limit; i++) {
			newsHtml = "";
			FocusPic_01.Add(json[i].imgPath, '', '/Portal/portal/news/news_manage.htm?showNewDetails&id='+json[i].id, '');
			jQuery('.picNews_a').append(newsHtml);
		}
        FocusPic_01.begin();
	});
	
	//系部链接
	jQuery.post("/Portal/portal/resources/resources_manage.htm?getResources",{"type":"10006","webId":"0001"},function(data){
		var resHtml_1 = "";
		var resHtml_2 = "";
		var json= eval(data);
		for(var i=0; i<json.length; i++) {
			if(i<14){
					resHtml_1 +="<a target='_blank' href='"+json[i].url+"'>"+json[i].name+"</a>";
				}
				else{
					resHtml_2 +="<a target='_blank' href='"+json[i].url+"'>"+json[i].name+"</a>";
				}
		}
		jQuery('.departmentUrl_1').append(resHtml_1);
		jQuery('.departmentUrl_2').append(resHtml_2);
	});
	
	//资源链接
	jQuery.post("/Portal/portal/resources/resources_manage.htm?getResources",{"type":"20008","webId":"0001"},function(data){
		var resHtml = "";
		var json= eval(data);
		for(var i=0; i<json.length; i++) {
			resHtml +="<a style='float:left' target='_blank' href='"+json[i].url+"'>"+json[i].name+"</a>";
		}
		jQuery('.resUrl').append(resHtml);
	});
	
	//快速通道
	jQuery.post("/Portal/portal/resources/resources_manage.htm?getResources",{"type":"10015","webId":"0001"},function(data){
		var resHtml = "<dt>快速通道</dt>";
		var json= eval(data);
		for(var i=0; i<json.length; i++) {
			if(i>6) break;
			resHtml +="<dd><a target='_blank' href='"+json[i].url+"'><img style='width:181px;height:45px;' src='"+json[i].imgUrl+"' alt='"+json[i].name+"' /></a></dd>";
		}
		jQuery('.fast_track').append(resHtml);
	});
	
	jQuery.post("/Portal/portal/website/getSite.htm",{"siteId":"0001"},function(data){
		var json = eval("("+data+")");
		var bgimgsrc = json.website.bgimgsrc;
		var isSlide=json.website.isSlide;
		if(bgimgsrc){
			jQuery(document.body).css("background-image","url(/Portal/"+bgimgsrc+")");
			if(isSlide==1){
				$("#space").show();
				$("#space").animate({"height":"160px"},1500);
				$("#close").show();
				$("#main").css("background","#fff")
			}
		}
	})
	
	}catch(e) {
	}
});
