//			var n_thumbs = 20; //numero di thumbs
			
			
			
			$(document).ready(function(){			
//				var num_visu = 10; //numero thumb visibili
//				var larghe = 85; //larghezza thumb
//				slider_colori_det(10, 85);
			});

			function slider_colori_det(n_visu, larg){
				// Start animation
				$("#cover_slider").hover(function(){
					
					$("#cover_slider").css("width","850px");
					if($("#hidden_num_art").val()>10){
						$("#fr_sx").show();
						$("#fr_dx").show();
					}
				
					
				}, function(){
					if ($("#hidden_num_art").val() > 10) {
						$("#fr_sx").hide();
						$("#fr_dx").hide();
					}
					$("#cover_slider").css("width","85px");
				});
	
				$("#fr_dx").hover(function(){
					left_pos = parseInt($("#down_slider").css("left"));
					n_thumbs=$("#hidden_num_art").val()
					marg_dx = parseInt((n_thumbs - n_visu) * larg);
					dx_step = parseInt(marg_dx + left_pos);
					
									
					if(marg_dx>left_pos)
					$("#down_slider").animate({
						left: '-=' + dx_step + 'px'
					}, 3000);
				}, function(){
					$("#down_slider").stop();
				});
				
				// Start animation in the opposite direction
				$("#fr_sx").hover(function(){
					left_pos = parseInt($("#down_slider").css("left"));
					$("#down_slider").animate({
						left: '-=' + left_pos + 'px'
					}, 3000);
				}, function(){
					$("#down_slider").stop();
				});
				
//				$("#down_slider .cont_img").hover(function(){
				$(".cont_img img").hover(function(){
					id_sel=$(this).attr("id");
					id_sel=id_sel.substring(4,id_sel.length);
					
					art_detta(id_sel, 'ico_hov');
				}, function(){
					id_sel_h=$(this).attr("id");
					id_sel_h=id_sel_h.substring(4,id_sel_h.length);
					 
					art_detta(id_sel_h, 'ico');
					
				}).click(function(){
					id_sel=$(this).attr("id")
					id_sel=id_sel.substring(4,id_sel.length)
					num_artic=$("#hidden_num_art").val()
					str_arti=$("#hidden_arr_art").val()
					
					arr_arti=str_arti.split('###');
					ffd=arr_arti.length
					for(j=0; j<arr_arti.length; j++){
						appo_arr=arr_arti[j].split('@@@')
						if(appo_arr[0]==id_sel){
							refresh_slider(appo_arr[0], appo_arr[1], str_arti)							
						}
					}
					if ($("#hidden_num_art").val() > 10) {
						$("#fr_sx").hide();
						$("#fr_dx").hide();
					}
					$("#cover_slider").css("width","85px");

//					art_detta(id_sel, "");
					cambia_prodotto(id_sel)
				});
			}
			
			function refresh_slider(id, ico, arr_articoli){
				arr_icone=arr_articoli.split('###')
				dime_array=arr_icone.length	
				str='';
				str1='';
				str2='';
				
					
				for(i=0; i<dime_array; i++){
					arr_det_art=arr_icone[i].split('@@@');
					id_artic=arr_det_art[0];
					ico_artic=arr_det_art[1];
					icohov_artic=arr_det_art[2];
					id_catego=arr_det_art[3];
					
					if(id_artic==id && ico_artic==ico){		
						str1='<div id="art_'+id+'" class="cont_img"><img alt="'+arr_det_art[3]+'" id="imm_'+id+'" src="http://www.ex-t.it/media/img_articoli/'+ id +'/'+ ico+'"/></div>'
					}else if(id_artic!=id && ico_artic!=ico){
							art="art_"+id_artic;
							imm="imm_"+id_artic;
							categ=arr_det_art[3];
							str2+='<div id="'+art+'" class="cont_img"><img alt="'+categ+'" id="'+imm+'" src="http://www.ex-t.it/media/img_articoli/'+ id_artic +'/'+ ico_artic +'"/></div>'
					}
								
					
				}
				str=str1+str2;
				$("#down_slider").html(str);
				slider_colori_det(10, 85);
			}
			
			function init_slider(id_arti, ico_art, arr_str, n_art){
				$("#hidden_num_art").val(n_art)
				$("#hidden_arr_art").val(arr_str)
				
				
				var n_visu = 10;
				var larg = 85; //larghezza thumb
				var n_thumbs=n_art;
				var marg_dx = parseInt((n_thumbs - n_visu) * larg);

				//	var marg_dx=parseInt(0-((n_thumbs-n_visu)*larg));
				var marg_sx = 0;
				var limit_for=parseInt(n_thumbs+1)

				arr_icone=arr_str.split('###')
				dime_array=arr_icone.length	
				
			}
			
			function visu_img(id_img){
				path="prodotto_"+id_img+".jpg";
				$("#content").html("<img src='"+path+"'  width='700'/>")
				$("#content").css("margin-top","42px");
			}
			
			/**************************************************************************
			 * GetXmlHttpObject
			 **************************************************************************/
			function GetXmlHttpObject(){
			    if (window.XMLHttpRequest) {
			        // code for IE7+, Firefox, Chrome, Opera, Safari
			        return new XMLHttpRequest();
			    }
			    if (window.ActiveXObject) {
			        // code for IE6, IE5
			        return new ActiveXObject("Microsoft.XMLHTTP");
			    }
			    return null;
			}
			
			
			
			function art_detta(id, tipo){
				
			    var url = "./slider/artic.php";
			    var param = 'idart=' + id;
				
				if(tipo==""){
					xmlhttp_artdet = GetXmlHttpObject();
				    if (xmlhttp_artdet == null) {
				        alert("Browser does not support HTTP Request");
				        return;
				    }
				    xmlhttp_artdet.onreadystatechange = stateChanged_artdet;
					xmlhttp_artdet.open("POST", url, true);
				    xmlhttp_artdet.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				    xmlhttp_artdet.setRequestHeader("Content-length", param.length);
				    xmlhttp_artdet.send(param);
					
				}else if(tipo=="ico_hov"){
					xmlhttp_artdet_ico_hov = GetXmlHttpObject();
				    if (xmlhttp_artdet_ico_hov == null) {
				        alert("Browser does not support HTTP Request");
				        return;
				    }
					xmlhttp_artdet_ico_hov.onreadystatechange = stateChanged_artdet_ico_hov;
					xmlhttp_artdet_ico_hov.open("POST", url, true);
				    xmlhttp_artdet_ico_hov.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				    xmlhttp_artdet_ico_hov.setRequestHeader("Content-length", param.length);
				    xmlhttp_artdet_ico_hov.send(param);
					
				}else if(tipo=="ico"){
					xmlhttp_artdet_ico = GetXmlHttpObject();
				    if (xmlhttp_artdet_ico == null) {
				        alert("Browser does not support HTTP Request");
				        return;
				    }
					xmlhttp_artdet_ico.onreadystatechange = stateChanged_artdet_ico;
					xmlhttp_artdet_ico.open("POST", url, true);
				    xmlhttp_artdet_ico.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				    xmlhttp_artdet_ico.setRequestHeader("Content-length", param.length);
				    xmlhttp_artdet_ico.send(param);
				}
				
			    
			}
			
			
			function stateChanged_artdet_ico_hov(){
			    if (xmlhttp_artdet_ico_hov.readyState == 4) {
					dettagli_hov = eval('(' + xmlhttp_artdet_ico_hov.responseText + ')');
					if (dettagli_hov.length != 0) {
						dett_articolo_hov = dettagli_hov[0];
						
						id_hov=dett_articolo_hov['id_articoli'];
						img_hov=dett_articolo_hov['img_2_articoli'];
//						$("#logo").html(id_hov+" - hov - "+img_hov);
						$("#imm_"+id_hov).attr("src", "http://www.ex-t.it/media/img_articoli/"+id_hov+"/"+img_hov);
					}
			    }
			}
			
			function stateChanged_artdet_ico(){
			    if (xmlhttp_artdet_ico.readyState == 4) {
					dettagli = eval('(' + xmlhttp_artdet_ico.responseText + ')');
					if (dettagli.length != 0) {
						dett_articolo = dettagli[0];
						
						id=dett_articolo['id_articoli'];
						img=dett_articolo['img_articoli'];
//						$("#prod_info").html(id+" - icona -  "+img);
						$("#imm_"+id).attr("src", "http://www.ex-t.it/media/img_articoli/"+id+"/"+img);
						
					}
			    }
			}


			function stateChanged_artdet(){
			    if (xmlhttp_artdet.readyState == 4) {
					dettagli = eval('(' + xmlhttp_artdet.responseText + ')');
					if (dettagli.length != 0) {
						
						dett_articolo = dettagli[0];
						for (key in dett_articolo) {
//							if (key == 'id_articoli') {
//								id = dett_articolo[key];
//							}		
//							if (key == 'designer') {
//								designer = dett_articolo[key];
//							}		
//							if (key == 'sku_articoli') {
//								sku_articoli = dett_articolo[key];
//								
//							}	
//							if (key == 'dimensioni_articoli') {
//								dimensioni_articoli = dett_articolo[key];
//								
//							}	
//							if (key == 'sottotitolo_articoli_it') {
//								sottotitolo_articoli_it = dett_articolo[key];
//								
//							}	
//							if (key == 'sottotitolo_articoli_en') {
//								sottotitolo_articoli_en = dett_articolo[key];
//								
//							}	
//								
//							if (key == 'testo_articoli_it') {
//								testo_articoli_it = dett_articolo[key];
//								
//							}		
//							if (key == 'testo_articoli_en') {
//								testo_articoli_en = dett_articolo[key];
//								
//							}		
//							 	
//	
//							
//							if (key == 'file_articoli') {
//								file_articoli = dett_articolo[key];
//								
//							}	
//							if (key == 'file_1_articoli') {
//								file_1_articoli = dett_articolo[key];
//								
//							}	
//							if (key == 'file_2_articoli') {
//								file_2_articoli = dett_articolo[key];
//								
//							}
//														
//							if (key == 'img_colore1') {
//								img_colore1 = dett_articolo[key];
//							}	
//							if (key == 'img_colore2') {
//								img_colore2 = dett_articolo[key];
//							}	
//							if (key == 'img_colore3') {
//								img_colore3 = dett_articolo[key];
//							}	
//							if (key == 'img_colore4') {
//								img_colore4 = dett_articolo[key];
//							}	
//							if (key == 'img_colore5') {
//								img_colore5 = dett_articolo[key];
//							}	
//							if (key == 'img_colore6') {
//								img_colore6 = dett_articolo[key];
//							}	
//							if (key == 'img_colore7') {
//								img_colore7 = dett_articolo[key];
//							}	
//							if (key == 'img_colore8') {
//								img_colore8 = dett_articolo[key];
//							}	
//							if (key == 'img_colore9') {
//								img_colore9 = dett_articolo[key];
//							}	
//							if (key == 'img_colore10') {
//								img_colore10 = dett_articolo[key];
//							}	
//																
//							if (key == 'colore1') {
//								colore1 = dett_articolo[key];	
//							}	
//							if (key == 'colore2') {
//								colore2 = dett_articolo[key];	
//							}	
//							if (key == 'colore3') {
//								colore3 = dett_articolo[key];	
//							}	
//							if (key == 'colore4') {
//								colore4 = dett_articolo[key];	
//							}	
//							if (key == 'colore5') {
//								colore5 = dett_articolo[key];	
//							}	
//							if (key == 'colore6') {
//								colore6 = dett_articolo[key];	
//							}	
//							if (key == 'colore7') {
//								colore7 = dett_articolo[key];	
//							}	
//							if (key == 'colore8') {
//								colore8 = dett_articolo[key];	
//							}	
//							if (key == 'colore9') {
//								colore9 = dett_articolo[key];	
//							}	
//							if (key == 'colore10') {
//								colore10 = dett_articolo[key];	
//							}

	
								if (key == 'id_articoli') {
									id = dett_articolo[key];
								}
								nu=0;
								if (key == 'img_articoli') {
									img_articoli = dett_articolo[key];
									alert(img_articoli)
//									if(img_articoli!='')
//									nu++;
								}
								if (key == 'img_articoli2') {
									img_articoli2 = dett_articolo[key];
//									if(img_articoli2!='')
//									nu++;
								}
								if (key == 'img_articoli3') {
									img_articoli3 = dett_articolo[key];
//									if(img_articoli3!='')
//									nu++;
								}
								if (key == 'img_articoli4') {
									img_articoli4 = dett_articolo[key];
//									if(img_articoli4!='')
//									nu++;
								}
								if (key == 'img_articoli5') {
									img_articoli5 = dett_articolo[key];
//									if(img_articoli5!='')
//									nu++;
								}
								
								
								
//								for(i=0; i<nu; i++){
//									if(i==0)
//										str_ss+='<img style="background: url(../media/img_articoli/'+id+'/'+img_articoli+'"/>'
//									else
//										str_ss+='<img style="background: url(../media/img_articoli/'+id+'/'+img_articoli+i+'"/>'
//								}
								str_ss='<div class="slideshow">'
									str_ss+='<img style="background: url(../media/img_articoli/'+id+'/'+img_articoli+'"/>'
									str_ss+='<img style="background: url(../media/img_articoli/'+id+'/'+img_articoli2+'"/>'
									str_ss+='<img style="background: url(../media/img_articoli/'+id+'/'+img_articoli3+'"/>'
									str_ss+='<img style="background: url(../media/img_articoli/'+id+'/'+img_articoli4+'"/>'
									str_ss+='<img style="background: url(../media/img_articoli/'+id+'/'+img_articoli5+'"/>'
								str_ss+='</div>'
								
								
							
//							if (key == 'img_1_articoli') {
//								img_1_articoli = dett_articolo[key];
//								
//							}	
//							if (key == 'img_2_articoli') {
//								img_2_articoli = dett_articolo[key];
//								
//							}	
//							if (key == 'link_store') {
//								link_store = dett_articolo[key];
//								
//							}	
//							if (key == 'link_store_visible') {
//								link_store_visible = dett_articolo[key];
//								
//							}	

							
							
						}
//							str_prodinfo="<h2><?=$titolo?></h2><p>designer: <B>"+designer+"</B></p><div id=\"sottotitolo\">"+testo_articoli_it+"</div>";
//							$("#prod_info").html(str_prodinfo);
//							
//							
//							str_prod_dettcont="<div class=\"prod_dett\"><?=$testi['codice'];?><br /><span class=\"grass\">"+sku_articoli+"</span></div>";
//							str_prod_dettcont+="<div class=\"prod_dett\"><?=$testi['misure'];?><br /><span class=\"grass\">"+dimensioni_articoli+"</span></div>"
//							str_prod_dettcont+="<div class=\"prod_dett\"><?=$testi['download'];?><br /><? if("+file_articoli+"!=''){if($_SESSION['SESSION_USERNAME']!=''){?>";
//							str_prod_dettcont+="<a href=\"/media/img_articoli/"+id+"/"+file_articoli+"\"><span class=\"grass\">PDF</span></a>"
//							str_prod_dettcont+="<?	}else{ ?><a href=\"index.php?p=login\"><span class=\"grass\">PDF</span></a><?	}}"
//							str_prod_dettcont+="if("+file_1_articoli+"!='') {if($_SESSION['SESSION_USERNAME']!=''){?>"
//							str_prod_dettcont+="<a href=\"downloadit.php?path_file=<?php echo SITE_URL; ?>media/img_articoli/"+id+"/"+file_1_articoli+"&nome_file="+file_1_articoli+"\"><span class=\"grass\">2D</span></a>";
//							str_prod_dettcont+="<?	}else{ ?><a href=\"index.php?p=login\"><span class=\"grass\">2D</span></a><?}}";
//							
//							str_prod_dettcont+="if("+file_2_articoli+"!='') {if($_SESSION['SESSION_USERNAME']!=''){?>"
//							str_prod_dettcont+="<a href=\"downloadit.php?path_file=<?php echo SITE_URL; ?>media/img_articoli/"+id+"/"+file_2_articoli+"&nome_file="+file_2_articoli+"\"><span class=\"grass\">3D</span></a>";
//							str_prod_dettcont+="<?	}else{ ?><a href=\"index.php?p=login\"><span class=\"grass\">3D</span></a><?}}</div>";
//		
//	
//							$("#prod_dettcont").html(str_prod_dettcont);
							$("#content").html(str_ss);
	
					}
			    }
			}
			
			function cambia_prodotto(id){
				categoria=$("#hidden_cat_art").val();
				subcategoria=$("#hidden_catsub_art").val();
				stringa="http://www.ex-t.it/index.php?p=prodotti&c1="+categoria+"&c2="+subcategoria+"&id="+id;
				$("#appo").text(stringa)
				location.href =stringa 
//				<a href="index.php?p=prodotti&amp;c1=<?=$c1get;?>&amp;c2=<?=$c2get;?>&amp;id=<?=$id;?>&amp;next=1">
			}
			
			

