var ajaxObj = new XMLHTTP("ajax.php");
ajaxObj.abort_timeout = 30000;

var c="abcdfghjklmnpqrstvwxyz";
var v="aeiou";
var n="0123456789";
var s="!@#$%^&*()-+";

function setIdCongressesVisitorsType(strValue) {
    var objIdCongressesVisitorsType = document.getElementById("idCongressesVisitorsType");

    objIdCongressesVisitorsType.value = strValue;
}

function getVisitorPrice(intIdCongress, intIdVisitorType, strDate) {
    var url  = "action=ajax/admin/getVisitorPrice";
        url += "&idCongress=" + intIdCongress;
        url += "&idVisitorType=" + intIdVisitorType;
        url += "&date=" + strDate;

    ajaxObj.format = "JSON";
    ajaxObj.call(url, function(result) {
        if (result) {
            $("price").value = result;
        } else {
            $("price").value = "0";
        }
    });
}

function makeRand(max) {
	return Math.floor(Math.random()*max);
}

function generatePassword(intLength, blnIncludeNumbers, blnIncludeSpecials) {
	var o=""+v+v+v;
	if (blnIncludeNumbers) o+=n+v;
	if (blnIncludeSpecials) o+=s+v;
	if (""==o) o=v;

	var pw="";
	var p=3;
	for (var i=0; i<intLength; i++) {
		switch (i%p) {
		case 0:
            pw+=c.substr(makeRand(21), 1);
            break;
        default:
			pw+=o.substr(makeRand(o.length), 1);
			break;
		}
	}
	return pw;
}

function updatePassword() {
    var pass = generatePassword(6, false, false);

    document.getElementById("password").value = pass;
}