function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImagesArray(array) {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<array.length; i+=2) {
			document[array[i]].src = array[i+1];
		}
	}
}

function changeImages() {
	changeImagesArray(changeImages.arguments);
}

function toggleImages() {
	for (var i=0; i<toggleImages.arguments.length; i+=2) {
		if (selected == toggleImages.arguments[i])
			changeImagesArray(toggleImages.arguments[i+1]);
	}
}

var selected ='';
var preloadFlag = false;

// Pre-loads the images, plus sets the selected tab:
function preloadImages(selectedTab) {
	selected = selectedTab;
	if (document.images) {
		tab_home_over = newImage("images/web/tab_home_over.gif");
		tab_home_sel = newImage("images/web/tab_home_sel.gif");
		tab_services_over = newImage("images/web/tab_services_over.gif");
		tab_services_sel = newImage("images/web/tab_services_sel.gif");
		tab_clients_over = newImage("images/web/tab_clients_over.gif");
		tab_clients_sel = newImage("images/web/tab_clients_sel.gif");
		tab_forsale_over = newImage("images/web/tab_forsale_over.gif");
		tab_forsale_sel = newImage("images/web/tab_forsale_sel.gif");
		tab_company_over = newImage("images/web/tab_company_over.gif");
		tab_company_sel = newImage("images/web/tab_company_sel.gif");
		preloadFlag = true;
		
		// Set selected tab:
		if(selected == 'tab_services') servicesOnOut();
		else if(selected == 'tab_clients') clientsOnOut();
		else if(selected == 'tab_forsale') forsaleOnOut();
		else if(selected == 'tab_company') companyOnOut();
		else homeOnOut();
	}
}



///////////////////
// Mouse handlers for swapping out tab images:

// Home tab onmouseover, onmouseout, and onmouseup handlers.
function homeOnOver() {
	toggleImages('tab_services',   new Array('tab_home', 'images/web/tab_home_over.gif'), 
	             'tab_clients',    new Array('tab_home', 'images/web/tab_home_over.gif'), 
	             'tab_forsale', new Array('tab_home', 'images/web/tab_home_over.gif'), 
	             'tab_company',    new Array('tab_home', 'images/web/tab_home_over.gif'),
	             '',               new Array('tab_home', 'images/web/tab_home_over.gif')); 
	return true;
}
function homeOnOut() {
	toggleImages('tab_home',       new Array('tab_home', 'images/web/tab_home_sel.gif', 'tab_services', 'images/web/tab_services.gif', 'tab_clients', 'images/web/tab_clients.gif', 'tab_forsale', 'images/web/tab_forsale.gif', 'tab_company', 'images/web/tab_company.gif'), 
	             'tab_services',   new Array('tab_home', 'images/web/tab_home.gif', 'tab_services', 'images/web/tab_services_sel.gif', 'tab_clients', 'images/web/tab_clients.gif', 'tab_forsale', 'images/web/tab_forsale.gif', 'tab_company', 'images/web/tab_company.gif'), 
	             'tab_clients',    new Array('tab_home', 'images/web/tab_home.gif', 'tab_services', 'images/web/tab_services.gif', 'tab_clients', 'images/web/tab_clients_sel.gif', 'tab_forsale', 'images/web/tab_forsale.gif', 'tab_company', 'images/web/tab_company.gif'), 
	             'tab_forsale', new Array('tab_home', 'images/web/tab_home.gif','tab_services', 'images/web/tab_services.gif','tab_clients', 'images/web/tab_clients.gif', 'tab_forsale', 'images/web/tab_forsale_sel.gif', 'tab_company', 'images/web/tab_company.gif'), 
	             'tab_company',    new Array('tab_home', 'images/web/tab_home.gif', 'tab_services', 'images/web/tab_services.gif', 'tab_clients', 'images/web/tab_clients.gif', 'tab_forsale', 'images/web/tab_forsale.gif', 'tab_company', 'images/web/tab_company_sel.gif'),
	             '',               new Array('tab_home', 'images/web/tab_home.gif')); 
	return true;
}
function homeOnUp() { 
	selected='tab_home'; 
	changeImages('tab_home',       'images/web/tab_home_sel.gif', 
	             'tab_services',   'images/web/tab_services.gif', 
	             'tab_clients',    'images/web/tab_clients.gif', 
	             'tab_forsale', 'images/web/tab_forsale.gif', 
	             'tab_company',    'images/web/tab_company.gif');
	return true;
}	


// Services tab onmouseover, onmouseout, and onmouseup handlers.
function servicesOnOver() {
	toggleImages('tab_home', new Array('tab_services', 'images/web/tab_services_over.gif'), 'tab_clients', new Array('tab_services', 'images/web/tab_services_over.gif'), 'tab_forsale', new Array('tab_services', 'images/web/tab_services_over.gif'), 'tab_company', new Array('tab_services', 'images/web/tab_services_over.gif'),'', new Array('tab_services', 'images/web/tab_services_over.gif'));
	return true;
}
function servicesOnOut() {
	toggleImages('tab_home', new Array('tab_home', 'images/web/tab_home_sel.gif', 'tab_services', 'images/web/tab_services.gif', 'tab_clients', 'images/web/tab_clients.gif', 'tab_forsale', 'images/web/tab_forsale.gif', 'tab_company', 'images/web/tab_company.gif'), 'tab_services', new Array('tab_home', 'images/web/tab_home.gif','tab_services', 'images/web/tab_services_sel.gif', 'tab_clients', 'images/web/tab_clients.gif', 'tab_forsale', 'images/web/tab_forsale.gif', 'tab_company', 'images/web/tab_company.gif'), 'tab_clients', new Array('tab_home', 'images/web/tab_home.gif', 'tab_services', 'images/web/tab_services.gif', 'tab_clients', 'images/web/tab_clients_sel.gif','tab_forsale', 'images/web/tab_forsale.gif', 'tab_company', 'images/web/tab_company.gif'), 'tab_forsale', new Array('tab_home', 'images/web/tab_home.gif', 'tab_services', 'images/web/tab_services.gif', 'tab_clients', 'images/web/tab_clients.gif', 'tab_forsale', 'images/web/tab_forsale_sel.gif', 'tab_company', 'images/web/tab_company.gif'),'tab_company', new Array('tab_home', 'images/web/tab_home.gif', 'tab_services', 'images/web/tab_services.gif', 'tab_clients', 'images/web/tab_clients.gif', 'tab_forsale', 'images/web/tab_forsale.gif', 'tab_company', 'images/web/tab_company_sel.gif'), '', new Array('tab_services', 'images/web/tab_services.gif')); 
	return true;
}
function servicesOnUp() { 
	selected='tab_services'; 
	changeImages('tab_home', 'images/web/tab_home.gif', 'tab_services', 'images/web/tab_services_sel.gif', 'tab_clients', 'images/web/tab_clients.gif', 'tab_forsale', 'images/web/tab_forsale.gif', 'tab_company', 'images/web/tab_company.gif');
	return true;
}	

// Clients tab onmouseover, onmouseout, and onmouseup handlers.
function clientsOnOver() {
	toggleImages('tab_home', new Array('tab_clients', 'images/web/tab_clients_over.gif'), 'tab_services', new Array('tab_clients', 'images/web/tab_clients_over.gif'), 'tab_forsale', new Array('tab_clients', 'images/web/tab_clients_over.gif'), 'tab_company', new Array('tab_clients', 'images/web/tab_clients_over.gif'), '', new Array('tab_clients', 'images/web/tab_clients_over.gif'));
	return true;
}
function clientsOnOut() {
	toggleImages('tab_home', new Array('tab_home', 'images/web/tab_home_sel.gif', 'tab_services', 'images/web/tab_services.gif', 'tab_clients', 'images/web/tab_clients.gif', 'tab_forsale', 'images/web/tab_forsale.gif', 'tab_company', 'images/web/tab_company.gif'), 'tab_services', new Array('tab_home', 'images/web/tab_home.gif', 'tab_services', 'images/web/tab_services_sel.gif', 'tab_clients', 'images/web/tab_clients.gif', 'tab_forsale', 'images/web/tab_forsale.gif', 'tab_company', 'images/web/tab_company.gif'), 'tab_clients', new Array('tab_home', 'images/web/tab_home.gif', 'tab_services', 'images/web/tab_services.gif', 'tab_clients', 'images/web/tab_clients_sel.gif', 'tab_forsale', 'images/web/tab_forsale.gif', 'tab_company', 'images/web/tab_company.gif'), 'tab_forsale', new Array('tab_home', 'images/web/tab_home.gif', 'tab_services', 'images/web/tab_services.gif', 'tab_clients', 'images/web/tab_clients.gif', 'tab_forsale', 'images/web/tab_forsale_sel.gif', 'tab_company', 'images/web/tab_company.gif'), 'tab_company', new Array('tab_home', 'images/web/tab_home.gif', 'tab_services', 'images/web/tab_services.gif', 'tab_clients', 'images/web/tab_clients.gif', 'tab_forsale', 'images/web/tab_forsale.gif', 'tab_company', 'images/web/tab_company_sel.gif'), '', new Array('tab_clients', 'images/web/tab_clients.gif'));
	return true;
}
function clientsOnUp() { 
	selected='tab_clients';
	changeImages('tab_home', 'images/web/tab_home.gif', 'tab_services', 'images/web/tab_services.gif', 'tab_clients', 'images/web/tab_clients_sel.gif', 'tab_forsale', 'images/web/tab_forsale.gif', 'tab_company', 'images/web/tab_company.gif');
	return true;
}	

// forsale tab onmouseover, onmouseout, and onmouseup handlers.
function forsaleOnOver() {
	toggleImages('tab_home', new Array('tab_forsale', 'images/web/tab_forsale_over.gif'), 'tab_services', new Array('tab_forsale', 'images/web/tab_forsale_over.gif'), 'tab_clients', new Array('tab_forsale', 'images/web/tab_forsale_over.gif'), 'tab_company', new Array('tab_forsale', 'images/web/tab_forsale_over.gif'), '', new Array('tab_forsale', 'images/web/tab_forsale_over.gif'));
	return true; 
}
function forsaleOnOut() {
	toggleImages('tab_home', new Array('tab_home', 'images/web/tab_home_sel.gif', 'tab_services', 'images/web/tab_services.gif', 'tab_clients', 'images/web/tab_clients.gif', 'tab_forsale', 'images/web/tab_forsale.gif', 'tab_company', 'images/web/tab_company.gif'), 'tab_services', new Array('tab_home', 'images/web/tab_home.gif', 'tab_services', 'images/web/tab_services_sel.gif', 'tab_clients', 'images/web/tab_clients.gif', 'tab_forsale', 'images/web/tab_forsale.gif', 'tab_company', 'images/web/tab_company.gif'), 'tab_clients', new Array('tab_home', 'images/web/tab_home.gif', 'tab_services', 'images/web/tab_services.gif', 'tab_clients', 'images/web/tab_clients_sel.gif', 'tab_forsale', 'images/web/tab_forsale.gif', 'tab_company', 'images/web/tab_company.gif'), 'tab_forsale', new Array('tab_home', 'images/web/tab_home.gif', 'tab_services', 'images/web/tab_services.gif', 'tab_clients', 'images/web/tab_clients.gif', 'tab_forsale', 'images/web/tab_forsale_sel.gif', 'tab_company', 'images/web/tab_company.gif'), 'tab_company', new Array('tab_home', 'images/web/tab_home.gif', 'tab_services', 'images/web/tab_services.gif', 'tab_clients', 'images/web/tab_clients.gif', 'tab_forsale', 'images/web/tab_forsale.gif', 'tab_company', 'images/web/tab_company_sel.gif'), '', new Array('tab_forsale', 'images/web/tab_forsale.gif'));
	return true;
}
function forsaleOnUp() { 
	selected='tab_forsale';
	changeImages('tab_home', 'images/web/tab_home.gif', 'tab_services', 'images/web/tab_services.gif', 'tab_clients', 'images/web/tab_clients.gif', 'tab_forsale', 'images/web/tab_forsale_sel.gif', 'tab_company', 'images/web/tab_company.gif');
	return true;
}	

// Company tab onmouseover, onmouseout, and onmouseup handlers.
function companyOnOver() {
	toggleImages('tab_home', new Array('tab_company', 'images/web/tab_company_over.gif'), 'tab_services', new Array('tab_company', 'images/web/tab_company_over.gif'), 'tab_clients', new Array('tab_company', 'images/web/tab_company_over.gif'), 'tab_forsale', new Array('tab_company', 'images/web/tab_company_over.gif'), '', new Array('tab_company', 'images/web/tab_company_over.gif'));
	return true;
}
function companyOnOut() {
	toggleImages('tab_home', new Array('tab_home', 'images/web/tab_home_sel.gif', 'tab_services', 'images/web/tab_services.gif', 'tab_clients', 'images/web/tab_clients.gif', 'tab_forsale', 'images/web/tab_forsale.gif', 'tab_company', 'images/web/tab_company.gif'), 'tab_services', new Array('tab_home', 'images/web/tab_home.gif', 'tab_services', 'images/web/tab_services_sel.gif', 'tab_clients', 'images/web/tab_clients.gif', 'tab_forsale', 'images/web/tab_forsale.gif', 'tab_company', 'images/web/tab_company.gif'), 'tab_clients', new Array('tab_home', 'images/web/tab_home.gif', 'tab_services', 'images/web/tab_services.gif', 'tab_clients', 'images/web/tab_clients_sel.gif', 'tab_forsale', 'images/web/tab_forsale.gif', 'tab_company', 'images/web/tab_company.gif'), 'tab_forsale', new Array('tab_home', 'images/web/tab_home.gif', 'tab_services', 'images/web/tab_services.gif', 'tab_clients', 'images/web/tab_clients.gif', 'tab_forsale', 'images/web/tab_forsale_sel.gif', 'tab_company', 'images/web/tab_company.gif'), 'tab_company', new Array('tab_home', 'images/web/tab_home.gif', 'tab_services', 'images/web/tab_services.gif', 'tab_clients', 'images/web/tab_clients.gif', 'tab_forsale', 'images/web/tab_forsale.gif', 'tab_company', 'images/web/tab_company_sel.gif'), '', new Array('tab_company', 'images/web/tab_company.gif'));
	return true;
}
function companyOnUp() { 
	selected='tab_company';
	changeImages('tab_home', 'images/web/tab_home.gif', 'tab_services', 'images/web/tab_services.gif', 'tab_clients', 'images/web/tab_clients.gif', 'tab_forsale', 'images/web/tab_forsale.gif', 'tab_company', 'images/web/tab_company_sel.gif');
	return true;
}	



