// JavaScript Document

counter=1
id_mem=0
id_opened=0
count_brand_link=1 //memorizza il nuero di link dei marchi
var newwindow;
poptastic = function(image, url)
{
    var theImg = document.getElementById(image);
	newwindow=window.open(url,'name','height='+theImg.height,'width='+theImg.width);
	newwindow.focus()
}
/*performe_display=function(id, class){
	if(id==id_mem){
		$(id).css("display", "none")
		id_mem=0
	}else{
		$(class).css("display", "none")
		$(id).css("display", "block")
		id_mem=id
	}
}*/

start_splash_gallery = function(){
	$("#splash_image").animate({opacity: 0},500,function(){
		$("#splashed_image").remove()
		setTimeout("show_splash_image()",500);
	})
}

show_splash_image = function(){
	if(counter==6){
		counter=1
		$("#splash_image").append("<img id =\"splashed_image\" src=\"image/lato/lato"+counter+".png\" />")
		img="<img id =\"splashed_image\" src=\"image/lato/lato"+counter+".png\" />";
		$("#splash_image").animate({opacity: 1},1000)
		setTimeout("start_splash_gallery()", 8000)		
	}else{
		$("#splash_image").append("<img id =\"splashed_image\" src=\"image/lato/lato"+counter+".png\" />")
		img="<img id =\"splashed_image\" src=\"image/lato/lato"+counter+".png\" />";
		$("#splash_image").animate({opacity: 1},1000)		
		setTimeout("start_splash_gallery()", 8000)
	}
	counter++;

}
append_description = function(msg){
	if(msg==""){
		$("#testo_appended").remove()			
	}else{
		$("#testo_appended").remove()	
		$("#append_description").append("<h3 id=\"testo_appended\">"+msg+"</h3>")
	}
}
load_ajax = function(cont, page, label){
	$("#no_select_image").css("display", "none");
	valore=document.getElementById(label).value
	pagina=page+"?valore="+valore.replace(/ /g,"__");
	$(cont).load(pagina)
	$("#img_logo img").remove()	
	low_val = valore.toLowerCase
	$("#img_logo").append("<img src=\"image/marche_auto/"+valore.toLowerCase()+"\" width=\"60\" />")
	// alert(pagina)	
}
load_ajax2 = function(cont, page, label){
	valore=document.getElementById(label).value
	pagina=page+"&valore="+valore.replace(/ /g,"__");
	$(cont).load(pagina)
	 //alert(pagina)	
}
send = function(cont, page){
/*		 modello=document.selezione_centraline.modello.value
		 marca=document.selezione_centraline.marche.value
		 motore=document.selezione_centraline.motore.value	*/
		 car_model=document.getElementById('modello').value
		 motore=document.getElementById('motore').value
		 marca=document.getElementById('marca').value 		
		 pagina=page+"?modello="+car_model.replace(/ /gi, "__")+"&motore="+motore.replace(/ /gi, "__")+"&marca="+marca.replace(/ /gi, "__")
		 $(cont).load(pagina) 
		 	 
}

load_product = function(cont, page){
	$(cont).load(page)
}
load_gallery = function(cont, page){
	$(cont).load(page)
}
load_gallery_viewer = function(cont, page){
	$("#big_image").remove()
	$("#titolo_image").remove()
	$("#descrizione_image").remove()
	$("#conteiner-imgsmall").remove()
	gallery=document.getElementById("select_gallery").value
	$(cont).load(page+"?gallery="+gallery)
}
js_submit = function(){
	valore=$("#camp_select_gallery").val();
	window.location="gallery.php?gallery="+valore+"";
}

show_big_image = function(path, path1, path2, modello, descrizione){
/*	alert(path)
	alert(descrizione)
	alert(modello)*/
	$("#big_image").remove()
	$("#titolo_image").remove()
	$("#descrizione_image").remove()
	$("#conteiner-imgsmall").remove()
	$("#view_image").append("<div style=\"float:left;\"><img id = \"big_image\" src=\""+path+"\"/></div>")
	$("#didascalia").append("<h3 id=\"titolo_image\" style=\"text-align:left; padding-bottom:5px; font-family:Verdana, Geneva, sans-serif; font-size:12px;\"><strong>"+modello+"</strong></h3><div id=\"descrizione_image\" style=\"text-align:left; padding-bottom:5px;  font-family:Verdana, Geneva, sans-serif; font-size:12px;\">"+descrizione+"</div>")	
	if($("#big_image").attr('height')>$("#big_image").attr('width')){
		if(path1!="image/gallerie/"){
			img1="<div><img id = \"big_image\" src=\""+path1+"\" width=\"185\" style=\"margin-bottom:10px;\"/></div>";
		}else{img1=""}
		if(path2!="image/gallerie/"){
			img2="<div><img id = \"big_image\" src=\""+path2+"\" width=\"185\"/></div>";
		}else{img2=""}
		$("#view_image").append("<div style=\"float:right;\ margin-left:10px;\" id=\"conteiner-imgsmall\">"+img1+img2+"</div>")
	}else if($("#big_image").attr('height')<$("#big_image").attr('width')){
		$("#big_image").attr('width', "390")
		if(path1!="image/gallerie/"){
			img1="<div style=\"float: left; margin-top: 10px\"><img id = \"big_image\" src=\""+path1+"\" width=\"185\" /></div>";
		}else{img1=""}
		if(path2!="image/gallerie/"){
			img2="<div style=\"float: right; margin-top: 10px\"><img id = \"big_image\" src=\""+path2+"\" width=\"185\"/></div>";
		}else{img2=""}
		$("#view_image").append("<div id=\"conteiner-imgsmall\">"+img1+img2+"<div class=\"clearer\"></div></div>")
	}		
}
enlarge_news_content = function(id){
	if(id!=id_opened){
		$(id_opened).css("display", "none");		
		$(".contenuto_news").css("display", "none");
		$(id).show("slide", { direction: "up" }, 400);
		id_opened=id
	}else{
	
	}
}
id_opened2=0;
enlarge_prodotti_content = function(id){
	if(id!=id_opened2){
		$(id_opened2).css("display", "none");		
		$(".contenuto_prodotti").css("display", "none");
		$(id).show("slide", { direction: "up" }, 400);
		id_opened2=id
	}else{
	
	}
}

load_camp = function(cont, page, campo){
		val=$(campo).val()
		name=$(campo).attr("name")
		pagina=page+"?"+name+"="+val.replace(" ", "_")		
		$(cont).load(pagina)
}
show_another= function(action){
	if(action=="add"){
		count_brand_link++	
		$("#form_table").append("<tr><td><h3 id=\"testo"+count_brand_link+"\">link marche</h3></td><td><input type=\"text\" name=\"linkmarche[]\" id=\"linkmarche"+count_brand_link+"\" /><img src=\"../../../image/icon/add.png\" onclick=\"show_another('add')\" id=\"add"+count_brand_link+"\" width=\"17\" style=\"margin-left:10px;\"/><img src=\"../../../image/icon/delete.png\" onclick=\"show_another('remove')\" id=\"remove"+count_brand_link+"\" width=\"17\" style=\"margin-left:10px;\"/></td></tr>")
	}else{
		if(count_brand_link==1){}
		else{
			$("#testo"+count_brand_link).remove()			
			$("#linkmarche"+count_brand_link).remove()
			$("#remove"+count_brand_link).remove()	
			$("#add"+count_brand_link).remove()					
			count_brand_link--
		}
	}
}
chiedi_conferma = function(db, id){
	if (confirm("Sicuro di voler cancellare definitvamente e permanentemente?")){
		$("#delete").load("delete.php?db="+db+"&id="+id)
		alert("Cancellazione avvenuta.");
		location.reload(true);
	}else{

	}
}
navigation_page = function(cont, pagina){
	$(cont).load(pagina)
}
id_gallery_yet_opened=0;
shower=function(id){
	if(id==0){
		id_gallery_yet_opened=id
		$(id).show("slide", { direction: "up" }, 300);
	}else{
		$(id_gallery_yet_opened).hide("slide", { direction: "bottom" }, 100);
		id_gallery_yet_opened=0
		$(id).show("slide", { direction: "up" }, 300);
		id_gallery_yet_opened=id
		
	}
}
chiedi_cancellazione = function(id, path){
	if (confirm("Sicuro di voler cancellare definitvamente e permanentemente?")){
		$("#delete").load(path+"?id="+id)
		alert("Cancellazione avvenuta.");
		location.reload(true);
	}else{

	}
}
id_centralina_mem=0
show_dettagli_centralina = function(id){
	if(id==id_centralina_mem){
		$(".table_dettail").css("display", "none");	
		id_centralina_mem=0		
	}else{
		$(".table_dettail").css("display", "none");		
		id_centralina_mem=id
		$("#table_dettail_"+id).css("display", "block");
	}
}
evidence = function(id){
	$("#"+id).css("background-color", "#A5A5A5");	
	$("#"+id).css("font-weight", "bold");				
}
unevidence = function(id){
	$("#"+id).css("background-color", "transparent");		
	$("#"+id).css("font-weight", "normal");			
}
image_loader = function(){
	valore = document.getElementById('select_marca').value 		
	$("#img_logo img").remove()	
	low_val = valore.toLowerCase
	$("#img_logo").append("<img src=\"image/marche_auto/"+valore.toLowerCase()+".png\" width=\"80\" />")	

}
cancella_immagine=function(cont, imgid, image_n, path){
	if (confirm("Sicuro di voler cancellare definitvamente e permanentemente?")){
		$("#"+cont).load("delete_image_particolare.php?imgid="+imgid+"&image_n="+image_n+"&path="+path)
		alert("Cancellazione avvenuta.");
		location.reload(true);
	}else{

	}
}

