function disableSubmit() {
        var submitted_ref = document.getElementById("submitted");
	submitted_ref.value = "1";
        return true;
}

function validate() {
        var error_str = "";
        var valid = true;
        var end = "<BR>";
        var spaces = "&nbsp;&nbsp;";
        var error_row_ref = document.getElementById("error_row");
        var error_text_ref = document.getElementById("error_txt");
        var status_msg_ref = document.getElementById("status");
        var title_ref = document.getElementById("title");
        var ss_status_ref = document.getElementById("submission_status_id");
        var category_ref = document.getElementById("category_id");
        var lake_ref = document.getElementById("lake_id");
        var first_name_ref = document.getElementById("first_name");
        var last_name_ref = document.getElementById("last_name");
        var email_ref = document.getElementById("email_address");
        var password_ref = document.getElementById("password");
        var phone_ac_ref = document.getElementById("phone_ac");
        var phone_npa_ref = document.getElementById("phone_npa");
        var phone_nxx_ref = document.getElementById("phone_nxx");
        var description_ref = document.getElementById("desc");
        var asking_price_ref = document.getElementById("asking_price");
        var picture_1_ref = document.getElementById("picture_1");
        var picture_2_ref = document.getElementById("picture_2");
        var picture_3_ref = document.getElementById("picture_3");
        var picture_4_ref = document.getElementById("picture_4");
        var picture_5_ref = document.getElementById("picture_5");
        var picture_6_ref = document.getElementById("picture_6");

        var title = trim(title_ref.value);
        if (title.length == 0) {
                valid = false;
                error_str += spaces + "Please enter the title." + end;
        }

        var category_id = category_ref.value;
        if (category_id == 0) {
                valid = false;
                error_str += spaces + "Please select the category." + end;
        }
        var asking_price = trim(asking_price_ref.value);
        if ( (asking_price.length == 0) || (asking_price == 0) ) {
                valid = false;
                error_str += spaces + "Please enter the price." + end;
	}
        var desc = trim(description_ref.value);
        if (desc.length == 0) {
                valid = false;
                error_str += spaces + "Please enter the description." + end;
	}

	
        var first_name = trim(first_name_ref.value);
        if (first_name.length == 0) {
                valid = false;
                error_str += spaces + "Please enter the seller first name." + end;
        }
        var last_name = trim(last_name_ref.value);
        if (last_name.length == 0) {
                valid = false;
                error_str += spaces + "Please enter the seller last name." + end;
        }
        var email_address = trim(email_ref.value);
        if (email_address.length == 0) {
                valid = false;
                error_str += spaces + "Please enter the seller email address." + end;
        }
        else if (!validateEmail(email_address)) {
                valid = false;
                error_str += spaces + "Please enter a valid seller email address." + end;
        }
	
	var password = trim(password_ref.value);
        if (password.length == 0) {
                valid = false;
                error_str += spaces + "Please enter a password." + end;
        }
	if (phone_ac_ref.value && phone_npa_ref.value && phone_nxx_ref.value) {
        	if (!checkPhone(phone_ac_ref.value,phone_npa_ref.value,phone_nxx_ref.value)) {
                	valid = false;
                	error_str += spaces + "Please enter a valid seller phone number." + end;
        	}
	}

	//alert("BEGINNING PIC CHECK");
        // check picture_1 a
	//alert("PIC 1 val: " + picture_1_ref.value);
        if (picture_1_ref.value != "") {
                var toks = picture_1_ref.value.split(".");
                var ext = toks[toks.length-1].toLowerCase();
                if ( (ext != "gif") && (ext != "jpeg") && (ext != "jpg") && (ext != "png") ) {
                        valid = false;
                        error_str += spaces + "Please upload a valid file type for the first picture (.gif,.jpg,.png)" + end;
                }
        }
	//alert("BEGINNING PIC 2 CHECK");
        // check picture_2 
        if (picture_2_ref.value != "") {
                var toks = picture_2_ref.value.split(".");
                var ext = toks[toks.length-1].toLowerCase();
                if ( (ext != "gif") && (ext != "jpeg") && (ext != "jpg") && (ext != "png") ) {
                        valid = false;
                        error_str += spaces + "Please upload a valid file type for the second picture (.gif,.jpg,.png)" + end;
                }
        }
        // check picture_3 
        if (picture_3_ref.value != "") {
                var toks = picture_3_ref.value.split(".");
                var ext = toks[toks.length-1].toLowerCase();
                if ( (ext != "gif") && (ext != "jpeg") && (ext != "jpg") && (ext != "png") ) {
                        valid = false;
                        error_str += spaces + "Please upload a valid file type for the third picture (.gif,.jpg,.png)" + end;
                }
        }
        // check picture_4 
        if (picture_4_ref.value != "") {
                var toks = picture_4_ref.value.split(".");
                var ext = toks[toks.length-1].toLowerCase();
                if ( (ext != "gif") && (ext != "jpeg") && (ext != "jpg") && (ext != "png") ) {
                        valid = false;
                        error_str += spaces + "Please upload a valid file type for the fourth picture (.gif,.jpg,.png)" + end;
                }
        }
        // check picture_5
        if (picture_5_ref.value != "") {
                var toks = picture_5_ref.value.split(".");
                var ext = toks[toks.length-1].toLowerCase();
                if ( (ext != "gif") && (ext != "jpeg") && (ext != "jpg") && (ext != "png") ) {
                        valid = false;
                        error_str += spaces + "Please upload a valid file type for the fifth picture (.gif,.jpg,.png)" + end;
                }
        }
        // check picture_6
        if (picture_6_ref.value != "") {
                var toks = picture_6_ref.value.split(".");
                var ext = toks[toks.length-1].toLowerCase();
                if ( (ext != "gif") && (ext != "jpeg") && (ext != "jpg") && (ext != "png") ) {
                        valid = false;
                        error_str += spaces + "Please upload a valid file type for the sixth picture (.gif,.jpg,.png)" + end;
                }
        }


	//alert("RETURNING FROM VALIDATE: " + valid);
        if (!valid) {
                status_msg_ref.style.display = "";
                status_msg_ref.innerHTML = error_str;
                scrollTo(0,0);
		return valid;
        }
        return valid;
}

function postSaveClassifiedForm(action) {
        var action_ref = document.getElementById("post_action");
        action_ref.value = action;
        //return document.feedback.submit();
	//alert("VALIDATING");
	var valid = validate();
	if (valid) {	
        	return document.forms[0].submit();
	}
	else {
		return valid;
	}
}

function postCancelClassifiedForm(action) {
        var action_ref = document.getElementById("post_action");
        action_ref.value = action;
        //return document.feedback.submit();
       	return document.forms[0].submit();
}

