function doTitle(){
	if (vidTitle != "" && vidTitle != null) document.write("<h2>"+vidTitle+"</h2>");document.close();
}
function doCaption(){
	if (vidCaption != "" && vidCaption != null) {
	document.write('<div class="caption">'+vidCaption+'</div>');document.close();
	}else {
	document.write('<div class="caption"></div>');document.close();
	}
}
function doSection(){
	if (vidSection != "" && vidSection != null) document.write(vidSection); document.close(); 
}

function emailToFriend(){
		openPopup('/go/email/mailerPopUp.jsp', "mailpopup", "width=425,height=600,top=50,left=50");
}

function selectItem(){
	urlStr=document.videonav.vehicledropdown.options[document.videonav.vehicledropdown.selectedIndex].value;
	location.href = "index.jsp?self=t&"+urlStr;
	return;
}

function showVidNav(){
	var d = document.getElementById('vidNavDropdown');
	if (d.style.visibility != "visible") {
	d.style.visibility = "visible";  
	document.getElementById('changeLinkIcon').src = "images/minusIcon.jpg";
	}
	else if (d.style.visibility == "visible") {
	d.style.visibility = "hidden"; 
	document.getElementById('changeLinkIcon').src = "images/plusIcon.jpg";
	}
	d.style.top = "65px";
}

function hideDropdown(){
	var d = document.getElementById('vidNavDropdown');
	if (d.style.visibility == "visible") {
	d.style.visibility = "hidden";  
	}
}








var aStep = 0;
function moveOn(arg,step){
	var theArray;
	var arrayLength = 0;
	var isValt = false;
	var isXml = false;
	try {
	arrayLength = mmy.length;
	theArray = mmy;
	isValt = true;
	}catch (e){
	arrayLength = mmyXml.length;
	theArray = mmyXml;
	isXml = true;
	}
	if (arg == 'prev' && (aStep - step >= 0)) aStep = aStep - step;
	else if (arg == 'next' && (aStep + step < arrayLength)) aStep += step; 

	 if (aStep < step) $("#prevLink").css("visibility","hidden");
	 if (aStep >= step) $("#prevLink").css("visibility","visible");
	 if (aStep < arrayLength + step) $("#nextLink").css("visibility","visible");	
	
	
//alert (arg+";"+aStep);
	var arr = [];
	var divsArray = $("div").get();
	for (i=0; i<divsArray.length; i++){
   		if(divsArray[i].id == 'thumbUnit'){
		arr.push(divsArray[i]);
		}
	}
		
	for (i=0;i<arr.length;i++){
		try{
		var theMmy; 
		var theHtml;
		theMmy = theArray[aStep+i].split(",");
		if(isValt) {
			theHtml = '<a href="/go/video/index.jsp?makeid='+theMmy[1]+'&modelid='+theMmy[2]+'&year='+theMmy[0]+'&location='+theMmy[6]+navParams+'"><img id="navThumb" src="'+theMmy[3]+'"  onerror="this.src=\'/images/pixel.gif\';">'+theMmy[0]+' '+theMmy[4]+' '+theMmy[5]+'</a>';
		}else if(isXml){
			theHtml = '<a href="/go/video/index.jsp?'+theMmy[2]+navParams+'"><img id="navThumb" src="'+theMmy[1]+'"  onerror="this.src=\'/images/pixel.gif\';">'+theMmy[0]+'</a>';
		}
	
		
		
		$(arr[i]).html(theHtml);
		}
		catch(e){
		if (arg == 'next') $("#nextLink").css("visibility","hidden");
		else if (arg == 'prev') $("#prevLink").css("visibility","hidden");
		$(arr[i]).html(""); //$(arr[i]).css("border","0");
		}
	}
	var stepStart = aStep+1;
	var stepEnd = aStep+step;
	if(stepEnd > arrayLength) stepEnd = arrayLength;
	if(stepStart > stepEnd) stepStart = stepEnd;
	$("#navText").text("Viewing "+(stepStart)+"-"+(stepEnd)+" of "+ (arrayLength));
}

function scrollRel(dir){
	scrollStep = 0;
	
	if (dir == 'down') {
	scrollStep = scrollStep + 2;
		for(i=1;i<=3;i++){
			var divName = 'thumbCont' + i;
			if((i+scrollStep) < thumbUnitsArray.length){
			$('#'+divName).html(thumbUnitsArray[i+scrollStep]);
			}else{
			$('#'+divName).css("visibility","hidden");
			}
		}
	}else if(dir == 'up'){
		for(i = 3; i > 0; i--){
		var divName = 'thumbCont' + i;
			if(i+scrollStep-1 >= 0){
			$('#'+divName).css("visibility","visible");
			$('#'+divName).html(thumbUnitsArray[i+scrollStep-1]);
			}
		}
	scrollStep = scrollStep - 2;
	}
}




function getList(list,ctr){
mmy = null;
mmyXml = null;
aStep= ctr;
aStep = -aStep;
$("#thumbnailDisplay").css("opacity",".2");
$("#loading").css("visibility","visible");

$.ajax({
  type: "GET",
  url: "/go/video/includes/_getThumbsListAjax.jsp?"+list,
  dataType: "script",
	 success: function (d,t) {
	 if(t == 'success') {
  	moveOn('next',ctr);
	$("#thumbnailDisplay").css("opacity","1");
	$("#loading").css("visibility","hidden");
	}
  }
});
removeHlt();
navParams = "&"+list;
}

function removeHlt(){
$(".navLinkOver").addClass("navLink");
$(".navLinkOver").removeClass("navLinkOver");
navLinkStatus = "navLinkOver";
}