var propCount = propCount; // Total number of properties to rotate. Max 32.

var switchPosition = 1;
		

function getRandomMLSno() {
    var random_num= Math.round(Math.random()*propCount);
    if(random_num==0) {
    	random_num =1;
    }
    return random_num;	
}

function switch_featured_property()
	{
	
	if (MLSNOArray.length == 0) { 
	//alert(MLSNOArray.length);
		var featPropLink1 = document.getElementById('featPropLink1');
		featPropLink1.href = "/html/topmainindex.htm?LISTINGS";
		
		//var featPropLink2 = document.getElementById('featPropLink2');
		//featPropLink2.href = "/html/topmainindex.htm?LISTINGS";
		
		var featLabel1 = document.getElementById('featLabel1');
		featLabel1.innerHTML = "";
		
		var BedBathLabel1 = document.getElementById('BedBathLabel1');
		BedBathLabel1.innerHTML = "";
		
		var PriceLabel1 = document.getElementById('PriceLabel1');
		PriceLabel1.innerHTML = "";
		
		var imgObj = document.getElementById('featPropImg1');
		imgObj.width = 160;
		imgObj.height = 101;
		imgObj.src = "http://www.trackmy.com/images/spotlight_NA.gif";
		
		
	} else {	
		
		//change the Link URL
		var featPropLink1 = document.getElementById('featPropLink1');
		featPropLink1.href = "javascript:openflyer('"+cRandomMLSNO+"')";
		
		//var featPropLink2 = document.getElementById('featPropLink2');
		//featPropLink2.href = "javascript:openflyer('"+cRandomMLSNO+"')";

		//chage the Address name
		var featLabel1 = document.getElementById('featLabel1');
		featLabel1.innerHTML = AddressArray[switchIndex];
		
		//change the Beds & Baths
		var BedBathLabel1 = document.getElementById('BedBathLabel1');
		BedBathLabel1.innerHTML = BedBathArray[switchIndex];
		
		//change the Price
		var PriceLabel1 = document.getElementById('PriceLabel1');
		PriceLabel1.innerHTML = PriceArray[switchIndex];

		//change the picture
		var imgObj = document.getElementById('featPropImg1');
		//if (imgObj.filters)
		//	imgObj.filters.item(0).Apply();
	
		imgObj.src =  banArray[switchPosition];
		//alert('banArray[switchPosition] = '+banArray[switchPosition]+' = banArray['+switchPosition+']');

		//alert(AddressArray[switchIndex] +', '+BedBathArray[switchIndex]+', '+imgObj.src+', '+banArray[switchPosition]);
	
		//if (imgObj.filters)	
			//imgObj.filters.item(0).Play();

		switchPosition++;
		//alert('switchPosition = '+switchPosition+', eval(PropPhotosArray[switchIndex])'+eval(PropPhotosArray[switchIndex]));
		
		if (switchPosition > eval(PropPhotosArray[switchIndex]))	{	
			switchPosition = 1;
			switchIndex++;
			if (switchIndex > propCount) {	
				switchIndex = 1;
			}
			cRandomMLSNO = MLSNOArray[switchIndex];
			buildPhotoURLs();
		}
		
		
	}		
			
}
	
var timer = window.setInterval("buildPhotoURLs()", 2000);
var timer = window.setInterval("switch_featured_property()", 3000);

function buildPhotoURLs() {

	var i;
	var max =  eval(PropPhotosArray[switchIndex]);
	for (i = 0; i < max+1; i++) {
	  banArray[i] = "http://photos.trackmy.com/160/" + cRandomMLSNO.charAt(0) +"/" + cRandomMLSNO.substr(cRandomMLSNO.length-2,2) + "/"+cRandomMLSNO+"_"+i+".jpg";
	}

}
//propCount = 32;
//switchIndex = 19;
//downloadIndex = 19;
