


/**
 * FILE: contact.jsp
 * DESCRIPTION: This file contains javascript functions used by all contact.jsp pages
 * CREATED: 02/03/2001
**/

/**
 * build query string for success url
 */
function buildSuccessURL(baseURL){
    var isIe = navigator.appName.indexOf("Microsoft") >= 0;
    var qs = "?";
    for (var i=0; i < document.form.elements.length; i++){
        var paramName = document.form.elements[i].name;
        var paramValue = document.form.elements[i].value;
		// don't capture custom fields, org id, or anything with http in it
        if (paramName.indexOf('00N') == -1 && paramName.indexOf('oid') == -1 && paramValue != null && paramValue.indexOf('http') == -1){
            qs = qs + paramName +"="+ escape( isIe ? escape(document.form.elements[i].value) : document.form.elements[i].value) + "&";
        }
    }
    return baseURL + qs;
}

/**
 * perform redirect if country changed (used on US and IE)
 */
function assertCountryRedirect(){
    var selectedCountry = document.form.country[document.form.country.selectedIndex].value;
    var redirectURL = null;
    if(selectedCountry == '') 
        return false;

    // if owned by US, redirect to US contact
    var countries = Country.getCountries();
    for (var i = 0; i < countries.length; i++){
        if(selectedCountry == countries[i].getIsoCode()) {
            redirectURL = "/" + countries[i].getSignupPath().toLowerCase() + "/orderEntry/contact.jsp";
            break;
        } 
    }

    document.form.action=redirectURL+"?country="+selectedCountry;
    document.form.submit();
    return true;
}

