function createRequestObject(){
	var request_o; 
	var browser = navigator.appName; 
	if(browser == "Microsoft Internet Explorer"){
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_o = new XMLHttpRequest();
	}
	return request_o;
}

var http = createRequestObject(); 

/* Function creates thumbnail list */

function findbooth(n){
	var bn = eval("document.form1.booth" + n + ".value");
	http.open('get', 'findbooth.asp?boothno=' + bn + '&q=' + n);
	
	http.onreadystatechange = handleboothsearch; 
	http.send(null);
}

function handleboothsearch(){
	if(http.readyState == 4){ 
		var response = http.responseText;
		
		if(response > '') {
			document.getElementById('boothcheck').innerHTML = response;	
		}
	}
}

function addboothperson() {
	var fnme = document.form1.firstName.value;
	document.form1.firstName2.value = fnme;
	
	var lnme = document.form1.lastName.value;
	document.form1.lastName2.value = lnme;
	
	var title = document.form1.title.value;
	document.form1.title2.value = title;
	
	var add1 = document.form1.address1.value;
	document.form1.bp_address1.value = add1;
	
	var add2 = document.form1.address2.value;
	document.form1.bp_address2.value = add2;
	
	var cty = document.form1.city.value;
	document.form1.city2.value = cty;
	
	var st = document.form1.ste.value;
	document.form1.ste2.value = st;
	
	var zi = document.form1.zip.value;
	document.form1.zip2.value = zi;
	
	var selectIndex = document.form1.country.selectedIndex;
	document.form1.bp_country.selectedIndex = selectIndex;
	
	var ph = document.form1.phone.value;
	document.form1.phone2.value = ph;
	
	var fx = document.form1.fax.value;
	document.form1.fax2.value = fx;
	
	var em = document.form1.email.value;
	document.form1.email2.value = em;
}

function copymarketing() {
	var add1 = document.form1.company.value;
	document.form1.company3.value = add1;
	
	var add1 = document.form1.address1.value;
	document.form1.cm_address1.value = add1;
	
	var add2 = document.form1.address2.value;
	document.form1.cm_address2.value = add2;
	
	var cty = document.form1.city.value;
	document.form1.city3.value = cty;
	
	var st = document.form1.ste.value;
	document.form1.ste3.value = st;
	
	var zi = document.form1.zip.value;
	document.form1.zip3.value = zi;
	
	var selectIndex = document.form1.country.selectedIndex;
	document.form1.cm_country.selectedIndex = selectIndex;
	
	var ph = document.form1.phone.value;
	document.form1.phone3.value = ph;
	
	var fx = document.form1.fax.value;
	document.form1.fax3.value = fx;

}

function newWindow(n){
	new_window = window.open('' + n + '',null,'width=750,height=620,left=0,top=0,resizable');
	new_window.focus();
	
}


function getNumber() {
var formname = eval("document.form1.qty.value");
var no = parseInt(formname);
var n = 0;
var inserttable = '';


if(isNaN(no)) {
	var message = "<br><b>Please fill in a quantity and reselect your booth style.</b>";
} else {
	var message = "<br><b>Please fill in your booth numbers below (<a href=\"#1\" onClick=\"newWindow('floorplanLayout.html')\" >Click here to view available Booths</a>)</b><br>";
    	for (i=0; i < no; i++) {
			n = n + 1;
			inserttable += 'Space Number ' + n + ': <input type="text" name="booth' + n + '" id="booth" onBlur="findbooth(' + n + ');"  maxlength="4" /><br>';
   	   }
}
document.getElementById('attendees').innerHTML = message+inserttable;


}

// Admin Section

function updateDB(r,f) {
	var dbrecord = eval("document.form1." + r + ".value");
	var id = document.form1.recordno.value;
	var tdate = document.form1.tdate.value;
	http.open('get', 'updateDB.asp?tdate=' + tdate + '&dbfield=' + f + '&dbrecord=' + dbrecord + '&id=' + id);
	
	http.onreadystatechange = handleupdatedb; 
	http.send(null);
	
}

function handleupdatedb(){
	if(http.readyState == 4){ 
		var response = http.responseText;
		document.getElementById('updated').innerHTML = "Updated" + response;	
	}
}


function deleteInvoice(n,i) {
	http.open('get', 'deleteInvoice.asp?Recno=' + n + '&id=' + i);
	
	http.onreadystatechange = handledeleteInvoice; 
	http.send(null);
	
}

function handledeleteInvoice(){
	if(http.readyState == 4){ 
		var response = http.responseText;
		document.getElementById('invoices').innerHTML = response;	
	}
}


function deletePayment(n,i) {
	http.open('get', 'deletePayment.asp?Recno=' + n + '&id=' + i);
	
	http.onreadystatechange = handledeletePayment; 
	http.send(null);
	
}

function handledeletePayment(){
	if(http.readyState == 4){ 
		var response = http.responseText;
		document.getElementById('paytable').innerHTML = response;	
	}
}


function enterPayment() {
	var PayAmt = document.form1.paymentAmount.value;
	var CheckNo = document.form1.checkNo.value;
	var id = document.form1.recordno.value;
	var tdate = document.form1.chkdate.value;
	http.open('get', 'enterPayment.asp?tdate=' + tdate + '&PayAmt=' + PayAmt + '&CheckNo=' + CheckNo + '&id=' + id);
	
	http.onreadystatechange = handleupdatedb; 
	http.send(null);
	
}

function handleupdatePayment(){
	if(http.readyState == 4){ 
		var response = http.responseText;
		document.getElementById('payments').innerHTML = response;	
	}
}

