﻿function displayShadow (objName)
{
	var obj = document.getElementById(objName);
	var shadow = document.getElementById("shadow");
	var pstn = new Array();

	pstn = findPos(obj);
	shadow.style.width = obj.clientWidth + "px";
	shadow.style.height = obj.clientHeight + "px";
	shadow.style.position = "absolute";
	shadow.style.top = (pstn[1]+6) + "px";
	shadow.style.left = (pstn[0]+6) + "px";
	shadow.style.display = "block";
	obj.style.zIndex = 1000;
	shadow.style.zIndex = 10;
}

function findPos(obj) 
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
		return [curleft,curtop];
	}
}
			
			
var cProductObj=-1;
var cProducts=-1;
//	parameter1: main holder
//	parameter2: object cliked on
//	parameter3: hidden field id
//	parameter4: content object id
//	parameter5: container height when collapsed
function doAccordeon(parent, objClick, hdnFld, target, clpsdH) { 
	if(objClick != cProductObj){
		var h = document.getElementById(hdnFld).value; 
		var d = document.getElementById(parent);
        var el = document.getElementById(target);
        var xpndH = 0;

		if(parseInt(d.style.height) != clpsdH) {
			if(d.tw2!=undefined) d.tw2.stop();
			d.tw2 = new Tween(d.style, "height", Tween.strongEaseOut, parseInt(d.style.height), clpsdH, 1, "px");
			d.tw2.start();

//			if(objClick.className == "on")
//				objClick.className = "";
//			if(d.className == "sugCategoryTitleOn")
//				d.className = "sugCategoryTitle";
		}
		else
		{
			if(d.tw2!=undefined) d.tw2.stop();
			d.tw2 = new Tween(d.style, "height", Tween.strongEaseOut, parseInt(d.style.height), h, 1, "px");
			d.tw2.start();
			
//			if(objClick.className == "")
//				objClick.className = "on";
//			if(d.className == "sugCategoryTitle")
//				d.className = "sugCategoryTitleOn";
		}
	}
}	

var pageCounter = 1;
var t;
var totalPages = 2;

var _arr = new Array();


/*function PopulateArray() {
    _arr[0] = "<a href=\"luxury_choice/default_location.aspx?alias=VIZCAYA\"><img src=\"/upload/images/sliderComm1.jpg\" id=\"slideImg1\" /></a>";
    _arr[1] = "<a href=\"active_choice/default_location.aspx?alias=THE_POINTE_AT_TURNBURY\"><img src=\"/upload/images/sliderComm2.jpg\" id=\"slideImg2\" /></a>";
    _arr[2] = "<a href=\"metro_choice/default_location.aspx?alias=RIVER_PARK_AT_HARRISON\"><img src=\"/upload/images/sliderComm3.jpg\" alt=\"Photo\" id=\"slideImg3\" /></a>";
    _arr[3] = "<a href=\"family_choice/default_location.aspx?alias=THE_RESERVE_AT_NEW_WINDSOR\"><img src=\"/upload/images/sliderComm4.jpg\" alt=\"Photo\" id=\"slideImg4\" /></a>";
    _arr[4] = "<a href=\"florida_choice/default_location.aspx?alias=THE_VILLAS_AT_POSITANO\"><img src=\"/upload/images/sliderComm5.jpg\" alt=\"Photo\" id=\"slideImg5\" /></a>";
    _arr[5] = "<a href=\"rental_choice/default_location.aspx?alias=THE_CLUB_AT_AUTUMN_RIDGE\"><img src=\"/upload/images/sliderComm6.jpg\" alt=\"Photo\" id=\"slideImg6\" /></a>";

}*/
function AddImagesToGallery() {
    for (var i = 0; i < _arr.length; i++) {
        var _div = document.createElement("div");
        _div.innerHTML = _arr[i];
        document.getElementById("box1").appendChild(_div);
        
    }
    totalPages ++;
   
}

function RemoveImages(count, fromstart) {
    var _div = document.getElementById("box1");
    var _length = document.getElementById("box1").childNodes.length;
    if ((_length - count) >= 6) {
        if (fromstart) {
            for (var i = 0; i < count; i++) {
                _div.removeChild(_div.childNodes[i]);
            }
        } else {
            for (var i = _length - 1; i >= _length - count; i--) {
                _div.removeChild(_div.childNodes[i]);
            }
//            for (var i = _length - count; i < document.getElementById("box1").childNodes.length; i++) {
//               
//            }
        }
    }
    
    //alert(document.getElementById("box1").childNodes.length);
}

var _boolSlide = true;

function slideRight()
{
    var box1 = document.getElementById("box1");
    if (_boolSlide) {
        if (pageCounter < totalPages) {
            t.stop();
            t = new Tween(box1.style, "left", Tween.strongEaseOut, parseInt(box1.style.left), -888 * pageCounter, 2, "px");
            _boolSlide = false;
            t.onMotionFinished = function() { _boolSlide = true; }
            t.start();
            pageCounter++;
        }
    }
    AddImagesToGallery();
}

function slideLeft()
{
    var box1 = document.getElementById("box1");
    if (_boolSlide) {
        if (pageCounter > 1) {
            pageCounter--;
            t.stop();
            t = new Tween(box1.style, "left", Tween.strongEaseOut, parseInt(box1.style.left), parseInt(box1.style.left) + 888, 2, "px");
            _boolSlide = false;
            t.onMotionFinished = function() { _boolSlide = true; }
            t.start();
        }
        RemoveImages(3, false);
    }
}






//	parameter1: parent content that holds expanding objects. eg.: tabHolderMain
function autoPopObjs(area) {
	var tagName;	//element that holds the whole content
	var hfp;
	var height;
	
	switch(area)
	{
		case "tabHolderMain":
			tagName = "div";
			hfp = "hf";
			height = 48;
			break;
	}

	 var il = document.getElementById(area).getElementsByTagName(tagName);
	 for(i=0; i < il.length; i++){
		//alert(i + ' ' +il[i].offsetHeight)
		document.getElementById(hfp+i).value = il[i].offsetHeight;
		il[i].style.height = height + "px";
	 }
	 document.getElementById(area).style.visibility = "visible";
}

//Thumbs
var imageIndex=1;
var toggle=true;
var timerID = 0;


function loadPhoto(path){
    var photoHolder = document.getElementById("choiceImg");
    if(document.getElementById('img_1')==null){
        var img = (document.getElementById("overViewPhoto")==null) ? path : document.getElementById("overViewPhoto").src;
        var str = "";
		str += (navigator.appVersion.indexOf("MSIE")!=-1) ? "<div>" : "<div style='margin-left:0px;'>" ; 
		str += "<div style=\"position:absolute;z-index:1\" id=\"div1\"><img id=\"img_1\" src=\"\" style='filter:Alpha(opacity=100);'/></div>";
	    str += "<div style=\"position:absolute;z-index:2\" id=\"div2\"><img id=\"img_2\" src=\""+img+"\" style='filter:Alpha(opacity=100);'/></div>";
		str += "</div>";
        photoHolder.innerHTML = str;
    }
    popNextImage(path);
}


    
function nextImage(){
    if(toggle){
	    opacityTween = new OpacityTween(document.getElementById('img_1'),Tween.regularEaseOut, 100, 0, 1);
	    opacityTween2 = new OpacityTween(document.getElementById('img_2'),Tween.regularEaseOut, 0, 100, 1);
    }else{
    
	    opacityTween = new OpacityTween(document.getElementById('img_2'),Tween.regularEaseOut, 100, 0, 1);	
	    opacityTween2 = new OpacityTween(document.getElementById('img_1'),Tween.regularEaseOut, 0, 100, 1);
    }
    opacityTween.start();
    opacityTween2.start();
}

function popNextImage(path){
    var d = document.getElementById("div1");
    var img;
    if(toggle){
	    img = document.getElementById("img_1");
	    d.style.zIndex = "3";
	    toggle=false;	
    }else{
	    img = document.getElementById("img_2");
	    d.style.zIndex = "0";
	    toggle=true;
    }
	
    img.src = path;	
    img.style['opacity'] = 0;
    img.style['-moz-opacity'] = 0;
    img.onload = function(){
        nextImage();
        imageIndex=2;
        //timerID  = setTimeout("nextImage()", 1000);
    }
    if(img.filters) img.filters.alpha['opacity'] = 0;	
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i, x, a = document.MM_sr; 
  for(i=0; a && i < a.length && (x=a[i]) && x.oSrc; i++) 
  {
	x.src = x.oSrc;
  }
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i, j=0, x, a = MM_swapImage.arguments; 
	document.MM_sr = new Array; 
	
	for(i=0; i<(a.length-2); i+=3)
	{
		if ((x = MM_findObj(a[i]))!=null)
		{
			document.MM_sr[j++]=x; 
			if(!x.oSrc) x.oSrc=x.src; 
			x.src=a[i+2];
		}
	}
}










