//*********************************************************************************************
// DEFINICJE

/*var buttons = new Array();
buttons[0] = "trasy";
buttons[1] = "cennik";
buttons[2] = "omnie";
buttons[3] = "kontakt";
buttons[4] = "aktualnosci";*/

var num_of_products = new Number;
var selected_th = new Number;
var img_src = html_src;
selected_th = 1;
var x = new Array();				// trzyma w sobie odnosniki do przyciskow


//*********************************************************************************************
//INICJALIZACJA

num_of_products = html_il_produktow;		//musi to byc w html podane


y =  document.getElementById("img_big");
y.src = 'images/products/'+ img_src + '/img_' + selected_th + '.jpg';
select_thumb();

for (var i=1;i<=num_of_products;i++) {			// przejscie przez miniaturki i przypisanie im funkcji	
	x["img_" +i] = document.getElementById("img_" +i);
	x["img_" +i].my_id = i;	
	x["img_" +i].onmouseover = function(){ 
		this.src = 'images/numbers/sell_' + this.my_id + '.jpg';
	}
	x["img_" +i].onmouseout = function(){ 		
			this.src = 'images/numbers/num_' + this.my_id  + '.jpg';	
			select_thumb();
	}	
	x["img_" +i].onclick = function() {		
		selected_th = this.my_id;
		y.src = 'images/products/'+ img_src + '/img_' + selected_th + '.jpg';		
		select_thumb();
	}
	
}




document.getElementById("next_img").onmouseover = function(){ this.src = 'images/next_on.gif';}
document.getElementById("next_img").onmouseout = function(){ this.src = 'images/next_off.gif';}
document.getElementById("prev_img").onmouseover = function(){ this.src = 'images/prev_on.gif';}
document.getElementById("prev_img").onmouseout = function(){ this.src = 'images/prev_off.gif';}

//*********************************************************************************************
// FUNKCJE

document.getElementById("next").onclick = function() {
	if (selected_th < num_of_products) {
		selected_th++;		
	}
	else {
		selected_th = 1;
	}
	y.src = 'images/products/'+ img_src + '/img_' + selected_th + '.jpg';
	select_thumb();
}
//------------------------------------------------------------

document.getElementById("prev").onclick = function() {	
	if (selected_th > 1) {
		selected_th--;		
	}
	else {
		selected_th = num_of_products;
	}
	y.src = 'images/products/'+ img_src + '/img_' + selected_th + '.jpg';
	select_thumb() ;
}
//------------------------------------------------------------

function select_thumb() {					// odznacza wszystkie i zaznacza tylko ten ktory ma numer  selected_th	
	for (var i=1;i<=num_of_products;i++){
		document.getElementById("img_" +i).src = 'images/numbers/num_' + i + '.jpg';
	}	
	document.getElementById("img_" + selected_th).src = 'images/numbers/sell_' + selected_th + '.jpg';
	
}
//------------------------------------------------------------

//*********************************************************************************************
		
	
