function open_popup(passed_url, passed_width, passed_height) 
{
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(passed_url,'" + id + "','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=' + passed_width + ',height=' + passed_height);");
}

function open_cars_com(passed_url, passed_width, passed_height) 
{
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(,'" + id + "','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=' + passed_width + ',height=' + passed_height);");
}

function open_site_seal(url) 
{
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(url,'" + id + "','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=540,height=435');");
}

function check_header_used() 
{
    error_message = "";

    if(document.getElementById('ddl_used_make').selectedIndex == 0)
        error_message += "Please select a make.\n";

    if(document.getElementById('ddl_used_model').selectedIndex == 0)
        error_message += "Please select a model.\n";

    if (!IsZipcode(document.getElementById('used_zip_code').value))
        error_message += "Please enter a valid zip code.\n";

    if(error_message != "") 
    {
        error_message = "Please Fix the following Field(s):\n\n" + error_message;
        alert(error_message); 
        return false; 
    } 
    
    return true; 
}

function post_to_url(path,params,method){
	method=method||"post";
	var form=document.createElement("form");
	form.setAttribute("method",method);
	form.setAttribute("action",path);
	for(var key in params){
		var hiddenField=document.createElement("input");
		hiddenField.setAttribute("type","hidden");
		hiddenField.setAttribute("name",key);
		hiddenField.setAttribute("value",params[key]);
		form.appendChild(hiddenField);
	}
	document.body.appendChild(form);
    form.submit();
}

//***** REDIR POST FUNCTION *****//
function post_url_to_new_window(path, params, method) {
    method = method || "post"; // Set method to post by default, if not specified.
    var form = document.createElement("form");
    form.setAttribute("method", method);
    form.setAttribute("action", path);
    form.setAttribute("target","_blank")
    for (var key in params) {
        var hiddenField = document.createElement("input");
        hiddenField.setAttribute("type", "hidden");
        hiddenField.setAttribute("name", key);
        hiddenField.setAttribute("value", params[key]);

        form.appendChild(hiddenField);
    }
    document.body.appendChild(form);    // Not entirely sure if this is necessary
    form.submit();
}

