

//学部TOP
function getHeadLineByUpsite(upsite) {
	// データを取得
	// upsite 1:名芸総合 2:音楽学部 3:美術学部 4:デザイン学部 5:人間発達学部 6:大学院
	var param = {
		upsite: upsite
	};
	tools.getHeadLineByUpsite(
		param,
		function(_xml) {
			$(_xml).find('contents').each(function(){
				$(this).find('data').each(function(){
					// [日付]
					var sdate = $(this).find('date').text();
					// [リンク先]
					var link_url = $(this).find('link_url').text();
					// [表示文字列]
					var link_str = $(this).find('link_str').text();
					// [画像ID]
					var photo_id = $(this).find('photo_id').text();

					//タグの設定
					//名芸総合      class = "red"
					//音楽学部      class = "purple"
					//芸術学部      class = "green"
					//デザイン学部　class = "yellow"
					//人間発達学部　class = "blue"
					//大学院        class = "brown"

					//画像が設定されてない場合は表示しない。
					if( photo_id != 0){
						var clas="";
						if(upsite==1){
							clas= "red";
						}else if(upsite==2){
							clas= "purple";
						}else if(upsite==3){
							clas= "green";
						}else if(upsite==4){
							clas= "yellow";
						}else if(upsite==5){
							clas= "blue";
						}else{
							clas= "brown";
						}

						var tag = "";
						tag = tag + "<dl><dt>";
						tag = tag + '<img src="/services/tools/api/report/get-image/photo_id/'+photo_id+'" alt="'+link_url+'">';
						tag = tag + "</dt><dd>";
						tag = tag + '<p class="'+clas+'">'+sdate+'</p>';
						tag = tag + '<p class="txt">'+link_str+'</p>';
						tag = tag + "</dd></dl>";
						$("#list").append(tag);
					}
				});


			});

			//////////////////////////////////////////////////////////////////
			// 動作処理
			//////////////////////////////////////////////////////////////////

			//記事数
			var list_count = $("#list").find("dl").length;
			//記事オブジェクト幅
			var list_width = 100;

			$("#list").css({ width: list_count * list_width+5 });



			//記事のマウスオーバー、アウトのアクション
			$("#list dl").hover(
			function () {
				$(this).css("cursor", "pointer");
				$(this).css("color","#333333");

				$(this).css("background-color","#FAFAFA");
				$(this).css("border-color","#999999");
			},
			function () {
				$(this).css("cursor", "default");
				$(this).css("color","#666666");
				$(this).css("background-color","#FFFFFF");
				$(this).css("border-color","#FFFFFF");
			}
			);
			//記事をクリックのアクション
			$("#list dl").click(function () {
				window.location = $(this).find("img").attr("alt");
			});


			//スクロール位置
			var pos_x = $("#list").position().left;

			//右に移動できる数
			var r_count = 0;
			//左に移動できる数
			var l_count = 0;

			$("#b_lmove").fadeTo(0,0.2);
			$("#b_rmove").fadeTo(0,0.2);

			if( 6 < list_count ){
				r_count = list_count-6;
				$("#b_rmove").css("cursor", "pointer");
				$("#b_rmove").fadeTo(0,1);
			}


			function r_check(){
				if( 0 >= r_count ){
					$("#b_rmove").css("cursor", "default");
					$("#b_rmove").fadeTo(150,0.2);
				}else{
					$("#b_rmove").css("cursor", "pointer");
					$("#b_rmove").fadeTo(500,1);
				}
			}
			function l_check(){
				if( 0 >= l_count ){
					$("#b_lmove").css("cursor", "default");
					$("#b_lmove").fadeTo(150,0.2);
				}else{
					$("#b_lmove").css("cursor", "pointer");
					$("#b_lmove").fadeTo(500,1);
				}
			}


			//ボタン連打禁止フラグ
			var btn_active = true;

			//右移動ボタン
			$("#b_rmove").click(function () {
			if( 0 < r_count && btn_active ){
				btn_active = false;
				$("#list").animate({ left: pos_x - list_width-10 }, 500, function () {
					pos_x = $("#list").position().left;
					r_count = r_count-1;
					l_count = l_count+1;
					r_check();
					l_check();
					btn_active = true;
				});
			}
			});
			//左移動ボタン
			$("#b_lmove").click(function () {
			if( 0 < l_count && btn_active ){
				btn_active = false;
				$("#list").animate({ left: pos_x + list_width-10 }, 500 , function () {
					pos_x = $("#list").position().left;
					r_count = r_count+1;
					l_count = l_count-1;
					l_check();
					r_check();
					btn_active = true;
				});
			}
			});

		}
	);
}

