     if (!window.ArchiveManager) {
var ArchiveManager = {
		currentIndex : 0,
		thumbnailPathFilter : ['_12.jpg','.jpg'],
		isExpanded : false,
		recordCount : 35,
		photoDelay : 3,
		videoDelay : 15,
		animationTimeout : null,
		MbrTypeIF: 'Basic',
		MbrTypeFC: 'Guest',
		MbrMatchesVCH: '',
		VCHEdit: '',
		VCHLive:	'',
		hasMetaData : false,
		SecureServnamePath : 'https://secure.ifriends.net',
		isHD : false,
		allImages : [],
		StarsLikeMeEnabled: 'Y',
		loggingEnabled : false,
		init : function(nElementID){
			this.populateContentWindow(nElementID);
			this.getAllImages();
		},
		populateContentWindow : function (nElementID){
			this.hidePanel();
			if(this.currentIndex != nElementID){
				this.opts = {};
				this.getOptions(nElementID);
				this.styleActiveContent(nElementID);
				this.currentIndex = nElementID;
				if(this.opts.ContentType == 'Photo'){
					this.loadPhotoContent(nElementID);
				}else{
					this.loadVideoContent(nElementID);
				}
				this.updateToolbar($('#fc-ContentNavBar') , nElementID);
				this.populateDate();
				this.setInfo(this.opts.ContentType);
				this.logContentView();
			}else if (this.opts.ContentType == 'Photo'){
				if (this.VCHEdit == 'true' && this.MbrMatchesVCH == 'Y'){
					var obj = document.getElementById('fc-editContentInfoLink');
					obj.href = '/membrg/VCHContentManager_Custom.dll?t=site/fanclubs/starpages/eyecandy/tFCarchiveViewer/includes/VCHeditContentInfo_Modal&pClub='+this.opts.VCHScreennameSimple+'&pMode='+this.Mode+'&pArchiveRef='+this.opts.ArchiveRef;
					openFancyBox(obj);
				} else if(this.MbrTypeIF.match(/vip/gi) || this.MbrMatchesVCH == 'Y'){
					loadArchiveLightbox(document.getElementById('thmImageParent_'+ this.currentIndex).getElementsByTagName('A')[0]);
					this.stop();
				}else if(this.MbrTypeIF == 'Guest'){
					var obj = {};
					obj.width = 900;
					obj.height = 672;
					obj.href = this.SecureServNamePath + '/ifpage.dll?t=Site/Secure/Signup&s=Modal_v2&pCallingHost='+this.WebHost+'&pTextColor=b1b1b1&pShowVCHWelcomeBox=Y&pClub='+this.opts.VCHScreennameSimple+'&pSiteCode=iFriendsV2&pAccess=full&pCache=yes';
					openFancyBox(obj);
				}else{
					upgradeRequired('imageclicked' , '');
				}
			}
		},
		logContentView : function(){
			if(this.loggingEnabled && this.opts.OverlayType == 'NONE'){
				var cURL = '/membrg/twrp.dll?pAppCode=TWRP_LogView&t=stdResultAjax&pClub='+this.opts.VCHScreennameSimple+'&pSourceAppCode=tFCArchiveManager_V2_Custom&pArchiveRef='+this.opts.ArchiveRef+'&pContentID='+this.opts.ArchiveID+'&pPostDateTimeStamp='+this.opts.PostDateTimeStamp;
				$.get(cURL, function(){});
			}
		},
		getAllImages : function(){
			jQuery.each(jQuery("a[rel=imagegroup]") , function(i , val){
				if(jQuery(val).parent().children('.io-imgArchiveThumbnail').length == 0){
					var cSrc = jQuery(val).parent().children('.io-imgArchiveThumbnailDummy').attr('src');
				}else{
					var cSrc = jQuery(val).parent().children('.io-imgArchiveThumbnail').attr('src');
				}
				if(jQuery('#Has640Format_'+(i+1)).val() == 'Y'){
					ArchiveManager.allImages[i] = cSrc.replace(/_12\.jpg/, '_640\.jpg');
				}else{
					ArchiveManager.allImages[i] = cSrc.replace(/_12\.jpg/, '.jpg').replace(/_68\.jpg/, '.jpg');
				}
			});
		},
		getOptions : function(nElementID){
			var obj = this;
			$('#thmImageParent_'+nElementID).find('input[type="hidden"]').each(function(){
					obj.opts[this.id.replace(/_\d{1,}/,'')] = this.value;
			});
		},
		populateDate : function(){
			document.getElementById('contentPublishedNote').style.display = 'inline-block';
			document.getElementById('contentDateLabel').innerHTML = this.opts.submittedDate;
		},
		updateToolbar : function(oParent , nElementID){ // I think this section can be improved upon in a way that will be more apparent as the feature develops.
			var rateEle 			= oParent.find('.icon-rate');
			var saveEle 			= oParent.find('.icon-save');
			var addEle 				= oParent.find('.icon-privatecollection');
			var shareEle			= oParent.find('.icon-share');

			if(document.getElementById('anchProfileImageDesignator')){
				var profileImageLink	= document.getElementById('anchProfileImageDesignator');
				profileImageLink.href = '/ifpage.dll?t=site/fanclubs/starpages/eyecandy/profileImageDesignator/main&pArchiveRef='+this.opts.ArchiveRef+'&pClub='+this.opts.VCHScreennameSimple;
			}
			addEle.mousedown((function (cPClub , cArchiveRef, cArchivePath, cFilterStatus, cIsCensorDesignated, cImagepathType, cPostDateTimeStamp , cArchiveOverlayType, cNoRedirect) {
			  return function () {
				cArchivePath = cArchivePath.substring(0,cArchivePath.indexOf('.jpg'));
				add2PrivateCollection(cPClub , cArchiveRef, cArchivePath, cFilterStatus, cIsCensorDesignated, cImagepathType, cPostDateTimeStamp , cArchiveOverlayType, cNoRedirect);
			  };
			})(this.opts.VCHScreennameSimple,this.opts.ArchiveRef,this.opts.archivePath,this.opts.filterStatus,this.opts.isCensorDesignated,this.opts.imagePathType,this.opts.PostDateTimeStamp,this.opts.OverlayType,true));


			var cRateLink = '/membrg/tFCarchiveViewer_v2_custom.dll?t=Site/FanClubs/misc/RateContent_Modal&pClub='+this.opts.VCHScreennameSimple+'&pMode='+this.Mode+'&pRemoveDatesFromTop=true';
			var cSaveLink = this.ContentPath;
			var cAddLink = '/ifpage.dll?t=site/fanclubs/misc/Add2privatecollection/main&pDisplayMode=modal&pClub='+this.opts.VCHScreennameSimple;
			switch(this.opts.OverlayType){
				case 'NONE':
					cRateLink += '&pArchiveRef='+this.opts.ArchiveRef;
					saveEle.attr('target',"_blank");
					saveEle.unbind('click');
					addEle.attr('js-iFrameWidth',711);
					addEle.attr('js-iFrameHeight',842);
					rateEle.attr('js-iFrameWidth',680);
					rateEle.attr('js-iFrameHeight',530);
				break;
				case 'Privacy':
					cRateLink += '&pArchiveRef='+this.opts.ArchiveRef;
					saveEle.attr('href', '#fc-privacy-notice');
					$('a#fc-saveThis').fancybox({
						'padding'				: 0,
						'overlayOpacity' 		: .75,
						'overlayColor'	 		: '#000',
						'autoScale'				: true,
						'hideOnContentClick' 	: true
					});
				break;
				case 'ContentOver30DaysOld':
					cRateLink = cRateLink += '&pArchiveRef='+this.opts.ArchiveRef;
				break;
				case 'FansOnly':
					cRateLink = this.FanclubsServNamepath + '/membrG/tFCjoin_custom.dll?t=Site/fanclubs/FCJoin/Main&pDisplayType=iFrameModal_FancyBox&pClub='+this.opts.VCHScreennameSimple+'&pDisplayContext=iFrameModal&pdisplayglobalvartestpage=false';
					cSaveLink = 'javascript:void(0);';
					cAddLink = this.FanclubsServNamepath + '/membrG/tFCjoin_custom.dll?t=Site/fanclubs/FCJoin/Main&pDisplayType=iFrameModal_FancyBox&pClub='+this.opts.VCHScreennameSimple+'&pDisplayContext=iFrameModal&pdisplayglobalvartestpage=false';
					addEle.attr('js-iFrameWidth',522);
					addEle.attr('js-iFrameHeight',392);
					rateEle.attr('js-iFrameWidth',522);
					rateEle.attr('js-iFrameHeight',392);
					saveEle.attr('target',"_self");
					saveEle.click(function(){
						$.fancybox({
							'padding'				: 0,
							'overlayOpacity' 		: .75,
							'overlayColor'	 		: '#000',
							'autoScale'				: false,
							'transitionIn'			: 'none',
							'transitionOut'			: 'none',
							'scrolling'				: 'no',
							'width'					: 522,
							'height'				: 392,
							'href'					: ArchiveManager.FanclubsServNamepath + '/membrG/tFCjoin_custom.dll?t=Site/fanclubs/FCJoin/Main&pDisplayType=iFrameModal_FancyBox&pClub='+ArchiveManager.opts.VCHScreennameSimple+'&pDisplayContext=iFrameModal&pdisplayglobalvartestpage=false',
							'hideOnContentClick' 	: true,
							'type'					: 'iframe'
						});
					});
				break;
				case 'ClubElite':
					cRateLink = cRateLink += '&pArchiveRef='+this.opts.ArchiveRef;
					///ifpage.dll?t=Site/Secure/Upgrade/VIP/Includes/OneClickUpgrade&pDisplayType=Modal.htm
				break;
				case 'LoginRequired':
					rateEle.attr('js-iFrameWidth',900);
					rateEle.attr('js-iFrameHeight',672);
					addEle.attr('js-iFrameWidth',900);
					addEle.attr('js-iFrameHeight',672);
					cRateLink = this.SecureServnamePath + '/ifpage.dll?t=Site/Secure/Signup&s=Modal_v2&pCallingHost='+this.WebHost+'&pTextColor=b1b1b1&pShowVCHWelcomeBox=Y&pClub='+this.opts.VCHScreennameSimple+'&pSiteCode='+this.SiteCode+'&pAccess=full&pCache=yes&pSource=rateContent&pTextMode=Auto';
					cSaveLink = this.SecureServnamePath + '/ifpage.dll?t=Site/Secure/Signup&s=Modal_v2&pCallingHost='+this.WebHost+'&pTextColor=b1b1b1&pShowVCHWelcomeBox=Y&pClub='+this.opts.VCHScreennameSimple+'&pSiteCode='+this.SiteCode+'&pAccess=full&pCache=yes&pSource=rateContent&pTextMode=Auto';
					cAddLink  = this.SecureServnamePath + '/ifpage.dll?t=Site/Secure/Signup&s=Modal_v2&pCallingHost='+this.WebHost+'&pTextColor=b1b1b1&pShowVCHWelcomeBox=Y&pClub='+this.opts.VCHScreennameSimple+'&pSiteCode='+this.SiteCode+'&pAccess=full&pCache=yes&pSource=rateContent&pTextMode=Auto';
				break;
				case 'HDPass':
					cRateLink = 'ifpage.dll?t=Site/Secure/Upgrade/HDpass/Includes/OneClickUpgrade.htm&pDisplayType=Modal&pClub='+this.opts.VCHScreennameSimple+'&pMode='+this.Mode+'&pCurrentTab=HighDef';
					rateEle.attr('js-iFrameWidth',680);
					rateEle.attr('js-iFrameHeight',530);
				break;
				default:
					cRateLink += '&pArchiveRef='+this.opts.ArchiveRef;
				break;
			}

			rateEle.attr('href',cRateLink);
			if((ArchiveManager.MbrTypeIF.match(/VIP/gi) || this.MbrMatchesVCH == 'Y') && this.opts.OverlayType == 'NONE'){		
				if(this.opts.VideoArchiveFormat == 'WindowsMediaLiveStream' || this.opts.isMp4Ready != 'Y'){
					saveEle.attr('target','');
					if(this.MbrTypeIF.match(/VIPE/gi) && this.opts.isMp4Ready != 'Y' && this.opts.ContentType == 'HighDef'){
						if(this.opts.isHDadvanced == 'Y' || this.opts.isHDadvanced == 'T'){
							cSaveLink = cSaveLink.replace('_tv.','_1080i.');	
						}else{
							cSaveLink = cSaveLink.replace('_tv.','_720p.');
						}
					}else if(this.opts.isMp4Ready != 'Y' && this.opts.ContentType == 'HighDef'){
						cSaveLink = cSaveLink.replace('_tv.','_480p.');
					}
				}else{
					saveEle.attr('target','_blank');
				}

				saveEle.attr('href', this.prepForDownload(cSaveLink));
				saveEle.attr('title', 'Right-Click, Save as...');
			}
			if(ArchiveManager.MbrTypeIF.match(/VIP/gi) || this.MbrMatchesVCH == 'Y'){
				addEle.attr('href', cAddLink);
			}
			addthis.button("#" + $(shareEle)[0].id, {}, {url: $('#thmImageParent_'+nElementID).find('.anchArchiveImageHyperlink').attr('href'), title: ""});
		},
		animate : function(obj){
			var nAnimationDelay = this.animationDelay;
			var bPlay = true;
			if(obj){
				nAnimationDelay = 1;
				if(!obj.className.match(/icon-play/gi)){
					this.stop();
					bPlay = false;
				}
			}
			if(bPlay){
				this.animationTimeout = setTimeout(function(){
					ArchiveManager.next();
					ArchiveManager.animate();
				}, nAnimationDelay * 1000);
			}
		},
		animateFancyBox : function(obj){
			var nAnimationDelay = this.animationDelay;
			this.fancyBoxPlaying = true;
			if(obj){
				nAnimationDelay = 1;
				if(!obj.className.match(/icon-play/gi)){
					this.stop();
					this.fancyBoxPlaying = false;
				}
			}
			if(this.fancyBoxPlaying){
				this.animationTimeout = setTimeout(function(){
					jQuery.fancybox.next();
				}, nAnimationDelay * 1000);
			}
		},
		stop : function (){
			clearTimeout(this.animationTimeout);
			this.animationTimeout = null;
		},
		styleActiveContent : function(nElementID){
			document.getElementById('ContentParent_'+nElementID).className = 'ArchiveActiveContent';
			if(document.getElementById('ContentParent_'+this.currentIndex)){
				document.getElementById('ContentParent_'+this.currentIndex).className = '';
			}
		},
		resizeVideo : function(cDirection){
			var oElement = document.getElementById("ContentContainer_Video");
			if(cDirection == "expand"){
				oElement.className = 'largevideo';
				this.isExpanded=true;
				document.getElementById('fc-content-titledesc-infoIcon').className = 'raised';
			}else{
				oElement.className = 'smallvideo';
				this.isExpanded=false;
				document.getElementById('fc-content-titledesc-infoIcon').className = '';
			}
		},
		popOut : function(){
			if(!this.isHD){
			ArchiveManager.popOutRef = window.open("/membrg/tFCVwrDisPicVid_v2_custom.dll?t=site/FanClubs/StarPages/EyeCandy/includes/videoPopOut&pClub="+this.opts.VCHScreennameSimple+"&pArchiveRef="+this.opts.ArchiveRef,"videoPopOut",this.isExpanded ? "width=640,height=505,resizable=yes" : "width=320,height=265,resizable=yes");
			}else{
			ArchiveManager.popOutRef = window.open("/membrg/tFCvwrDispHD_V2_Custom.dll?t=site/FanClubs/StarPages/EyeCandy/includes/videoPopOut&pClub="+this.opts.VCHScreennameSimple+"&pArchiveRef="+this.opts.ArchiveRef,"videoPopOut","width=640,height=385,resizable=yes");
			}
		},
		previous : function(){
			if(document.getElementById('thmImageParent_'+(this.currentIndex-1))){
				this.populateContentWindow((this.currentIndex-1));
			}else{
				this.populateContentWindow(this.recordCount);
			}
		},
		next : function (){
			if(document.getElementById('thmImageParent_'+(this.currentIndex+1))){
				this.populateContentWindow((this.currentIndex+1));
			}else{
				this.populateContentWindow(1);
			}
		},
		showInfo : function(){
			 $('#fc-content-titledesc-infoIcon').fadeOut('fast', function() {
				$('#fc-content-titledesc').fadeIn('fast');
			  });
		},
		autohideInfo  : function(){
			setTimeout(this.hideInfo,5000);
		},
		hideInfo : function(contentType){
			$('#fc-content-titledesc').fadeOut('fast', function() {
				if(contentType != 'ViewerVideo')
					$('#fc-content-titledesc-infoIcon').fadeIn('fast');
			  });
		},
		setInfo	: function(contentType){
				this.hideInfo(contentType);
				var cTitleParent 	 	= document.getElementById('fc-content-titledesc');
				var cDuration 		 	= document.getElementById('fc-content-videoDuration');
				var title 	 			= document.getElementById('fc-content-titledesc-title');
				var desc  	 			= document.getElementById('fc-content-titledesc-desc');
				var duration 			= document.getElementById('fc-content-titledesc-duration');

				title.innerHTML = desc.innerHTML = duration.innerHTML = '&lt; Not Provided &gt;';

				if(this.MbrMatchesVCH == 'Y'){
					var editLink		= document.getElementById('fc-editContentInfoLink');

					switch(contentType)
					{
						case 'Photo':
							editLink.href = '/membrg/VCHContentManager_Custom.dll?t=site/fanclubs/starpages/eyecandy/tFCarchiveViewer/includes/VCHeditContentInfo_Modal&pClub='+this.opts.VCHScreennameSimple+'&pMode='+this.Mode+'&pArchiveRef='+this.opts.ArchiveRef;
							editLink.setAttribute('js-iFrameHeight', '570');
							editLink.setAttribute('js-iFrameWidth', '680');
							cTitleParent.style.bottom = '0';
							cDuration.style.display = 'none';
						break;
						case 'Video':
							editLink.href = '/membrg/VCHContentManager_Custom.dll?t=site/fanclubs/starpages/eyecandy/tFCarchiveViewer/includes/VCHeditContentInfo_Modal&pClub='+this.opts.VCHScreennameSimple+'&pMode='+this.Mode+'&pArchiveRef='+this.opts.ArchiveRef;
							cTitleParent.style.bottom = '25px';
							cDuration.style.display = 'block';
						break;
						case 'HighDef':
							editLink.href = '/membrg/tFCvwrDispHD_V2_Custom.dll?t=site/fanclubs/starpages/eyecandy/tFCarchiveViewer/includes/VCHeditContentInfo_Modal&pClub='+this.opts.VCHScreennameSimple+'&pMode='+this.Mode+'&pArchiveRef='+this.opts.ArchiveRef;
							cTitleParent.style.bottom = '25px';
							cDuration.style.display = 'block';
						break;
					}
				}

				if(this.opts.videoDuration){
					var mins = Math.floor(this.opts.videoDuration/60);
					var secs = this.opts.videoDuration % 60;
					var hrs = 0;
					var totalTime;
					if(mins > 60){
						hrs = Math.floor(mins/60);
						mins = mins % 60;;
					}
					if(mins > 0){
						if(hrs > 0){
							totalTime =	hrs +"h "+ mins +"m "+ secs +"s";
						}else{
							totalTime = mins +"m "+ secs +"s";
						}
					}else{
						totalTime = secs +"s";
					}
					duration.innerHTML = totalTime;
				}
				if((this.opts.contentTitle.trim() != '' || this.opts.contentDescription.trim() != '') || this.MbrMatchesVCH == 'Y'){
					this.hasMetaData = true;
					title.innerHTML = (this.opts.contentTitle ? this.opts.contentTitle : title.innerHTML);
					desc.innerHTML = (this.opts.contentDescription ? this.opts.contentDescription : desc.innerHTML );
					if(contentType != 'ViewerVideo'){
						$('#fc-content-titledesc-infoIcon').show();
					}else{
						$('#fc-content-titledesc-infoIcon').hide();
					}
					
					if(this.MbrMatchesVCH == 'Y' && this.opts.contentTitle.trim() == '' && this.opts.contentDescription.trim() == '' && contentType != 'ViewerVideo'){
						this.showInfo();
					}
					
				}else{
					this.hasMetaData = false;
					$('#fc-content-titledesc-infoIcon').hide();
				}
		},
		animateVideoThumbnail : function(oImage){
			this.videoThumbnailAnimationTimeout = setTimeout(function(){
				ArchiveManager.nextThumbnailImage(oImage);
				ArchiveManager.animateVideoThumbnail(oImage);
			} , '500');
		},
		nextThumbnailImage : function(oImage){
			var cStr = oImage.src.replace('_12.jpg','');
			var nNextImageIndex = ((cStr.substr(cStr.length-1 , cStr.length) * 1) + 1);
			if(nNextImageIndex > 9){
				nNextImageIndex = 0;
			}
			$('#thumbnailProgressBar').css('width' , ((nNextImageIndex + 1) * 10) + '%');
			oImage.src = cStr.substr(0,cStr.length-1) + (nNextImageIndex) + '_12.jpg';
		},
		onMouseOver : function (obj , nElementID){
			if(($('#ContentType_'+nElementID).val() == 'Video' || $('#ContentType_'+nElementID).val() == 'HighDef')&& $('#OverlayType_'+nElementID).val() == 'NONE' ){
				var oImage = $(obj).find('.io-imgArchiveThumbnail')[0];
				var cSrc = oImage.src.replace(/\d_12.jpg/,'');
				var oPreloadImageObj = new Image();
				for(var i=0;i<=9;i++){
					oPreloadImageObj.src = cSrc + 'i' + '_12.jpg';
				}
				var oDiv = document.createElement('DIV');
				oDiv.id = 'thumbnailProgressBar';
				oDiv.style.position = 'absolute';
				oDiv.style.zIndex = 1;
				oDiv.style.backgroundColor = '#EF251B';
				oDiv.style.height = '2px';
				oDiv.style.bottom = '-2px';
				$('#thmImageParent_'+nElementID).append(oDiv);
				oImage.src = cSrc + '0_12.jpg';
				this.animateVideoThumbnail(oImage);
			}
		},
		onMouseOut : function (obj , nElementID){
			$('#thumbnailProgressBar').remove();
			clearTimeout(this.videoThumbnailAnimationTimeout);
		},
		loadPhotoContent: function(nElementID){

			var oContentContainer = document.getElementById('ContentContainer');
			var oContentContainerVideo = document.getElementById('ContentContainer_Video_Parent');
			var oContentNavBar = $('#fc-ContentNavBar');
			var oEnlargeOption = $('#fc-EnlargeOption');
			var oEmbedOption = $('#fc-EmbedOption');
			var oSaveOption = $('#fc-SaveOption');
			this.animationDelay = this.photoDelay;
			oSaveOption.removeClass('second');
			oSaveOption.show();
			oContentNavBar.addClass('pics').removeClass('vids');
			oEnlargeOption.show();
			oEmbedOption.hide();
			var oContent = document.getElementById('thmImageParent_'+nElementID).cloneNode(true);
			oContent.style.margin = 'auto';
			oContentContainer.innerHTML = '';
			oContent.id = "";
			var arrImages = oContent.getElementsByTagName('IMG');
			var arrDivs = oContent.getElementsByTagName('DIV');
			var cWidth = '320px';
			for(var i=0;i<arrImages.length;i++){
				if(!arrImages[i].src.match(/_icon\./gi)){
					arrImages[i].style.width = '320px';
					arrImages[i].style.height = '240px';
				}
				if(arrImages[i].className.match(/io-imgArchiveThumbnail/gi)){
					var cOldLargePath = arrImages[i].src.toString();
					arrImages[i].src = cOldLargePath.replace((cOldLargePath.match(/_68.jpg/gi) ? '_68.jpg' : this.thumbnailPathFilter[0]), (this.opts.Has640Format == 'Y' ? '_640.jpg' : this.thumbnailPathFilter[1]));
					this.ContentPath = cOldLargePath.replace((cOldLargePath.match(/_68.jpg/gi) ? '_68.jpg' : this.thumbnailPathFilter[0]), this.thumbnailPathFilter[1]);
					if(this.opts.OverlayType == 'NONE'){
						oContent.style.textAlign='center';
						cWidth = 'auto';
						arrImages[i].style.width = 'auto';
						arrImages[i].className = 'io-imgArchiveThumbnailDummy';
					}
				}
			}

			for(var i=0;i<arrDivs.length;i++){
				if(arrDivs[i].style.width){
					arrDivs[i].style.width = cWidth;
					arrDivs[i].style.height = '240px';
				}
			}
			oContent.style.width = cWidth;
			oContent.style.height = '240px';

			$(oContent).find('.anchArchiveImageHyperlink').removeAttr('rel');
			oContentContainer.appendChild(oContent);
			oContentContainerVideo.style.display = 'none';
			oContentContainer.style.display = '';
			if(this.opts.isHDArchiveImage){
				var oHDIcon = document.createElement('IMG');
				oHDIcon.className = 'hdarchive';
				oHDIcon.src = 'http://images.ifriends.net/if_v2/tp.gif';
				oContentContainer.appendChild(oHDIcon);
			}

		},
		loadVideoContent : function(nElementID){

			var oElement = document.getElementById("ContentContainer_Video");
			if(this.opts.ContentType == 'HighDef'){
				this.isHD = true;
				this.hideExpand  = true;
				document.getElementById('fc-content-titledesc-infoIcon').className = 'raised';
				var oHDIcon = document.createElement('IMG');
				oHDIcon.src = 'http://images.ifriends.net/if_v2/tp.gif';
				oHDIcon.className = this.opts.isHDadvanced ? 'hdadvanced' : 'hdarchive';
				oElement.appendChild(oHDIcon);
			}else{
				this.isHD = false;
			}
			this.animationDelay = this.videoDelay;
			if( this.opts.isMp4Ready != 'Y' && this.opts.VideoArchiveFormat == 'WindowsMediaLiveStream' && this.opts.OverlayType == 'NONE'){
				oElement.className = 'smallvideoWMV';
				this.loadWindowsMediaContent();
			}else if (this.opts.isMp4Ready != 'Y' && this.opts.ContentType == 'HighDef' && this.opts.OverlayType == 'NONE'){
				oElement.className = 'hdvideoWMV';
				this.loadWindowsMediaContent();
			}else{
				if (swfobject.hasFlashPlayerVersion("9")) {
					var att = { wmode: "transparent", allowFullScreen: "true" , data:"/SWF/iFvideoPlayer.swf", width:"", height:"", style:"width:100%;height:100%;"};
					var par = {
								flashvars: this.opts.flashVars +'&pTape='+ this.opts.tapeScene + '_360&pIsHDAdvanced=' + this.opts.isHDadvanced + '&pAutoPlay=true' + (this.isExpanded == true ? '&pDisplayMode=expanded' : '') + (this.hideExpand == true ? '&pHideExpand=true' : ''),
								wmode: "transparent", allowFullScreen: "true"
							  };
					var id = "FLVarchiveViewer";
					swfobject.createSWF(att, par, id);
				}else {
					var att = {  wmode: "transparent", data:"/SWF/expressInstall.swf", width:"600", height:"240" };
					var par = {};
					var id = "FLVarchiveViewer";
					swfobject.showExpressInstall(att, par, id, function(){});
				}
				oElement.className = (this.isExpanded ? 'largevideo' : (this.isHD ? 'hdvideo' : 'smallvideo'));
				if(this.opts.ContentType == 'HighDef'){
					var cStr = $('#thmImageParent_'+nElementID).find('.io-imgArchiveThumbnail').attr('src').replace(/\d_12\.jpg/i,'360.mp4');
					this.ContentPath = cStr.substr(0,cStr.lastIndexOf('T')) + 'MP4.' + cStr.substr(cStr.lastIndexOf('T'),cStr.length);
				}else{
					this.ContentPath = $('#thmImageParent_'+nElementID).find('.io-imgArchiveThumbnail').attr('src').replace(/\d_12\.jpg/i,'.mp4');
				}
			}

			var oContentContainer = document.getElementById('ContentContainer');
			var oContent = document.getElementById('thmImageParent_'+nElementID);
			var oContentContainerVideo = document.getElementById('ContentContainer_Video_Parent');
			oContentContainerVideo.style.textAlign = 'center'
			oContentContainerVideo.style.display = '';
			var oContentNavBar = $('#fc-ContentNavBar');
			var oEnlargeOption = $('#fc-EnlargeOption');
			var oEmbedOption = $('#fc-EmbedOption');
			var oSaveOption = $('#fc-SaveOption');
			oSaveOption.addClass('second');
			oContentNavBar.addClass('vids').removeClass('pics');
			oSaveOption.show();
			oEnlargeOption.hide();
			oEmbedOption.hide();
			oContentContainer.style.display = 'none';
			
		},
		loadWindowsMediaContent : function(bAutoStart){
			var cHTML = '';
			var bAutoStart = (bAutoStart == undefined ? true : bAutoStart);
			if(!this.isHD){
				var cPath = 'http://vidarchives.ifriends.net:8080/'+ this.opts.PostDateTimeStamp.substr(2,2) + this.opts.PostDateTimeStamp.substr(4,2) +'/'+ this.opts.RootPath +'/'+ this.opts.VCHScreennameSimple + '/' + this.opts.PostDateTimeStamp.substr(2,2) + '/' + this.opts.PostDateTimeStamp.substr(4,2) + '/' + this.opts.PostDateTimeStamp.substr(6,2) + '/' + this.opts.PostDateTimeStamp.substr(9,2)+ this.opts.PostDateTimeStamp.substr(12,2) + '.asf';
				var nWidth=320;
				var nHeight=285;
				this.ContentPath = cPath;

			}else{
				var cStubURL = 'http://hd.ifriends.net:8080/' + this.opts.RootPath + '/' + this.opts.VCHScreennameSimple + '/FCM.T'+this.opts.tapeScene;
				var cPath = cStubURL + '_tv.wmv';
				this.ContentPath = cPath;
				var nWidth=640;
				var nHeight=404;
				//upgradeRequired
				var bHasHDAccess = false;
				var bHasHD1080Access=false;
				if(this.MbrTypeFC != 'Guest'){
					bHasHDAccess=true;
					bHasHD1080Access=true;
				}
				if(this.MbrTypeIF.match(/VIP/gi)){
					bHasHDAccess=true;
				}

				if(this.MbrTypeIF.match(/VIPE/gi)){
					bHasHD1080Access=true;
				}

				cHTML += '<div style="background-color:#000;color:#ccc;text-align:right;width:640px;"><img ' + (this.opts.isHDadvanced == 'Y' || this.opts.isHDadvanced == 'T' ? 'class="hdadvanced"' : 'class="hdarchive"' ) + '><div style="padding:3px;"><span style="vertical-align:middle;">Available Formats: TV - </span><img src="http://images.ifriends.net/if_v2/iFriends/vip/vip_icon_small_text_new.png" style="vertical-align:middle;margin-right:3px;"><span style="vertical-align:middle"><a  target="_blank" '+ (bHasHDAccess ? 'href="'+cStubURL+'_480p.wmv" onclick="ArchiveManager.loadWindowsMediaContent(false);" ' : 'href="javascript:void(0);" onclick="upgradeRequired(\'hdlink\',\'VIP\');return false;" ' ) + '>480P</a></span><span style="vertical-align:middle;"> - <img src="http://images.ifriends.net/if_v2/elite_icon_mini.png" style="vertical-align:middle;margin-right:3px;"><a target="_blank" '+ (bHasHD1080Access ? 'href="'+cStubURL+'_720p.wmv"  onclick="ArchiveManager.loadWindowsMediaContent(false);" ' : 'href="javascript:void(0);" onclick="upgradeRequired(\'hdlink\',\'VIPE\');return false;" ' ) + '>720P</a>';
				if(this.opts.isHDadvanced == 'Y' || this.opts.isHDadvanced == 'T'){
					cHTML += ' <a target="_blank" '+ (bHasHD1080Access ? 'href="'+cStubURL+'_1080i.wmv"  onclick="ArchiveManager.loadWindowsMediaContent(false);" ' : 'href="javascript:void(0);" onclick="upgradeRequired(\'hdlink\',\'VIPE\');return false;" ' ) + '>1080i</a></span>';
				}
				cHTML += '</div></div>';
			}

			cHTML += '<OBJECT  id="wmoArchiveVideo"  name="wmoArchiveVideo" WIDTH='+nWidth+' HEIGHT='+nHeight+' classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"';
			cHTML += 'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"';
			cHTML += 'standby="Loading Microsoft Windows Media Player components..."';
			cHTML += 'type="application/x-oleobject" allowFullScreen="false" >';
			cHTML += '<PARAM NAME="FileName" VALUE="'+cPath+'">';
			cHTML += '<PARAM NAME="ShowControls" VALUE="1">';
			cHTML += '<PARAM NAME="ShowDisplay" VALUE="0">';
			cHTML += '<PARAM NAME="windowlessVideo" VALUE="1">';
			cHTML += '<PARAM NAME="ShowStatusBar" VALUE="0">';
			cHTML += '<PARAM NAME="allowFullScreen" VALUE="0">';
			cHTML += '<PARAM NAME="AutoStart" VALUE="'+ (bAutoStart ? 1 : 0) +'">';
			cHTML += '<PARAM NAME="AutoSize" VALUE="1">';
			cHTML += '<Embed AutoStart="'+ (bAutoStart ? 1 : 0) +'" type="application/x-mplayer2" autoSize="1" windowlessVideo=1 ShowControls=1  allowFullScreen="0" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/" src="'+cPath+'" id="wmoArchiveVideo"  name="wmoArchiveVideo" displaysize="0" ShowDisplay=0 width="'+nWidth+'" height="'+nHeight+'" ShowStatusBar=0></embed></OBJECT>';
			//document.getElementById('FLVarchiveViewer').innerHTML = cHTML;
			document.getElementById("ContentContainer_Video").innerHTML = '<div id="FLVarchiveViewer">' + cHTML + '</div>';
		},
		showSimilarHostsPanel: function(){
			this.hidePanel();
			if(this.VCHLive != 'Y' && this.StarsLikeMeEnabled=='Y'){
				var cURL = '/membrg/hotlist_v2_custom.dll?pvch='+this.opts.VCHScreennameSimple+'&pSimilarChathostsShowMoreHostsOption=&pSimilarChathostsMaxHosts=11&pSimilarChathostsShowMoreHostsOption=true&pImageWidth=120&pImageHeight=90&pSource=EndOfMovie&t=Site\\Includes\\Components\\Includes\\SimilarChathosts_Ajax_v3';
				Ajax.Execute(cURL , function(cResponse){
					var oSimilarHostsTemplate = $('#SimilarHostsModule').clone();
					oSimilarHostsTemplate.attr('id','PanelRendered');
					oSimilarHostsTemplate.find('#SimilarHostsModuleContent').html(cResponse);
					document.getElementById('ContentContainer_parent').appendChild(oSimilarHostsTemplate[0]);
					document.getElementById('ContentContainer_parent').style.height='400px';
					if(ArchiveManager.isExpanded){
						document.getElementById('ContentContainer_Video').style.height='auto';
					}

					oSimilarHostsTemplate.show();
				});
			}
		},
		hidePanel: function(){
			$('#PanelRendered').remove();
			document.getElementById('ContentContainer_parent').style.height='auto';
			if(ArchiveManager.isExpanded){
				document.getElementById('ContentContainer_Video').style.height='';
			}
		},
		prepForDownload: function(cPath){
			return cPath.replace(':8080','');
		}
	}
}

function getWidthHeight(ele,attribute){
if(attribute == "width"){
if(ele.getAttribute == undefined){
	return 680;
}else{
	return ele.getAttribute('js-iFrameWidth') != null ? Number(ele.getAttribute('js-iFrameWidth')) : 680;
}
}else if (attribute == "height"){
if(ele.getAttribute == undefined){
	return 530;
}else{
	return ele.getAttribute('js-iFrameHeight') != null ? Number(ele.getAttribute('js-iFrameHeight')) : 530;
}
}
}

function openFancyBox(obj){
$.fancybox({
'padding'				: 0,
'overlayOpacity' 		: .75,
'overlayColor'	 		: '#000',
'autoScale'				: false,
'transitionIn'			: 'none',
'transitionOut'			: 'none',
'scrolling'				: 'no',
'width'					: obj.width ? obj.width : getWidthHeight(obj , 'width'),
'height'				: obj.height ? obj.height : getWidthHeight(obj , 'height'),
'href'					: obj.href,
'hideOnContentClick' 	: true,
'type'					: 'iframe'
});
return false;
}

function loadArchiveLightbox(obj){
ArchiveManager.stop();
var arrAllImages = ArchiveManager.allImages.slice();
jQuery.fancybox(arrAllImages,
	{
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'titlePosition' 	: 'over',
		'overlayOpacity' 	: .75,
		'overlayColor'	 	: '#000',
		'type'              : 'image',
		'index'				: (ArchiveManager.currentIndex-1),
		'titlePosition'		: 'inside',
		'padding'			: 20,
		'cyclic'			: true,
		'onClosed'			: function() {
			$('#fancybox-outer').css('background-color','#ffffff');
		},
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			var oTitleBar = document.getElementById('EnlargeImageModalOptions').cloneNode(true);
			oTitleBar.id = '';
			oTitleBar.style.display = '';
			var oDiv = document.createElement('DIV');
			oDiv.appendChild(oTitleBar);
			$(oTitleBar).find('.icon-share').attr('id' , 'share_' + currentIndex);
			if(ArchiveManager.animationTimeout != null){
				jQuery(oDiv).find('#EnlargePlayPause').toggleClass('icon-play').toggleClass('icon-pause');
			}
			//return (currentArray.length > 1 ? '<span id="fancybox-title-over">'+ oDiv.innerHTML +'</span>' : '');
			return '<span id="fancybox-title-over">'+ oDiv.innerHTML +'</span>';
		},
		'onStart' : function(){
			var oTarget = $('#fancybox-inner');
			oTarget.css('visibility','hidden');
			$('#fancybox-outer').css('background-color','#000000');
		},
		'onClosed' : function(){
			ArchiveManager.stop();
			ArchiveManager.fancyBoxPlaying = false;
		},
		'onComplete':function(currentArray, currentIndex, currentOpts) {

			var oFancyBox = $('#fancybox-outer');
			var findResult = $(oFancyBox).find('#fc-imageModalHeader');
			var infoPrefix = $('#fc-imageModalHeader-info').html();
			var info = (currentIndex + 1) + '/ ' + currentArray.length;
			if(findResult.length == 0){
				var oHeaderBar = $('#fc-imageModalHeader').clone(true);
				$(oHeaderBar).css('display','block');
				$(oFancyBox).append(oHeaderBar);
				$(oHeaderBar).find('#fc-imageModalHeader-info').html(infoPrefix+info);
			}else{
				$(findResult).find('#fc-imageModalHeader-info').html(infoPrefix+info);
			}

			var oTarget = $('#fancybox-inner');
			var oDiv = document.createElement('DIV');
			jQuery.each(jQuery('#thmImageParent_'+(currentIndex+1)).parent().find('.io-imgOverlayParent'), function(i , val){
				var oElement = val.cloneNode(true);
				oDiv.appendChild(oElement);
			});

			if(ArchiveManager.allImages[currentIndex + 1]){
				var objNext = new Image();
				objNext.src = ArchiveManager.allImages[currentIndex + 1];
			}
			var nTargetWidth = oTarget.width();
			var nTargetHeight = oTarget.height();
			thumbnailPathFilter = ['_12.jpg','.jpg'];
			overlayPathFilter = ['80x60_notext.png','1280x720_notext.png'];
			var arrImages = oDiv.getElementsByTagName('IMG');
			var arrDivs = oDiv.getElementsByTagName('DIV');
			for(var i=0;i<arrImages.length;i++){
				arrImages[i].style.width = nTargetWidth + 'px';
				arrImages[i].style.height = nTargetHeight + 'px';
				if(arrImages[i].className.match(/io-imgArchiveThumbnail/gi)){
					var cOldLargePath = arrImages[i].src.toString();
					arrImages[i].src = cOldLargePath.replace(thumbnailPathFilter[0],thumbnailPathFilter[1]);
				} else if(arrImages[i].className == 'io-imgArchiveImageOverlay'){
					var cOldLargePath = arrImages[i].src.toString();
					arrImages[i].src = cOldLargePath.replace(overlayPathFilter[0],overlayPathFilter[1]);
				}
			}
			for(var i=0;i<arrDivs.length;i++){
				if(arrDivs[i].style.width){
					arrDivs[i].style.width = nTargetWidth + 'px';
					arrDivs[i].style.height = nTargetHeight + 'px';
				}
				if(arrDivs[i].className.match(/io-textOverlay/gi)){
					arrDivs[i].style.fontSize = '23px';
				}
			}
			oTarget.append(oDiv);
			oTarget.css('visibility','visible');

			if((document.getElementById('fancybox-wrap').style.width.replace(/px/gi,'') * 1) < 386){
				jQuery.each(jQuery("#fancybox-title-over").find("li") , function(){
					if(!this.className.match(/last/gi)){
						this.style.width = '17%';
					}else{
						this.style.width = '26%';
					}
				});
			}
			//alert($('#fancybox-title').find('.imageModalOptions').length);
			ArchiveManager.populateContentWindow(currentIndex+1);
			ArchiveManager.updateToolbar($('#fancybox-title').find('.imageModalOptions') , currentIndex+1);

			if(ArchiveManager.fancyBoxPlaying){
				ArchiveManager.animateFancyBox();
			}
		}
	}
	);
}
