// SCRIPT PARA ABRIR POP-UPS ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		function popWin(URL,NAME,WIDTH,HEIGHT,RESIZE,SCROLL)  // by yudi Kondo
		{
		winId = window.open(URL,NAME,'width='+WIDTH+',height='+HEIGHT+',resizable='+RESIZE+',scrollbars='+SCROLL+',menubar=no,toolbar=yes,location=no,directories=no,status=no');
				var clientWidth = screen.availWidth;
				var clientHeight = screen.availHeight;
				var xPos = (clientWidth - WIDTH)/2;
				var yPos = (clientHeight - HEIGHT)/2;
				winId.moveTo(xPos,yPos);
		}
		
// CALENDARIO DE DATAS ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$(document).ready(function(){
						   

$(".exemplo_sem_parametros").calendar();

	$(".exemplo_com_parametros").calendar({autoPopUp: 'both', 

	buttonImageOnly: true, buttonImage: 'calendar.gif', 

	buttonText: 'Calendar'});

});

// VERIFICA A FORÇA DA SENHA /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var bCheckNumbers = true;
var bCheckUpperCase = true;
var bCheckLowerCase = true;
var bCheckPunctuation = true;
var nPasswordLifetime = 365;

// Check password
function checkPassword(strPassword)
{
    // Reset combination count
    nCombinations = 0;
    
    // Check numbers
    if (bCheckNumbers)
    {
        strCheck = "0123456789";
        if (doesContain(strPassword, strCheck) > 0) 
        { 
                nCombinations += strCheck.length; 
            }
    }
    
    // Check upper case
    if (bCheckUpperCase)
    {
        strCheck = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        if (doesContain(strPassword, strCheck) > 0) 
        { 
                nCombinations += strCheck.length; 
            }
    }
    
    // Check lower case
    if (bCheckLowerCase)
    {
        strCheck = "abcdefghijklmnopqrstuvwxyz";
        if (doesContain(strPassword, strCheck) > 0) 
        { 
                nCombinations += strCheck.length; 
            }
    }
    
    // Check punctuation
    if (bCheckPunctuation)
    {
        strCheck = ";:-_=+\|//?^&!.@$£#*()%~<>{}[]";
        if (doesContain(strPassword, strCheck) > 0) 
        { 
                nCombinations += strCheck.length; 
            }
    }
    
    // Calculate
    // -- 500 tries per second => minutes 
        var nDays = ((Math.pow(nCombinations, strPassword.length) / 500) / 2) / 86400;

    // Number of days out of password lifetime setting
    var nPerc = nDays / nPasswordLifetime;
    
    return nPerc;
}

// Runs password through check and then updates GUI 
function runPassword(strPassword, strFieldID) 
{
    // Check password
    nPerc = checkPassword(strPassword);
    
     // Get controls
        var ctlBar = document.getElementById(strFieldID + "_bar"); 
        var ctlText = document.getElementById(strFieldID + "_text");
        if (!ctlBar || !ctlText)
            return;
        
        // Set new width
        var nRound = Math.round(nPerc * 100);
    if (nRound < (strPassword.length * 5)) 
    { 
        nRound += strPassword.length * 5; 
    }
    if (nRound > 100)
        nRound = 100;
        ctlBar.style.width = nRound + "%";

    // Color and text
    if (nRound > 95)
    {
        strText = "Bastante Seguro";
        strColor = "#7aa700";
    }
    else if (nRound > 75)
    {
        strText = "Seguro";
        strColor = "orange";
    }
    else if (nRound > 50)
    {
        strText = "Baixa Segurança";
        strColor = "#ffd801";
    }
    else
    {
        strColor = "red";
        strText = "Muito Baixa Segurança";
    }
    ctlBar.style.backgroundColor = strColor;
    ctlText.innerHTML = "<span style='color: " + strColor + ";'>" + strText + "</span>";
}

// Checks a string for a list of characters
function doesContain(strPassword, strCheck)
{
        nCount = 0; 

    for (i = 0; i < strPassword.length; i++) 
    {
        if (strCheck.indexOf(strPassword.charAt(i)) > -1) 
        { 
                nCount++; 
        } 
    } 

    return nCount; 
} 