/*
 * json格式：
 * 其中每个 '{}' 内表示一张图片的路径。
 * 
 * [{
 * 	imgPath: "../images/xx/xx1.jpg"
 * },{
 * 	imgPath: "../images/xx/xx2.jpg"
 * },{
 * 	imgPath: "../images/xx/xx3.jpg"
 * }]
 * 
 * 
 */
var counter = 0; //计数器
var picJSON;
var total = 0; //图片的总数

//读取JSON
function readerJSON(jsonUrl){
    var xmlHttp;
    
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if (XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
    xmlHttp.open("GET", jsonUrl, false);
    xmlHttp.send(null);
    
    return eval(xmlHttp.responseText.toString());
}

/*
 * 显示图片
 * iCount = 0 时，显示当前图片
 * iCount = -1 时，显示前一张图片
 * iCount = 1 时，显示下一张图片
 */
function showImg(iCount){
	
	counter += iCount;

	if(counter < 0)
		counter = total + counter;
	if(counter > total-1)
		counter = counter - total;
		
	var src = picJSON[counter].imgPath;
	var oImg = document.getElementById("imgShow");
    document.getElementById("showImage").href=picJSON[counter].imgPath_Big;
	document.getElementById("showImage").title=picJSON[counter].imgTitle;
    oImg.src = src;
    oImg.width = 235;
    oImg.height = 157;
    document.getElementById("recorderImg").innerHTML = (counter + 1) + "/" + total;		//显示效果:'1/5'
}

//初始化
function initShowImg(jsonUrl){
	
	picJSON = readerJSON(jsonUrl);
	total = picJSON.length; 
	showImg(0);
}
           