$(document).ready(function() {
	$("a#inline").fancybox({
		'autoDimensions': false,
		'width': 300,
		'height': 100
	});
	
	$('.validatedForm').validate({
		rules: {
			password_first: "required",
			password_confirm: {
				equalTo: "#password_first"
			}
		}
	});
	
	$("a[title]").tooltip({ position: 'bottom right', effect: 'fade', offset: [0, -20] });
});

function deleteEntry(type, id) {
	var del = confirm('Are you sure you want to delete this entry? Deleted resumes and jobs cannot be recovered!');
	if (del) {
		window.location = '/delete-entry.php?type=' + type + '&id=' + id;
	}
}

// ajax for displaying county lists
function ajaxobject() {
  try {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
  }
  catch (e) {
    // Internet Explorer
    try {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
      try {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e) {
        alert("Your browser does not support AJAX!");
        return false;
      }
    }
  }
  return xmlHttp;
}

// state selection changed
function statechange(selement) {
  // if the selection has length then process as state
  if( selement.value.length > 0 ) {
    countyobj = ajaxobject();

    // define ajax object response function
    countyobj.onreadystatechange=function() {
      if( countyobj.readyState==4 ) {
        // store the server response in the select element div HTML
        e = document.getElementById("countyspan")
        e.innerHTML = countyobj.responseText;
      }
    }

    // setup the county request
    if( selement.value.length > 0 ) {
      countyobj.open("GET", "/county.php?county=" + selement.value);

      countyobj.send(null)
    }
  }
  else {
    // select value is empty so clear county
    e = document.getElementById("countyspan")
    e.innerHTML = ""
  }
}
