// rollover images
function swapImage(id,im) {
	document.images[id].src=im;
}

// prompt confirm delete of item
// accepts case for type of response
function confirmDelete(strCase) {
	return confirm("Are you sure you want to delete "+strCase+"?");	
}

///////////////////////////////////////////////////////////////


// prompt confirm approval and close actions
// accepts case for type of response
function confirmApprove(strCase) {
	return confirm("Confirm approval of "+strCase+"?");	
}

function confirmClose(strCase) {
	return confirm("Confirm closing of "+strCase+"?");	
}

function confirmArchive() {
	return confirm("Are you sure you are ready to archive these jobs? \n\nHit Cancel to abort.");	
}

function confirmDearchive(filename) {
	return confirm("Are you sure you want to de-archive "+filename+"? \n\nHit Cancel to abort.");	
}

function confirmClose(strCase) {
	return confirm("Are you sure you want to close "+strCase+"?");	
}

function confirmOverdueMailReminder() {
	return confirm("Send email reminder for overdue tickets now?");	
}

function confirmDeny() {
	return confirm("Are you sure you want to deny access to this technician?");	
}



///////////////////////////////////////////////////////////////


function displayResults(msg) {
	alert(msg);
}

function openWindow(URL, intWidth, intHeight) {
		newWindow = window.open(URL, "loading", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width="+intWidth+",height="+intHeight+",left=200,top=200")
		newWindow.focus();
}



///////////////////////////////////////////////////////////////
//get state and country, show relevant states by selected country
function setCountry() {

	var US=document.getElementById("USStates");
	var CAN=document.getElementById("CANStates");

	if (document.form.country.value==1) { // US
		document.form.stateCode.value = document.form.USState.value;
		
		
		US.style.display='block';
		CAN.style.display='none';
		
	} else { //CAN
		document.form.stateCode.value = document.form.CANState.value;
		
		US.style.display='none';
		CAN.style.display='block';
	}
		
}


function setState() {
	
	if (document.form.country.value==1) { // US
		document.form.stateCode.value = document.form.USState.value;
	} else { //CAN
		document.form.stateCode.value = document.form.CANState.value;
	}
	
}


// Ajax function for calling client paycodes in a drop down menu


function getXMLHTTP() {
	var xmlHttp;
	try {
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		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;
}



function getClientDropDown() {
	
	var vendor_id = document.getElementById("vendor").value;
	
	
	if (vendor_id != 'choose') {
		
		  xmlHttp = getXMLHTTP();
		  			
			xmlHttp.onreadystatechange=function(){
				  if(xmlHttp.readyState==4){
						document.getElementById("vndpaycodes").innerHTML = xmlHttp.responseText;
				  }
			}
			
			xmlHttp.open("GET","../php_lib/get_vendor_paycodes.php?vendor_id="+vendor_id,true);
			xmlHttp.send(null);
		  }
		    document.getElementById("vndpaycodes").innerHTML = "<span class=\"red\"please wait...</span>";
	} 

  
  
  

