$(function(){
var adid=0;
var pic_list=$('#pic_list').text();
if(!pic_list) return false;
var piclist=new Array();
piclist=pic_list.split('|'); 
var bpic_array=new Array();
var url_array=new Array();
bpic_array=piclist[0].split(','); 
url_array=piclist[1].split(','); 
index_ad2_html='';
var pic_length=bpic_array.length;
if(pic_length>4) pic_length=4;
for(k=0;k<pic_length;k++){
if(k==0){
index_ad2_html+='<img src="'+ bpic_array[k].replace('/upload/','/upload/') +'" alt="'+k+'" id="spic_'+k+'" style="border:2px solid #FFCC00" />';	
}else{index_ad2_html+='<img src="'+ bpic_array[k].replace('/upload/','/upload/') +'" alt="'+k+'" id="spic_'+k+'" style="border:2px solid #FFFFFF" />';}
}
$('#index_ad2').html(index_ad2_html);
$('#index_ad1').html('<img src="'+ bpic_array[0] +'"/>');
setInterval(function(){
adid++;
if(adid>=pic_length) adid=0;



$('#index_ad1 img').fadeOut("slow",function(){
$('#index_ad1 img').attr('src',bpic_array[adid]);
$('#index_ad1 img').fadeIn("fast");	
 });



$('#index_ad2 img').css({ border: "2px solid #FFFFFF"});
$('#spic_'+adid).css({ border: "2px solid #FFCC00"});
},10000);
$('#index_ad1 img').click(function(){window.open(url_array[adid]);})
$('#index_ad2 img').click(function(){
var clickid=$(this).attr('alt');		
$('#index_ad2 img').css({ border: "2px solid #FFFFFF"});
$(this).css({ border: "2px solid #FFCC00"});
$('#index_ad1 img').fadeOut("slow",function(){
$('#index_ad1 img').attr('src',bpic_array[clickid]);
$('#index_ad1 img').fadeIn("fast");										  
											  
											  });	
									   
adid=clickid;							   
})
})
