function setActionValue(button){    
    document.formulario.action_field.value = button.value;
}

function validateLogin()
{
    var user = document.getElementById("subformEmail");
    var pass = document.getElementById("subformPassword");
    
    if(user.value == "")
    {
        alert("Please enter your e-mail address.");
        
        return false;
    }
    if(pass.value == "")
    {
        alert("Please enter your password.");
        
        return false;
    }
    
    return true;
}

function jobPreview(base_url){
	WYSIWYG.updateTextArea('description');
	
    //tinyMCE.triggerSave();
    var html = "", i;
    var c = document.formulario.description.value; //tinyMCE.getContent();
    //var pos = c.indexOf('<body'), pos2, css = tinyMCE.getParam("content_css").split(',');
	/*var pos = 0;
	
    if (pos != -1) {
        pos = c.indexOf('>', pos);
        pos2 = c.lastIndexOf('</body>');
        c = c.substring(pos + 1, pos2);
    }
    */
    var name = document.formulario.jobTitle.value;
    var responseEmail = document.formulario.contactEmail.value;
    var city = document.formulario.city.value;
    var state = document.formulario.state.options[document.formulario.state.selectedIndex].text;
    var contractPosition = document.formulario.contractPosition[0].checked?
        document.formulario.contractPosition[0].value :
        document.formulario.contractPosition[1].value;
    //var description = document.formulario.description.value;
    var description = c;
    
    /*testwindow= window.open (base_url + "/system/application/views/job_preview.php?name="+ name
                             + "&location=" + location
                             +"&responseEmail="+responseEmail
                             +"&contractPosition="+ contractPosition
                             +"&description=" + description, "mywindow",
    "location=1,status=1,scrollbars=1,width=400,height=480");
    */
    testwindow= window.open ("", "mywindow", "location=1,status=1,scrollbars=1,width=400,height=480");
    testwindow.moveTo(100,100);
    //alert(name + ", " + subject+ ", " +responseEmail+ ", " +location+ ", " + contractPosition + ", " + description);
    
    html += '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
    html += '<html xmlns="http://www.w3.org/1999/xhtml">';
    html += '<head>';
    html += '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />';
    html += '<title>SoftwareTestingJobs.net</title>';
    html += '</head>';
    html += '<body>';
    html += '<style>';
    html += '#formTitle{';
    html += 'border-bottom: 1px solid #fdbb3a;';
    html += 'font-family: Verdana;';
    html += 'font-size: 11pt;';
    html += 'font-weight: bold;';
    html += 'margin-bottom: 15px;';
    html += 'text-align: center;';
    html += '}';
    html += '#label{';
    html += 'font-weight: bold;';
    html += '}';
    html += '#field{';
    html += 'margin: 0 0 5px 0;';
    html += 'font-size: 10pt;';
    html += 'font-style: italic;';
    html += '}';
    html += '</style>';
    html += '</style>';
    html += '<div id="formTitle">Job Description</div>';
    html += '<div id="job">';
    html += '<div id="label">Title:</div>';
    html += '<div id="field">'+ name + '</div>';
    html += '<div id="label">City:</div>';
    html += '<div id="field">'+ city +'</div>';
    html += '<div id="label">State:</div>';
    html += '<div id="field">'+ state +'</div>';
    html += '<div id="label">Response Email:</div>';
    html += '<div id="field">'+ responseEmail + '</div>';
    html += '<div id="label">Contract Position:</div>';
    html += '<div id="field">' + contractPosition + '</div>';
    html += '<div id="label">Description:</div>';
    html += '<div id="field">' + description + '</div>';
    html += '</div>';
    html += '<p><a href="#" onclick="window.close();">Close window</a>';
    html += '</body>';
    html += '</html>';
    testwindow.document.write(html);
    testwindow.document.close();
}

function openwindow(title,url){    
    window.open(url,'',"resizable=1,toolbar=1,menubar=1,directories=1,location=1,status=1,scrollbars=1,width=640,height=480");    
}
