// JavaScript Document


		       
MAX_PICTERS=24  <!--max picters to show  in gallery -->
MAX_IMG_VIEW=6 <!--max picters to show in one row-->
<!--don't  touch the code bellow to correct work of the gallery-->
MIN_PICTERS=1 
count=1	
function gallery_load(){
	if (MAX_IMG_VIEW>MAX_PICTERS){MAX_IMG_VIEW=MAX_PICTERS}		
	for (i=1;i<=MAX_IMG_VIEW;i++){
		document.getElementById('gallery').innerHTML+='<img src="images/img_gallery_'+i+'.jpg"  alt="Braided Rugs, Matching Chair Pads & Stair Treads Available"  border="0px" id="main_pic'+i+'" onclick="image_big('+i+')" style="cursor:pointer;margin-right:23px;margin-top:23px;" />';						
	}
}								
function gallery(){	
	if (MAX_IMG_VIEW>MAX_PICTERS){MAX_IMG_VIEW=MAX_PICTERS}	
	document.getElementById('gallery').innerHTML='';
	for (i=count;i<(count+MAX_IMG_VIEW);i++){
		number_of_img=i;
		if (number_of_img>MAX_PICTERS){number_of_img=(i-MAX_PICTERS)}	
		document.getElementById('gallery').innerHTML+='<img src="images/img_gallery_'+number_of_img+'.jpg"  alt="Braided Rugs Popular Braided Rug Gallery Image #'+number_of_img+'."  border="0px" id="main_pic'+number_of_img+'" onclick="image_big('+number_of_img+')" style="cursor:pointer;margin-right:23px; margin-top:23px;"  />';						
	}			
	
}
/*function image_big(numb){					
	for (var i = MIN_PICTERS; i < (MAX_PICTERS+1); i++){
	   if ((document.getElementById('main_pic'+numb).src.indexOf('img_gallery_'+i))!=-1){
		document.getElementById('main').src='images/img_gallery_big_'+i+'.jpg';}				 
	}															
}*/
function left(){						
	count--;
	if (count<(MIN_PICTERS)){count=MAX_PICTERS}					
	gallery();												
}
function right(){	
	count++;
	if (count>MAX_PICTERS){count=MIN_PICTERS}	
	gallery();	
}	



// JavaScrjpt Document
	MAX_PICTERS1=5  <!--max picters to show  in gallery -->
	MAX_IMG_VIEW1=5 <!--max picters to show in one row-->
	<!--don't  touch the code bellow to correct work of the gallery-->
	MIN_PICTERS1=1 
	count1=1	
	function header_gallery_load(){
		if (MAX_IMG_VIEW1>MAX_PICTERS1){MAX_IMG_VIEW1=MAX_PICTERS1}
		for (j=1;j<=MAX_IMG_VIEW1;j++){
			document.getElementById('header_gallery').innerHTML+='<img src="images/header_gallery_img_'+j+'.png" alt="Braided Rugs, Chair Pads & Stair Treads" style="cursor:pointer;" id="header_pic'+j+'" />';
		}
		document.getElementById('header_pic1').onclick = function() { header_next2()};	
		document.getElementById('header_pic2').onclick = function() { header_next()};
		document.getElementById('header_pic4').onclick = function() { header_back()};
		document.getElementById('header_pic5').onclick = function() { header_back2()};
	}
	
	function header_gallery(){	
		if (MAX_IMG_VIEW1>MAX_PICTERS1){MAX_IMG_VIEW1=MAX_PICTERS1}	
		document.getElementById('header_gallery').innerHTML='';
				
		for (x=count1;x<(count1+MAX_IMG_VIEW1);x++){
			number_of_img1=x;
			if (number_of_img1>MAX_PICTERS1){number_of_img1=(x-MAX_PICTERS1)}	
			document.getElementById('header_gallery').innerHTML+='<img src="images/header_gallery_img_'+number_of_img1+'.png" style="cursor:pointer;"  alt="Braided Rugs Image #'+number_of_img1+' on braid rugs collage" />';						
		}
		
		var arr_of_img = document.getElementById("header_gallery").getElementsByTagName("IMG");
		for (var y=0;y<arr_of_img.length;y++) { arr_of_img[y].id = "header_pic"+[y+1];}
		
		document.getElementById('header_pic1').onclick = function() { header_next2()};
		document.getElementById('header_pic2').onclick = function() { header_next()};
		document.getElementById('header_pic4').onclick = function() { header_back()};
		document.getElementById('header_pic5').onclick = function() { header_back2()};
	}
	
	function header_next(){
		count1--;
		if (count1<MIN_PICTERS1){count1=MAX_PICTERS1}
		header_gallery();
	}
	
	function header_next2(){
		count1=count1-2;
		if (count1<MIN_PICTERS1){if(count1==MIN_PICTERS1-2){count1=MAX_PICTERS1-1} else { count1=MAX_PICTERS1}}
		header_gallery();
	}
	
	function header_back(){
		count1++;
		if (count1>MAX_PICTERS1){count1=MIN_PICTERS1}
		header_gallery();
	}
	
	function header_back2(){
		count1=count1+2;
		if (count1>MAX_PICTERS1){if(count1==MAX_PICTERS1+2){count1=MIN_PICTERS1+1} else { count1=MIN_PICTERS1}}
		header_gallery();
	}
