/**
 * @author UAB Estina  http://www.estina.lt
 * @product Dreams CMS
 * @version 1.0
 * @coments: Last change 2009-03-09
 *
 */

function Message(message, link){
	 if (window.confirm(message)){
		window.location.href = link;
	}
}

function show(element) {
    if (element){
        obj = document.getElementById(element);
        if (obj) {
            if (obj.style.display == 'none') {
                obj.style.display = 'block';
            } else {
                obj.style.display = 'none';
            }
        }
    }
 }
 
function verify(strPassword, id){
	var nUpperCount = strPassword.replace(/[^A-Z]/g, "").length;
	var nLowerCount = strPassword.replace(/[^a-z]/g,"").length;
	var nLowerUpperCount = nUpperCount + nLowerCount;
	var nNumberCount = strPassword.replace(/[^0-9]/g, "").length;
	var nCharacterCount = strPassword.replace(/[^!@#$%^&*?_~]/g, "").length;
	
	var strenght = 0;
	if (strPassword.length <= 4 && strPassword.length > 0) {
		strenght += 5;
	} else {
		if (strPassword.length >= 8) {
			strenght += 25;
		} else {
			if (strPassword.length > 0) {
				strenght += 10;
			}
		}
	}
	
	if (strPassword.length == nLowerCount && strPassword.length !=0) {
		strenght += 10;
	} else {
		if (nLowerUpperCount != 0) {
			strenght += 20;
		}
	}
	
	if (nNumberCount >= 3) {
		strenght += 20;
	} else {
		if (nNumberCount >= 1) {
			strenght += 10;
		}
	}
	
	if (nCharacterCount > 1) {
		strenght += 25;
	} else {
		if (nCharacterCount == 1) {
			strenght += 10;
		}
	}
	
	if (nNumberCount > 0 && nLowerCount > 0 && nUpperCount > 0 && nCharacterCount > 0) {
		strenght += 5;
	} else {
		if (nCharacterCount > 0 && nNumberCount > 0 && nLowerUpperCount > 0) {
			strenght += 3;
		} else {
			if (nNumberCount > 0 && nLowerUpperCount > 0) {
				strenght += 2;
			}
		}
	}
	
	
	document.getElementById(id).innerHTML = '<b>' + Math.round(strenght*100/95) + "%</b>";
	var color = Math.round(strenght*200/95);
	document.getElementById(id).style.color = 'rgb('+(200 - color)+','+color+',0)';
    
}


