/**
* Internally used to prepare Post data.
* If the form is submited with &lt;input type=submit|image&gt;,
* submitButton is a reference to the DHTML object. Otherwise - undefined.
*/
function preparePostData(formId, submitButton) {
    var form = document.getElementById(formId);
    var result = "xmlrequest=true";
    for (var i = 0; i < form.elements.length; i++) {
        var el = form.elements[i];
        if (el.tagName.toLowerCase() == "select") {
            for (var j = 0; j < el.options.length; j++) {
                var op = el.options[j];
                if (op.selected)
                    result += "&" + encodeURIComponent(el.name) + "=" + encodeURIComponent(op.value);
            }
        } else if (el.tagName.toLowerCase() == "textarea") {
            result += "&" + encodeURIComponent(el.name) + "=" + encodeURIComponent(el.value);
        } else if (el.tagName.toLowerCase() == "input") {
            if (el.type.toLowerCase() == "checkbox" || el.type.toLowerCase() == "radio") {
                if (el.checked)
                    result += "&" + encodeURIComponent(el.name) + "=" + encodeURIComponent(el.value);
            } else if (el.type.toLowerCase() == "submit") {
               if (el == submitButton) {// is "el" the submit button that fired the form submit?
                    result += "&" + encodeURIComponent(el.name) + "=" + encodeURIComponent(el.value);
               }
            } else if (el.type.toLowerCase() != "button") {
                result += "&" + encodeURIComponent(el.name) + "=" + encodeURIComponent(el.value);
            }
        }
    }
    if(submitButton != '') {
    	var button = document.getElementById(submitButton);
    	result += "&" + encodeURIComponent(button.name) + "=" + encodeURIComponent(button.value);
    /*
    if (typeof submitButton != 'undefined' && submitButton != null && submitButton.type.toLowerCase() == "image") {
        if (submitButton.name == null || submitButton.name == "" || typeof submitButton.name == "undefined")
            result += "&x=1&y=1"; // .x and .y coordinates calculation is not supported.
        else
            result += "&" + encodeURIComponent(submitButton.name) + ".x=1&" +
                      encodeURIComponent(submitButton.name) + ".y=1";
    }*/
    }
    return result;
}


function openPopup(url,width,height){
	//alert("url"+url);
	window.open(url,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width='+width+',height='+height+',top=100,left=100')
}

function openPopupOpciones(url,width,height,texto){
	child = window.open(url,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width='+width+',height='+height+',top=150,left=700');

}


function enviado() {
	if (cuenta == 0)
	{
		cuenta++;
		return true;
	}
	else
	{
		alert("Enviando formulario, por favor aguarde un instante.");
		return false;
	}

}
