pid = 0;

imgList = el = document.getElementById('slide');
tags_a = el.getElementsByTagName('a');
tags_img = el.getElementsByTagName('img');

if(imgList.length <= 2){
	for(var i = 0;i < 3;i++){
		if(imgList.length <= i){
			tags_a[i].href = '#';
			tags_img[i].style.height = '50px';
			tags_img[i].style.width = '50px';
			tags_img[i].src = 'http://www.mycloz.com/app/webroot/uploads/user_photo/75_75thum_noimage_110.jpg';
		}else{
			tags_a[i].href = imgList[i][0]['url'];
			tags_img[i].src = imgList[i][0]['img'];
			if(i == pid){
				tags_img[i].style.border = '2px solid #ff6600';
			}else{
				tags_img[i].style.border = '1px solid #dddddd';
			}
		}
	}
}else{
	//左画像
	if(0 == pid){
		tp_prev = imgList[imgList.length - 1][0]['url'];
		ti_prev = imgList[imgList.length - 1][0]['img'];
	}else{
		tp_prev = imgList[pid-1][0]['url'];
		ti_prev = imgList[pid-1][0]['img'];
	}
	tags_a[0].href = tp_prev;
	tags_img[0].src = ti_prev;
	tags_img[0].style.border = '1px solid #dddddd';
	//中心画像
	tp_this = imgList[pid][0]['url'];
	ti_this = imgList[pid][0]['img'];
	tags_a[1].href = tp_this;
	tags_img[1].src = ti_this;
	tags_img[1].style.border = '2px solid #ff9900';
	//右画像
	if(imgList.length - 1 == pid){
		tp_next = imgList[0][0]['url'];
		ti_next = imgList[0][0]['img'];
	}else{
		tp_next = imgList[pid+1][0]['url'];
		ti_next = imgList[pid+1][0]['img'];
	}
	tags_a[2].href = tp_next;
	tags_img[2].src = ti_next;
	tags_img[2].style.border = '1px solid #dddddd';
}

if(imgList.length < 3){
	document.getElementById('prevbtn').style.display = 'none';
	document.getElementById('nextbtn').style.display = 'none';
}

function parallelSlide(types){
	if(types == 'right'){
		pid = pid+1;
		if(imgList.length == pid){
			pid = 0;
		}
	}else if(types == 'left'){
		pid = pid-1;
		if(-1 == pid){
			pid = imgList.length - 1;
		}
	}
	//左画像
	if(0 == pid){
		tp_prev = imgList[imgList.length - 1][0]['url'];
		ti_prev = imgList[imgList.length - 1][0]['img'];
		if(17582 == imgList[imgList.length - 1][0]['id']) tags_img[0].style.border = '2px solid #ff9900';
		else tags_img[0].style.border = '1px solid #dddddd';
	}else{
		tp_prev = imgList[pid-1][0]['url'];
		ti_prev = imgList[pid-1][0]['img'];
		if(17582 == imgList[pid-1][0]['id']) tags_img[0].style.border = '2px solid #ff9900';
		else tags_img[0].style.border = '1px solid #dddddd';
	}
	//中心画像
	tp_this = imgList[pid][0]['url'];
	ti_this = imgList[pid][0]['img'];
	if(17582 == imgList[pid][0]['id']) tags_img[1].style.border = '2px solid #ff9900';
	else tags_img[1].style.border = '1px solid #dddddd';
	//右画像
	if(imgList.length - 1 == pid){
		tp_next = imgList[0][0]['url'];
		ti_next = imgList[0][0]['img'];
		if(17582 == imgList[0][0]['id']) tags_img[2].style.border = '2px solid #ff9900';
		else tags_img[2].style.border = '1px solid #dddddd';
	}else{
		tp_next = imgList[pid+1][0]['url'];
		ti_next = imgList[pid+1][0]['img'];
		if(17582 == imgList[pid+1][0]['id']) tags_img[2].style.border = '2px solid #ff9900';
		else tags_img[2].style.border = '1px solid #dddddd';
	}
	tags_a[0].href = tp_prev;
	tags_a[1].href = tp_this;
	tags_a[2].href = tp_next;
	tags_img[0].src = ti_prev;
	tags_img[1].src = ti_this;
	tags_img[2].src = ti_next;
}