var fx; var currentPosition=0; var selectedYear=0; var videoArray = []; var videoOrder = []; var videoImgArray = []; var initialVideo=0; var transparencyEnabled = true; var currentlySliding = false; var videoCount=0; var currentGroup = 31; var site = 'racing'; function urldecode( str ) { var histogram = {}; var ret = str.toString(); var replacer = function(search, replace, str) { var tmp_arr = []; tmp_arr = str.split(search); return tmp_arr.join(replace); }; // The histogram is identical to the one in urlencode. histogram["'"] = '%27'; histogram['('] = '%28'; histogram[')'] = '%29'; histogram['*'] = '%2A'; histogram['~'] = '%7E'; histogram['!'] = '%21'; histogram['%20'] = '+'; for (replace in histogram) { search = histogram[replace]; // Switch order when decoding ret = replacer(search, replace, ret) // Custom replace. No regexing } // End with decodeURIComponent, which most resembles PHP's encoding functions ret = decodeURIComponent(ret); return ret; } function shiftBar(shiftAmount) { if (!currentlySliding) { currentlySliding = true; var newLeft = parseInt($('videoDisplay').style.left.substring(0,$('videoDisplay').style.left.length - 2)); var overflowFlag = false; if (shiftAmount>0) { if (((videoCount-currentPosition)-5) < shiftAmount) { var allowedShift = (videoCount-currentPosition)-5; if (allowedShift>0) { shiftAmount=allowedShift; } else { overflowFlag=true; } } } else { if ((currentPosition+shiftAmount)<0) { if (currentPosition!==0) { shiftAmount = -currentPosition; } else { overflowFlag=true; } } } newLeft -= shiftAmount * 124; if (!overflowFlag) { currentPosition += shiftAmount; if (currentPosition == 0) { $("arrow_left").style.display = "none"; } else { $("arrow_left").style.display = "block"; } var allowedShift = (videoCount-currentPosition)-5; if (allowedShift <= 0) { $("arrow_right").style.display = "none"; } else { $("arrow_right").style.display = "block"; } fx.start({'left':newLeft + "px"}).chain( function(){ currentlySliding=false; } ); } else { currentlySliding = false; } } } /*get timestmap for AJAX requests to prevent caching*/ function getTimestamp() { var date = new Date(); var timestamp = date.getTime(); return timestamp; } function showOverlay(element) { var vidId = element.id.split("_")[1]; $("video_" + vidId + "_overlay").style.zIndex = "2"; } function hideOverlay(element) { var vidId = element.id.split("_")[1]; $("video_" + vidId + "_overlay").style.zIndex = "0"; } function loadTimeline(groupId) { var prevGroup = currentGroup; currentGroup = groupId; videoArray = []; currentPosition=0; videoOrder = []; $('videoDisplay').style.left = "0px"; while($('videoDisplay').childNodes.length>=1) { $('videoDisplay').removeChild($('videoDisplay').firstChild); } var req = new Request({ method:'get', url:'video_gallery.cfm', data:{'action':'load','video_group':groupId,'template_site':site,'timestamp':getTimestamp()}, onComplete:function(response) { var localVideoCount=0; var i=0; videoResponseSplit = response.split("_VIDEO_"); videoCount = videoResponseSplit.length-1; if (!$("group_" + prevGroup)) { videoCount = 0; $("slideYearHolder").style.display = "none"; $("video_bottom_padding").style.display = "none"; } if (videoCount != 0) { $("slideYearHolder").style.display = "block"; $("video_bottom_padding").style.display = "block"; //$("widgetMainVideo").style.background = "#ffce84"; //$("intro_text").style.background = "#ffbf5f"; //$("intro_text").style.fontColor = "#fff"; //$("intro_text").innerHTML = "Click on a video below to view"; if (prevGroup != 0) { //$("group_" + prevGroup).style.background = "#ffbf5f url(imgs/unselected_tab.jpg) bottom no-repeat"; $("group_" + prevGroup).className = "unSelectedTab"; $("group_link_" + prevGroup).className = "tabLink"; } //$("group_" + groupId).style.background = "#ff9900 url(imgs/selected_tab.jpg) bottom no-repeat"; $("group_" + groupId).className = "selectedTab"; $("group_link_" + groupId).className = "tabLinkSelected"; for (i=0; i" + videoArray[curVideoId]["video_desc"] + "";//" + curVideoId + "/video.xml\");'/>"; } else if (videoArray[curVideoId]["video_type"] == 2) { var tempString = urldecode(videoArray[curVideoId]["video_path"]).split("/v/")[1].split("&hl")[0]; var youtubeThumbnail = "http://img.youtube.com/vi/" + tempString + "/default.jpg"; newThumb.innerHTML = "" + videoArray[curVideoId]["video_desc"] + ""; } else if (videoArray[curVideoId]["video_type"] == 3) { var tempString = urldecode(videoArray[curVideoId]["video_path"]).split("docid=")[1].split("&hl=")[0]; newThumb.innerHTML = "" + videoArray[curVideoId]["video_desc"] + ""; } newThumbHolder.className = "slideVideoThumbBox"; newThumbHolder.name = curVideoId; newThumbHolder.innerHTML = ""; newThumbHolder.id = "thumb_holder_" + curVideoId; if (i==1) { newThumbHolder.style.marginLeft = "15px"; } newThumb.id = "thumb_" + curVideoId; var newTitleDiv = new Element('DIV'); newTitleDiv.innerHTML = "" + videoArray[curVideoId]["video_title"] + ""; newTitleDiv.style.width = "130px"; newTitleDiv.style.height = "40px"; newTitleDiv.style.border = "0px solid red"; //newTitleDiv.style.marginLeft = "10px"; newTitleDiv.style.backgroundColor = "#ffbf5f"; newTitleDiv.style.fontFamily = "Arial"; newTitleDiv.style.color = "#fff"; newTitleDiv.style.fontWeight = "bold"; newTitleDiv.style.fontSize = "12px"; newThumbHolder.appendChild(newThumb); newThumbHolder.appendChild(newTitleDiv); $('videoDisplay').style.width = parseInt($('videoDisplay').getWidth() + 270) + "px"; $('videoDisplay').appendChild(newThumbHolder); } } //var targetBump = currentPosition; currentPosition=0; //shiftBar(targetBump-3); //bumpButton(targetYear); if (videoCount > 5) { $("arrow_left").style.display = "none"; $("arrow_right").style.display = "block"; } else { $("arrow_left").style.display = "none"; $("arrow_right").style.display = "none"; } } else { //$("widgetMainVideo").style.background = "#fff"; //$("intro_text").style.background = "#fff"; //$("intro_text").style.fontColor = "#ffbf5f"; //$("intro_text").innerHTML = "No videos available"; } } }).send(); } window.addEvent('domready', function() { fx = new Fx.Morph('videoDisplay', {duration:500, wait:true}); fx.options.transition = Fx.Transitions.Linear; //initialYear = Math.floor(Math.random()*(yearCount-6)); //initialYear += 3; loadTimeline(currentGroup); });