﻿	//Front Cover Scripts
	
	function PhotoNotAvailLarge(obj){obj.src ="images/en-US/prop_no_photo.gif";obj.width=390;obj.height=240;}
	
	function GetEl(sElId){return document.getElementById( sElId );}
	// Set Slide Show Speed (milliseconds)
	var iFCDelay = 7000;
    var iMaxHeight = 66;
    var iMaxWidth = 130;

	// Duration of crossfade (seconds)
	var FadeDuration = 3;

	var arFCImg = new Array();
	var arFCName = new Array();
	var arFCTxt = new Array();
	var arFCId = new Array();
	var arFCHref = new Array();
	var arFCAddr = new Array();
	var preFCLoad = new Array();
   var lastItem = 1;
	var elementsPerRow=3;
	
	var vous;
	var bAuto = true;
	var iFCCnt = 0;
	var iFCCur = 0;

	function RunFCSlideShow(iFCIdx, iFCDelay)
	{
		if(iFCCnt<1) return;

		var fcDiv=GetEl("divPlayer");
		var html='';
		//set max height and width for featured property image and resize it
		iMaxHeight = 150;
		iMaxWidth = 190;

		if(elementsPerRow>iFCCnt)
			elementsPerRow=iFCCnt;
			
		for(var iItem = 0; iItem<elementsPerRow;iItem++){
			if(iFCIdx==iFCCnt)
				iFCIdx=0;
			html+=fcCreateElement(iFCIdx);
			iFCIdx++;
	
		}
		//add clear div, because of the previus controls are float to the left
		fcDiv.innerHTML=html+'<div style="clear:both"></div>';
		
		iFCCur = iFCIdx;
		lastItem = iFCIdx + 1;
		if(bAuto){
			if (iFCIdx > (iFCCnt-1)) iFCIdx=0;
			vous = setTimeout('RunFCSlideShow('+iFCIdx+',iFCDelay)', iFCDelay);
		}
	}
	
	function fcCreateElement(iFCIdx){
		//resize image
		resizeMCImage(preFCLoad[iFCIdx], preFCLoad[iFCIdx]);
		//get image html
		var imgHtml=preFCLoad[iFCIdx].outerHTML;
		if(imgHtml==null){
			//Firefox doesn't suport outerHTML, so we need to add image to a div and then get innerHTML
			var newdiv = document.createElement('div');
			//add image to a div so we can grab rendered html
			newdiv.appendChild(preFCLoad[iFCIdx]);
			imgHtml=newdiv.innerHTML
		}
		
		var sHtml='';
		sHtml='<ul>';
		sHtml+='	<li>';
		sHtml+='		<div class="fcItem_img"><a href="'+arFCHref[iFCIdx]+'">'+imgHtml+'</a></div>';
		sHtml+='	</li>';
		sHtml+='	<li class="fcItem_Title"><a href="'+arFCHref[iFCIdx]+'">'+arFCName[iFCIdx].replace('@','<span>@</span>')+'</a></li>';
		sHtml+='	<li><span>'+arFCAddr[iFCIdx]+'</span></li>';
		sHtml+='</ul>';
		//&nbsp;<span>Index: '+iFCIdx+'</span>
		//alert(sHtml);
		return sHtml;
	}
	
	
	function PrevFC(){
		clearTimeout(vous);
		var iPrv = (iFCCur==elementsPerRow) ? 0 : iFCCur - (elementsPerRow*2);	
		if(iPrv<1)
			iPrv=0;
		RunFCSlideShow(iPrv,iFCDelay);
	}
	function NextFC(){
		clearTimeout(vous);
		var iNxt = (iFCCur<iFCCnt-1) ? iFCCur : 0;	
		RunFCSlideShow(iNxt,iFCDelay);
	}
	var arFCPausSrc = new Array("images/un-pause-home.gif","images/pause-home.gif");
	function ToggleFCPause(item){

	    bAuto = false;
	 

        RunFCSlideShow(item,iFCDelay);
	    clearTimeout(vous);
			
	}
	
	
	//Rotating/Fading Banner Scripts
	function PhotoNotAvailForBanner(obj){obj.src ="/images/en-US/prop_no_photo.gif";}
	
	function GetElMC(sElId){ return document.getElementById( sElId );}
	// Set Slide Show Speed (milliseconds)
	var iMCDelay = 7000;

	// Duration of crossfade (seconds)
	//var FadeDuration = 3;

	var arMCImg = new Array();
	var arMCAlt = new Array();
	var arMCName = new Array();
	var arMCTxt = new Array();
	var arMCId = new Array();
	var arMCHref = new Array();
	var arMCTitle = new Array();
	var preLoadMC = new Array();

	function StartMC(sURL, sPageParms){
		
		LoadMCItemsXML(sURL+sPageParms);
	}	
	
	
	function ShowSingleLogo()
	{
		var oPhotoLnkMC = GetElMC("MCPhotoLink1");
		var oPhotoLnkMC2 = GetElMC("MCPhotoLink2");
		var oPhotoLnkMC3 = GetElMC("MCPhotoLink3");
		
		var MCPhotoDiv2 = GetElMC('MCPhotoDiv2');
		var MCPhotoDiv3 = GetElMC('MCPhotoDiv3');
		var MCPhotoDiv4 = GetElMC('MCPhotoDiv4');
		var MCPhotoDiv5 = GetElMC('MCPhotoDiv5');
		
		//Default image size
		iMaxHeight = 66;
		iMaxWidth = 130;
		
		iMCIndex1 = 0;
		oPhotoLnkMC.href = arMCHref[iMCIndex1];
		oPhotoLnkMC.title = arMCTitle[iMCIndex1];
		document.images.MCPhoto1.src = preLoadMC[iMCIndex1].src;
		document.images.MCPhoto1.alt = arMCAlt[iMCIndex1];
		resizeMCImage(document.images.MCPhoto1, preLoadMC[iMCIndex1]);
		
		
		oPhotoLnkMC2.href = '#';
		document.images.MCPhoto2.src = 'images/1x1.gif';
		
		if(oPhotoLnkMC3 != null){
			oPhotoLnkMC3.href = '#';
			document.images.MCPhoto3.src = 'images/1x1.gif';
		}		
		MCPhotoDiv2.style.visibility = "hidden";
		if(MCPhotoDiv3 != null)
			MCPhotoDiv3.style.visibility = "hidden";
		if(MCPhotoDiv4 != null)
			MCPhotoDiv4.style.visibility = "hidden";
		if(MCPhotoDiv5 != null)
			MCPhotoDiv5.style.visibility = "hidden";
	}
	
	
	

	var vousMC;
	var bAutoMC = true;
	var iMCCnt = 0;
	var iMCCur = 0;
	
	var iMCIndex1 = 0;
	var iMCIndex2 = 0;
	var iMCIndex3 = 0;
	var iMCIndex4 = 0;
	var iMCIndex5 = 0;
	
	var iMCIndexPrev2 = 0;
	
	
	function RunMCSlideShow(iMCIdx){
		if(iMCCnt<1) return;
		//Default image size
		iMaxHeight = 66;
		iMaxWidth = 130;
		
		var oFC = document.getElementById("divFeatProps");
		
		iMCCur = iMCIdx;
		if (document.all){
		
			document.images.MCPhoto1.style.filter="blendTrans(duration=2)";
			document.images.MCPhoto1.style.filter="blendTrans(duration=crossFadeDuration)";
			document.images.MCPhoto1.filters.blendTrans.Apply();   
			
			
			document.images.MCPhoto2.style.filter="blendTrans(duration=2)";
			document.images.MCPhoto2.style.filter="blendTrans(duration=crossFadeDuration)";
			document.images.MCPhoto2.filters.blendTrans.Apply();  

            
		   if(oFC == null)
		   {			
			   document.images.MCPhoto3.style.filter="blendTrans(duration=2)";
			   document.images.MCPhoto3.style.filter="blendTrans(duration=crossFadeDuration)";
			   document.images.MCPhoto3.filters.blendTrans.Apply();
    			
				document.images.MCPhoto4.style.filter="blendTrans(duration=2)";
			   document.images.MCPhoto4.style.filter="blendTrans(duration=crossFadeDuration)";
			   document.images.MCPhoto4.filters.blendTrans.Apply();

				document.images.MCPhoto5.style.filter="blendTrans(duration=2)";
			   document.images.MCPhoto5.style.filter="blendTrans(duration=crossFadeDuration)";
			   document.images.MCPhoto5.filters.blendTrans.Apply();
         }
		}
		

		var oPhotoLnkMC = GetElMC("MCPhotoLink1");
		var oPhotoLnkMC2 = GetElMC("MCPhotoLink2");
		
		if(oFC == null)
		{	
    		var oPhotoLnkMC3 = GetElMC("MCPhotoLink3");
    	   var oPhotoLnkMC4 = GetElMC("MCPhotoLink4");
    	   var oPhotoLnkMC5 = GetElMC("MCPhotoLink5");
	    }
	    //Image #1
	    if(iMCIdx < iMCCnt)
		{
			iMCIndex1 = iMCIdx;
			oPhotoLnkMC.href = arMCHref[iMCIndex1];
			oPhotoLnkMC.title = arMCTitle[iMCIndex1];
            //alert(preLoadMC[iMCIndex1].height);
            //resizeMCImage(preLoadMC[iMCIndex1]);
			document.images.MCPhoto1.src = preLoadMC[iMCIndex1].src;
			document.images.MCPhoto1.alt = arMCAlt[iMCIndex1]; 
			resizeMCImage(document.images.MCPhoto1, preLoadMC[iMCIndex1], false);
			
			/*
			alert(document.images.MCPhoto1.height);
			alert(document.images.MCPhoto1.width );
			*/
		}
		//Image #2
		if((iMCIdx + 1) < iMCCnt)
		{
		   iMCIndex2 = iMCIdx + 1;
			oPhotoLnkMC2.href = arMCHref[iMCIndex2];
			oPhotoLnkMC2.title = arMCTitle[iMCIndex2];
			document.images.MCPhoto2.src = preLoadMC[iMCIndex2].src;
			document.images.MCPhoto2.alt = arMCAlt[iMCIndex2];
			resizeMCImage(document.images.MCPhoto2, preLoadMC[iMCIndex2]);
			iMCIndexPrev2 = iMCIndex2;
		}
		else
		{
		   iMCIndex2 = Math.round(0 + ((iMCCnt-2)-0)*Math.random());
			while(iMCIndexPrev2 == iMCIndex2)
			{
				iMCIndex2 = Math.round(0 + ((iMCCnt-2)-0)*Math.random());
			}
			oPhotoLnkMC2.href = arMCHref[iMCIndex2];
			oPhotoLnkMC2.title = arMCTitle[iMCIndex2];
			document.images.MCPhoto2.src = preLoadMC[iMCIndex2].src;
			document.images.MCPhoto2.alt = arMCAlt[iMCIndex2];
			resizeMCImage(document.images.MCPhoto2, preLoadMC[iMCIndex2]);
		}
		
	    if(oFC == null)
	    {	
		    //Image #3
    		var MCPhotoDiv3 = GetElMC('MCPhotoDiv3');
    		if((iMCIdx + 2) < iMCCnt)
    		{
    		   iMCIndex3 = iMCIdx + 2;
    		   oPhotoLnkMC3.href = arMCHref[iMCIndex3];
    		   oPhotoLnkMC3.title = arMCTitle[iMCIndex3];
    		   document.images.MCPhoto3.src = preLoadMC[iMCIndex3].src;
    		   document.images.MCPhoto3.alt = arMCAlt[iMCIndex3];
    		   resizeMCImage(document.images.MCPhoto3, preLoadMC[iMCIndex3]);
    	
    		   MCPhotoDiv3.style.visibility = "visible";
    		}
    		else
    		{
    			iMCIndex3 = 0;
    			MCPhotoDiv3.style.visibility = "hidden";
    		}
    		
		    //Image #4
    		var MCPhotoDiv4 = GetElMC('MCPhotoDiv4');
    		if((iMCIdx + 3) < iMCCnt)
    		{
    		   iMCIndex4 = iMCIdx + 3;
    		   oPhotoLnkMC4.href = arMCHref[iMCIndex4];
    		   oPhotoLnkMC4.title = arMCTitle[iMCIndex4];
    		   document.images.MCPhoto4.src = preLoadMC[iMCIndex4].src;
    		   document.images.MCPhoto4.alt = arMCAlt[iMCIndex4];
    		   resizeMCImage(document.images.MCPhoto4, preLoadMC[iMCIndex4]);
    	
    		   MCPhotoDiv4.style.visibility = "visible";
    		}
    		else
    		{
    			iMCIndex4 = 0;
    			MCPhotoDiv4.style.visibility = "hidden";
    		}
    		
 		    //Image #5
    		var MCPhotoDiv5 = GetElMC('MCPhotoDiv5');
    		if((iMCIdx + 4) < iMCCnt)
    		{
    		   iMCIndex5 = iMCIdx + 4;
    		   oPhotoLnkMC5.href = arMCHref[iMCIndex5];
    		   oPhotoLnkMC5.title = arMCTitle[iMCIndex5];
    		   document.images.MCPhoto5.src = preLoadMC[iMCIndex5].src;
    		   document.images.MCPhoto5.alt = arMCAlt[iMCIndex5];
    		   resizeMCImage(document.images.MCPhoto5, preLoadMC[iMCIndex5]);
    	
    		   MCPhotoDiv5.style.visibility = "visible";
    		}
    		else
    		{
    			iMCIndex5 = 0;
    			MCPhotoDiv5.style.visibility = "hidden";
    		}
     }
		
		if (document.all){
			document.images.MCPhoto1.filters.blendTrans.Play();
			document.images.MCPhoto2.filters.blendTrans.Play();
		    if(oFC == null)
		    {	
			    document.images.MCPhoto3.filters.blendTrans.Play();
			    document.images.MCPhoto4.filters.blendTrans.Play();
			    document.images.MCPhoto5.filters.blendTrans.Play();
            }
			
		}
		
		if(bAutoMC){
		
		    if (oFC == null)
			    iMCIdx += 4;
			else
			    iMCIdx += 2;
			    
			if (iMCIdx > (iMCCnt-1)) iMCIdx=0;
			vousMC = setTimeout('RunMCSlideShow('+iMCIdx+')', iMCDelay);
		}
	}
	
//Default values for Front Page community	
var maxheight=256;
var maxwidth= 379;
	
function resizeMCImage( oPageImg, oImg, bDebug )
{
    // Create variables

    var iRatio = 0;
    var bWasAdjusted = false;
    // Get Original dimensions of the image
    var iBaseHeight = oImg.height;
    var iBaseWidth = oImg.width;
    var iNewHeight = iBaseHeight;
    var iNewWidth = iBaseWidth;    
    
    // Check the width of the image 
    if (iBaseWidth==0)
		iBaseWidth=iMaxWidth + 1;
    if (iBaseHeight==0)
		iBaseHeight=iMaxHeight + 1;
		
    if (iBaseWidth > iMaxWidth)
    {
        iRatio = (iMaxWidth / iBaseWidth);
        iNewWidth = Math.round(iBaseWidth * iRatio);
        iNewHeight = Math.round(iBaseHeight * iRatio);
        bWasAdjusted = true;
        
        if (bDebug)
        {
            alert("WIDTH TEST\n" +
                  "iMaxWidth: " + iMaxWidth + "\n" +
                  "iMaxHeight: " + iMaxHeight + "\n" +
                  "iBaseWidth: " + iBaseWidth + "\n" +
                  "iBaseHeight: " + iBaseHeight + "\n" +
                  "iRatio: " + iRatio + "\n" +
                  "iNewWidth: " + iNewWidth + "\n" +
                  "iNewHeight: " + iNewHeight);
        }
    }
    
    // Check the height of the image
    if(bWasAdjusted)
    {
        // If the image was previously adjusted for width
        // If the new height is greater than the maximum then readjust the image
        if (iNewHeight > iMaxHeight)
        {
            iRatio = (iMaxHeight / iNewHeight);
            iNewWidth = Math.round(iNewWidth * iRatio);
            iNewHeight = Math.round(iNewHeight * iRatio);
            
            if (bDebug)
            {
                alert(JSResource.HeightTest +
                      "iMaxWidth: " + iMaxWidth + "\n" +
                      "iMaxHeight: " + iMaxHeight + "\n" +
                      "iBaseWidth: " + iBaseWidth + "\n" +
                      "iBaseHeight: " + iBaseHeight + "\n" +
                      "iRatio: " + iRatio + "\n" +
                      "iNewWidth: " + iNewWidth + "\n" +
                      "iNewHeight: " + iNewHeight);
            }
        }
    }
    else
    {
        // If the image was NOT previously adjusted for width
        // If the image height is greater than the maximum then adjust the image
        if (iBaseHeight > iMaxHeight)
        {
            iRatio = (iMaxHeight / iBaseHeight);
            iNewWidth = Math.round(iBaseWidth * iRatio);
            iNewHeight = Math.round(iBaseHeight * iRatio);
            
            if (bDebug)
            {
                alert(JSResource.NormalHeightTest +
                      "iMaxWidth: " + iMaxWidth + "\n" +
                      "iMaxHeight: " + iMaxHeight + "\n" +
                      "iBaseWidth: " + iBaseWidth + "\n" +
                      "iBaseHeight: " + iBaseHeight + "\n" +
                      "iRatio: " + iRatio + "\n" +
                      "iNewWidth: " + iNewWidth + "\n" +
                      "iNewHeight: " + iNewHeight);
            }            
        }
    }
    
    // Determine how much padding to add to the top and bottom of the image for vertical alignment.
    var iPadHeight = ((iMaxHeight - iNewHeight) / 2)
    if (iPadHeight > 0)
    {
        oPageImg.style.marginTop = iPadHeight + "px";
    }
    else
    {
        oPageImg.style.marginTop = "0px";
    }
    oPageImg.height = iNewHeight;
    oPageImg.width = iNewWidth;
    return;
}
	
var bannerStarted = false;
function startBanner() {
		if(!bannerStarted){
			StartFC();
			StartMC();
			bannerStarted = true;
		}
	}



//****Front Page Property Script Start ***//
var iFPDelay = 7000;
var arFPImg = new Array();
var arFPName = new Array();
var arFPTxt = new Array();
var arFPId = new Array();
var arFPHref = new Array();
var arFPAmen = new Array();
var preLoad = new Array();
var lastItem = 1;
var buttonListId;


var vous;
var bAuto = true;
var iFPCnt = 0;
var iFPCur = 0;

function RunFPSlideShow(iFPIdx, iFPDelay, bShowImage)
{
	if(iFPCnt<1) return;
	iFPCur = iFPIdx;
	SelectRadioButton(iFPCur);
	
	if (document.all){
		document.images.FPPhoto.style.filter="blendTrans(duration=2)";
		document.images.FPPhoto.style.filter="blendTrans(duration=crossFadeDuration)";
		document.images.FPPhoto.filters.blendTrans.Apply(); 
	}

	var currentItem;
    currentItem = iFPIdx + 1; 

	var oTxtCntr = GetEl("FPTextCntr");
	var oTitleLnk = GetEl("FPTitleLink");
	var oPhotoLnk = GetEl("FPPhotoLink");
	var oSeeLnk = GetEl("FPSeeLink");
	
	oTitleLnk.innerHTML = arFPName[iFPIdx]; 
	oTitleLnk.href = arFPHref[iFPIdx];
	addAmenImages(iFPIdx);
	oTxtCntr.innerHTML = arFPTxt[iFPIdx];
	oSeeLnk.href =  arFPHref[iFPIdx];
	oPhotoLnk.href = arFPHref[iFPIdx];
	if(bShowImage){
		document.images.FPPhoto.src = preLoad[iFPIdx].src;
	}
		ResizeThem(document.images.FPPhoto, preLoad[iFPIdx]);
	
	
	if (document.all){
		document.images.FPPhoto.filters.blendTrans.Play();
	}
	lastItem = iFPIdx + 1;
	if(bAuto){
		iFPIdx++;
		
		if (iFPIdx > (iFPCnt-1)) iFPIdx=0;
		vous = setTimeout('RunFPSlideShow('+iFPIdx+',iFPDelay, true)', iFPDelay);
	}
}

function ResizeThem(oPageImg, oImg) {
	var w=oImg.width;
	var h=oImg.height;
	var iNewHeight = h;
	var iNewWidth = w;
	if (w>maxwidth) {
		iNewHeight=(maxwidth/w)*h;
		iNewWidth=maxwidth;
	}
	if (h>maxheight) {
		iNewWidth=(maxheight/h)*w;
		iNewHeight=maxheight;
	}
	
    // Determine how much padding to add to the top and bottom of the image for vertical alignment.
    var iPadHeight = ((maxheight - iNewHeight) / 2)
    if (iPadHeight > 0)
    {
        oPageImg.style.marginTop = iPadHeight + "px";
    }
    else
    {
        oPageImg.style.marginTop = "0px";
    }
    oPageImg.height = iNewHeight;
    oPageImg.width = iNewWidth;
    //alert(oPageImg.width);
}



function addAmenImages(iCurId){
	var oAmenCtrl = GetEl("divAmen");
	var amenArr = arFPAmen[iCurId].split(',');
	var i = 0;
	//clear inner Html of a div before adding new images
	oAmenCtrl.innerHTML = "";
	while (i < amenArr.length) {
		var img = document.createElement('img');
		img.setAttribute("src","images/Amenity/icon_" + amenArr[i] + ".gif");
		oAmenCtrl.appendChild(img);
		i++;
	}

}

function SelectRadioButton(iCurId){
   var aItems=document.getElementsByName(groupName);
   for (var i = 0; i < aItems.length; i++)
   {
		if(i == iCurId)
			aItems[i].checked = true;
   }
   return null;
}
function MoveToFP(iCurId){
	clearTimeout(vous);
	RunFPSlideShow(iCurId,iFPDelay, true);
}
function PrevFP(){
	clearTimeout(vous);
	var iPrv = (iFPCur==0) ? iFPCnt-1 : iFPCur - 1;	
	RunFPSlideShow(iPrv,iFPDelay, true);
}
function NextFP(){
	clearTimeout(vous);
	var iNxt = (iFPCur<iFPCnt-1) ? iFPCur+1 : 0;	
	RunFPSlideShow(iNxt,iFPDelay, true);
}
var arFPPausSrc = new Array("images/un-pause-home.gif","images/pause-home.gif");
function ToggleFPPause(item){

    bAuto = false;
 

     RunFPSlideShow(item,iFPDelay, true);
    clearTimeout(vous);
		
}
	
//****Front Page Property Script Ends ***//
