function jInit()
{
	// SIDE CONTENT
	
	if($('#caixa-lateral').html() != null)
	{
		$('.contentLeftInner').html($('#caixa-lateral').html());
		$('#caixa-lateral').html('');
		$('.contentLeftInner').show();
	}else{
		$('.contentLeftInner').show();
	}
	
	
	
	// PRODUCT IMAGE
	$("div.scrollable").scrollable(); 
	
	$('.items div').click(function(){

		$('.detalhe-produtos-bigIma img').attr({src:$(this).attr('rel')});
	});
	
	$('.items img').click(function(){
		$('.detalhe-produtos-descricao').html($(this).attr('alt'));
	});
	
	$('.detalhe-produtos-bigIma').attr("src",$('.detalhe-produtos-bigIma img').attr({src:$('.items div').attr('rel')}))
	$('.detalhe-produtos-descricao').html($('.items div img').attr("alt"))
	
	
	// CORNERS
	
	$('.tableCatalogo').corners('10px');
	$('.catalogs-filter-form').corners('10px');
	$('.news-navbar').corners('5px');
	$('.contact-list').corners('10px');
	$('.detalhe-documents').corners('5px');
	$('.advanced-catalog-filter').corners('10px');
	$('.advanced-catalog-results').corners('10px');
	
	/* DA HOME
	$('.catalogs-filter').corners('10px');
	$('.detalhe-documents-info').corners('5px');
	$('#pesquisa-header').corners('10px');
	$('#pesquisa-footer').corners('10px');*/
	
	
	/* CATALOGO*/
	$('#catalogs h1').html($('.titulo-catalogo span').html())
	
	// SFIR
	$.sifr({
		// path: 'http://www.int.spcomercial.pt/_SWF/',
		path: 'http://www.spcomercial.makewise.pt/_SWF/',
		save: true
	});
	$('h1').sifr({ font: 'titulo-h1_Fontin', color: '#0d6d0d' });
	
	
	$('.advanced-catalog-row:odd').addClass('advanced-catalog-row-odd');
	
	// PRODUTOS
	detailInputClick();
	
	
	
	$('#dummyBuy').click(function(){
		$('.detalhe-produto-comprar-form').slideToggle();
		$('.produto-pedir-info').slideToggle();
		
		//var textToArea = "Venho por este meio adquirir o produto com a ref. num. "+ $('.produto-referencia p').html() + ".\n\nAguardo detalhes da vossa parte para concluir o processo de compra.\nCumprimentos";
		//$('#dummyBuyText').val(textToArea)
		
		if($(this).val() == "Encomendar")
			{$(this).val('Pedir Informacões')}
		else{$(this).val('Encomendar')}
	});
	
	// PRODUCT IMAGE
	$("div.scrollable").scrollable(); 
	
	$('.items div').click(function(){

		$('.detalhe-produtos-bigIma img').attr({src:$(this).attr('rel')});
	});
	
	
	
	// LISTA DE PRODUTOS SÓ IMAGENS!!
	
	// CONTAGEM DOS TIPO
	
	
	// LISTA DE CATEGORIAS
	var catList = false;
	try{
		CategoriesImagesList;
		}
	catch(e)
	{
		catList = true;
	}
	
	
	if(catList == false && CategoriesImagesList.length !=0)
	{
		nprod = 1;
		
		
		
		var prodArray = CategoriesImagesList.length; // Total de arrays == total de produtos
		for(i=0; i<prodArray; i++)
		{
			var gamaNome = CategoriesImagesList[i][0];
			var gamaLink = CategoriesImagesList[i][1];
			var gamaImagem = CategoriesImagesList[i][2];
			
			if(count == 4)
			{
				$('.listagem-produtos').append('<li><a href="' + gamaLink + '"><img src="' + gamaImagem + '" width="145" class="clear" alt="" /></a><div class="listagem-produtos-nome"><b>'+ gamaNome +'</b></div></li>');
				count =1;
			}
			else if(count != 4)
				{
					$('.listagem-produtos').append('<li><a href="' + gamaLink + '"><img src="' + gamaImagem + '" width="145" alt="" /></a><div class="listagem-produtos-nome"><b>' + gamaNome +'</b></div></li>');
					count = count +1;
				}
		}
		$('.infoListProd').css("display","block");
	}
	
	// LISTA DE PRODUTOS
	var pdlist = false;
	try{
	ProductsImagesList}
	catch(e){
		 pdlist = true;
		}	
		
	if(pdlist == false && ProductsImagesList.length != 0)
	{
		
		var topArray = ProductsImagesList.length; // Total de arrays == total de produtos
	
		for(i=0; i<topArray;i++)
		{
			var linkP = "prodImaList("+ i +")";
			var linN = ProductsImagesList[i][0]
			typeProd = "<li><span><a href='javascript:" + linkP + "'>" + linN + "</a></span></li>";
			$('.productSearch-picturesMenu ul').append(typeProd);
		}
	
		$('.productSearch-picturesMenu li:eq(0)').addClass('select')
	
		// CRIA A PRIMEIRA GALERIA
		var innerArray = ProductsImagesList[0].length; // Total de itens no interior do primeiro array arrays
		var count = 1;
		
		for(e=1; e<innerArray; e = e +3)
		{
			if(e != 0)
			{
				var proLink = ProductsImagesList[0][e];
				var proIma = ProductsImagesList[0][e+1];
				var proName = ProductsImagesList[0][e+2];
				if(count == 4)
				{
					$('.listagem-produtos').append('<li><a href="' + proLink + '"><img src="' + proIma + '" width="145" class="zoomi" class="clear" alt="" /></a><div class="listagem-produtos-nome">'+ proName +'</div></li>');
					count =1;
				}
				else if(count != 4)
				{
					$('.listagem-produtos').append('<li><a href="' + proLink + '"><img src="' + proIma + '" width="145" class="zoomi" alt="" /></a><div class="listagem-produtos-nome">' + proName +'</div></li>');
					count = count +1;
				}
			}
		}
		
		$('img.zoomi').zoomi();
	}
	else if(pdlist == false && ProductsImagesList.length == 0)
	{
		
		var noProd = "<li style='width:100%;'>Não existem produtos nesta secção.</li>"
		$('.listagem-produtos').append(noProd)
		$('.productSearch-picturesList').css("background-color","#FFFFFF");
		$('.listagem-produtos li').css("background-color","#FFFFFF");
	}
	
	try
	{
		if(SetRequestHandler == '1')
		{
			Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
		}
	}
	catch(e){ }
	
	
	//Flash detection
	try
	{
		DetectFlash();
	}
	catch(e){ }
}

// MUDA AS IMAGENS DA GALERIA
function prodImaList(listId)
{
	
	$('.listagem-produtos').empty(); // APAGA AS IMAGENS
	
	$('.productSearch-picturesMenu ul li').each(function(){$(this).removeClass('select')});
	$('.productSearch-picturesMenu ul li').eq(listId).addClass('select'); // Adiciona class
	$('.productSearch-picturesMenu ul li a').eq(listId).blur();
	
	var innerArrayIn = ProductsImagesList[listId].length;
	
	var count = 1;
	
	for(e=1; e<innerArrayIn; e = e +3)
		{
			if(e != 0)
			{
				var proLink = ProductsImagesList[listId][e];
				var proIma = ProductsImagesList[listId][e+1];
				var proName = ProductsImagesList[listId][e+2];
	
				if(count == 4)
				{
					$('.listagem-produtos').append('<li><a href="' + proLink + '"><img src="' + proIma + '" width="145" class="zoomi" class="clear" alt="" /></a><div class="listagem-produtos-nome">'+ proName +'</div></li>');
					count =1;
				}
				else if(count != 4)
				{
					$('.listagem-produtos').append('<li><a href="' + proLink + '"><img src="' + proIma + '" width="145" class="zoomi" alt="" /></a><div class="listagem-produtos-nome">' + proName +'</div></li>');
					count = count +1;
				}
			}
		}
	$('img.zoomi').zoomi();
}

function detailInputClick(){
	$('.produto-info-name').focus(function(){if($(this).val() == 'Nome')$(this).val('');}).blur(function(){if($(this).val() == '')$(this).val('Nome');});
	$('.produto-info-empresa').focus(function(){if($(this).val() == 'Empresa')$(this).val('');}).blur(function(){if($(this).val() == '')$(this).val('Empresa');});
	$('.produto-info-email').focus(function(){if($(this).val() == 'Email')$(this).val('');}).blur(function(){if($(this).val() == '')$(this).val('Email');});
	
	$('.produto-compra-name').focus(function(){if($(this).val() == 'Nome')$(this).val('');}).blur(function(){if($(this).val() == '')$(this).val('Nome');});
	$('.produto-compra-empresa').focus(function(){if($(this).val() == 'Empresa')$(this).val('');}).blur(function(){if($(this).val() == '')$(this).val('Empresa');});
	$('.produto-compra-email').focus(function(){if($(this).val() == 'Email')$(this).val('');}).blur(function(){if($(this).val() == '')$(this).val('Email');});
	$('.produto-compra-telefone').focus(function(){if($(this).val() == 'Telefone')$(this).val('');}).blur(function(){if($(this).val() == '')$(this).val('Telefone');});
}


function printWebPart(tagid){
    if (tagid) {
        //build html for print page
        var html = "<HTML>\n<HEAD>\n";
		html = html + '<link rel="stylesheet" type="text/css" href="_css/spc_makewisePrint.css">';
		html = html + '<script type="text/javascript" language="javascript" src="_js/jquery-1.3.2.min.js"></script><script type="text/javascript">';
		html = html + '$(document).ready(function(){$("#ctl00_masterContentPlaceHolder_ctl02").removeAttr("style");';
		html = html + '$("#ctl00_masterContentPlaceHolder_ctl02_ctl01").removeAttr("style");';
		html = html + 'var ab = $(".ajax__tab_tab").length; var abHtml = ""; for(i=0; i<ab;i++){if(i == 0){'
		html = html + 'abHtml += $(".ajax__tab_tab").eq(i).html(); alert(i)}else{'
		html = html + 'abHtml += " / " + $(".ajax__tab_tab").eq(i).html();}} $(".ajax__tab_header").empty();$(".ajax__tab_header").html(abHtml) })</script>'+
            "\n</HEAD>\n<BODY>\n"+
            $("#"+tagid).html()+
            "\n</BODY>\n</HTML>";
        //open new window
        var printWP = window.open("","printWebPart","height=550,width=572,scrollbars=yes");
		
        printWP.document.open();
        //insert content
        printWP.document.write(html);
        printWP.document.close();
        //open print dialog
        printWP.print();
    }
}

