//private functions
var g_sModelId = '';
var g_sTrimId = '';
var g_sFamilyId = '';
var g_s360ViewTab = 100; // features wanting this code to handle 360Views need to override this value for the correct tab number that represents the 360Views
var g_sVideoTab = 101; // features wanting this code to handle Videos need to override this value for the correct tab number that represents the Videos

/*
The 360Viewers cannot be controlled client-side so a thumbnail click --
which calls Target_Update -- reloads the master page with an additional 
query string for the "BigImage" so that the 360 control is intialized
server-side. However, the master page also called Gallery_onLoad which
in turn calls Target_Update again causing an infinite loop. This variable
suppresses that behavior by allowing only one reload by Target_Update.
*/
var g_suppressNextRedirect = false;

var g_sBackgroundColor = "#366AB3";

function Gallery_Reset(nImgIndex)
{
	if(oImageGrid != null)
		Gallery_ChangeHighlight(nImgIndex);
	Gallery_UpdateTargets(nImgIndex);
	g_nCurrentImgIndex = nImgIndex;
}

function Gallery_UpdateTargets(nClickIdx)
{
	for (var nLooper = 0;nLooper < oTarget.length; nLooper++)
	{
		if (null != oTarget[nLooper])
			oTarget[nLooper].Update(nClickIdx);
	}
}

var ix = 0;
function TrackMe()
{
	var ping = document.getElementById("ping");
	if (null != ping)
		ping.firstChild.src = ping.href + "?src=" + document.location.pathname + "&ix=" + ++ix;
}

function Gallery_UpdateAd()
{
    TrackMe();
    var adFrame = parent.document.getElementById("AdFrame");
    var taxImg = parent.document.getElementById("taxImg");
    //Removed the older iframe refresh code and called renderad method to refresh the ad.
    renderAd();
    taxImg.src = taxImg.src;
    if(parent.document.getElementById("omni"))
    {
        var s_code=s.t();
        if(s_code)
            parent.document.write(s_code);
    }
}

function Gallery_ChangeHighlight(nClickIdx)
{
	if (g_nCurrentImgIndex <= oTarget[g_CurrentTarget].ImagesList[g_CurrentImgList].m_rgImages.length)
	{
		document.getElementById("ImageBorder" + g_nCurrentImgIndex).bgColor = g_sUnSelectedColor;
		document.getElementById("ImageBorder" + g_nCurrentImgIndex).style.borderColor = g_sUnSelectedColor;
	}
	else
	{
		document.getElementById("ImageBorder" + g_nCurrentImgIndex).bgColor = g_sBackgroundColor;
		document.getElementById("ImageBorder" + g_nCurrentImgIndex).style.borderColor = g_sBackgroundColor;
	}
	document.getElementById("ImageBorder" + nClickIdx).bgColor = g_sSelectedColor;
	document.getElementById("ImageBorder" + nClickIdx).style.borderColor = g_sSelectedColor;
	document.getElementById("Image" + g_nCurrentImgIndex).width  =  80
	document.getElementById("Image" + g_nCurrentImgIndex).height =  48
	document.getElementById("Image" + nClickIdx).width  =  78
	document.getElementById("Image" + nClickIdx).height =  46
}

function Gallery_UpdateRadio(nAlbumID, nIndex)
{
	document.getElementById("RadioSpan" + nIndex).innerHTML = oAlbums[nAlbumID].m_sShortName.substring(0,20);
	document.getElementById("Radio" + nIndex).value = oAlbums[nAlbumID].m_nAlbum;
}

function Gallery_UpdateTabs(sImageList)
{
	var sTempinnerHTML = "";
	for(var nLooper = 0;nLooper < g_nNumberOfImageLists;nLooper++)
	{
		sTempinnerHTML = document.getElementById("Tab" + nLooper).innerHTML;
		document.getElementById("Tab" + nLooper).innerHTML = sTempinnerHTML.replace(/up/g, "down");
	}
	sTempinnerHTML = document.getElementById("Tab" + sImageList).innerHTML;
	document.getElementById("Tab" + sImageList).innerHTML = sTempinnerHTML.replace(/down/g, "up");
}

//Event functions
function Gallery_onLoad(nImgIndex, sImageList)
{
	if(oImageGrid != null)
	{
		Gallery_UpdateTabs(sImageList);
		oImageGrid.LoadImages(oTarget[g_CurrentTarget].Album.m_nAlbumID);
		Gallery_ChangeHighlight(nImgIndex);
	}
	Gallery_UpdateTargets(nImgIndex);
	g_nCurrentImgIndex = nImgIndex;
}

function Gallery_FMustReloadPage(sImageList)
{
	var s = oTarget[g_CurrentTarget].ImagesList[g_CurrentImgList].m_sTab;
	if ("360view" == s || "video" == s) return true;
	
	s = oTarget[g_CurrentTarget].ImagesList[sImageList].m_sTab;
	if ("360view" == s || "video" == s) return true;
	
	return false;
}

function Gallery_onTabClick(sImageList, sModelId, sTrimId, sFamilyId, sPictureId)
{
	if (sImageList == g_CurrentImgList) return;

	var fMustReload = Gallery_FMustReloadPage(sImageList);	
	g_CurrentImgList = sImageList;

	// going to or coming from one of these requires a reload
	if (!fMustReload)
	{
		if (oImageGrid != null)
		{
			Gallery_UpdateTabs(sImageList);
			oImageGrid.LoadImages(oTarget[g_CurrentTarget].Album.m_nAlbumID);
		}
		Gallery_UpdateAd();
		Gallery_Reset(0);
	}
	else
	{
		if (sPictureId === (void 0)) sPictureId = "0";
		
		imageList = oTarget[g_CurrentTarget].ImagesList[sImageList];
		galleryImage = imageList.m_rgImages[sPictureId];
		
		var qs = "?action=" + galleryImage.m_sAction + "&picturetab=" + imageList.m_sTab + "&modelid=" + sModelId + "&trimid=" + sTrimId + "&familyid=" + sFamilyId + "&pictureid=" + sPictureId + "&usage=" + "&file=" + galleryImage.GetBigImage();
		var dl = document.location;
		dl.href = 'http://' + dl.hostname + dl.pathname + qs;
		return true;
	}
}

function  Gallery_onClickRadio(oRadio)
{
	var nIndex = parseInt(oRadio.id.replace("Radio", ""));
	g_CurrentTarget = nIndex;
	if(oImageGrid != null)
		oImageGrid.LoadImages(oTarget[nIndex].Album.m_nAlbumID);
	Gallery_Reset(g_nCurrentImgIndex);
	Gallery_UpdateAd();
}

function Gallery_onClickImage(oImageID)
{
	var nFromIndex = parseInt(oImageID.id.replace("Image", ""));
	if (document.getElementById("Image" + nFromIndex).src.indexOf("space") == -1)
	{
		if(oImageGrid != null)
			Gallery_ChangeHighlight(nFromIndex);
		Gallery_UpdateTargets(nFromIndex);	
		g_nCurrentImgIndex = nFromIndex;
		Gallery_UpdateAd();
	}
}

function Gallery_onChangeVehicleList(nAlbumID, nIndex)
{
	var nAddValue;
	if (nAlbumID != "add")
	{
		oTarget[nIndex] =  new Target(oAlbums[nAlbumID], nIndex);
		oTarget[nIndex].AddImages();
		oTarget[nIndex].Update(g_nCurrentImgIndex);
		sTrimValue =  "t" + nAlbumID;
		ModifyProperties('g_nPhotoCompareVehicle' + (nIndex + 1), sTrimValue);
		if(g_bAddMode == false && oImageGrid != null)
			Gallery_UpdateRadio(nAlbumID, nIndex);
		if (g_CurrentTarget == nIndex)
		{
			if(oImageGrid != null)
				oImageGrid.LoadImages(nAlbumID);
			Gallery_Reset(g_nCurrentImgIndex);
		}
	}
	else
	{
		ModifyProperties('g_nCurrentImageList', g_CurrentImgList);
		ModifyProperties('g_nCurrentImage', g_nCurrentImgIndex);
		ModifyProperties('g_nPhotoCompareVehicle' + (nIndex + 1), 0);
		if(g_bAddMode)
			SubmitCompare('photoCompare.aspx?','&a=2&tgt=' + (nIndex + 1));
		else
			SubmitCompare('photoCompare.aspx?','&a=1&tgt=' + (nIndex + 1));
	}
	document.getElementById("VehicleList" + nIndex).selectedIndex = 0;	
	Gallery_UpdateAd();
}

function Gallery_onChangeButtomImage(oButton, sState, sDirection)
{
	switch(sState)
	{
		case "up":
			oButton.src = g_sImagePath + "control_" + sDirection + "_up.gif";
		break;
		case "down":
			oButton.src = g_sImagePath + "control_" + sDirection + "_down.gif";
		break;
		case "hover":
			oButton.src = g_sImagePath + "control_" + sDirection + "_hover.gif"; 
		break;
		default:
			oButton.src = g_sImagePath + "control_" + sDirection + "_up.gif";
		break;
	}
}

function Gallery_onClickNavButton(sDirection)
{
	var tmpImgList = g_CurrentImgList;
	var nTempIdx = g_nCurrentImgIndex + 1;
	
	var doAdRefresh = true;
	if(sDirection == "back")
	{
		nTempIdx = g_nCurrentImgIndex - 1;
	
		if (nTempIdx < 0)
		{
			if(tmpImgList != 0) 
				tmpImgList--;
			else
				tmpImgList = (g_nNumberOfImageLists - 1);
			
			nTempIdx = (oTarget[g_CurrentTarget].ImagesList[tmpImgList].m_rgImages.length - 1);
			doAdRefresh = Gallery_FMustReloadPage(tmpImgList);
			if (Gallery_onTabClick(tmpImgList, g_sModelId, g_sTrimId, g_sFamilyId, nTempIdx)) return;
		}
	}	
	else if (nTempIdx == (oTarget[g_CurrentTarget].ImagesList[g_CurrentImgList].m_rgImages.length))
	{
		nTempIdx = 0;
		if(tmpImgList != (g_nNumberOfImageLists - 1)) 
			tmpImgList++;
		else
			tmpImgList = 0;
			
		doAdRefresh = Gallery_FMustReloadPage(tmpImgList);
		if (Gallery_onTabClick(tmpImgList, g_sModelId, g_sTrimId, g_sFamilyId, nTempIdx)) return;
	}
	
	if(oImageGrid != null)
		Gallery_ChangeHighlight(nTempIdx);
		
	Gallery_UpdateTargets(nTempIdx);	
	g_nCurrentImgIndex = nTempIdx;
	if (doAdRefresh)
		Gallery_UpdateAd();
}

// Album Object. This object will get initialized with the master control. 
function Album(nAlbumID, sName, sShortName, sAds) 
{	
	this.m_sName = sName;
	this.m_sShortName = sShortName;
	this.m_nAlbumID = nAlbumID;
	this.m_sAds = sAds;
	this.m_rgImages = Array(1);
	this.m_nNumImage = 0;
	//methods
	this.AddImage = Album_AddImage;
}

// Compresed Image object. Property of Album object
function CompressedImage(sType, sSrc, sCaption, sAltText, sTitle)
{	
	this.m_sType = sType;
	this.m_sSrc = sSrc;
	this.m_sTitle = sTitle;
	this.m_sCaption = sCaption;
	this.m_sAltText = sAltText;
}

//Album add image method
function Album_AddImage(oImage)
{
	this.m_rgImages[this.m_nNumImage] = oImage;
	this.m_nNumImage++;
}

//Target Object
function Target(oAlbum, nIndex) 
{
	this.m_nIndex = nIndex;	
	this.ImagesList = Array(1);
	this.Album = oAlbum;
	
	//Methods
	this.AddImages = Target_AddImages;
	this.Update = Target_Update;
}

//Update Method
function Target_Update(nClickIdx)
{
	if (this.Album.m_sName != 0)
	{
		var imagesList = this.ImagesList[g_CurrentImgList];
		var galleryImage = imagesList.m_rgImages[nClickIdx];
		switch (galleryImage.m_sAction)
		{
			case "360Int":
			case "360Ext":
			case "Video":
				g_suppressNextRedirect = false;				
				break;
			default:
				document.getElementById("TargetSrc" + this.m_nIndex).src = galleryImage.GetBigImage();
				document.getElementById("TargetSrc" + this.m_nIndex).width = imagesList.m_nWidth; 
				document.getElementById("TargetSrc" + this.m_nIndex).height = imagesList.m_nHeight;
				document.getElementById("TargetSrc" + this.m_nIndex).alt =  this.Album.m_sName;
			break;
		}
		
		if (document.getElementById("TargetTitle" + this.m_nIndex))
			document.getElementById("TargetTitle" + this.m_nIndex).innerHTML = this.Album.m_sName;
		var cap=document.getElementById("TargetCaption" + this.m_nIndex);
		cap.innerHTML = galleryImage.m_sCaption==''?'&nbsp;':galleryImage.m_sCaption;
		var vip=document.getElementById("vip");
		if(vip)vip.style.display=(cap.innerHTML.length <= 250 && vip)?"block":"none";
	}
	else
	{
		document.getElementById("TargetSrc" + this.m_nIndex).width = 0; 
		document.getElementById("TargetSrc" + this.m_nIndex).height = 0;
	}
}

function Target_SlideShow(imagesList)
{
	// clear the slideshow
	while(ss_rgsImgURL.length > 0)
		ss_rgsImgURL.pop();
	
	for (var nLooper = 0; nLooper < imagesList.m_rgImages.length; nLooper++)
	{
		var galleryImage = imagesList.m_rgImages[nLooper];
		ss_rgsImgURL.push(galleryImage.GetBigImage());
	}
	ss_play();
}

//Add method
function Target_AddImages()
{
	for (var nOuterLooper = 0; nOuterLooper < this.Album.m_nNumImage; nOuterLooper++)
	{
		var rgTempImg = Array(1);
		var rgTempCaption = Array(1);
		sType = this.Album.m_rgImages[nOuterLooper].m_sType;
		this.ImagesList[nOuterLooper] = new ImageList();
		switch(sType)
		{
		case "autoshow":
			this.ImagesList[nOuterLooper] = new ImageList(g_sVImagePath, "", "photos/t_", "photos/l_", 380, 228, "as");
			rgTempImg = this.Album.m_rgImages[nOuterLooper].m_sSrc.split('^');
			rgTempCaption = this.Album.m_rgImages[nOuterLooper].m_sCaption.split('^');
			rgTempAltText = this.Album.m_rgImages[nOuterLooper].m_sAltText.split('^');
			for (var nLooper = 0; nLooper < rgTempImg.length; nLooper++)
			{
				this.ImagesList[nOuterLooper].m_rgImages[nLooper] = new GalleryImage(rgTempImg[nLooper] + this.ImagesList[nOuterLooper].m_sSuffix,rgTempCaption[nLooper], rgTempAltText[nLooper]);
			}
			break;
		case "general":
			this.ImagesList[nOuterLooper] = new ImageList(g_sVImagePath, "a.jpg", "thumbnail/t", "gallery/c", 380, 228, "gen");
			rgTempImg = this.Album.m_rgImages[nOuterLooper].m_sSrc.split('^');
			rgTempCaption = this.Album.m_rgImages[nOuterLooper].m_sCaption.split('^');
			rgTempAltText = this.Album.m_rgImages[nOuterLooper].m_sAltText.split('^');
			for (var nLooper = 0; nLooper < rgTempImg.length; nLooper++)
			{
				this.ImagesList[nOuterLooper].m_rgImages[nLooper] = new GalleryImage(rgTempImg[nLooper] + this.ImagesList[nOuterLooper].m_sSuffix,rgTempCaption[nLooper], rgTempAltText[nLooper], '', 'gen');
			}
			break;
		case "compareext":
			this.ImagesList[nOuterLooper] = new ImageList(g_sVImagePath, ".jpg", "evox/stills/thumbnail/", "evox/stills/gallery/", 365, 275, "ext");
			for (var nLooper = 0; nLooper < oExtEvoxImages.length; nLooper++)
			{
				this.ImagesList[nOuterLooper].m_rgImages[nLooper] = new GalleryImage(this.Album.m_rgImages[nOuterLooper].m_sSrc + "_" + oExtEvoxImages[nLooper].m_sID + this.ImagesList[nOuterLooper].m_sSuffix, this.Album.m_rgImages[nOuterLooper].m_sCaption, oExtEvoxImages[nLooper].m_sText, '', 'evox');
			}
			break;
		case "compareint":
			this.ImagesList[nOuterLooper] = new ImageList(g_sVImagePath, ".jpg", "evox/stills/thumbnail/", "evox/stills/gallery/", 365, 275, "int");
			for (var nLooper = 0; nLooper < oIntEvoxImages.length; nLooper++)
			{
				this.ImagesList[nOuterLooper].m_rgImages[nLooper] = new GalleryImage(this.Album.m_rgImages[nOuterLooper].m_sSrc + "_" + oIntEvoxImages[nLooper].m_sID + this.ImagesList[nOuterLooper].m_sSuffix, this.Album.m_rgImages[nOuterLooper].m_sCaption, oIntEvoxImages[nLooper].m_sText, '', 'evox');
			}
			break;
		case "360View":
			this.ImagesList[nOuterLooper] = new ImageList(g_sVImagePath, "a.jpg", "GenericThumb/a", "", 365, 275, "360view");
			
			rgTemp360 = this.Album.m_rgImages[nOuterLooper].m_sSrc.split('@@');
			if (rgTemp360[0])
				rgTemp360Int = rgTemp360[0].split('^');
			else
				rgTemp360Int = null;
			if (rgTemp360[1])
				rgTemp360Ext = rgTemp360[1].split('^');
			else
				rgTemp360Ext = null;
			
			rgTempThumb = this.Album.m_rgImages[nOuterLooper].m_sCaption.split('@@');
			var rgTempThumbInt;
			var rgTempThumbExt;
			if (rgTempThumb[0])
				rgTempThumbInt = rgTempThumb[0].split('^');
			if (rgTempThumb[1])
				rgTempThumbExt = rgTempThumb[1].split('^');
				
			rgTempCaption = this.Album.m_rgImages[nOuterLooper].m_sAltText.split('@@');
			var rgTempCaptionInt;
			var rgTempCaptionExt;
			if (rgTempCaption[0])
				rgTempCaptionInt = rgTempCaption[0].split('^');
			if (rgTempCaption[1])
				rgTempCaptionExt = rgTempCaption[1].split('^');
			
			rgTempTitle = this.Album.m_rgImages[nOuterLooper].m_sTitle.split('@@');
			var rgTempTitleInt;
			var rgTempTitleExt;
			if (rgTempTitle[0])
				rgTempTitleInt = rgTempTitle[0].split('^');
			if (rgTempTitle[1])
				rgTempTitleExt = rgTempTitle[1].split('^');
			
			var nLoopOffset = 0;
			if (rgTemp360Ext != null)
			{
				for (var nLooper = 0; nLooper < rgTemp360Ext.length; nLooper++)
				{
					var sSrc = rgTemp360Ext[nLooper];
					var sCaption = ''; if (rgTempCaptionExt) {sCaption = rgTempCaptionExt[nLooper]};
					var sTitle = ''; if (rgTempTitleExt) {sTitle = rgTempTitleExt[nLooper]};
					var sThumb = ''; if (rgTempThumbExt) {sThumb = rgTempThumbExt[nLooper]};
					this.ImagesList[nOuterLooper].m_rgImages[nLooper] = new GalleryImage(sSrc, sCaption, sTitle, sThumb, '360Ext');
				}
				nLoopOffset = rgTemp360Ext.length;
			}
			if (rgTemp360Int != null)
			{
				for (var nLooper = 0; nLooper < rgTemp360Int.length; nLooper++)
				{
					var sSrc = rgTemp360Int[nLooper];
					var sCaption = ''; if (rgTempCaptionInt) {sCaption = rgTempCaptionInt[nLooper]};
					var sTitle = ''; if (rgTempTitleInt) {sTitle = rgTempTitleInt[nLooper]};
					var sThumb = ''; if (rgTempThumbInt) {sThumb = rgTempThumbInt[nLooper]};
					this.ImagesList[nOuterLooper].m_rgImages[nLoopOffset + nLooper] = new GalleryImage(sSrc, sCaption, sTitle, sThumb, '360Int');
				}
			}
			break;
		case "Video":
			this.ImagesList[nOuterLooper] = new ImageList(g_sVImagePath, "a.jpg", "GenericThumb/a", "", 365, 275, "video");
			
			var rgTempSrc = this.Album.m_rgImages[nOuterLooper].m_sSrc.split('^');
			var rgTempAltText = this.Album.m_rgImages[nOuterLooper].m_sAltText.split('^');
			var rgTempTitle = this.Album.m_rgImages[nOuterLooper].m_sTitle.split('^');
			var rgTempCaption = this.Album.m_rgImages[nOuterLooper].m_sCaption.split('^');
			
			for (var nLooper = 0; nLooper < rgTempSrc.length; nLooper++)
			{
				this.ImagesList[nOuterLooper].m_rgImages[nLooper] = new GalleryImage(rgTempSrc[nLooper], rgTempAltText[nLooper], rgTempTitle[nLooper], rgTempCaption[nLooper], 'Video');
			}
			break;
		}
	}
}

//Image Category Object Property of Album Object. 
function ImageList(sImgPath, sSuffix, sThumbImgValue, sBigImgValue, nWidth, nHeight, sTab)
{
	this.m_sSuffix = sSuffix;  // a.jpg
	this.m_sImgPath = sImgPath;
	this.m_sThumbImgValue = sThumbImgValue; // thumbnail/t
	this.m_sBigImgValue = sBigImgValue; // ""
	this.m_nWidth = nWidth; // 365
	this.m_nHeight = nHeight; // 275
	this.m_rgImages = Array(1);
	this.m_sTab = sTab;
}

// Album Image Object. Property of Album Object. This object could be an array.
function GalleryImage(sSrc, sCaption, sAltText, sThumb, sAction)
{
	this.m_sSrc = sSrc;
	this.m_sCaption = sCaption;
	this.m_sAltText = sAltText;
	this.m_sThumb = sThumb;
	this.m_sAction = sAction;
	//method
	this.GetBigImage = Image_GetBigImage;
	this.GetThumbImage = Image_GetThumbImage;
}

//Image method for getting large image values
function Image_GetBigImage()
{
	sImageList = oTarget[g_CurrentTarget].ImagesList[g_CurrentImgList];
	if (this.m_sAction === (void 0)) // not all GalleryImages define an action
	{
		return(sImageList.m_sImgPath + sImageList.m_sBigImgValue + this.m_sSrc);
	}
	else if (this.m_sAction == "Video")
	{
		return(this.m_sSrc);
		//return("http://autos.msn.com/Media/ASX/0211_MBR.asx");
	}
	else
	{
		return(sImageList.m_sImgPath + sImageList.m_sBigImgValue + this.m_sSrc);
	}
}

//Image method for getting thumbnail image values
function Image_GetThumbImage()
{
	sImageList = oTarget[g_CurrentTarget].ImagesList[g_CurrentImgList];
	if (this.m_sAction === (void 0)) // not all GalleryImages define an action
	{
		return(sImageList.m_sImgPath + sImageList.m_sThumbImgValue + this.m_sSrc);
	}
	else if (this.m_sAction == "360Int")
	{
		return ("/Images/Media/360view_interior.jpg");
	}
	else if (this.m_sAction == "360Ext")
	{
		return ("/Images/Media/360view_exterior.jpg");
	}
	else if (this.m_sAction == "Video")
	{
		if (this.m_sThumb.search(/orig/) > -1)
			return "/images/vip/streamingvideo_generic.jpg";
		else if (this.m_sThumb.search(/iihs/) > -1)
			return "/images/include/GalleryCtrls/iihs_frontal.jpg";
		else if (this.m_sThumb.search(/\/images\/vip\/stv1\.gif/) > -1)
			return "/images/vip/streamingvideo_generic.jpg";
		else
			return (sImageList.m_sImgPath + sImageList.m_sThumbImgValue + this.m_sThumb + sImageList.m_sSuffix);
	}
	else
	{
		return(sImageList.m_sImgPath + sImageList.m_sThumbImgValue + this.m_sSrc);
	}
}

//Image Grid Object. This object will get initialized with the ImageGrid control.
function ImageGrid(nMinCount, nMaxCount, oTarget)
{
	this.m_nMinCount = nMinCount;
	this.m_nMaxCount = nMaxCount;
	this.m_Target = oTarget;
	
	//Methods
	this.LoadImages = ImageGrid_LoadImages;
}

function ImageGrid_LoadImages(nAlbumID)
{
	this.m_Target = oTarget[g_CurrentTarget];
	var nCurrentLength = this.m_Target.ImagesList[g_CurrentImgList].m_rgImages.length;
	for (var nLooper = nCurrentLength; nLooper < this.m_nMaxCount; nLooper++)
	{
		document.getElementById("ImageBorder" + nLooper).bgColor = g_sUnSelectedColor;
		document.getElementById("ImageBorder" + nLooper).style.borderColor = g_sBackgroundColor;
		document.getElementById("Image" + nLooper).src  =  g_sSpacerImage;
		document.getElementById("Image" + nLooper).style.cursor = "default";
		document.getElementById("Image" + nLooper).alt = "";
	}
	for (var nLooper = 0; nLooper < nCurrentLength; nLooper++)
	{	
		document.getElementById("ImageBorder" + nLooper).bgColor = g_sUnSelectedColor;
		document.getElementById("ImageBorder" + nLooper).style.borderColor = "#99BBD6";
		document.getElementById("Image" + nLooper).src  =  this.m_Target.ImagesList[g_CurrentImgList].m_rgImages[nLooper].GetThumbImage();
		document.getElementById("Image" + nLooper).alt  =  this.m_Target.ImagesList[g_CurrentImgList].m_rgImages[nLooper].m_sAltText; 
		document.getElementById("Image" + nLooper).style.cursor = "hand";
	}
}

// Compare images object
function EvoxImages(sID, sText)
{	
	this.m_sID = sID;
	this.m_sText = sText;
}