$(document).ready(function(){
		/*mainpage pictures flow */
		var defaultImg="/_templates/DefaultTemplates/DefaultSkins/images/default.gif";
		var pic_num=0;//show pic number
		var pic_width=332;//$("#pic_flow li").width();//length per pic
		//alert(pic_width);
		var pic_totle=$("#pic_flow li").length;//totle of pic numb
		var titles_list=new Array();
		var links_list=new Array();
		var images_list=new Array();
		$.ajax({
		  url: '/jsp/news/picture_news_array.jsp?cid=8&count=6',
		  type:"post",
		  dataType:"json",
		  success: function(data) {
		  	titles_list=data.TITLES;
		  	links_list=data.LINKS;
		  	$("#pic_flow a").each(function(index){
		  		$(this).attr("href",data.LINKS[index]==""?"/":data.LINKS[index]);
		  	});
		  	$("#pic_flow img").each(function(index){
		  		$(this).attr("src",data.IMAGES[index]==""?defaultImg:data.IMAGES[index]);
		  	});
		  	$(".pic_title a").html(titles_list[0]).attr("href",links_list[0]);
		  }
		});
		/*left btn*/
		$("#pic_left_btn").click(function(){
			pic_num=++pic_num>=pic_totle?0:pic_num;
			changeElement();
		});
		/*right btn*/
		$("#pic_right_btn").click(function(){
			pic_num=--pic_num<0?(pic_totle-1):pic_num;
			changeElement();
		});
		 function changeElement(){
		 	$(".pic_title a").html(titles_list[pic_num]);
		 	$(".pic_title a").attr("href",links_list[pic_num]);
 			picsmoveElement("pic_flow",-pic_num*pic_width,0,50);
 		 }
	});

 function picsmoveElement(elementID, final_x, final_y, interval) {
    if (!document.getElementById) return false;
    if (!document.getElementById(elementID)) return false;
    var elem = document.getElementById(elementID);
    if (elem.movement) {
        clearTimeout(elem.movement);
    }
    if (!elem.style.left) {
        elem.style.left = "0px";
    }
    if (!elem.style.top) {
        elem.style.top = "0px";
    }
    var xpos = parseInt(elem.style.left);
    var ypos = parseInt(elem.style.top);
    if (xpos == final_x && ypos == final_y) {
        return true;
    }
    if (xpos < final_x) {
        var dist = Math.ceil((final_x - xpos) / 10);
        xpos = xpos + dist;
    }
    if (xpos > final_x) {
        var dist = Math.ceil((xpos - final_x) / 10);
        xpos = xpos - dist;
    }
    if (ypos < final_y) {
        var dist = Math.ceil((final_y - ypos) / 10);
        ypos = ypos + dist;
    }
    if (ypos > final_y) {
        var dist = Math.ceil((ypos - final_y) / 10);
        ypos = ypos - dist;
    }
    elem.style.left = xpos + "px";
    elem.style.top = ypos + "px";
    var repeat = "picsmoveElement('" + elementID + "'," + final_x + "," + final_y + "," + interval + ")";
    elem.movement = setTimeout(repeat, interval);
	}
