var lIndex = 0;
var lImages = 0;
var sImages;
var bPaused = false;

function swapImage(objImage, sImage1, sImage2)
{
var objNewImage;

	objNewImage = new Image();
	objNewImage.src = sImage1;

	if (objImage.src == objNewImage.src)
	{
		objImage.src = sImage2;
	}
	else
	{
		objImage.src = sImage1;
	}
}

function selectOption(cboDestination, cboSource, objValue)
{
var objOption = document.createElement("OPTION");


	objOption.text = cboSource.options(cboSource.selectedIndex).text;
	
	objOption.value = cboSource.options(cboSource.selectedIndex).value;
	
	cboDestination.add(objOption);
	cboSource.remove(cboSource.selectedIndex);
	objValue.value = objValue.value + "," + objOption.value
}

function validateRequired(objTextbox, objImage, sRequiredImage, sMissingRequiredImage)
{
	if (objTextbox.value == "")
	{
		objImage.src = sMissingRequiredImage;
	}
	else
	{
		objImage.src = sRequiredImage;
	}
}

function toggleMenu(objMenu)
{
	if (objMenu.style.display == "")
	{
		objMenu.style.display = "None";
	}
	else
	{
		objMenu.style.display = "";
	}
}

function bCalculateDate(sName)
{
var lDay;
var lMonth;
var lYear;
	
	lDay = document.all(sName + "Day").value;
	lMonth = document.all(sName + "Month").value;
	lYear = document.all(sName + "Year").value;

	document.all(sName).value = lYear + "-" + lMonth + "-" + lDay;
}

function bCalculateDatetime(sName)
{
var lDay;
var lMonth;
var lYear;
var lHour;
var lMinute;
var sAMPM;
	
	lDay = document.all(sName + "Day").value;
	lMonth = document.all(sName + "Month").value;
	lYear = document.all(sName + "Year").value;
	lHour = document.all(sName + "Hour").value;
	lMinute =document.all(sName + "Minute").value;
	sAMPM = document.all(sName + "AMPM").value;

	document.all(sName).value = lYear + "-" + lMonth + "-" + lDay + " " + lHour + ":" + lMinute + " " + sAMPM;
		
}

function bCalculateTime(sName)
{
var lHour;
var lMinute;
var sAMPM;
	
	lHour = document.all(sName + "Hour").value;
	lMinute =document.all(sName + "Minute").value;
	sAMPM = document.all(sName + "AMPM").value;

	document.all(sName).value = lHour + ":" + lMinute + " " + sAMPM;
	
}

function printWindow(sPage)
{
	objWindow = window.open(sPage, "printWindow", "width=700,height=500,resizable");
}

function slideShow()
{
var objImage;
var objNextImage;

	objImage = document.getElementById('imgViewer');
	objImage.src = sImages[lIndex];	
	if (lIndex >= lImages - 1)
	{
		lIndex = 0;
	}
	else
	{
		lIndex++;
	}
	objNextImage = new Image();
	objNextImage.src = sImages[lIndex];		
	if (!bPaused) {
		lTimer = setTimeout(slideShow, 3000);		
	}
	else{
		clearTimeout(lTimer);
	}
}
function slideShow1(lIndex1)
{
	lIndex = lIndex1;
	lTimer = setTimeout(slideShow, 1000);
}
function loadImages()
{
var objImage;
var lIndex = 0;
    
    objImage = new Image();
    for (lIndex = 0; lIndex < lImages; lIndex++)
    {
		objImage.src = sImages[lIndex];	   
    }
}

function loadApplicaton()
{

	//sImages = new Array();
	
	//sImages[lImages++] = "/images/content/contentBackground.gif";

	//loadImages();
}

//*********************************************************************************

function SelectPricing(optPricing)
{
var txtPriceLower;
var txtPriceUpper;
var txtAuctionLocation;
var txtAuctionDateDay;
var txtAuctionDateMonth;
var txtAuctionDateYear;
var txtClosingDateDay;
var txtClosingDateMonth;
var txtClosingDateYear;

	txtPriceLower = document.all("txtPriceLower");
	txtPriceUpper = document.all("txtPriceUpper");
	txtAuctionLocation = document.all("txtAuctionLocation");
	txtAuctionDateDay = document.all("txtAuctionDateDay");
	txtAuctionDateMonth = document.all("txtAuctionDateMonth");
	txtAuctionDateYear = document.all("txtAuctionDateYear");
	txtClosingDateDay = document.all("txtClosingDateDay");
	txtClosingDateMonth = document.all("txtClosingDateMonth");
	txtClosingDateYear = document.all("txtClosingDateYear");
	
	switch(optPricing.id)
	{
		case "optByNegotiation":
			txtPriceLower.style.display = '';
			lblPriceLower.style.display = '';
			txtPriceUpper.style.display = '';
			lblPriceUpper.style.display = '';
			
			lblAuctionDate.style.display = 'none';
			txtAuctionDateDay.style.display = 'none';
			txtAuctionDateMonth.style.display = 'none';
			txtAuctionDateYear.style.display = 'none';
			
			txtAuctionLocation.style.display = 'none';
			lblAuctionLocation.style.display = 'none';
			
			lblClosingDate.style.display = 'none';
			txtClosingDateDay.style.display = 'none';
			txtClosingDateMonth.style.display = 'none';
			txtClosingDateYear.style.display = 'none';
			
			break;
			
		case "optByAuction": //By Auction
			txtPriceLower.style.display = 'none';
			lblPriceLower.style.display = 'none';
			txtPriceUpper.style.display = 'none';
			lblPriceUpper.style.display = 'none';
			
			lblAuctionDate.style.display = '';
			txtAuctionDateDay.style.display = '';
			txtAuctionDateMonth.style.display = '';
			txtAuctionDateYear.style.display = '';
			
			txtAuctionLocation.style.display = '';
			lblAuctionLocation.style.display = '';
			
			lblClosingDate.style.display = 'none';
			txtClosingDateDay.style.display = 'none';
			txtClosingDateMonth.style.display = 'none';
			txtClosingDateYear.style.display = 'none';
			
			break;
			
		case "optFrom": //From
			txtPriceLower.style.display = '';
			lblPriceLower.style.display = '';
			txtPriceUpper.style.display = 'none';
			lblPriceUpper.style.display = 'none';
			
			lblAuctionDate.style.display = 'none';
			txtAuctionDateDay.style.display = 'none';
			txtAuctionDateMonth.style.display = 'none';
			txtAuctionDateYear.style.display = 'none';
			
			txtAuctionLocation.style.display = 'none';
			lblAuctionLocation.style.display = 'none';
			
			lblClosingDate.style.display = 'none';
			txtClosingDateDay.style.display = 'none';
			txtClosingDateMonth.style.display = 'none';
			txtClosingDateYear.style.display = 'none';
			
			break;		
			
		case "optSetPrice": //Set Price
			txtPriceLower.style.display = '';
			lblPriceLower.style.display = '';
			txtPriceUpper.style.display = 'none';
			lblPriceUpper.style.display = 'none';
			
			lblAuctionDate.style.display = 'none';
			txtAuctionDateDay.style.display = 'none';
			txtAuctionDateMonth.style.display = 'none';
			txtAuctionDateYear.style.display = 'none';
			
			txtAuctionLocation.style.display = 'none';
			lblAuctionLocation.style.display = 'none';
			
			lblClosingDate.style.display = 'none';
			txtClosingDateDay.style.display = 'none';
			txtClosingDateMonth.style.display = 'none';
			txtClosingDateYear.style.display = 'none';
				
			break;
			
		case "optPriceOnApplication":
			txtPriceLower.style.display = 'none';
			lblPriceLower.style.display = 'none';
			txtPriceUpper.style.display = 'none';
			lblPriceUpper.style.display = 'none';
			
			lblAuctionDate.style.display = 'none';
			txtAuctionDateDay.style.display = 'none';
			txtAuctionDateMonth.style.display = 'none';
			txtAuctionDateYear.style.display = 'none';
			
			txtAuctionLocation.style.display = 'none';
			lblAuctionLocation.style.display = 'none';
			
			lblClosingDate.style.display = 'none';
			txtClosingDateDay.style.display = 'none';
			txtClosingDateMonth.style.display = 'none';
			txtClosingDateYear.style.display = 'none';
			
			break;
					
        case "optTender":
			txtPriceLower.style.display = 'none';
			lblPriceLower.style.display = 'none';
			txtPriceUpper.style.display = 'none';		
			lblPriceUpper.style.display = 'none';
			
			lblAuctionDate.style.display = 'none';
			txtAuctionDateDay.style.display = 'none';
			txtAuctionDateMonth.style.display = 'none';
			txtAuctionDateYear.style.display = 'none';
			
			txtAuctionLocation.style.display = 'none';
			lblAuctionLocation.style.display = 'none';
			
			lblClosingDate.style.display = '';
			txtClosingDateDay.style.display = '';
			txtClosingDateMonth.style.display = '';
			txtClosingDateYear.style.display = '';
			
			break;
        
	}
}

function bValidate()
{

	if (frmMain.txtStreetNumber.value == "")
	{
        alert("Please enter a street number.");
        frmMain.txtStreetNumber.focus();
        return false;
    }

    if (frmMain.txtStreet.value == "")
    {
		alert("Please enter a street name.");
		frmMain.txtStreet.focus();
		return false;
    }

    if (frmMain.txtSuburb.value == "")
    {
        alert("Please enter a suburb.");
        frmMain.txtSuburb.focus();
        return false;
    }

    if (frmMain.txtState.value == "")
    {
        alert("Please enter a state.")
        frmMain.txtState.focus();
        return false;
    }

    if (frmMain.txtPostCode.value == "")
    {
        alert("Please enter a post code.")
        frmMain.txtPostCode.focus();
        return false;
    }

    if (frmMain.cboStaff.value == "")
    {
        alert("Please select a listing agent.")
        frmMain.cboStaff.focus();
        return false;
    }

    if (frmMain.cboType.value == "")
    {
        alert("Please select a listing type.")
        frmMain.cboType.focus();
        return false;
    }

    if (frmMain.cboStyle.value == "")
    {
        alert("Please select a property style.")
        frmMain.cboStyle.focus();
        return false;
    }

    if (frmMain.cboType.value.toUpperCase() == "1315BF1A-A6FF-4CFF-A957-9DCF6DB2B96D" &&
        frmMain.dtAvailable.value == "")
    {
        alert("Please enter a date available.")
        frmMain.dtAvailableDay.focus();
        return false;
    }

	return true;
}
	
function PostCode(objState, objSuburb, objPostCode)
{
var sPostCode = '';

	switch(objState.value.toUpperCase())
	{
		case 'WA':
			switch(objSuburb.value.toUpperCase())
			{
				case 'PERTH':
					sPostCode = '6000';
					break;

				case 'WEST PERTH':
					sPostCode = '6005';
					break;

				case 'DOUBLEVIEW':
					sPostCode = '6018';
					break;

				case 'DOUBLE VIEW':
					sPostCode = '6018';
					break;
					
				case 'DALKEITH':
					sPostCode = '6009';
					break;
					
				case 'NEDLANDS':
					sPostCode = '6009';
					break;
					
				case 'CITY BEACH':
					sPostCode = '6015';
					break;
					
				case 'GLENDALOUGH':
					sPostCode = '6016';
					break;
					
				case 'MOUNT HAWTHORN':
					sPostCode = '6016';
					break;
					
				case 'HERDSMAN':
					sPostCode = '6017';
					break;
					
				case 'OSBORNE PARK':
					sPostCode = '6017';
					break;
					
				case 'SCARBOROUGH':
					sPostCode = '6019';
					break;
					
				case 'STIRLING':
					sPostCode = '6021';
					break;
					
				case 'HAMERSLEY':
					sPostCode = '6022';
					break;
					
				case 'DUNCRAIG':
					sPostCode = '6023';
					break;
					
				case 'GLENGARRY':
					sPostCode = '6023';
					break;
					
				case 'GREENWOOD':
					sPostCode = '6024';
					break;
					
				case 'WARWICK':
					sPostCode = '6024';
					break;
					
				case 'CRAIGIE':
					sPostCode = '6025';
					break;
					
				case 'HILLARYS':
					sPostCode = '6025';
					break;
					
				case 'KALLAROO':
					sPostCode = '6025';
					break;
					
				case 'PADBURY':
					sPostCode = '6025';
					break;
					
				case 'JOONDALUP':
					sPostCode = '6027';
					break;
					
				case 'MOUNT LAWLEY':
					sPostCode = '6050';
					break;
					
				case 'DIANELLA':
					sPostCode = '6059';
					break;
					
				case 'MIRRABOOKA':
					sPostCode = '6061';
					break;
					
				case 'SOUTH PERTH':
					sPostCode = '6151';
					break;
					
				case 'SUBIACO':
					sPostCode = '6008';
					break;
					
				case 'NOLLAMARA':
					sPostCode = '6061';
					break;
					
				case 'LEEDERVILLE':
					sPostCode = '6007';
					break;
					
				case 'DAGLISH':
					sPostCode = '6008';
					break;
					
				case 'CHURCHLANDS':
					sPostCode = '6018';
					break;

				case 'IGGLEWOOD':
					sPostCode = '6052';
					break;

				case 'MORLEY':
					sPostCode = '6062';
					break;

				case 'MIDLAND':
					sPostCode = '6056';
					break;

				case 'MAYLANDS':
					sPostCode = '6051';
					break;

				case 'MOUNT CLAREMONT':
					sPostCode = '6010';
					break;

				case 'NORTH PERTH':
					sPostCode = '6005';
					break;

				case 'NORTHBRIDGE':
					sPostCode = '6003';
					break;
					
				case 'SHENTON PARK':
					sPostCode = '6008';
					break;					

				case 'VICTORIA PARK':
					sPostCode = '6100';
					break;

				case 'WEMBLEY':
					sPostCode = '6014';
					break;

				case 'WEST LEEDERVILLE':
					sPostCode = '6007';
					break;							
			}
			break;
	}

	if (sPostCode != '')
	{
		objPostCode.value = sPostCode;
	}
	else
	{
		alert('No valid post code found.')
	}
}