window.onload = loadDispatcher;

function $(myID){
	if(document.getElementById(myID)){
		return document.getElementById(myID);	
	}else{
		return false;	
	}
}

var isBusy = false;
function createRequestObject() {
	var XmlHttpRequestObject;
	if (typeof XMLHttpRequest != "undefined"){
		XmlHttpRequestObject = new XMLHttpRequest();
	}
	else if (window.ActiveXObject){
	// look up the highest possible MSXML version
		var tryPossibleVersions=["MSXML2.XMLHttp.5.0",
		"MSXML2.XMLHttp.4.0",
		"MSXML2.XMLHttp.3.0",
		"MSXML2.XMLHttp",
		"Microsoft.XMLHttp"];

		for (i=0; i< tryPossibleVersions.length; i++){
			try{
				XmlHttpRequestObject = new ActiveXObject(tryPossibleVersions[i]);
				break;
			}
				catch (xmlHttpRequestObjectError){
			}
		}
	}
	return XmlHttpRequestObject;
}

var forEval = '';

function delayEval(){
	eval(forEval);
	forEval = '';	
	
}

function resetBusy(){
	isBusy = false;	
}



function timeStamp(){
	var now = new Date();
	return "?timestamp="+now.getTime();
}

function showLoading(){
	var loadImage = '<img id="loadingImage" src="./systemImages/loading.gif" alt="Please Wait...Loading" />';
	if($('tplMainContentDiv')){
		$('tplMainContentDiv').innerHTML = loadImage;
	}
}

function hideLoading(){
	if($('tplMainContentDiv')){
		$('tplMainContentDiv').innerHTML = '';
	}
}

var forOpacity = '';
var newLabelImage = '';
function blankOpacity(){
	clearTimeout(mainTO);
	if (navigator.appName.indexOf("Microsoft")!=-1) {
		$(forOpacity).style.filter = 'alpha(opacity=0)';	
	}else{
		$(forOpacity).style.opacity = 0.0;
	}	
	$(forOpacity).src = './admin/images/'+newLabelImage;
	newLabelImage = '';	
	mainTO = setTimeout('halfOpacity()', 35);
	
}

function halfOpacity(){
	clearTimeout(mainTO);
	//$(forOpacity).style.display = '';
	if (navigator.appName.indexOf("Microsoft")!=-1) {
		$(forOpacity).style.filter = 'alpha(opacity=50)';	
	}else{
		$(forOpacity).style.opacity = 0.5;
	}	
	mainTO = setTimeout('fullOpacity()', 35);
}


function fullOpacity(){
	clearTimeout(mainTO);
	if (navigator.appName.indexOf("Microsoft")!=-1) {
		$(forOpacity).style.filter = 'alpha(opacity=100)';	
	}else{
		$(forOpacity).style.opacity = 1.0;
	}	
	forOpacity = '';
}

function resetOpacity(resetWho){
	clearTimeout(mainTO);
	if (navigator.appName.indexOf("Microsoft")!=-1) {
		resetWho.style.filter = 'alpha(opacity=100)';	
	}else{
		resetWho.style.opacity = 1.0;
	}	
	forOpacity = '';
}

var mainTO;

function fadeInImage(toWhere, myImage){
	if($(toWhere)){
		forOpacity = toWhere;
		newLabelImage = myImage;
		blankOpacity();
		
		
	}	
}

function insertToMain(insertWhat){
	if($('tplMainContentDiv')){
		$('tplMainContentDiv').innerHTML = insertWhat;
	}
}

function insertToThumbs(insertWhat){
	if($('tplRightMenuDiv')){
		$('tplRightMenuDiv').innerHTML = insertWhat;
	}
}

function insertBookTitleLabel(insertWhat){
	if(insertWhat == 'BOOKS'){
		insertWhat = '<img src="./systemImages/booksLabel.gif" alt="Books" />';	
	}
	if($('tplBooksNavHeaderText')){
		$('tplBooksNavHeaderText').innerHTML = insertWhat;
		if(insertWhat == ''){
			$('tplBooksNavHeaderText').style.display = 'none';
		}else{
			$('tplBooksNavHeaderText').style.display = '';
		}
	}
}

function insertBookTitle(insertWhat){
	if($('tplBooksLabel')){
		if(insertWhat != ''){
			$('tplBooksLabel').innerHTML = '<img id="topTplBooksLabelImg" src="./admin/images/'+insertWhat+'" alt="" />';
		}
		if(insertWhat == ''){
			$('tplBooksLabel').style.display = 'none';
		}else{
			$('tplBooksLabel').style.display = '';
		}
	}
}

function setBookColour(newColour){
	if($('tplBooksLabel')){
		$('tplBooksLabel').style.color = newColour;
	}
}


function insertTopBookLinks(insertWhat){
	if($('tplAvailableGalleries')){
		$('tplAvailableGalleries').innerHTML = insertWhat;
	}
}

function switchTopBookLabelImage(myBookID){
	if($('topTplBooksLabelImg')){
		if(bookLabelImageH[myBookID]){
				$('topTplBooksLabelImg').src = bookLabelImageH[myBookID].src;
		}
		
	}	
}

function dynamicBookTitle(newTitle, newColour){
	if(!$('tplBooksLabel') || parseInt(newTitle)<1){
		insertBookTitle(newTitle);
		setBookColour(newColour);
	}else{
		switchTopBookLabelImage(newTitle);	
	}
}

function showDefaultTitle(){
	if($('defaultTitleText')){
		insertBookTitle($('defaultTitleText').value);	
	}
	if($('defaultTitleColour')){
		//setBookColour($('defaultTitleColour').value);
	}
}


function addToThumbsSection(addWhat){
	if($('thumbsListDiv')){
		$('thumbsListDiv').innerHTML = addWhat;	
	}
}

var labelSectionText = new Image();

var labelSectionTextH = new Image();



function loadDispatcher(e){
	if(!e){var e = window.event;}
	ajaxLoadBooks();
	labelSectionTextH.src = './systemImages/thumbsLabelH.gif';
	labelSectionText.src = './systemImages/thumbsLabel.gif';
}

function pageReset(){
	ajaxLoadBooks();
}

function changeBanner(changeTo){
	if($('bannerImage')){
		$('bannerImage').src = './systemImages/banner'+changeTo+'.gif';
	}	
}

function changeHighlight(newHighlight){
	var knt = 0;
	var num = 15;
	if($('numberOfImages')){
		num = $('numberOfImages').value;
	}
	for(knt = 0; knt <= num; knt++){
		if(knt != newHighlight){
			if($('thumbNail'+knt)){
				$('thumbNail'+knt).className = 'inactiveThumbDiv';	
			}	
		}else{
			$('thumbNail'+knt).className = 'activeThumbDiv';	
			
		}
	}	
}
var currentOpacity = 10;
var slideShowTO;
function fadeOut(){
	clearTimeout(slideShowTO);
	currentOpacity = currentOpacity - 1;
	var currentObject = 'showCaseImage';
	var testObj = $(currentObject);
	
	if (navigator.appName.indexOf("Microsoft")!=-1) {
		testObj.style.filter = 'alpha(opacity=' + (currentOpacity*10) + ')';
	}else{
		testObj.style.opacity = parseFloat(parseFloat(currentOpacity)/10);;
	}
	$('currentOpacity').value = currentOpacity;

	if(currentOpacity >= 1){
		slideShowTO = setTimeout('fadeOut()', 35);
	}else{
		
		return;
	}
}

function defuse(){
	if($('ssMode').value == '1'){
		clearTimeout(slideShowTO);
		currentOpacity = currentOpacity - 1;
		var currentObject = 'showCaseImage';
		var testObj = $(currentObject);
		
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			testObj.style.filter = 'alpha(opacity=' + (currentOpacity*10) + ')';
		}else{
			testObj.style.opacity = parseFloat(parseFloat(currentOpacity)/10);;
		}
		$('currentOpacity').value = currentOpacity;
	
		if(currentOpacity >= 1){
			slideShowTO = setTimeout('defuse()', 35);
		}else{
			slideShowTO = setTimeout('switchImage()', 35);
			return;
		}
	}else{
		clearTimeout(slideShowTO);
		stopSlideShow();	
	}
}

function switchImage(){
	clearTimeout(slideShowTO);
	//$('showCaseImage').style.display = 'none';
	eval($('slideShowAssist').value);
	//$('showCaseImage').style.display = '';
	slideShowTO = setTimeout('infuse()', 35);
}

function infuse(){
	if($('ssMode').value == '1'){
		clearTimeout(slideShowTO);
		var currentObject = 'showCaseImage';
		currentOpacity = parseFloat(currentOpacity + 1.0);
		$('currentOpacity').value = currentOpacity;
		if($(currentObject)){
			var testObj = $(currentObject);
			if (navigator.appName.indexOf("Microsoft")!=-1) {
				testObj.style.filter = 'alpha(opacity=' + (currentOpacity*10) + ')';
			}else{
				testObj.style.opacity = parseFloat(currentOpacity)/10;
			}
		}
		if(currentOpacity < 10){
			slideShowTO = setTimeout('infuse()', 35);
		}else{	
			slideShowTO = setTimeout('defuse()', 4000);
			return;
		}
	}else{
		clearTimeout(slideShowTO);
		stopSlideShow();		
	}
}


function startSlideShow(){
	clearTimeout(slideShowTO);
	if($('slideShowButtonDiv')){
		$('slideShowButtonDiv').innerHTML = "<a onclick=\"stopSlideShow(); return false;\" style=\"background-image: url('../systemImages/stopSlideShow.gif'); color: #FFFFFF;\" class=\"slideShowButtonLinkText\" href=\"#\">SLIDESHOW&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>";
	}
	$('ssMode').value = '1';
	defuse();
}

function stopSlideShow(){
	clearTimeout(slideShowTO);
	$('ssMode').value = '0';
	clearTimeout(slideShowTO);
	var currentObject = 'showCaseImage';
	if($(currentObject)){
		var testObj = $(currentObject);
		currentOpacity = parseFloat(10.0);
		$('currentOpacity').value = currentOpacity;
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			testObj.style.filter = 'alpha(opacity=' + (currentOpacity*10) + ')';
		}else{
			testObj.style.opacity = parseFloat(currentOpacity)/10;
		}
	}
	if($('slideShowButtonDiv')){
		$('slideShowButtonDiv').innerHTML = "<a onclick=\"startSlideShow(); return false;\" style=\"background-image: url('../systemImages/startSlideShow.gif');\" class=\"slideShowButtonLinkText\" href=\"#\">SLIDESHOW&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>";
	}
	clearTimeout(slideShowTO);	
}


function loadFullImage(newImageID, newImage, imageHeight, newHighlight){
	
	isBusy = true;
	var myPath = new String(newImage);
	//showLoading();
	changeHighlight(newHighlight);
	if(myPath.indexOf('/thumbs/')){
		myPath = myPath.replace('/thumbs/', '/');	
	}
	//alert(myPath);
	var newFullImage = new Image();
	var forMain = '';
	newFullImage.src = myPath;
	var margin = parseInt((400-imageHeight)/2);
	if(!margin){
		var margin = 0;
	}
	
	
	if($('showCaseImage')){
		
		if(newImageID>0 && galleryImage[newImageID]){
			$('showCaseImage').src = galleryImage[newImageID].src;	
		}else{
			$('showCaseImage').src = myPath;
		}
		$('showCaseImage').style.marginTop = margin+'px';
	}else{
		if(null == galleryImage[newImageID]){
			galleryImage[newImageID] = newFullImage;
		}
		if($('ssMode').value == '0'){
			forMain = '<img id="showCaseImage" src="'+myPath+'" style="alpha(opacity=100); opacity:1.0; margin-top:'+margin+'px;" alt="" />';
		}else{
			forMain = '<img id="showCaseImage" src="'+myPath+'" style="alpha(opacity=0); opacity:0.0; margin-top:'+margin+'px;" alt="" />';	
			infuse();
		}
		insertToMain(forMain);
	}
	if(null == galleryImage[newImageID]){
			galleryImage[newImageID] = newFullImage;	
	}
	if($('bookID')){
		 ajaxLoadBottomNav(newImage);
	}
	setTimeout('resetBusy()', 300);
}

function hideHomeLink(){
	if($('tplBottomLeftLinkDiv')){
		$('tplBottomLeftLinkDiv').style.display = 'none';
	}
}

function showHomeLink(){
	if($('tplBottomLeftLinkDiv')){
		$('tplBottomLeftLinkDiv').style.display = '';
	}
}


var httpLBR = createRequestObject();
var httpLBN = createRequestObject();
var httpLBIO = createRequestObject();
var httpLBBID = createRequestObject();
var httpLLBBID = createRequestObject();
var httpLCON = createRequestObject();
var httpSCON = createRequestObject();

// Load Books Request
function ajaxLoadBooks(){
	clearTimeout(mainTO);
	showLoading();
	if(httpLBR){
		if(isBusy){ 
			httpLBR.onreadystatechange = function (){
				httpLBR = createRequestObject();
			}
			httpLBR.abort();
		}
		isBusy = true;
		var doWhat = "./RPCs/rpcShowBookList.php";
		doWhat += timeStamp();
		httpLBR = createRequestObject();
    	httpLBR.open('GET', doWhat, true);
    	isBusy = true;
    	httpLBR.onreadystatechange = handleLBRResponse;
		httpLBR.send(null);
	}
}
var bookLabelImageH = new Array();
var galleryImage = new Array();
//Handle Load Books Response
function handleLBRResponse() {
    if(httpLBR){
		if(httpLBR.readyState == 4){
        	var response = httpLBR.responseText;
        	var d;
        	update = response.split('|~|');
        	clearTimeout(d);
        	if(response!="ERROR"){
        		addToThumbsSection('');
	        	stopSlideShow();
				hideHomeLink();
	        	changeBanner('');
	        	insertToMain(update[0]);
	        	insertToThumbs(update[1]);
	        	insertBookTitle('');
	        	insertTopBookLinks('');
	        	insertBookTitleLabel('');
	        	if(update[2]){
		        	eval(update[2]);	
	        	}
	        	//eval(update[3]);
	        	
	        	if($('tplBottomImageNavDiv')){
		        	$('tplBottomImageNavPrevDiv').innerHTML = '';	
		        	$('tplBottomImageNavLabelDiv').innerHTML = '';	
		        	$('tplBottomImageNavNextDiv').innerHTML = '';	
	        	}
	        	if($('currentImageLabel')){
	        		$('currentImageLabel').innerHTML = '';		
        		}
	        	
    		}else{
	    		//alert(response);
    		}
        }
        isBusy = false;
	}else{}
}

// Load Books Request
function ajaxLoadBookById(action){
	clearTimeout(slideShowTO);
	showLoading();
	if(httpLBBID){
		if(isBusy){ 
			httpLBBID.onreadystatechange = function (){
				httpLBBID = createRequestObject();
			}
			httpLBBID.abort();
		}
		isBusy = true;
		var doWhat = "./RPCs/rpcLoadBookById.php";
		doWhat += timeStamp();
		doWhat += "&bookID="+action;
		doWhat += "&slideShow="+$('ssMode').value;
		httpLBBID = createRequestObject();
    	httpLBBID.open('GET', doWhat, true);
    	isBusy = true;
    	httpLBBID.onreadystatechange = handleLBBIDResponse;
		httpLBBID.send(null);
	}
}


// Load Books Request
function ajaxLoadBookById(action, sectionID){
	clearTimeout(slideShowTO);
	showLoading();
	if(httpLBBID){
		if(isBusy){ 
			httpLBBID.onreadystatechange = function (){
				httpLBBID = createRequestObject();
			}
			httpLBBID.abort();
		}
		isBusy = true;
		var doWhat = "./RPCs/rpcLoadBookById.php";
		doWhat += timeStamp();
		doWhat += "&bookID="+action;
		doWhat += "&slideShow="+$('ssMode').value;
		doWhat += "&sectionID="+sectionID;
		httpLBBID = createRequestObject();
    	httpLBBID.open('GET', doWhat, true);
    	isBusy = true;
    	httpLBBID.onreadystatechange = handleLBBIDResponse;
		httpLBBID.send(null);
	}
}

//Handle Load Books Response
function handleLBBIDResponse() {
    if(httpLBBID){
		if(httpLBBID.readyState == 4){
        	var response = httpLBBID.responseText;
        	update = response.split('|~|');
        	var d;
        	clearTimeout(d);
        	if(response!="ERROR"){
	        	clearTimeout(slideShowTO);
	        	showHomeLink();
	        	changeBanner('2');
	        	insertToThumbs(update[0]);
	        	loadFullImage(-1, update[3], update[4], 0);
	        	infuse();
	        	insertBookTitle(update[1]);
	        	insertTopBookLinks(update[2]);
	        	insertBookTitleLabel('BOOKS');
	        	forEval = update[6];
	        	setTimeout('delayEval()', 333);
	        	if($('ssMode')=='1'){
		        	if($('showCaseImage')){
	        			slideShowTO = setTimeout('startSlideShow()', 6500);
        			}else{
	        			slideShowTO = setTimeout('startSlideShow()', 7500);	
        			}
        		}
        		addToThumbsSection(update[7]);
    		}else{
	    		//alert(response);
    		}
        }
        isBusy = false;
	}else{}
}

// Load Books Request
function ajaxLoadLastBookById(action){
	showLoading();
	if(httpLLBBID){
		if(isBusy){ 
			httpLLBBID.onreadystatechange = function (){
				httpLLBBID = createRequestObject();
			}
			httpLLBBID.abort();
		}
		isBusy = true;
		var doWhat = "./RPCs/rpcLoadBookById.php";
		doWhat += timeStamp();
		doWhat += "&bookID="+action;
		doWhat += "&loadLast=1";
		httpLLBBID = createRequestObject();
    	httpLLBBID.open('GET', doWhat, true);
    	isBusy = true;
    	httpLLBBID.onreadystatechange = handleLLBBIDResponse;
		httpLLBBID.send(null);
	}
}


// Load Books Request
function ajaxLoadLastBookById(action, sectionID){
	showLoading();
	if(httpLLBBID){
		if(isBusy){ 
			httpLLBBID.onreadystatechange = function (){
				httpLLBBID = createRequestObject();
			}
			httpLLBBID.abort();
		}
		isBusy = true;
		var doWhat = "./RPCs/rpcLoadBookById.php";
		doWhat += timeStamp();
		doWhat += "&bookID="+action;
		doWhat += "&loadLast=1";
		doWhat += "&sectionID="+sectionID;
		httpLLBBID = createRequestObject();
    	httpLLBBID.open('GET', doWhat, true);
    	isBusy = true;
    	httpLLBBID.onreadystatechange = handleLLBBIDResponse;
		httpLLBBID.send(null);
	}
}

//Handle Load Books Response
function handleLLBBIDResponse() {
    if(httpLLBBID){
		if(httpLLBBID.readyState == 4){
        	var response = httpLLBBID.responseText;
        	update = response.split('|~|');
        	var d;
        	clearTimeout(d);
        	if(response!="ERROR"){
	        	showHomeLink();
	        	changeBanner('2');
	        	insertToThumbs(update[0]);
	        	insertBookTitle(update[1]);
	        	insertTopBookLinks(update[2]);
	        	insertBookTitleLabel('BOOKS');
	        	loadFullImage(-1, update[3], update[4], update[5]);
	        	forEval = update[6];
	        	setTimeout('delayEval()', 333);
        		addToThumbsSection(update[7]);
    		}else{
	    		//alert(response);
    		}
        }
        isBusy = false;
	}else{}
}


// Load Bio Request
function ajaxLoadBio(){
	showLoading();
	if(httpLBIO){
		if(isBusy){ 
			httpLBIO.onreadystatechange = function (){
				httpLBIO = createRequestObject();
			}
			httpLBIO.abort();
		}
		isBusy = true;
		var doWhat = "./RPCs/rpcLoadBio.php";
		doWhat += timeStamp();
		httpLBIO = createRequestObject();
    	httpLBIO.open('GET', doWhat, true);
    	isBusy = true;
    	httpLBIO.onreadystatechange = handleLBIOResponse;
		httpLBIO.send(null);
	}
}

//Handle Load BIO Response
function handleLBIOResponse() {
    if(httpLBIO){
		if(httpLBIO.readyState == 4){
        	var response = httpLBIO.responseText;
        	update = response.split('|~|');
        	var d;
        	clearTimeout(d);
        	if(response!="ERROR"){
	        	showHomeLink();
	        	changeBanner('');
	        	insertToMain(update[0]);
	        	insertToThumbs(update[1]);
	        	insertBookTitle('');
	        	insertTopBookLinks('');
	        	insertBookTitleLabel('');
	        	if($('tplBottomImageNavDiv')){
		        	$('tplBottomImageNavPrevDiv').innerHTML = '';	
		        	$('tplBottomImageNavLabelDiv').innerHTML = '';	
		        	$('tplBottomImageNavNextDiv').innerHTML = '';	
	        	}
	        	if($('currentImageLabel')){
	        		$('currentImageLabel').innerHTML = '';		
        		}
        		addToThumbsSection('');
    		}else{
	    		//alert(response);
    		}
        }
        isBusy = false;
	}else{}
}

// Load Image Bottom Nav
function ajaxLoadBottomNav(action){
	//showLoading();
	if(httpLBN){
		if(isBusy){ 
			httpLBN.onreadystatechange = function (){
				httpLBN = createRequestObject();
			}
			httpLBN.abort();
		}
		isBusy = true;
		var doWhat = "./RPCs/rpcLoadBottomNav.php";
		doWhat += timeStamp();
		doWhat += "&bookID="+$('bookID').value;
		doWhat += "&myImage="+action;
		httpLBN = createRequestObject();
    	httpLBN.open('GET', doWhat, true);
    	isBusy = true;
    	httpLBN.onreadystatechange = handleLBNResponse;
		httpLBN.send(null);
	}
}

//Handle Image Bottom Nav
function handleLBNResponse() {
    if(httpLBN){
		if(httpLBN.readyState == 4){
        	var response = httpLBN.responseText;
        	update = response.split('|~|');
        	var d;
        	clearTimeout(d);
        	if(response!="ERROR"){
	        	showHomeLink();
	        	if($('tplBottomImageNavDiv')){
		        	$('tplBottomImageNavPrevDiv').innerHTML = update[0];	
		        	$('tplBottomImageNavLabelDiv').innerHTML = update[1];
		        	$('tplBottomImageNavNextDiv').innerHTML = update[2];
	        	}
	        	if($('tplBottomImageNavLabelDiv')){
		        	$('tplBottomImageNavLabelDiv').style.color = update[3];
	        	}
	        	if($('currentImageLabel')){
	        		$('currentImageLabel').innerHTML = update[4];	
        		}
        		if($('slideShowAssist')){
	        		$('slideShowAssist').value = update[5];
        		}
    		}else{
	    		//alert(response);
    		}
        }
        isBusy = false;
	}else{}
}



//Load Contact
function ajaxLoadContactForm(){
	showLoading();
	if(httpLCON){
		if(isBusy){ 
			httpLCON.onreadystatechange = function (){
				httpLCON = createRequestObject();
			}
			httpLCON.abort();
		}
		isBusy = true;
		var doWhat = "./RPCs/rpcLoadContactForm.php";
		doWhat += timeStamp();
		httpLCON = createRequestObject();
    	httpLCON.open('GET', doWhat, true);
    	isBusy = true;
    	httpLCON.onreadystatechange = handleLCONResponse;
		httpLCON.send(null);
	}
}

//Load Contact
function handleLCONResponse() {
    if(httpLCON){
		if(httpLCON.readyState == 4){
        	var response = httpLCON.responseText;
        	update = response.split('|~|');
        	var d;
        	clearTimeout(d);
        	if(response!="ERROR"){
	        	showHomeLink();
	        	changeBanner('');
	        	insertToMain(update[0]);
	        	insertToThumbs(update[1]);
	        	insertBookTitle('');
	        	insertTopBookLinks('');
	        	insertBookTitleLabel('');
        		addToThumbsSection('');
	        	if($('tplBottomImageNavDiv')){
		        	$('tplBottomImageNavPrevDiv').innerHTML = '';	
		        	$('tplBottomImageNavLabelDiv').innerHTML = '';	
		        	$('tplBottomImageNavNextDiv').innerHTML = '';	
	        	}
	        	if($('currentImageLabel')){
	        		$('currentImageLabel').innerHTML = '';		
        		}	        	
    		}else{
	    		//alert(response);
    		}
        }
        isBusy = false;
	}else{}
}

// Load Image Bottom Nav
function ajaxSendContactForm(){
	if(httpSCON){
		if(isBusy){ 
			httpSCON.onreadystatechange = function (){
				httpSCON = createRequestObject();
			}
			httpSCON.abort();
		}
		isBusy = true;
		var doWhat = "./RPCs/rpcSendContactForm.php";
		doWhat += timeStamp();
		doWhat += "&fullName="+$('fullName').value;
		doWhat += "&eMail="+$('eMail').value;
		doWhat += "&jobTitle="+$('jobTitle').value;
		doWhat += "&phoneNumber="+$('phoneNumber').value;
		doWhat += "&subject="+$('subject').value;
		doWhat += "&fullMessage="+$('fullMessage').value;
		httpSCON = createRequestObject();
    	httpSCON.open('GET', doWhat, true);
    	isBusy = true;
    	httpSCON.onreadystatechange = handleSCONResponse;
		httpSCON.send(null);
		showLoading();
	}
}

//Handle Image Bottom Nav
function handleSCONResponse() {
    if(httpSCON){
		if(httpSCON.readyState == 4){
        	var response = httpSCON.responseText;
        	update = response.split('|~|');
        	var d;
        	clearTimeout(d);
        	if(response!="ERROR"){
	        	showHomeLink();
	        	changeBanner('');
	        	insertToMain(update[0]);
	        	insertToThumbs(update[1]);
	        	insertBookTitle('');
	        	insertTopBookLinks('');
	        	insertBookTitleLabel('');
	        	
        		addToThumbsSection('');
	        	if($('tplBottomImageNavDiv')){
		        	$('tplBottomImageNavPrevDiv').innerHTML = '';	
		        	$('tplBottomImageNavLabelDiv').innerHTML = '';	
		        	$('tplBottomImageNavNextDiv').innerHTML = '';	
	        	}
	        	if($('currentImageLabel')){
	        		$('currentImageLabel').innerHTML = '';		
        		}	   
        		if(update[2] == '1'){     	
					mainTO = setTimeout('ajaxLoadBooks()', 2500);
				}
    		}else{
	    		//alert(response);
    		}
        }
        isBusy = false;
	}else{}
}

