/**
 * @author r.pannisco
 */

function load_provincia(nazione){
	if (nazione==1){
		document.getElementById("prov").style.display="inline";
		document.getElementById("prov2").style.display="inline";
		document.getElementById("prov_ext").style.display="none";
		document.getElementById("prov_ext2").style.display="none";
	}
	else {
		document.getElementById("prov_ext").style.display="inline";
		document.getElementById("prov_ext2").style.display="inline";
		document.getElementById("prov").style.display="none";
		document.getElementById("prov2").style.display="none";
	}
}

function contatti_open(id,sezione){
	document.contatti.scelta.value=id;document.getElementById('tipo_info').value=sezione;document.contatti.submit();
}

function goWhere(f) {

	url='';
	if (f.cerca.value!=''){
		var search;
		var search2;
		search=f.cerca.value;
		search2=search.replace(/[^a-zA-Z 0-9]+/g,'');
		if(search2 == ''){
			search2 = 'Ricerca';
		}
		url=url+search2 + '/00/';
	}
	else{
		url='Ricerca/00/';
	}
	return url;
}



function freccia_on(id){
	window.document.getElementById("scegli1").style.backgroundImage="url(/siteimages/freccia-sfondo-scelta.gif)";
	window.document.getElementById("scegli2").style.backgroundImage="url(/siteimages/freccia-sfondo-scelta.gif)";
	window.document.getElementById("scegli3").style.backgroundImage="url(/siteimages/freccia-sfondo-scelta.gif)";
	window.document.getElementById(id).style.backgroundImage="url(/siteimages/freccia-sfondo-scelta-s.gif)";
}
function freccia2_on(id){
	var max = window.document.getElementsByName("id_indirizzospedizione");
	for (i = 1; i <= max.length; i++) {
		id_arrow = "scegli" + i;
		window.document.getElementById(id_arrow).style.backgroundImage = "url(/siteimages/freccia-sfondo-scelta.gif)";
	}

	window.document.getElementById(id).style.backgroundImage="url(/siteimages/freccia-sfondo-scelta-s.gif)";
}

function SelezionaImg(img,id,price,qta){
	var a;
	window.document.getElementById('img_col').src=img;
	a=window.document.getElementById('button_form');
		if (a!=null){
	//		window.document.getElementById('button_form').action='negozio/basket/bsk_add,' + id + '/basket.html';
			window.document.getElementById('prezzo').innerHTML = price + ' &euro;'
			window.document.getElementById('bsk_add').value = id;
		}
	
	window.document.getElementById('col').value = id;
	if (qta==0){
		$("#button_form").hide();
		$("#non_dispo").show();
	}
	else{
		$("#button_form").show();
		$("#non_dispo").hide();
	}
}

function SelezionaSelect(val,val2,val3,val4){
	var a;
	a=window.document.getElementById('prezzo');
	if (a!=null){
		window.document.getElementById('prezzo').innerHTML = window.document.getElementById(val).value + ' &euro;'
	}
	window.document.getElementById('img_col').src = window.document.getElementById(val2).value;
	
	
//	a=window.document.getElementById('button_form');
	//if (a!=null){
	//	window.document.getElementById('button_form').action='negozio/basket/bsk_add,' + window.document.getElementById('col').value + '/basket.html';
	//}
	
	a=window.document.getElementById('link_whl');
	if (a!=null){
		window.document.getElementById('link_whl').href='negozio/addon/whl_add,' + window.document.getElementById('col').value + '/wishlist.html';
	}
	if (window.document.getElementById('bsk_add') != null) {
		window.document.getElementById('bsk_add').value = window.document.getElementById('col').value;
	}
	
	a=window.document.getElementById(val4).value;
	if (a==0){
		$("#button_form").hide();
		$("#non_dispo").show();
	}
	else{
		$("#button_form").show();
		$("#non_dispo").hide();
	}
}

function cancella_text(thisfield, defaulttext) {




	if (thisfield.value == defaulttext || thisfield.value.replace(/^\s\s*/, '').replace(/\s\s*$/, '') == "") {
		thisfield.value = "";

		
		return false;

	}

	thisfield.value = thisfield.value.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
	
	return true;
	
}

function cancella_text_ripristina(thisfield, defaulttext) {
	if (thisfield.value == "") {
		thisfield.value = defaulttext;
	}
}

function AddBasktFromLista(id){
	window.document.getElementById('bsk_add').value=id;
	window.document.getElementById('list_prd').submit();
	
}

//PopUp
function open_win(url, width, height)
{
	if (width==null && width == ''){
		width='800';
	}
	if(height==null && height == ''){
		height='600';	
	}
	
	window.open(url,'','width='+width+',height='+height+',resizable=1,menubar=0,toolbar=0,scrollbars=1,locations=0,status=0');
}


function showHelp(onoff){
	
	var onoff = document.getElementById('help').style.display;
	/*
	$("div.ituoidatisx").removeClass('corpo_left_menu_top_item_selected');
	$("div.ituoidatisx").addClass('corpo_left_menu_top_item');

	
	$("#bt_help").removeClass('corpo_left_menu_top_item');	*/
	$("#bt_help").addClass('corpo_left_menu_top_item_selected');
	$("div.help").hide();
	
	
	if (onoff=="block"){
		$("div.help").hide();
		$("#bt_help").removeClass('corpo_left_menu_top_item_selected');
	}
	else{
		$("div.help").show();
	}
}
