var myJSONObject = {"listing": [{"name": "1998 Monterey 262 Express cruiser", "price": "$21,990.00", "year": "1998", "manufacturer": "Monterey", "model": "262 Express Cruiser", "listingHref": "boat-listing-detail.html?ID=379", "photo": "media/images/boats/379/fm_photo_00003312_preview.jpg"},{"name": "2003 Dusky 203 Center Console", "price": "$19,990.00", "year": "2003", "manufacturer": "Dusky", "model": "203 CL", "listingHref": "boat-listing-detail.html?ID=384", "photo": "media/images/boats/384/fm_photo_00003365_preview.jpg"}]}; var _doIt="1"; var timerID = 0; var _currentIndex=""; var _listingCount; var _listingHref2=""; timerID = setTimeout("initListing();", 500); function goDetails(){ location="http://www.fischermarine.com/" + _listingHref2; } function Start() { timerID = setTimeout("listingNext()", 5000); } function Stop() { if(timerID) { clearTimeout(timerID); timerID = 0; } } function initListing(){ if(myJSONObject){ _listingCount = myJSONObject.listing.length-1; random_num = (Math.round((Math.random()*_listingCount))) loadListing(random_num); //alert(random_num); Start(); }else{ // alert("-1"); } } function listingNext(){ clearTimeout(timerID); _currentIndex++; if(_currentIndex>_listingCount){ _currentIndex=0; } loadListing(_currentIndex); timerID = setTimeout("listingNext()", 5000); } function listingPrev(){ clearTimeout(timerID); _currentIndex--; if(_currentIndex<0){ _currentIndex=_listingCount; } loadListing(_currentIndex); timerID = setTimeout("listingNext()", 5000); } function loadListing(_listingIndex){ _currentIndex=_listingIndex var _listingObj=myJSONObject.listing[_listingIndex]; if(_listingObj){ _listingHref2=_listingObj.listingHref; document.getElementById("fm_name").innerHTML=_listingObj.name; document.getElementById("photo1").src="http://www.fischermarine.com/" + _listingObj.photo; document.getElementById("fm_manufacturer").innerHTML="Manufacturer: " + _listingObj.manufacturer + "
"; document.getElementById("fm_model").innerHTML="Model: " + _listingObj.model + "
"; document.getElementById("fm_year").innerHTML="Year: " + _listingObj.year + "
"; document.getElementById("fm_price").innerHTML="Price: " + _listingObj.price + "
"; }else{ timerID = setTimeout("initListing();", 500); } }