var follow = 0;
var pivot = 0;
var sum = 0;
var org = 0;
function scrollTop_Boutique(total){
	sum = total;
    follow--;

    if(follow < 0) follow = 0;
	animBoutiqueVertical();
	}

function scrollBottom_Boutique(total){
	follow++;
	if(follow > total - 5) follow = total - 5;
	animBoutiqueVertical();
	}
	
	
	
function scrollLeft_Boutique(total){
	pivot--;
	sum = total;
	if(pivot < 0) pivot = 0;
	goto(pivot);
	}

function scrollRight_Boutique(total){
	pivot++;
	sum = total;
	if(pivot > total - 1) pivot = total - 1;
	goto(pivot);
	}	
	
	
	

function animBoutiqueVertical(){
	updateVerArrows();
	var H = 87;
	var gap = 5;
	var target = 0 +follow*(H + gap);
	$("#list").animate({scrollTop: target}, 200);
	}

var currentBoutique = 0;
function directBoutique(s){
	
	goto(s);
}

function switcher(s){
	$("#itm"+currentBoutique).attr("class", "itm_action");
	$("#surr"+currentBoutique).attr("class", "outer_action");
	
	$("#itm"+s).attr("class", "itm_action_click");
	$("#surr"+s).attr("class", "outer_action_click");
	
	currentBoutique = s;
}

function itmRollover(s){
	if(s != currentBoutique)
	$("#itm"+s).attr("class", "itm_action_over");
}

function itmRollout(s){
	if(s != currentBoutique)
	$("#itm"+s).attr("class", "itm_action");
}


function goto(s){
	switcher(s);
	
	var H = 500;
	var gap = 10;
	var target = 0 +s*(H + gap);
	pivot = s;
	$("#listBoutique").animate({scrollLeft: target}, 400);
	//$("#output").text(pivot+" " + follow);
	updateHorArrows();
	checker(s);
}

function checker(p){

    var pt= p;
	if(pt - follow > 4){
	follow++;
	animBoutiqueVertical();
	}
	
	if(pt - follow < 0){
	follow--;
	animBoutiqueVertical();
	}
	
	
	
	//$("#output").text(pt+"  " + follow);
	//if(follow < 0) follow = 0;
	//if(follow > total - 5) follow = total - 5;
	//animBoutiqueVertical();
	
}

function updateVerArrows(){
	
	$("#bottomenabled").css("display", "block");
	$("#bottomdisabled").css("display", "none");
	
	$("#topenabled").css("display", "block");
	$("#topdisabled").css("display", "none");
	
	
	if(follow == sum - 5 ){
	$("#bottomenabled").css("display", "none");
	$("#bottomdisabled").css("display", "block");
	}
	
	if(follow == 0 ){
	$("#topenabled").css("display", "none");
	$("#topdisabled").css("display", "block");
	}
	
	//$("#output").text( sum + ">>>>>" + follow);
	
}

function updateHorArrows(){
//$("#output").text( sum + ">>>>>" + pivot);
	$("#rightenabled").css("display", "block");
	$("#rightdisabled").css("display", "none");
	
	$("#leftenabled").css("display", "block");
	$("#leftdisabled").css("display", "none");
	
	
	if(pivot == sum -1 ){
	$("#rightenabled").css("display", "none");
	$("#rightdisabled").css("display", "block");
	}
	
	if(pivot == 0 ){
	$("#leftenabled").css("display", "none");
	$("#leftdisabled").css("display", "block");
	}
	
	
}

function rollout_Bottom(){ 	                         $("#bottomImg").attr("src", "img/bottom_arrow_00ff00.jpg"); }
function rollover_Bottom(){ 	                     $("#bottomImg").attr("src", "img/bottom_arrow_cccccc.jpg"); }
function rollclick_Bottom( total){ sum = total; 	$("#bottomImg").attr("src", "img/bottom_arrow_333333.jpg");}


function rollout_Top(){ 	                         $("#topImg").attr("src", "img/top_arrow_00ff00.jpg"); }
function rollover_Top(){ 	                     $("#topImg").attr("src", "img/top_arrow_cccccc.jpg"); }
function rollclick_Top( total){ sum = total; 	$("#topImg").attr("src", "img/top_arrow_333333.jpg");}




function rollout_Left(){ 	                     $("#leftImg").attr("src", "img/left00ff00.png"); }
function rollover_Left(){ 	                     $("#leftImg").attr("src", "img/leftcccccc.png"); }
function rollclick_Left( total){ sum = total; 	 $("#leftImg").attr("src", "img/left333333.png");}

function rollout_Right(){ 	                     $("#rightImg").attr("src", "img/right00ff00.png"); }
function rollover_Right(){ 	                     $("#rightImg").attr("src", "img/rightcccccc.png"); }
function rollclick_Right(total){ sum = total; 	 $("#rightImg").attr("src", "img/right333333.png");}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


