
$(document).ready(function()
{
	$('#jobAlertWindow').Draggable(
	{
		zIndex: 	20,
		ghosting:	false,
		opacity: 	0.7,
		handle:	'#jobAlertHandle'
	}
);	

$("#windowClose").click(function(){
	$("#jobAlertWindow").hide();
}

);
$("#jobAlertWindow").hide();
			

});


function jobalertShow() {
	document.getElementById('jobAlert').style.display = 'block';
}

function jobAlertClose() {
	document.getElementById('jobAlert').style.display = 'none';
}

function validZip() {
	
	if(document.jobalert.zip.value.length == 5) {
		$.post("/cityfromzip.php",{
		  zip: document.jobalert.zip.value
		},function(ret){
			if(ret != '') {
				
			}
			else {
				alert('That is not a valid zip code');
				document.jobalert.zip.value = '';
				document.jobalert.zip.focus();
			}
		});
	}
}

function jobAlertSubmit() {
	var list = '';

    for(var i = 0; i < document.jobalert.industry.options.length; i++) {
		if(document.jobalert.industry.options[i].selected) {
			list = list + document.jobalert.industry.options[i].value + ', ';
		}
	}
	
	var signup;
	if(document.jobalert.third_party_opt.checked) {
		signup = 1;
	}
	else {
		signup = 0;
	}
	
	$.getJSON("/misc/jobAlert",{
	  email: document.jobalert.email.value,
	  zip: document.jobalert.zip.value,
	  industry: list,
	  third_party_opt: signup
	},function(ret){
		if(ret['job_alert_id'] > 0) {
			alert('Job Alert Sign Up Successful!');
			$('#jobAlertWindow').hide();
		}
		else{
			alert(ret['error']);
		}
	});
}

function jobAlertReset() {
	document.forms["jobalert"].reset();
}