var width = 450;
var height = 230;
var imgAr1 = new Array();
var rImg1 = new Array();

var slide;
var btn_click=0;
var hpicPos=new Array();
hpicPos[0]="";
hpicPos[1]="hpos1";
hpicPos[2]="hpos2";
hpicPos[3]="hpos3";
hpicPos[4]="hpos4";


function photoSetting()
{
	for(var j = 0; j < imgAr1.length; j++)
	{
		rImg1[j] = new Image();
		imgAr1[j] = site_root+imgAr1[j];
        rImg1[j].src = imgAr1[j];
	}

	slide = document.getElementById('pic');
	slide.src = imgAr1[0];
	setTimeout("nextpslide()",2000);
}

var picture = 0;

function nextpslide()
{
	if(btn_click!=1){
	if(picture >= imgAr1.length-1) picture = -1;
		picture=picture+1;
		$('crtPh').innerHTML = picture+1;
		Effect.Fade('pic', { duration: 0.3,to:0.2,afterFinishInternal:function(){Effect.Appear('pic', { duration: 0.3,from:0.2,to:1});slide.src = imgAr1[picture]} });
		//Effect.Fade('pic');
		updatePos(picture+1);	
		setTimeout("nextpslide()", 3000);
	}	
}

function nextp(){
	
	btn_click =1;
	if(picture < imgAr1.length-1){
		picture=picture+1;
	}else{
		picture=0;
	}
	
		$('crtPh').innerHTML = picture+1;
		Effect.Fade('pic', { duration: 0.3,to:0.2,afterFinishInternal:function(){Effect.Appear('pic', { duration: 0.3,from:0.2,to:1});slide.src = imgAr1[picture]} });
	
}


function prev(){
	btn_click =1;
	if(picture > 0 ){
		picture=picture-1;
	}else{
		picture=imgAr1.length-1;
	}
	
		$('crtPh').innerHTML = picture+1;
		Effect.Fade('pic', { duration: 0.3,to:0.2,afterFinishInternal:function(){Effect.Appear('pic', { duration: 0.3,from:0.2,to:1 });slide.src = imgAr1[picture]} });
		//Effect.Fade("phCont",{speed:50});return false;		
}

function goToSlide(pos){
	btn_click =1;
	picture=pos;
	$('crtPh').innerHTML = picture;
	Effect.Fade('pic', { duration: 0.3,to:0.2,afterFinishInternal:function(){Effect.Appear('pic', { duration: 0.3,from:0.2,to:1});slide.src = imgAr1[picture]} });
    updatePos(pos+1);
}

function start(){
		slide.src = imgAr1[0];
		picture = 0;
}

function end(){
		slide.src = imgAr1[imgAr1.length-1];
		picture = imgAr1.length-1
}

function updatePos(pic)
{
	for(i=1;i<=4;i++){
		x = document.getElementById(hpicPos[i]);
		if(i==pic){
			x.className = 'hslide_on';	
		}else{
			x.className = 'hslide';
		}
	}
}
