function update_div(div_name, app_path, query_string) {
		
	var xmlHttpReq = false;	// Default to false just incase we can't create a req object

	if (window.XMLHttpRequest) {					// Non-IE browsers can do XMLHttpRequest
		xmlHttpReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {				// IE handles an ActiveXObject
		xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	xmlHttpReq.open('POST', app_path, true);
	xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	
	xmlHttpReq.onreadystatechange = function() {
		if (xmlHttpReq.readyState == 4) {
			updatepage(div_name, xmlHttpReq.responseText);
		}
	}
			
	xmlHttpReq.send(query_string);
}


function updatepage(div_name, html_output){
	document.getElementById(div_name).innerHTML = html_output;
}

function send_email(the_form) {
	var email_address = the_form.email_address.value;
	update_div('email_signup','src/email_signup.php','email_address='+email_address);
}

function send_form(div_name, app_path,the_form) {
	//show_screen();
	var full_app_path = app_path;
	var query_string = "";
	
	for(i=0; i<the_form.elements.length; i++) {
		//if(the_form.elements[i].type == "text" || the_form.elements[i].type == "textarea" || the_form.elements[i].type == "hidden" || the_form.elements[i].type == "radio") {
				//alert(the_form.elements[i].value);
			if(query_string != "") {
				query_string = query_string + "&";
			}
			
			if((the_form.elements[i].type == "checkbox") && (the_form.elements[i].checked == 0)) {
				continue;
			}
			
			query_string = query_string + escape(the_form.elements[i].name) + '=' + escape(the_form.elements[i].value);
		//}
	}
		
	update_div(div_name,full_app_path,query_string);
}

function send_contact(the_form) {
	send_form('contact_form','src/send_contact.php',the_form);	
}

function load_blog_archives(query) {
	update_div('blog_archives_list','src/get_blog_archives.php',query);
}

function begin_scan() {
	update_div('session_info', 'get_session.php', '');
	setTimeout("begin_scan()",2000);
}

function shift_right(div_name, shift_value) {
	var div = document.getElementById(div_name);
	var div_right;
	if(div.style.right == '') {
		div_right = 0;
	} else {
		div_right = parseInt(div.style.right);	
	}
	div_right = div_right + shift_value;
	div.style.right = div_right + 'px';
}

function shift_left(div_name, shift_value) {
	var div = document.getElementById(div_name);
	var div_left;
	if(div.style.left == '') {
		div_left = 0;
	} else {
		div_left = parseInt(div.style.left);	
	}
	div_left = div_left + shift_value;
	div.style.left = div_left + 'px';
}

