// Initialise global Hc context
var Hc = Hc || {};

Hc.PhotoUpload = {
	callback : function(photoData) {
		if(photoData.type == 'post') {			
			var rtes = $('a[href="/image/upload/post/'+photoData.objectId+'/"]').parents('.contentView').find('div[editwith=rte]');
			var htmlToInsert = '';
			if(photoData.videoUrl != '') {			
				htmlToInsert  = '<object type="application/x-shockwave-flash" width="560" height="340" data="http://www.youtube.com/v/'+photoData.videoUrl+'" rel="'+photoData.videoUrl+'">'
				htmlToInsert +=	'<param name="movie" value="http://www.youtube.com/v/'+photoData.videoUrl+'"></param>'
				htmlToInsert +=	'<param name="flashVars" value="playerMode=embedded"></param>'
				htmlToInsert +=	'<param name="allowFullScreen" value="true"></param>'
				htmlToInsert +=	'<param name="allowscriptaccess" value="always"></param>'
				htmlToInsert +=	'<param name="wmode" value="transparent">'	
				htmlToInsert +=	'</object>'						
			} else {
				htmlToInsert = '<div class="postPhotoFrame" rel="'+photoData.photoId+'"><img src="'+photoData.postPhotoSrc+'" /><br/><span>'+photoData.photoName+'</span></div>';
			}
			rtes.prepend($(htmlToInsert));			
		} else {
			if(photoData.profilePhotoSrc) {
				document.getElementById("profilePhoto").src = photoData.profilePhotoSrc;
			}
			$('#gallery').append('<a href="/'+photoData.photoSrc+'" class="lightbox" rel="profilePhotos" title="'+photoData.photoName+'"><img src="'+photoData.galleryPhotoSrc+'" alt="'+photoData.photoName+'" title="'+photoData.photoName+'"/></a>');
			$(".lightbox").lightbox({
				loopImages: true,
				fitToScreen: true,
				imageClickClose: false
			});	
		}
	}
};