/********************************************************************************************
    Dynamic List Menu Functions
*********************************************************************************************/
function changeList(type, country, formname, fieldname, any, city) {
    /*
    if ((type == 1 || type == 2) && browserSupport == 1) {
        if (country == '224') {
            showRow('row_city', 0);
            showRow('text_zip', 1);
        }
        else {
            //showRow('row_state', 1);
            showRow('row_city', 1);
            showRow('text_zip', 0);
        }
    }
    */


    // Popup change state window
    if (browserSupport == 0) {
        self.focus();
        window.open("/resource/state-change.php?popup=1&change=" + type + "." + country + "." + formname + "." + fieldname + "." + any + "." + ((city) ? city : ''), type, "resizable=0,status=0,toolbars=0,width=1,height=1");
        self.focus();
    }
    // No popup
    else {
        document.state_change.location = "/resource/state-change.php?popup=0&change=" + type + "." + country + "." + formname + "." + fieldname + "." + any + "." + ((city) ? city : '');
    }
}

function changeSubCategoryList(category, formname, fieldname, any) {
    // Popup change state window
    if (browserSupport == 0) {
        self.focus();
        window.open("/resource/category-change.php?popup=1&change=" + category + "." + formname + "." + fieldname + "." + any, 'FC_WIN', "resizable=0,status=0,toolbars=0,width=1,height=1");
        self.focus();
    }
    // No popup
    else {
        document.state_change.location = "/resource/category-change.php?popup=0&change=" + category + "." + formname + "." + fieldname + "." + any;
    }
}


function changeBreed(type, formname, fieldname) {
    // Popup change state window
    if (browserSupport == 0) {
        self.focus();
        window.open("/resource/breed-change.php?popup=1&change=" + type + "." + formname + "." + fieldname, 'PET_BREED', "resizable=0,status=0,toolbars=0,width=1,height=1");
        self.focus();
    }
    // No popup
    else {
        document.state_change.location = "/resource/breed-change.php?popup=0&change=" + type + "." + formname + "." + fieldname;
    }
}

function changeSubCategoryList(category, formname, fieldname, any) {
    // Popup change state window
    if (browserSupport == 0) {
        self.focus();
        window.open("/resource/category-change.php?popup=1&change=" + category + "." + formname + "." + fieldname + "." + any, 'FC_WIN', "resizable=0,status=0,toolbars=0,width=1,height=1");
        self.focus();
    }
    // No popup
    else {
        document.state_change.location = "/resource/category-change.php?popup=0&change=" + category + "." + formname + "." + fieldname + "." + any;
    }
}


function clearList(formname, fieldname) {
    eval("document." + formname + "." + fieldname + ".options.length = 0;");
}

function addListItem(formname, fieldname, pos, val, str) {
    eval("document." + formname + "." + fieldname + ".options[" + pos + "] = new Option('" + val + "','" + str + "', false, false);");
}

function setSelectedItem(formname, fieldname, pos) {
    eval("document." + formname + "." + fieldname + ".options[0] = null;");
    if (document.layers) { history.go(0); }
    eval("document." + formname + "." + fieldname + ".options[" + pos + "].selected = true;");
}

function checkHandle(handle, field) {
    if (browserSupport == 1 && handle.length > 5) {
        document.state_change.location = '/resource/check-username.php?username=' + handle + '&field=' + field;
    }
}

function validateHandle(value, handle, field) {
    if (value == 1) {
        alert('Sorry, the username "' + handle + '" that you have selected is already in use. Please select another one instead.');
        eval(field + '.focus()');
    }
}





/********************************************************************************************
    General Functions
*********************************************************************************************/
function checkBrowser() {
    // MOZ
    if (navigator.appName == 'Netscape') {
        return 0;
    }

    // NS
    //if (document.layers) { 
        //alert('NS'); 
    //    return 0; 
    //}
    // IE
    //else if (document.all) { 
        //alert('IE');
    //    return 1;
    //}
    // MOZ
    //else if (navigator.appName == 'Netscape') {
    //    return 0;
    //}
    // OPERA
    //else if (document.getElementById) {
        //alert('MOZ');
    //    return 1;
    //}
    // OTHER
    return 1;
}

function showRow(id, on_off) {
    //if (browserSupport == 1) {
        var el = document.all ? document.all[id] : document.getElementById(id);
        if(el) el.style.display = on_off ? '' : 'none';
    //}
}

var browserSupport = checkBrowser();
