jQuery(".sprite-icon_playVideoThumb").eq(0).addClass("tumbBorder")

//Embeds the video by replacing the vehicle Image.
jQuery("div.videoId").click(function() {
	var videoDivId = jQuery(this).attr("id");
	var videoType = videoDivId.split('videoId_', 2)[1];
	var videoIndex = videoType.split('_')[1];
	currentVideo = videoDivId;

	jQuery(".sprite-icon_playVideoThumb").removeClass("tumbBorder")
	jQuery(".tumbBorder").removeClass("tumbBorder");
	jQuery("#"+videoDivId).addClass('tumbBorder');
	jQuery("#vehPhoto").hide();
	jQuery("#vehicleVideo").empty();
	//Onclicking the video thumbnail in IE the toolip and hand cursor is shown on the same place. To remove the same below code is added.
	jQuery("div.videoToolTip").hide();
	jQuery("div.videoToolTip").css({ cursor:"pointer" });
	//Display video discalimer based on the configurations
	displayVideoDisclaimer( videoDisclaimer[videoIndex] );
	if(isSlideShow) clearInterval(slideshowTimer);
	jQuery("#vehicleVideo").show();
	try	{
		if (videoType.indexOf('pic2vid_') != -1) {
			// On click of pics-to-video icon, it should start playing automatically. 
			LTVAutoPlay = 1;
			LTVFLA();
		} else {
			var videoURL = videoUrls[videoIndex];
			var videoso = new SWFObject(videoURL, 'swfId', "250", "185" , "8", "#FFFFFF");
			videoso.addVariable("autoStart", "true"); 
			videoso.write(vehicleVideo);
		}
		sendPixelTag({
			pageLabel: videoPixelTag[videoIndex],
			pageName: uniquePageName,
			// send id so that VIN is included in pixel tag
			// var vehicleID is defined in details_widget_redesign.jsp
			id: vehicleID
		});
		// new framework
		EventManager.publish({
			eventName:'com.cobaltgroup.ws.view.media.video',
			publisherData:{pageLabel:videoPixelTag[videoIndex]}
		});
	}
	catch (exception){
		handleVideoException( );
		return;
	}
});
// video thumbnail mouseover action
jQuery('.sprite-icon_playVideoThumb').mouseover(
	function() {
		var thisThumbId = jQuery(this).attr("id");
		var thisToolTipId = jQuery(this).attr("id").split('_')[2];
		
		var videooffset = jQuery("div.videoId").offset();
		var toolTip = jQuery("div.videoToolTip");
		
		var thumboffset = jQuery("#"+thisThumbId).offset();
		var pIdoffset = toolTip.offset();

		var topOffset = videooffset.top ;
		var leftthumboffset = thumboffset.left ;
		var tooltipTop = topOffset - toolTip.height()-19;

		jQuery("#"+thisThumbId).addClass('tumbBorder');
		jQuery("#videoToolTip_"+thisToolTipId).css({ display:"block",top:tooltipTop,left:leftthumboffset-60 });
	}
)
// video thumbnail mouseout action
jQuery('.sprite-icon_playVideoThumb').mouseout(
	function() {
		var thisThumbId = jQuery(this).attr("id");
		var thisToolTipId = jQuery(this).attr("id").split('_')[2];
		if (currentVideo != thisThumbId)
			jQuery("#"+thisThumbId).removeClass('tumbBorder');

		jQuery("#videoToolTip_"+thisToolTipId).css({ display:"none"});
	}
)
function sendPixelTag(pixelData) {
	var o = pixelData;
	var postParameters;
	postParameters = "";
	postParameters += (!o.pageLabel) ? "" : "&pageLabel=" + o.pageLabel;
	postParameters += (!o.pageName) ? "" : "&pageName=" + o.pageName;
	// check for inclusion of vehicle id
	postParameters += (!o.id) ? "" : "&id=" + o.id;
	//
	var qString = (!o.queryString) ? "" : o.queryString;
	jQuery.ajax({
		type: "POST",
		dataType: "html",
		async: "false",
		data: postParameters,
		url: "pixelInformation.ajax" + qString, 
		success: function(data) {
			jQuery('body').append(data);
		},
		error: function(oXHR, err, oExc) {
			alert(err);
		}
	});
}

jQuery("#singleThumbnailPhoto").click(function() {
	showPhoto();
});	

function showPhoto(){
	jQuery("#vehicleVideo").empty();
	jQuery("#videoDisclaimerId").css({ display:"none" });
	jQuery("#vehPhoto").show();
	jQuery(".sprite-icon_playVideoThumb").removeClass("tumbBorder");
	currentVideo = "";
}

jQuery(".thumbImage").click(function() {
	jQuery(".sprite-icon_playVideoThumb").removeClass("tumbBorder");
	currentVideo = "";
});
function handleVideoException() {
	showPhoto();
	alert(VIDEO_CONTENT_NOT_AVAILABLE);
	if(isSlideShow) {
		slideshowTimer = setTimeout("slideshow()",5000);
		jQuery('.sprite-icon_playVideoThumb').removeClass("tumbBorder");
	}
}
function displayVideoDisclaimer( disclaimer ){
	if( disclaimer  != '') {
		jQuery("#videoDisclaimerId").html(disclaimer);
		jQuery("#videoDisclaimerId").css({ display:"block" });
	} else {
		jQuery("#videoDisclaimerId").css({ display:"none" });
	}
}