// JavaScript Document
function ListaProdottiHome()
{
		AggiornaProdotti('prodotti');
}

function ListaCategoria(categoria)
{
	$j.get("/js/listaProdotti.xml", {}, function(xml)
    {
      $j(xml).find("categoria").each(function()
      {
        var nomeCat = $j(this).attr('id');
		var descCat = $j(this).attr('desc');
		if(nomeCat == categoria){
			$j("#FRcontent").append('<h1>'+nomeCat+'</h1><h2>'+descCat+'</h2>');
			var i = 0;
			$j(this).find("articolo").each(function() {
				i++;
				if(i%4==0){}
				var content;
		        var nomeArt = $j(this).attr('id');
				var imageArt = $j(this).find("img").text();
				var descArt = $j(this).find("descr").text();

				var prezzoArt = $j(this).find("prezzo").text();
				var linkArt = $j(this).find("link").text();
				content = '<div id=\'FRpr\'><a href="'+linkArt+'" onClick="javascript:sezione(\''+getCookie('scelto')+'\')">';
				content += '<h1>'+nomeArt+'</h1>';
				content += '<img src="'+imageArt+'" width="190" alt="'+nomeArt+'" /><br />';
				content += '<h2>'+descArt+'</h2><br/><h2 id="prezzo">'+prezzoArt+'</h2>';
				content += '</a></div>'
				$j("#FRcontent").append(content);
			});
		}
      });
    }
    , "xml"
    );
}

function ListaSottoCategoria(categoria)
{
	$j.get("/js/listaProdotti.xml", {}, function(xml)
    {
      $j(xml).find("categoria").each(function()
      {
		  var nomeCat = $j(this).attr('id');
		  var linkCat = $j(this).find("link").text();
			$j(this).find("articolo").each(function() {	
				var nomeArt = $j(this).attr('id');
				var descArt = $j(this).find("descr").text();
				if(nomeArt == categoria) {
					$j("#FRcontent").append('<h1>'+nomeArt+'</h1><h2><a hrep="'+linkCat+'">'+nomeCat+'</a> '+descArt+'</h2>');
					$j(this).find("sottoarticolo").each(function() {
						var content;
						var nomeArt = $j(this).attr('id');
						var imageArt = $j(this).find("sottoimg").text();
						var descArt = $j(this).find("sottodescr").text();
						var prezzoArt = $j(this).find("sottoprezzo").text();
						var linkArt = $j(this).find("sottolink").text();
						content = '<div id=\'FRpr\'><a href="'+linkArt+'" onClick="javascript:sezione(\''+getCookie('scelto')+'\')">';
						content += '<h1>'+nomeArt+'</h1>';
						content += '<img src="'+imageArt+'" width="190"  alt="'+nomeArt+'" /><br />';
						content += '<h2>'+descArt+'</h2><br/><h2 id="prezzo">'+prezzoArt+'</h2>';
						content += '</a></div>'
						$j("#FRcontent").append(content);			
					});
				}
			});
	
      });
    }
    , "xml"
    );
}

// Categorie di HomePage
function AggiornaCategorieHome()
{
		segna('home');
} 

function segna(pagina) 
{
	//alert(pagina);
	// segniamo nel cookie la sezione scelta.
	$j('a.submenuheader').each(function()
	{
		//alert($j(this).attr("cod"));
		$j(this).bind('click', function()
		{
			//alert($j(this).attr("cod"));
			SetCookie('scelto', $j(this).attr("cod"));
		});
	});
	// apriamo la tendina
	//alert("prima if");
	if(pagina != 'home') {
	//alert("dopo if");
	$j('div.sepMenu').each(function()
	{
		//alert("assegna");
		$j(this).bind('click', function()
		{
			//alert("clik");
			if(getCookie('scelto') != $j(this).attr("id")){
				//alert('2 '+$j(this).attr("cod"));
				var $vecchio = $j('#'+getCookie('scelto')+'c');
				$vecchio.slideUp("slow");
				$j('#'+getCookie('scelto')).find('a:first').attr({style: 'background-position:bottom;'});
				
				var $nuovo = $j('#'+$j(this).attr("id")+'c');
				$nuovo.slideDown("slow");
				$j('#'+$j(this).attr("id")).find('a:first').attr({style: 'background-position:top;'});
				SetCookie('scelto', $j(this).attr("id"));
			} else  {
				var $nuovo = $j('#'+$j(this).attr("id")+'c');
				if($nuovo.css("display") != "none"){
					$j('#'+getCookie('scelto')).find('a:first').attr({style: 'background-position:bottom;'});
					$nuovo.slideUp("slow");
				} else {
					$j('#'+getCookie('scelto')).find('a:first').attr({style: 'background-position:top;'});
					$nuovo.slideDown("slow");
				}
			}
		});
	});
	}
}

function AggiornaCategorie()
{
  
	
		//$j("#FRcategorie").append(testo);
		//$j('#'+getCookie('scelto')+' img').attr({src: '/App_Themes/Home2/images/meno.gif'});
		$j('#'+getCookie('scelto')).find('a:first').attr({style: 'background-position:bottom;'});
		var $attiva = $j('#'+getCookie('scelto')+'c');
		//$attiva.sibling('img').attr({src: '/App_Themes/Home2/images/meno.gif'});
		$attiva.slideDown("slow");
		// --- 
		segna();
   
} 

function sezione(cod) 
{
	SetCookie('scelto', cod);
}

function AggiornaProdotti(tipo)
{
} 

