

var shvl = new Object();
shvl.tagAsins = Array();

var aShvlContent = Array();
var totalpagecount;
	
shvl.maxCell = 4;
shvl.curLevel = 0;    
shvl.curCell = shvl.maxCell - 1;    
shvl.asins = Array();    
shvl.delayTime = 75;    
shvl.count = 0;
shvl.requests = 0;
shvl.timer;    
shvl.maxLevel;    
shvl.trackImp = 0;
shvl.imp = Array();    
shvl.asinCache = Array();    
shvl.invalidAsins = new Array();
shvl.leftUp = new Image();
shvl.leftUp.src = "/images/site/sh_left_arrow.gif";
shvl.leftDown = new Image();
shvl.leftDown.src = "/images/site/sh_left_arrow.gif";
shvl.rightUp = new Image();
shvl.rightUp.src = "images/site/sh_right_arrow.gif";
shvl.rightDown = new Image();
shvl.rightDown.src = "/images/site/sh_right_arrow.gif";


function shovelResize() {
    var newPx;
    newPx = 400;
    shvl.maxCell = 5;
    //undisplay("shvlCell4");

    if (document.getElementById("shvlPagination")) document.getElementById("shvlPagination").style.display = "none";
    if (document.getElementById("todaysRecsShovel")) document.getElementById("todaysRecsShovel").className = "slicedBoxMiddle";   
	document.getElementById("SlidShowContainer").style.display = "block"; 
	
        setAsins(shvl.asinList);                
        loadShovelerContent();
   
}


    function setAsins(asins) {
        var newLevel = 0;
        var ta = asins;
        shvl.asins = Array();
        shvl.asinList = asins;
   
        var a = Array();
        var j = 0;
        for (var i = 0;i < ta.length;i++) {
            var thisAsin = ta[i];
            getAsin(thisAsin);
            if (!(shvl.invalidAsins[thisAsin])) {
                a[j++] = ta[i];
            }
        }

        var level = 0;
        shvl.count = a.length;
        if (document.getElementById("shvl")) {
            if (a.length == 0 && shvl.requests == 0) {
                undisplay("shovelerLoading");
                document.getElementById("shovelerNoData").style.display = "";
                undisplay("shvl");
            }
            else if (!isDisplayed("shvlNJS")) {
                document.getElementById("shovelerLoading").style.display = "";
                undisplay("shovelerNoData");
                undisplay("shvl");
            }
            if (a.length <= shvl.maxCell) {
                undisplay("shovelerPrevious");
                undisplay("shovelerPreviousText");
                undisplay("shovelerNext");
                undisplay("shovelerNextText");
            }
            else {
                document.getElementById("shovelerPrevious").style.display = "";
                if (document.getElementById("shovelerPreviousText")) document.getElementById("shovelerPreviousText").style.display = "";
                document.getElementById("shovelerNext").style.display = "";
                if (document.getElementById("shovelerNextText")) document.getElementById("shovelerNextText").style.display = "";
            }
        }

        for (i = 0; i < a.length; i++) {
            if (i % shvl.maxCell == 0) { 
                shvl.asins[level] = Array();
                shvl.maxLevel = level;
            }
            shvl.asins[level][i % shvl.maxCell] = a[i];
            if (i % shvl.maxCell == shvl.maxCell - 1) { level++; }
        }

        for (i = 0;i <= shvl.maxCell;i++) {
            if (!shvl.asins[i]) {
                setPageHTML(i,"clear");
            }
            else if (i > 0) {
                setPageHTML(i,"off");
            }
            else {
                setPageHTML(i,"on");
            }
        }
        shvl.curLevel = newLevel;
        if (shvl.trackImp) sendImp(shvl.asins[shvl.curLevel]);
    }

    function invalidateAsin(asin) {
        shvl.invalidAsins[asin] = 1;
    }

    function getAsin(asin) {
        var asinObj = shvl.asinCache[asin];
        if (!asinObj) {
            var tfContent = document.getElementById("cell_shoveler_" + asin);
            if (tfContent) {
                asinObj = new Object();
                var img = document.getElementById("productImage_shoveler_" + asin);
                if (img) {
                    preloadImage(img.src);
                    asinObj.img = img;
                }    
                else {
                    invalidateAsin(asin);
                }

                var link = document.getElementById("productLink_shoveler_" + asin);
                if (link) {
                    asinObj.link = link.href;
                    asinObj.linkName = link.name;
                }
                else {
                    invalidateAsin(asin);
                }
                if (!shvl.invalidAsins[asin]) {
                    shvl.asinCache[asin] = asinObj;
                }    
            }
            else if (asin != undefined) {
                invalidateAsin(asin);
            }
        }
        return asinObj;
    }
	
	
	preloadImages = new Array();
preloadImage = function (sImage, id) {
if (!id) id=preloadImages.length;
	if (!preloadImages[id]) {
	preloadImages[id]=new Image();
	preloadImages[id].src=sImage;
;
}
}

    function prevItems() {
        shvl.curCell = 0;
        if (shvl.nexttimer) clearInterval(shvl.nexttimer);
        shvl.nexttimer = setInterval('animatePrev()', shvl.delayTime);
    }

    function nextItems() {
        shvl.curCell = shvl.maxCell - 1;
        if (shvl.nexttimer) clearInterval(shvl.nexttimer);
        shvl.nexttimer = setInterval('animateNext()', shvl.delayTime);
    }
    
    function setPageHTML(level,state) {
        var page = document.getElementById("page" + (level+1));
        if (page) {
            if (state == "clear") {
                page.style.display = "none";
            }
            else if (state == "on") {
                page.style.display = "";
                changePage(level + 1) 
            }
            else {
                page.style.display = "";
            }
        }
    }
	
	
var bIsCSS = (document.body && document.body.style) ? true : false;


function getElementStyle(obj) {
var elem = document.getElementById(obj);
if (elem && bIsCSS) {
	elem = elem.style;
}
	return elem;
}


function undisplay(obj) {
var oStyle = getElementStyle(obj);
if (oStyle) {
	oStyle.display = 'none';
} 
}

function isDisplayed(obj) {
var oStyle = getElementStyle(obj);
if (oStyle) {
return oStyle.display != 'none';
}
return true;
}
    
    function pageItems(level) {
        shvl.curCell = shvl.maxCell - 1;
        if (shvl.pagetimer) clearInterval(shvl.pagetimer);
        shvl.pagetimer = setInterval('animatePage(' + (level - 1) + ')', shvl.delayTime);       
    }

    function animatePage(level) {
        if (shvl.curCell == -1) {
            clearInterval(shvl.pagetimer);
            shvl.curCell = shvl.maxCell - 1;
            setPageHTML(shvl.curLevel,"off");
            setPageHTML(level,"on");
            shvl.curLevel = level;
            if (shvl.trackImp) sendImp(shvl.asins[shvl.curLevel]);
        }
        else {
            var asinLevel = shvl.asins[level];
            var nextAsin;
            if (asinLevel) {
                nextAsin = asinLevel[shvl.curCell];
            }
            updateCell(nextAsin,shvl.curCell);
            shvl.curCell--;
        }
    }


    function updateCell(asin,cell)
    {
        var cellLink = document.getElementById("shovelerLink" + cell);
        var cellImage = document.getElementById("shovelerProductImage" + cell);
        var asinObj = getAsin(asin);
        var newLink = '';
        var newLinkName = '';
        var newTitle = '';
        var newImageSrc = 'http://www.allstarvacationhomes.com/images/site/spacer.gif'; 
        if (asinObj) {
            newLink = asinObj.link;
            newLinkName = asinObj.linkName;
            newImageSrc = asinObj.img ? asinObj.img.src : 'http://www.allstarvacationhomes.com/images/site/spacer.gif';
        }

        if (cellLink) {
            cellLink.href = newLink;
            cellLink.name = newLinkName;
        }
		
        if (cellImage) {
            cellImage.src = "http://www.allstarvacationhomes.com/images/site/spacer.gif"; 
            cellImage.src = newImageSrc; 
            if (cellImage.src == "http://www.allstarvacationhomes.com/images/site/spacer.gif") {
                cellImage.style.display = "";
				cellLink.href = 'javascript:void(0);';
				cellLink.className = 'no-slide';
            }
            else {
                cellImage.style.display="";
            }
        }
    }

    function animateNext(name) {
        if (shvl.curCell == -1) {
            clearInterval(shvl.nexttimer);
            shvl.curCell = shvl.maxCell - 1;
            var lastLevel = shvl.curLevel;
            if (shvl.asins[shvl.curLevel]) { shvl.curLevel++; }   
            if (!shvl.asins[shvl.curLevel]) { shvl.curLevel = 0; }   

            setPageHTML(lastLevel,"off");
            setPageHTML(shvl.curLevel,"on");
            if (shvl.trackImp) sendImp(shvl.asins[shvl.curLevel]);
        }
        else {
            var asin = shvl.asins[shvl.curLevel][shvl.curCell];
            var nextLevel = (shvl.asins[shvl.curLevel + 1]) ? shvl.curLevel + 1 : 0;
            var nextAsin = shvl.asins[nextLevel][shvl.curCell];
            updateCell(nextAsin,shvl.curCell);
            shvl.curCell--;
        }
    }

    function animatePrev(name) {
        if (shvl.curCell == shvl.maxCell) {
            clearInterval(shvl.nexttimer);
            shvl.curCell = 0;
            var lastLevel = shvl.curLevel;
            if (shvl.asins[shvl.curLevel]) { shvl.curLevel--; }   
            if (!shvl.asins[shvl.curLevel]) { shvl.curLevel = shvl.maxLevel; }   
            
            setPageHTML(lastLevel,"off");
            setPageHTML(shvl.curLevel,"on");
            if (shvl.trackImp) sendImp(shvl.asins[shvl.curLevel]);
        }
        else {
            var asin = shvl.asins[shvl.curLevel][shvl.curCell];
            var nextLevel = (shvl.asins[shvl.curLevel - 1]) ? shvl.curLevel - 1 : shvl.maxLevel;
            var nextAsin = shvl.asins[nextLevel][shvl.curCell];
            updateCell(nextAsin,shvl.curCell);
            shvl.curCell++;
        }
    }

    function loadShoveler(tag, asinList, reasonList) {        
        shvl.curLevel = 0;
        shvl.curCell = shvl.maxCell - 1;
        setAsins(asinList);
        shvl.timer = setInterval('loadShovelerContent()', 300);
    }

    function loadShovelerContent() {
        clearInterval(shvl.timer);
        var showElements = true;
        var numElements = 0;
        for (i = 0; i < shvl.maxCell; i++) {
            var level = shvl.asins[shvl.curLevel];
            if (level) {
                var asin = shvl.asins[shvl.curLevel][i];
                var asinContent = 1; 
                showElements = (showElements && !((asinContent == "") && (asin)));
                if (showElements) {
                    numElements++;
                }
                updateCell(asin,i);
            }
        }

        if (showElements && shvl.count > 0) {
            document.getElementById("shvl").style.display = "";
            document.getElementById("shovelerLoading").style.display = "none";
            document.getElementById("shovelerNoData").style.display = "none";
            undisplay("shvlNJS");
        }
        shvl.loadCloud = 0;
    }

    

    function shovelerShowProductPopover() {
        try {
            if (shvl.asins && shvl.asins[shvl.curLevel]) {
                for (var i=0;i < shvl.maxCell ;i++) {
                    var asin = shvl.asins[shvl.curLevel][i];
                    if (shvl.rating[asin] != undefined) {
                        savedRatings[asin] = shvl.rating[asin];
                        savedNotInterested[asin] = shvl.notInterested[asin];
                        savedIsOwned[asin] = shvl.isOwned[asin];
                    }
                    else {
                        shvl.rating[asin] = savedRatings[asin];
                        shvl.notInterested[asin] = savedNotInterested[asin];
                        shvl.isOwned[asin] = savedIsOwned[asin];
                    }
        
                    if (shvl.rating[asin] != undefined) amz_js_swapStars(asin,shvl.rating[asin]);
                    if (shvl.notInterested[asin] != undefined) amz_js_swapNotInterested(asin,shvl.notInterested[asin]);
                    if (shvl.isOwned[asin] != undefined) amz_js_swapIsOwned(asin,shvl.isOwned[asin]);

                }
            }
        } catch (e) {}
    }

    function sendImp(asins) { 
        var submit = Array();
        if (asins) {
            for (var i = 0; i < asins.length; i++) {
                if (!shvl.imp[asins[i]]) {
                    shvl.imp[asins[i]] = 1;
                }
            }
        }
      
    }       

function toggleCloud(name) {
    if ( !shvl.loadCloud && name != shvl.currentTag) {
        shvl.loadCloud = 1;
        if (document.getElementById(name)) {
            document.getElementById(name).className = 'active';
        }
        if (shvl.currentTag && document.getElementById(shvl.currentTag)) {
            document.getElementById(shvl.currentTag).className = '';
        }
        if (shvl.currentTag) cloudUp(shvl.currentTag);
        shvl.currentTag = name;
        if (shvl.tagAsins[name]) {
            loadShoveler('', shvl.tagAsins[name], '');
        }    
    }
}   







this.undisplay = function (obj) {
var oStyle = this.getElementStyle(obj);
if (oStyle) {
	oStyle.display = 'none';
	} 
}
this.isDisplayed = function(obj) {
var oStyle = this.getElementStyle(obj);
if (oStyle) {
	return oStyle.display != 'none';
}
	return true;
}


function cloudDown(id) {
    if (id != shvl.currentTag && !isDisplayed("shvlNJS")) {
        document.getElementById("shovelerLoading").style.display = "";
        undisplay("shovelerNoData");
        undisplay("shvl");
    }

    document.getElementById(id).style.backgroundColor = '#c60';
    document.getElementById(id).style.color = '#fff';
    document.getElementById(id).style.backgroundImage = 'url("images/select-gradient-click.gif")';
    document.getElementById(id).style.backgroundPosition = 'bottom';
}   

function cloudUp(id) {
    document.getElementById(id).style.backgroundColor = '';
    document.getElementById(id).style.color = '';
    document.getElementById(id).style.backgroundImage = '';
    document.getElementById(id).style.backgroundPosition = 'top';
}   

function togglePage(level) {
    changePage(level);
    shvl.curCell = shvl.maxCell - 1;
    if (shvl.pagetimer) clearInterval(shvl.pagetimer);
    shvl.pagetimer = setInterval('animatePage(' + (level - 1) + ')', shvl.delayTime);
}   

function changePage(level) {
    var name = "page" + level; 
	
    for(i = 1; i <= totalpagecount ; i++) {
        if (name == "page" + i) {
            document.getElementById(name).className = 'active';
        }
        else {
            document.getElementById("page" + i).className = '';
        }
    }
}

function pageDown(id) {
    document.getElementById(id).style.backgroundColor = '#c60';
    document.getElementById(id).style.color = '#fff';
    document.getElementById(id).style.backgroundImage = 'url("/images/site/sh_select-gradient-click.gif")';
    document.getElementById(id).style.backgroundPosition = 'bottom';
}   

function pageUp(id) {
    document.getElementById(id).style.backgroundColor = '';
    document.getElementById(id).style.color = '';
    document.getElementById(id).style.backgroundImage = '';
    document.getElementById(id).style.backgroundPosition = 'top';
}   
 

function leftShovelButton(e) {
    prevItems();
	pauseShow();
}   

function  rightShovelButton(e) {
    nextItems();
	pauseShow();
}   

function cloudBlur(id) {
    document.getElementById(id).blur();
}




var t;
var ImageArray = 0;
var current = 0;


function GetImageText(Ai){
document.getElementById('message').style.visibility = 'Visible';
if (document.layers) {
	document.NN4.document.write(txtStr[Ai]);
}
else if (document.getElementById) {
	document.getElementById('message').innerHTML = txtStr[Ai];
}
else if (document.all) {
	message.innerHTML = txtStr[Ai];
}

// set up image map for images 1 and 2
document.images.SlideShow.useMap = "";

if (Ai == 0) {

	if (document.getElementById('imagemap0') != null ) {
	
		document.images.SlideShow.useMap = "#" + PicShow[Ai];

	}

}

if (Ai == 1) {

	if (document.getElementById('imagemap1') != null ) {
	
		document.images.SlideShow.useMap = "#" + PicShow[Ai];

	}

}



}


function getanchor() {

			//window.location.hash = 'SlideShowAnchor';

}

function runSlideShow(){
   document.images.SlideShow.src = 'http://www.allstarvacationhomes.com/images/homes/' + PicShow[ImageArray];
   document.getElementById('ImageNumber').innerHTML = (ImageArray + 1);
   GetImageText(ImageArray);
 
   ImageArray = ImageArray + 1
   if (ImageArray > (PicShow.length-1)) ImageArray=0
   t = setTimeout('runSlideShow()', speed);
   document.getElementById('pauseShow').style.visibility = 'Visible';
   document.getElementById('pauseShow').innerHTML = '<a href="javascript:pauseShow();">Pause Slide Show</a>';

    getanchor();
   
}

function next() {
 getanchor();
if (PicShow[current+1]) {
   document.images.SlideShow.src = 'http://www.allstarvacationhomes.com/images/homes/' + PicShow[current+1];
   GetImageText(current+1);
   current += 1
   document.getElementById('ImageNumber').innerHTML = (current + 1);
   pauseShow();
   }
else first();
}


function previous() {
 getanchor();
if (current-1 >= 0) {
document.images.SlideShow.src = 'http://www.allstarvacationhomes.com/images/homes/' + PicShow[current-1];
 GetImageText(current-1);
 current += -1
 document.getElementById('ImageNumber').innerHTML = (current + 1);
 pauseShow();
   }
else last();
}

function first() {
current = 0;
document.images.SlideShow.src = 'http://www.allstarvacationhomes.com/images/homes/' + PicShow[0];
 GetImageText(0);
 document.getElementById('ImageNumber').innerHTML = (current + 1);
 pauseShow();
}


function last() {
current = (PicShow.length-1);
document.images.SlideShow.src = 'http://www.allstarvacationhomes.com/images/homes/' + PicShow[current];
 GetImageText(current);
 document.getElementById('ImageNumber').innerHTML = (current + 1);
 pauseShow();
}


function selectImage(strID) {
if (strID == 'x') {
 strID = 0
 } else {
 getanchor();
} 


current = (strID);
document.images.SlideShow.src = 'http://www.allstarvacationhomes.com/images/homes/' + PicShow[strID];
GetImageText(current);
document.getElementById('ImageNumber').innerHTML = (current + 1);
pauseShow();



}

function pauseShow() {
      if (t != null) {
         clearTimeout(t);
         t = null;
		 document.getElementById('pauseShow').innerHTML = '<a href="javascript:runSlideShow();">Start Slide Show</a>';
      }
   }
   
   

 function LoadFirstDesc(strID) {
 		GetImageText(current);
		//selectImage(current);
}




// getAnchorPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the page.
function getAnchorPosition(anchorname) {
	// This function will return an Object with x and y properties
	var useWindow=false;
	var coordinates=new Object();
	var x=0,y=0;
	// Browser capability sniffing
	var use_gebi=false, use_css=false, use_layers=false;
	if (document.getElementById) { use_gebi=true; }
	else if (document.all) { use_css=true; }
	else if (document.layers) { use_layers=true; }
	// Logic to find position
 	if (use_gebi && document.all) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_gebi) {
		var o=document.getElementById(anchorname);
		x=AnchorPosition_getPageOffsetLeft(o);
		y=AnchorPosition_getPageOffsetTop(o);
		}
 	else if (use_css) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_layers) {
		var found=0;
		for (var i=0; i<document.anchors.length; i++) {
			if (document.anchors[i].name==anchorname) { found=1; break; }
			}
		if (found==0) {
			coordinates.x=0; coordinates.y=0; return coordinates;
			}
		x=document.anchors[i].x;
		y=document.anchors[i].y;
		}
	else {
		coordinates.x=0; coordinates.y=0; return coordinates;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
	}

	
	// Functions for IE to get position of an object
function AnchorPosition_getPageOffsetLeft (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
	}
function AnchorPosition_getWindowOffsetLeft (el) {
	return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
	}	
function AnchorPosition_getPageOffsetTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;
	}
function AnchorPosition_getWindowOffsetTop (el) {
	return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
	}










