function toggleFaq(i)
{
	var faqID = i*100;
	if(document.getElementById('faq'+faqID).style.display == 'block')
	{
		document.getElementById('faq'+faqID).style.display = 'none';
		document.getElementById('faq'+i).style.backgroundImage = 'url(Images/icon_mais.gif)';
	}
	else
	{
		document.getElementById('faq'+faqID).style.display = 'block';
		document.getElementById('faq'+i).style.backgroundImage = 'url(Images/icon_menos.gif)';
	}
}


function showDoisMeses()
{
	document.getElementById('doisMeses').style.display = 'block';
	document.getElementById('alerta').style.display = 'none';
}

function hideDoisMeses()
{
	document.getElementById('doisMeses').style.display = 'none';
	document.getElementById('alerta').style.display = 'block';
	document.getElementById('alerta2').style.display = 'none';
}

function showFormRegisto()
{
	document.getElementById('formRegisto').style.display = 'block';
	document.getElementById('alerta').style.display = 'none';
}

function hideFormRegisto()
{
	document.getElementById('formRegisto').style.display = 'none';
	document.getElementById('alerta2').style.display = 'block';
	document.getElementById('alerta').style.display = 'none';
}

function showLocal()
{
	document.getElementById('nLocal').style.display = 'block';
	document.getElementById('nFiscal').style.display = 'none';
}

function showFiscal()
{
	document.getElementById('nLocal').style.display = 'none';
	document.getElementById('nFiscal').style.display = 'block';
}

function colorText(id, color, a)
{
	$(id).style.color = color;
	$(a).style.textDecoration = 'underline';
}

function decolorText(id, color, a)
{
	$(id).style.color = color;
	$(a).style.textDecoration = 'none';
}

function bigTooltip()
{
	document.getElementById('dhtmltooltip').style.backgroundImage = "url(Images/bg_tooltip2.gif)";
	document.getElementById('dhtmltooltip').style.height = "102px";
}

function smallTooltip()
{
	document.getElementById('dhtmltooltip').style.backgroundImage = "url(Images/bg_tooltip.gif)";
	document.getElementById('dhtmltooltip').style.height = "45px";
}

function counterUpdate(opt_countedTextBox, opt_countBody, maxSize) 
{
    var field = document.getElementById(opt_countedTextBox);
    var txtField = document.getElementById(opt_countBody);

    if (field && field.value.length >= maxSize) 
        {
            field.value = trim(field.value).substring(0, maxSize);
        }

        var lines = field.value.split('\n');
        if (lines.length > 7) {
            while (lines.length > 7)
                lines.pop();

            field.value = lines.join('\n').trim(); 
        }
  
        
    txtField.innerHTML = maxSize - field.value.length;
}

function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
