var fileContent='';
var fileLocation='';
var pageTitle='';
var xmlhttp;
var alerted;

/////////////
// Page call //
/////////////



function showConstruction() {
	pageTitle="Page Under Construction";
	showLoading();
	
	fileLocation="construction/index.php";
	// jQloadFile();
	jQloadFile();
	showTitle();
}

function showMain() {
	pageTitle="Welcome";
	showLoading();

	fileLocation="main.php";
	jQloadFile();
	showTitle();
}

////////////////////
// My Information //
////////////////////
function showResume() {
	pageTitle="<div class=\"section_date\">Last Updated: 02-23-08</div>";
	showLoading();

	fileLocation="myinfo/resume/index.php";
	jQloadFile();
	showTitle();
}

function showCoverLetter() {
	pageTitle = "<div class=\"section_date\">Last Updated: 02-23-08</div>";
	showLoading();

	fileLocation="myinfo/coverletter/index.php";
	jQloadFile();
	showTitle();
}

function showBio() {
	pageTitle = "<div class=\"section_date\">Last Updated: 03-29-08</div>";
	showLoading();

	fileLocation="myinfo/bio/index.php";
	jQloadFile();
	showTitle();
}

function showArchivePictures() {
	pageTitle = "Archive Pictures";
	showLoading();

	fileLocation="pictures/archivepictures/index.php";
	jQloadFile();
	showTitle();
}

function showArchivePictureFolder(pictureFolder) {
	pageTitle = "Archive Pictures: " + pictureFolder.replace(/_/g," ").replace(/200[0-9]\-[0-9][0-9]/,"");
	showLoading();
	
	fileLocation="pictures/archivepictures/loadpage.php?folder="+pictureFolder;
	jQloadFile();
	showTitle();
}

function showNewPictures() {
	pageTitle = "New Pictures";
	showLoading();

	fileLocation="pictures/newpictures/index.php";
	jQloadFile();
	showTitle();
}

function showPictureFolder(pictureFolder) {
	pageTitle = "New Pictures: " + pictureFolder.replace(/_/g," ").replace(/[0-9][0-9][0-9][0-9] [0-9][0-9] [0-9][0-9]/,"");
	showLoading();
	
	fileLocation="pictures/newpictures/loadpage.php?folder="+pictureFolder;
	jQloadFile();
	showTitle();
}

function showFamilyPictures() {
	pageTitle = "Family Pictures";
	showLoading();
	
	fileLocation="pictures/family/index.php";
	jQloadFile();
	showTitle();
}

function showGraphicsPictures() {
	pageTitle = "Graphics Pictures";
	showLoading();
	
	fileLocation="pictures/graphic/index.php";
	jQloadFile();
	showTitle();
}

function showPhotographyPictures() {
	pageTitle = "Photography Pictures";
	showLoading();
	
	fileLocation="pictures/photography/index.php";
	jQloadFile();
	showTitle();
}

function showMyCarPictures() {
	pageTitle = "My Car Pictures";
	showLoading();
	
	fileLocation="pictures/mycar/index.php";
	jQloadFile();
	showTitle();
}

function showVideos() {
	pageTitle = "My Videos";
	showLoading();
	
	fileLocation="videos/index.php";
	jQloadFile();
	showTitle();
}

///////////////
// DVD Track //
///////////////
function showDvdTrack() {
	pageTitle = "DVD Tracking";
	showLoading();
	
	fileLocation="smallcreation/dvdtrack/index.php";
	jQloadFile();
	showTitle();
}


//////////////////
// Monthly Bill //
//////////////////
function showMonthlyBills() {
	pageTitle = "Monthly Bills";
	showLoading();
	
	fileLocation="smallcreation/paybills/index.php";
	jQloadFile();
	showTitle();
}

function showPaymentDetail(payeeName, payeeLink) {
	pageTitle = "Payment Details <a target=\"_blank\" href=\"" + payeeLink + "\">" + payeeName + "</a>";
	showLoading();
	
	fileLocation="smallcreation/paybills/detail.php?BILLpayee=" + escape(payeeName) + "&BILLURL=" + escape(payeeLink);
	jQloadFile();
	showTitle();
}

function makePaymentForm() {
	pageTitle = "Make Payment Form";
	showLoading();
	
	fileLocation="smallcreation/paybills/makepaymentform.php";
	jQloadFile();
	showTitle();
}

function makePayment(payee, month, day, year, amount, method, trackingNumber) {
	fileLocation="smallcreation/paybills/makepayment.php?BILLPAYEE=" + payee + "&BILLMONTHSELECT=" + month + "&BILLDAYSELECT=" + day + "&BILLYEARSELECT=" + year + "&BILLPAYMENT_AMOUNT=" + amount + "&BILLPAYMENT_METHOD=" + method + "&BILLTRACKING_NUMBER=" + trackingNumber;
	jQloadFile();
}

function addPayeeForm() {
	pageTitle = "Add Payee Form";
	showLoading();
	
	fileLocation="smallcreation/paybills/addpayeeform.php";
	jQloadFile();
	showTitle();
}

function addPayee(payee, urlHead, urlBody) {
	fileLocation="smallcreation/paybills/addpayee.php?BILLPAYEE=" + payee + "&BILLHTTPHEADER=" + urlHead + "&BILLHTTPBODY=" + urlBody;
	jQloadFile();
}

function deletePayeeForm() {
	pageTitle = "Delete Payee Form";
	showLoading();
	
	fileLocation="smallcreation/paybills/deletepayeeform.php";
	jQloadFile();
	showTitle();
}

function deletepayeeconfirm(payee) {
	fileLocation="smallcreation/paybills/deletepayeeconfirm.php?BILLPAYEE=" + payee;
	jQloadFile();
}

function deletePayee(payee, password) {
	fileLocation="smallcreation/paybills/deletepayee.php?BILLPASSEORD=" + password + "&BILLPAYEE=" + payee;
	jQloadFile();
}

function restorePayeeForm() {
	pageTitle = "Retore Payee Form";
	showLoading();
	
	fileLocation="smallcreation/paybills/restorepayeeform.php";
	jQloadFile();
	showTitle();
}

function restorePayeeConfirm(payee) {
	fileLocation="smallcreation/paybills/restorepayeeconfirm.php?BILLPAYEE_NAME=" + payee;
	jQloadFile();
}

function restorePayee(payee, password) {
	fileLocation="smallcreation/paybills/restorepayee.php?BILLPASSEORD=" + password + "&BILLPAYEE_NAME=" + payee;
	jQloadFile();
}

function reviewBackupRecords() {
	pageTitle = "Review Backup Records";
	showLoading();
	
	fileLocation="smallcreation/paybills/reviewbackuprecord.php";
	jQloadFile();
	showTitle();
}

function reviewBackupRecordsDetail(payeeName, payeeLink) {
	pageTitle = "Payment Details <a target=\"_blank\" href=\"" + payeeLink + "\">" + payeeName + "</a>";
	showLoading();
	
	fileLocation="smallcreation/paybills/reviewbackuprecorddetail.php?BILLpayee=" + escape(payeeName)  + "&BILLURL=" + escape(payeeLink);
	jQloadFile();
	showTitle();
}

//////////////////
// Address Track //
/////////////////
function showAddressTrack() {
	pageTitle = "Who had visited";
	showLoading();
	
	fileLocation="smallcreation/addresstrack/index.php";
	jQloadFile();
	showTitle();
}

function getAddressTrack(fromMonth, fromDay, fromYear, toMonth, toDay, toYear) {
	pageTitle = "Who had visited";
	showLoading();
	
	fileLocation="smallcreation/addresstrack/index.php?fromMonth=" + fromMonth + "&fromDay=" + fromDay + "&fromYear=" + fromYear + "&toMonth=" + toMonth  + "&toDay=" + toDay + "&toYear=" + toYear;
	jQloadFile();
	showTitle();
}

////////////////////
// Site Statistic //
////////////////////
function showStatistic() {
	pageTitle = "Site Statistics";
	showLoading();
	
	fileLocation="reports/ipaddressReport.php";
	jQloadFile();
	showTitle();
}

//////////////////////////
// Inner Function calls //
//////////////////////////
function showBody() {
	document.getElementById("contentBody").innerHTML=fileContent;
}

function showFileUsingJava() {
	readFileViaApplet();
}

function showTitle() {
	document.getElementById("contentTitle").innerHTML=pageTitle+"<HR>";
	pageTitle='';
}

function showLoading() {
	document.getElementById("contentBody").innerHTML="";
	document.getElementById("contentTitle").innerHTML="Page is loading... please be patient";
}

function jQloadFile() {
	$('#contentBody').load(
		fileLocation,
		function() {
			$('a.lightbox').lightBox();
		}
	);
}

function showFileSimpleDivTag(divTag) {
	if (xmlhttp) {
		d=document
		xmlhttp.open("GET", fileLocation, true);
		xmlhttp.onreadystatechange=RSchangeDivTag(divTag)
		xmlhttp.send(null)
		fileLocation='';
	}
}

function showFileSimple() {
	if (xmlhttp) {
		d=document
		xmlhttp.open("GET", fileLocation, true);
		xmlhttp.onreadystatechange=RSchange
		xmlhttp.send(null)
		fileLocation='';
	}
}

function authenticateMonthlyBill(username, password) {
	pageTitle = "Monthly Bills";
	showLoading();
	
	fileLocation="smallcreation/paybills/authen.php?BILLusername="+username+"&BILLpassword="+password;
	jQloadFile();
	showTitle();
}

function unauthenBillPay() {
	pageTitle = "Log Out";
	showLoading();
	
	fileLocation="smallcreation/paybills/unauthen.php";
	jQloadFile();
	showTitle();
}

function authenticateDVD(username, password) {
	pageTitle = "DVD Tracking";
	showLoading();
	
	fileLocation="smallcreation/dvdtrack/authen.php?DVDusername="+username+"&DVDpassword="+password;
	jQloadFile();
	showTitle();
}

function unauthenDVD() {
	pageTitle = "Log Out";
	showLoading();
	
	fileLocation="smallcreation/dvdtrack/unauthen.php";
	jQloadFile();
	showTitle();
}


///////////////
// Read File //
///////////////

function readFileViaApplet() {
	document.getElementById("contentBody").innerHTML="Reading in progress... " + fileLocation;
	document.ReadURL.readFile(fileLocation);
	setTimeout("showFileContent()",10);
}

function showFileContent() {
	if (document.ReadURL.finished==0) {
		setTimeout("showFileContent()",10);
		return;
	}
	fileContent=document.ReadURL.fileContent;

	if (fileContent == "") {
		fileContent = "Nothing Read";
	}

	showBody();
}

////////////////////
// Database Calls //
////////////////////
if (!xmlhttp && !alerted) {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		alert("You need a browser which supports an XMLHttpRequest Object.")
	}
}

function RSchange() {
	if (xmlhttp.readyState==4) {
		document.getElementById('contentBody').innerHTML=xmlhttp.responseText
	}
}

function RSchangeDivTag(divTag) {
	if (xmlhttp.readyState==4) {
		document.getElementById(divTag).innerHTML=xmlhttp.responseText
	}
}

////////////////////////////////
// General Hide and Show Page //
////////////////////////////////
function show(C) {
	// alert(C);
	if ($('#' + C).is(':visible') == false) {
		// alert('Show: ' + C);
		$('#' + C).show('slow');
	} else {
		// alert('Hide: ' + C);
		$('#' + C).hide('slow');
	}
}

function showImage(C) {
	// alert(C);
	if ($('#' + C).is(':visible') == false) {
		$('#' + C).show('slow');
		for (i=1; i<=9; i++) {
			if (C != "hI"+i) {
				$('#hI' + i).hide('slow');
			}
		}
	} else {
		$('#' + C).hide('slow');
	}
}

function lightboxShow() {
	$().lightBox();
}


