function removeIndex(aArray) { var tempArray = new Array(); for(var i = 0; i < aArray.length; i++) { var item = aArray[i].toLowerCase(); if((item.indexOf('index') == -1) && (item.indexOf('featured') == -1) && (item.indexOf('related') == -1)) { tempArray.push(aArray[i]); } } return tempArray; } var getThumbs = function() { if(!document.forms[0].Attachments || document.forms[0].Attachments.value.length == 0) return null; var allThumbs = removeIndex((unescape(document.forms[0].Attachments.value)).split('; ')); var gifThumbs = new Array(); for(var i = 0; i < allThumbs.length; i++) { if(allThumbs[i].toLowerCase().indexOf('.gif') != -1)gifThumbs.push(allThumbs[i]); } if(!allThumbs.haveNumIndexes())return gifThumbs.sort(); gifThumbs.sortNumberedThumbs(); //alert(gifThumbs); return gifThumbs }; Array.prototype.haveNumIndexes = function() { for(var i = 0; i < this.length; i++) { var reExp = /[\d]+/gi; var matches = this[i].match(reExp); if(!(matches instanceof Array))//if the files are indexed with numbers { // alert('does not use numbers in index'); return false; } } return true; }; /* Array.prototype.sortNumberedThumbs = function() { var tempArray = new Array(); for(var i = 0; i < this.length; i++) { var reExp = /[\d]+/gi; var matches = this[i].match(reExp); if(matches instanceof Array)//if the files are indexed with numbers { tempArray[parseInt(matches[0])] = new String(this[i]); } else { return null;//if numbers are not used don't do anything } } if(this.length == tempArray.length)//check if arrays start at the zero index in order to loop correctly { var start = 0; var end = this.length; } else { var start = 1; var end = tempArray.length; } var sortedArray = new Array(); for(var i = start;i < end; i++)//loop tempArray in the indexed order and attach them to original array { sortedArray.push(tempArray[i]); } return sortedArray; }; */ Array.prototype.sortNumberedThumbs = function() { var tempArray = new Array(); var num = getPicNum(this[0]); if(!num) return null; tempArray.push(this[0]); for(var i = 0; i < (this.length - 1); i++) { for(var x = i + 1; x < this.length; x++) { var newNum = getPicNum(this[x]); var curNum = getPicNum(this[i]); if(!num)return null; if(newNum < curNum) { var temp = this[i]; this[i] = this[x]; this[x] = temp; } } } }; function getPicNum(pic) { var reExp = /[\d]+/gi; var matches = pic.match(reExp); if(matches instanceof Array)//if the files are indexed with numbers { return parseInt(matches[0]); } else { return null; } } function getURLParam(param) { var winLoc = window.location.toString().toLowerCase(); if(winLoc.indexOf(param) == -1)return null; var divider = '?'; if(winLoc.indexOf('&') != -1) { divider = '&'; } var arWinLoc = winLoc.split(divider); for(var i = 0; i < arWinLoc.length; i ++) { if(arWinLoc[i].indexOf(param.toLowerCase()) != -1) { return (arWinLoc[i].split('=')[1].toLowerCase()); } } return null; } function getCaption(imagesLength,docID,imgNum) { var article = new Article(docID); var str = article.loadAjax(); if(str.indexOf('articleResult') != -1) { eval(str); var summaries = unescape(articleResult.Summary); if(summaries && summaries.length > 0) { var aSummaries = summaries.split(';'); //alert(aSummaries.length + ' ' + imagesLength); if(aSummaries.length == imagesLength && typeof aSummaries[imgNum] != 'undefined') { return aSummaries[imgNum]; } } } return ""; } function popUp(oEvent) { var target = stopEvent(oEvent); //window.location = target.parentNode.getAttribute('href'); if(screen.height < 850) { window.open(target.parentNode.getAttribute('href'),"WheelsGallery", "fullscreen=0,height=640,width=876,resizable=0,status=0,scrollbars=1"); } else { window.open(target.parentNode.getAttribute('href'),"WheelsGallery", "fullscreen=0,height=643,width=856,resizable=0,status=0,scrollbars=0"); } } function getNav(start,count,itemsNum) { var pages = Math.ceil(parseFloat(itemsNum) / parseFloat(count)); } /* function attachClassToEdDeskTag() { document.getElementById('edDeskBody').className = 'galleryBody'; } addLoadEvent(attachClassToEdDeskTag); */ if (document.forms[0].PageType.value == "article" && currentSection == "Galleries" && currentSubsection == "Galleries") { var thumbs = getThumbs(); //alert(unescape(document.forms[0].Attachments.value) + '\n\n' + thumbs); var galleryStart = parseInt(getURLParam('start')); if(!galleryStart)galleryStart = 0; var end = galleryStart + 12; if(thumbs instanceof Array) { document.write('
'); //if(end > thumbs.length)end = thumbs.length; //alert(thumbs.length - 12); if((thumbs.length - galleryStart)< 12)end = thumbs.length; for(var i = galleryStart; i < end; i++) { var galleryLink = '/wheels/site/articleIDs/' + document.forms[0].DocID.value + '?open&template=domGallery&image=' + i; var imgSrc = '/wheels/site/articleIDs/' + document.forms[0].DocID.value + '/$file/' + thumbs[i]; var imgTitle = unescape(document.forms[0].Title.value) + ' - image ' + (i + 1); document.write('',getCaption(thumbs.length,document.forms[0].DocID.value,i),''); } var totalPages = Math.ceil(thumbs.length / 12); var currentPage = 1; for(var i = 0; i < thumbs.length; i= i + 12) { if(galleryStart >= i && galleryStart <= (i + 11)) { break; } currentPage++; } //document.write('
'); if(thumbs.length > 12) { document.write(''); } document.write(''); } }