
//the url used for the rpc call
var currentPos =0;
var rpcURL = "/rpc.php";
var imagesURL = "http://images.friendster.com/images/";
var siteURL = "/";
var profileURL = "http://profiles.friendster.com/";
var playNow = 0;
var currentPlayMode = 0;
var crequest_id;
var prev_crequest_id;
var srequest_id;
var prev_srequest_id;
var prequest_id;
var prev_prequest_id;
var abort_previous_requests = true;

var set_photo_comment_items = 0; //timeout id
var set_photo_rating_items = 0; //timeout id

//var PhotoIsReady = true;
/******************************************
 ***** COMMENTS ***************************
 *****************************************/
/*
 * gets photo comments belonging to a given uid and pid
 */
function getPhotoComments(uid, pid, rid, authcode, page) {
	if(!isSlideshow)
	{
	    var commentDiv = $('photocomments');
		commentDiv.innerHTML = '<img src="' + imagesUrl + 'loading-gif-sample-1.gif" /><span> ' + Locale.getString('fetchingComments') + '</span>';
		var commentsheader = $('commentsheader');
	    commentsheader.innerHTML = '';
	    
	    if (prev_crequest_id && abort_previous_requests == true) {
			abortXMLHttpRequest(prev_crequest_id)
	    }
	
		if(albumPrivacy==1 && rid != false) {
	    	var url = rpcURL + "?rpctype=getphotocomments&uid="+uid+"&ppid="+rid+"&mode="+currentPlayMode+'&n='+ new Date().getTime()+"&authcode="+authcode;
		} else {
	    	var url = rpcURL + "?rpctype=getphotocomments&uid="+uid+"&pid="+pid+"&rid="+rid+"&mode="+currentPlayMode+'&n='+ new Date().getTime()+"&authcode="+authcode;
		}
		
		if(page != undefined)
			url += '&page='+page;
			    
	    crequest_id = generateRequestId();
	    prev_crequest_id = crequest_id;
    	sendXMLHttpRequestText(url, 'getPhotoCommentsHandler',  crequest_id);
	}

}

/*
 * handles comments after httprequest call
 */
function getPhotoCommentsHandler(resp) {
    //make sure its commentable/ratable 
    /*if (Album[currentPage][currentPos].cancomment != 'true' && Album[currentPage][currentPos].cancomment != 'canview') {
        return false;
    }*/
    
    var maxComments=20;    
    var commentDiv = $('photocomments');
    var displayMoreLink;
    var previousPage;
    var numComments;
    commentDiv.innerHTML = '';

	if(resp) {
		var response = eval("(" + resp + ")");    
		var numComments = response.total;
		
		var comments = response.comments;
		var totalComments=(comments.length>maxComments)?maxComments:comments.length;
	   	if(response.page <= 0){
	   		displayMoreLink = false;
	   		previousPage = 0;
	   	} else {
	   		displayMoreLink = true;
	   		previousPage = response.page - 1; 
	   	}
	   	
	   	$('comment_count').innerHTML = '<a href="#photocommentsection">' + numComments + ' comments</a>';
	   	
    } else {
    	displayMoreLink=false;
    	$('comment_count').innerHTML = '';
    }
    

    var commentsheader = $('commentsheader');
    commentsheader.innerHTML = '';    
    
    if(displayMoreLink) {
    	var txt=commentsheader.innerHTML + '<a id="getAllCommentsLink" href="#" onclick="getPhotoComments(Album[currentPage][currentPos].uid, Album[currentPage][currentPos].pid, Album[currentPage][currentPos].rid,Album[currentPage][currentPos].authcode, '+previousPage+'); return false;">' + Locale.getString('seePreviousComments') + '</a>'; 
    	commentsheader.innerHTML=txt;
    }
    
    
    
    if (numComments > 0) {
        for (var i = 0; i < totalComments; i++) {
            var user = comments[i].user;
            var uid = user.id;
            var photo = user.photo_url;
            var firstname = user.firstname;
            var comment = comments[i].body;
            comment = comment.trim();
            var date = comments[i].datetime;
            var cid = comments[i].id;

			if (uid != '') {
            	if(albumPrivacy==1)
	            	appendUserComment(uid, photo, firstname, comment, date, cid, false, Album[currentPage][currentPos].guid, Album[currentPage][currentPos].uid, false /*insert at end*/, Album[currentPage][currentPos].authcode);
            	else
	            	appendUserComment(uid, photo, firstname, comment, date, cid, Album[currentPage][currentPos].pid, Album[currentPage][currentPos].rid, Album[currentPage][currentPos].uid, false /*insert at end*/, Album[currentPage][currentPos].authcode);
           	}
        }
    } else if (numComments == 0) {
        // show "no comments" message
        commentDiv.appendChild(document.createTextNode(Locale.getString('noComments')));
    } else {
        // temp error
    	if($('commentinput').innerHTML=='')
    		commentDiv.appendChild(document.createTextNode(Locale.getString('photoCommentsUnavail')));
    }
    
    

}

function appendUserComment(uid, photo, firstname, comment, date, cid, pid, rid, pownerid, insertAtEnd, authcode) {
    var allCommentsDIV = $('commentinput');
    comment = comment.trim();
    
    var photocommentDIV = document.createElement('div'); 
    photocommentDIV.className = 'photocomment clearfix';
    photocommentDIV.id = 'pcomment-'+cid;

    //photo
    var commentphotoDIV = document.createElement('div');
    commentphotoDIV.className = 'commentphoto';
    var imageLink = document.createElement('a');
    imageLink.setAttribute('href', profileURL + uid);
    var image = document.createElement('img');
    if (photo.length < 1) {
        image.setAttribute('src', imagesURL+"nophoto.jpg");
    } else {
        image.setAttribute('src', photo+"s.jpg");
    }
    imageLink.appendChild(image);
    commentphotoDIV.appendChild(imageLink);
    //end:photo

    //admin area
    var commentadminareaDIV = document.createElement('div');
    commentadminareaDIV.className = 'commentadminarea';
    var deleteLink = document.createElement('a');
    deleteLink.setAttribute('href', "javascript:deletePhotoComment("+cid+","+pid+",'"+rid+"','"+authcode+"')");
    deleteLink.appendChild(document.createTextNode(Locale.getString('deleteComment')));
    var blockLink = document.createElement('a');
    blockLink.setAttribute('href', "/friends.php?action=blockingprefs&block="+uid+'&firstname='+encodeURIComponent(firstname));
    blockLink.appendChild(document.createTextNode(Locale.getString('blockUser')));

    if (pownerid == pageViewerID || uid == pageViewerID) {
        commentadminareaDIV.appendChild(deleteLink);
        commentadminareaDIV.appendChild(document.createElement('br'));
    }

    if (pownerid == pageViewerID && uid != pageViewerID) {
        commentadminareaDIV.appendChild(blockLink);
        commentadminareaDIV.appendChild(document.createElement('br'));
    }

    //comment area
    var commentareaDIV = document.createElement('div');
    commentareaDIV.className = 'commentarea';
    var commenterDIV = document.createElement('div');
    commenterDIV.className = 'commenter';
    var namelink = document.createElement('a');
    namelink.setAttribute('href', profileURL+uid);
    namelink.appendChild(document.createTextNode(firstname));
    var datespan = document.createElement('span');
    datespan.className = 'posted';
    datespan.appendChild(document.createTextNode(' - ' + Locale.getString('commentPosted') + ' - ' + date));
    commenterDIV.appendChild(namelink);
    commenterDIV.appendChild(datespan);
    commentareaDIV.appendChild(commenterDIV);
    
    var commentText = document.createElement('div');
    //commentareaDIV.appendChild(document.createTextNode(unescape(comment)));
    commentText.innerHTML = comment;
    commentareaDIV.appendChild(commentText);
    
    //combine to make comment section
    photocommentDIV.appendChild(commentphotoDIV);
    photocommentDIV.appendChild(commentareaDIV);
    photocommentDIV.appendChild(commentadminareaDIV);
    
    //add it!
    //allCommentsDIV.appendChild(photocommentDIV);
    
    if (insertAtEnd) {
        allCommentsDIV.appendChild(photocommentDIV);
    } else {
    	if(allCommentsDIV.childNodes.length > 0)
    		allCommentsDIV.insertBefore(photocommentDIV,allCommentsDIV.childNodes[0]);
    	else
    		allCommentsDIV.appendChild(photocommentDIV);
    } 
    
    $('photocomments').innerHTML = '';
}

/*
 *  action taken when you submit a photo comment
 */
function clickPhotoComment() {
    //make sure its commentable/ratable
    if (Album[currentPage][currentPos].cancomment != 'true') {
        return false;
    }
    if ($('commentTextArea').value.trim() == '') {
        return false;
    }
    //check if they rated
    if (Album[currentPage][currentPos].hascommented == false) {
        return false;
    }
    
    if(albumPrivacy == 1)
	    addPhotoComment(Album[currentPage][currentPos].uid, false, Album[currentPage][currentPos].guid, Album[currentPage][currentPos].authcode);    
    else
	    addPhotoComment(Album[currentPage][currentPos].uid, Album[currentPage][currentPos].pid, Album[currentPage][currentPos].rid, Album[currentPage][currentPos].authcode);
    return false;
}

/*
 * adds a photo comment
 */
function addPhotoComment(uid, pid, rid, authcode) {
    //make sure its commentable/ratable
    if (Album[currentPage][currentPos].hascommented != true) {
        return false;
    }

	if(albumPrivacy == 1 && pid == false)
	    var url = rpcURL + "?rpctype=addphotocomment&uid="+uid+"&ppid="+rid+"&authcode="+authcode;	
	else
	    var url = rpcURL + "?rpctype=addphotocomment&uid="+uid+"&pid="+pid+"&rid="+rid+"&authcode="+authcode;

    url += "&comment="+encodeURIComponent($('commentTextArea').value.trim());
    //Album[currentPage][currentPos].canrate = false;
    sendXMLHttpRequestText(url, 'addPhotoCommentHandler');
    $('commentTextArea').disabled = 1;
    $('submitCommentButton').disabled = 1;
    $('submitCommentButton').onclick = function() {};
}

function addPhotoCommentHandler(resp) {
    //make sure its commentable/ratable
    if (Album[currentPage][currentPos].cancomment != 'true') {
        return false;
    }
    var statusDiv = $('commentstatusmsg');
    try {
   		var response = eval("(" + resp + ")");    
        var status = response.status;
        
        statusDiv.innerHTML = '';
        if (status == 'success') {
            //add comment
            var cid = response.cid;
            var today = new Date();
            var month = today.getMonth() + 1;
            var day = today.getDate();
            var year = today.getFullYear();
            var date = month + '/' + day + '/' + year;
            if(albumPrivacy == 1)
				appendUserComment(pageViewerID, pageViewerPhoto, pageViewerFirstname, $('commentTextArea').value, date, cid, false, Album[currentPage][currentPos].guid, Album[currentPage][currentPos].uid, true /* insert at end */, Album[currentPage][currentPos].authcode);            
            else
	            appendUserComment(pageViewerID, pageViewerPhoto, pageViewerFirstname, $('commentTextArea').value, date, cid, Album[currentPage][currentPos].pid, Album[currentPage][currentPos].rid, Album[currentPage][currentPos].uid, true /* insert at end */, Album[currentPage][currentPos].authcode);
	            

            $('photocommentsheader').style.display = '';
        } else {
            //show error occured message?
            Album[currentPage][currentPos].hascommented = true;
            statusDiv.appendChild(document.createTextNode(Locale.getString('tryAgain')));
        }
    } catch(e) {
        Album[currentPage][currentPos].hascommented = true;
        statusDiv.appendChild(document.createTextNode(Locale.getString('tryAgain')));
    }
    $('commentTextArea').value = '';
}

function deletePhotoComment(cid, pid, rid, authcode) {
	if(albumPrivacy == 1 && pid == false)
	    var url = rpcURL + "?rpctype=delphotocomment&uid="+Album[currentPage][currentPos].uid+"&ppid="+rid+"&cid="+cid+"&authcode="+authcode;	
	else		
	    var url = rpcURL + "?rpctype=delphotocomment&uid="+Album[currentPage][currentPos].uid+"&pid="+pid+"&rid="+rid+"&cid="+cid+"&authcode="+authcode;
    sendXMLHttpRequestText(url, 'deletePhotoCommentHandler');
}

function deletePhotoCommentHandler(resp) {
	var response = eval("(" + resp + ")");
    var status = response.status;
    var statusCid = 'pcomment-'+response.cid;
    if (status == 'success') {
        msgObj = $(statusCid);
        msgObj.parentNode.removeChild(msgObj);
    } else {

    }
}

/*
 * initializer of various photo comment items on the page
 */
function setPhotoCommentItems() {

	clearTimeout(set_photo_comment_items);
	
	if (currentPlayMode == 0) {
    	var url = rpcURL + "?rpctype=ping&mode="+currentPlayMode+'&n='+ new Date().getTime();
	    prequest_id = generateRequestId();
	    prev_prequest_id = prequest_id;
	  	sendXMLHttpRequest(url, 'getPhotoPingHandler',  prequest_id);
	}
	
    try
    {
        set_photo_comment_items = setTimeout(function() {
			//fix the comment message
			var ratingMsgArea = $('commentstatusmsg');
			ratingMsgArea.innerHTML = '';
			var commentDiv = $('commentinput');
			commentDiv.innerHTML = '';
			if (Album[currentPage][currentPos].hascommented == false) {
				if(ratingMsgArea)
					ratingMsgArea.appendChild(document.createTextNode(Locale.getString('alreadyCommented')));
			} else if (Album[currentPage][currentPos].cancomment == 'disabled') {
				if(ratingMsgArea)
					ratingMsgArea.appendChild(document.createTextNode(Locale.getString('disabledComments')));
			} else if (Album[currentPage][currentPos].cancomment == 'canview') {
				if(ratingMsgArea)
					ratingMsgArea.appendChild(document.createTextNode(Locale.getString('login2Comment')));
			} else if (Album[currentPage][currentPos].cancomment == 'false') {
				if(ratingMsgArea)
					ratingMsgArea.appendChild(document.createTextNode(Locale.getString('cannotComment')));
			}

			if(albumPrivacy == 1)
				getPhotoComments(Album[currentPage][currentPos].uid, false, Album[currentPage][currentPos].guid, Album[currentPage][currentPos].authcode);			
			else
				getPhotoComments(Album[currentPage][currentPos].uid, Album[currentPage][currentPos].pid, Album[currentPage][currentPos].rid, Album[currentPage][currentPos].authcode);

		},2000);
    }
    catch(e) {}
}

/******************************************
 ***** RATINGS  ***************************
 *****************************************/

function getPhotoRating(uid, pid, rid, authcode) {
    //make sure its commentable/ratable
    if(!isSlideshow)
    {
	    if (Album[currentPage][currentPos].canrate != 'true' && Album[currentPage][currentPos].canrate != 'canview') {
	        return false;
	    }
	    
	    if (prev_srequest_id && abort_previous_requests == true) {
			abortXMLHttpRequest(prev_srequest_id)
	    }	
	    
		if(albumPrivacy == 1)
			var url = rpcURL + "?rpctype=getphotorating&uid="+uid+"&ppid="+rid+"&authcode="+authcode;
		else
			var url = rpcURL + "?rpctype=getphotorating&uid="+uid+"&pid="+pid+"&rid="+rid+"&authcode="+authcode;	
	    var ratingSpan = $('photorating');
	    ratingSpan.innerHTML = '... ' +Locale.getString('fetchingRating')+ ' ...';
	    
	    srequest_id = generateRequestId();
	    prev_srequest_id = srequest_id;
	    
	    sendXMLHttpRequestText(url, 'getPhotoRatingHandler', srequest_id);
	}

}

function getPhotoRatingHandler(resp) {
    var ratingDiv = $('photorating');
    if(!ratingDiv) return;
    ratingDiv.innerHTML = '';

    var notRatedText = Locale.getString('first2rate');

    if (resp) {
		var response = eval("(" + resp + ")");
		var status = response.status;		
		var rating = response.rating;		
		
		if(status == 'success')
		{
			var score = rating.score;
	        var count = rating.count;
	
	        var current = score;
	
	        if (score == 0) {
	            ratingDiv.innerHTML = notRatedText;
	        } else if (score > 0) { 
	            for (var i = 0; i < 5; i++) {
	                var starIMG = document.createElement('img');
	                var image_string;
	                if (current >= 1) {
	                    image_string = 'rating_star_full_red.gif';
	                } else if (current == 0.5) {
	                    image_string = 'rating_star_half_red.gif';
	                } else {
	                    image_string = 'rating_star_empty.gif';
	                }
	                starIMG.setAttribute('src', imagesURL + image_string);
	                ratingDiv.appendChild(starIMG);
	                
	                current--;
	            } 
	            var ratingsText;
	            if (count > 1) {
	                ratingsText = Locale.getString('ratings');
	            } else {
	                ratingsText = Locale.getString('rating');
	            }
	            ratingDiv.innerHTML += ' '+count+' '+ratingsText;
	        } else {
	            ratingDiv.innerHTML = Locale.getString('tempUnavail');
	        }		
		} else {
            ratingDiv.innerHTML = Locale.getString('tempUnavail');		
		}
        
    } else {
        //show "no rating" message/check for error??
        ratingDiv.innerHTML = notRatedText;
    }

}

/*
 * action taken when you click on a star to rate a photo
 */
function clickPhotoRating(rating) {
    //make sure its commentable/ratable
    if (Album[currentPage][currentPos].canrate != 'true') {
        return false;
    }

    //check if they rated
    if (Album[currentPage][currentPos].rating > 0) {
        changeStars(Album[currentPage][currentPos].rating);
        return false;
    }
	
	if(albumPrivacy==1)
	    addPhotoRating(Album[currentPage][currentPos].uid, false, Album[currentPage][currentPos].guid, rating, Album[currentPage][currentPos].authcode);
	else
		addPhotoRating(Album[currentPage][currentPos].uid, Album[currentPage][currentPos].pid, Album[currentPage][currentPos].rid, rating, Album[currentPage][currentPos].authcode);

}

function addPhotoRating(uid, pid, rid, rating, authcode) {
    //make sure its commentable/ratable
    if (Album[currentPage][currentPos].canrate != 'true') {
        return false;
    }

	if(albumPrivacy==1 && pid==false)
	    var url = rpcURL + "?rpctype=addphotorating&uid="+uid+"&ppid="+rid+"&authcode="+authcode;
	else
	    var url = rpcURL + "?rpctype=addphotorating&uid="+uid+"&pid="+pid+"&rid="+rid+"&authcode="+authcode;
	    

    url += "&rating="+rating;


    //disable for possible double clicking
    Album[currentPage][currentPos].rating = rating;
    var ratingMsgArea = $('ratingformmsg');
    var text = Locale.getString('sendingRating');
    ratingMsgArea.innerHTML = text;
    sendXMLHttpRequestText(url, 'addPhotoRatingHandler');
    $('photorating').innerHTML = '';
}

function addPhotoRatingHandler(resp) {
    //make sure its commentable/ratable
    if (Album[currentPage][currentPos].canrate != 'true') {
        return false;
    }
	//var rating = eval("(" + resp + ")");        
    var response = eval("(" + resp + ")");
    var ratingMsgArea = $('ratingformmsg'),
        text = '';
        
    ratingMsgArea.innerHTML = '';
    if (response.status == 'success') {
        text = Locale.getString('ratingSubmitted');
    } else {
        //error
        Album[currentPage][currentPos].rating = 0;
        text = Locale.getString('tryAgain');
    }
    ratingMsgArea.innerHTML = text;
}

/*
 * initializer of photo rating items on the page
 */
function setPhotoRatingItems() {

	clearTimeout(set_photo_rating_items);

	set_photo_rating_items = setTimeout(function(){
		//fix the rating message
		var ratingMsgArea = $('ratingformmsg'),
			text = '';
		ratingMsgArea.innerHTML = '';
		changeStars(0);
	
		if (Album[currentPage][currentPos].rating > 0) {
			text = Locale.getString('alreadyRated');
		} else if (Album[currentPage][currentPos].canrate == 'disabled') {
			text = Locale.getString('disabledRating');
			if($('averageratingtitle'))
				$('averageratingtitle').style.display = 'none';
				
			if($('ratingform'))        	
				$('ratingform').style.display = 'none';
		} else if (Album[currentPage][currentPos].canrate == 'canview') {
			text = Locale.getString('login2rate');
			if($('averageratingtitle'))
				$('averageratingtitle').style.display = '';
			if($('ratingform'))	        
				$('ratingform').style.display = 'none';
		} else if (Album[currentPage][currentPos].canrate == 'false') {
			text = Locale.getString('cannotRate');
			if($('averageratingtitle'))
				$('averageratingtitle').style.display = 'none';
			if($('ratingform'))
				$('ratingform').style.display = 'none';
		} else {
			if($('averageratingtitle'))
				$('averageratingtitle').style.display = '';
			if($('ratingform'))
				$('ratingform').style.display = '';
		}
		ratingMsgArea.innerHTML = text;
		
		if(albumPrivacy == 1)
			getPhotoRating(Album[currentPage][currentPos].uid, false, Album[currentPage][currentPos].guid, Album[currentPage][currentPos].authcode);
		else
			getPhotoRating(Album[currentPage][currentPos].uid, Album[currentPage][currentPos].pid, Album[currentPage][currentPos].rid, Album[currentPage][currentPos].authcode);

	},2000);

}


/******************************************
 ***** HELPERS  ***************************
 *****************************************/

/*
 * rating of '0' will set them all to empty
 */
function changeStars(rating) {
    //todo: disable/check for this rating
    /*
    if(allowRating == false) {
        return false;
    }*/
    if (Album[currentPage][currentPos].rating > 0) {
        rating = Album[currentPage][currentPos].rating;
    }

    for (var i = 1; i <= 5; i++) {
        var starimage;

        if (i <= rating) {
            starimage = 'rating_star_full.gif';
        } else {
            starimage = 'rating_star_empty.gif';
        }

        $('ratestar'+i).src = imagesURL + starimage;
    }

}


//-------------------------------------------------
function resetCaptionForm()
{
    if(!$('caption_id')) return;
    if($('caption_id').value.length <= 0)
        document.caption_form.reset();
    else
        $('caption_id').value = (Album[currentPage][currentPos].caption.length > 0) ? Album[currentPage][currentPos].caption : Locale.getString('editTitle');
}


//var currentPos = 0;
var firstState = 'none';
var previousState = 'none';

function nextbtn () {
	if(typeof _hbLink == "function" && typeof _hbPageView == "function") {
//		_hbLink('slideshowNext', null);
		_hbPageView("photodetails","/Other"); 	
	}
	//urchinTracker ('/photodetails');
	if(typeof pageTracker == "object") pageTracker._trackPageview('/photodetails');
	if(typeof pageTrackerAnon == "object") pageTrackerAnon._trackPageview('/photodetails');		
    clearStatusMessage();
    pause();
    //next();
    Slideshow.next();
    refreshIframeAd('horiz');
    refreshIframeAd('mb');
    refreshGoogleAd();
    return false;  
}

function prevbtn () {
	if(typeof _hbLink == "function" && typeof _hbPageView == "function") {
//		_hbLink('slideshowPrev', null);
		_hbPageView("photodetails","/Other");	
	}
	//urchinTracker ('/photodetails');
	if(typeof pageTracker == "object") pageTracker._trackPageview('/photodetails');
	if(typeof pageTrackerAnon == "object") pageTrackerAnon._trackPageview('/photodetails');			
    clearStatusMessage();
    pause();
    //prev();
    Slideshow.prev();
    refreshIframeAd('horiz');
    refreshIframeAd('mb');
    refreshGoogleAd();
    return false;     
}

function clearStatusMessage(){
	if($('status_div'))
		$('status_div').innerHTML = '';	
}

//play and stop functions
var t
function play() {
//	if(typeof _hbLink == "function" && typeof _hbPageView == "function") {
//		_hbLink('slideshowPlay', null);	
//	}
	currentPlayMode = 1;
    clearStatusMessage();
    $('playLink1').href = 'javascript:pause()';
    //$('playBtn1').src = imagesUrl + 'slide_autopause.gif';
	$('playBtn1').innerHTML = Locale.getString('slidePause');
    Slideshow.next();	    	      
    t=setTimeout("play()",5000);
}

function pause() {
	currentPlayMode = 0;
    $('playLink1').href = 'javascript:play()';
    //$('playBtn1').src = 'http://images.friendster.com/images/slide_autoplay.gif';
	$('playBtn1').innerHTML = Locale.getString('slideAutoPlay');
    clearTimeout(t);
}

function showGrabLink() {
	if($('grabthisphoto_li'))
		$('grabthisphoto_li').style.display = '';
    $('grabthisphoto_msg').style.display = 'none';
    $('grabthisphoto_link').style.display = '';
}

function grabPhotoHandler(xmlObj) {

    var text = xmlObj.getElementsByTagName('text')[0].firstChild.data;
    var code = xmlObj.getElementsByTagName('code')[0].firstChild.data;    
    switch(code){
    	case '0': { rstext = Locale.getString('failedToGrab'); break; }
    	case '1': { rstext = Locale.getString('photoIsGrabbed'); break; }
    	case '2': { rstext = Locale.getString('cannotGrabPrivatePhoto'); break; }    	    	
    }

    $('grabMsg').innerHTML = rstext;
    $('grabMsg').innerHTML = '';
	$('grabthisphoto_msg').innerHTML = rstext;
    $('grabthisphoto_link').style.display = 'none';    
    closeDiv('grabPhotoPanel');
}

function grabPhoto () {
	$('grabthisphoto_msg').innerHTML = '';
    $('grabthisphoto_link').style.display = 'none';
    $('grabthisphoto_msg').style.display = '';
    $('grabMsg').innerHTML = Locale.getString('plsWait');
    var dropAlbum = document.grabPhotoForm.albumName.value;
    $('grabthisphoto_msg').innerHTML = Locale.getString('grabbingPhoto');
    
    url = 'http://' + grabHost + '/grab_this_photo.php?uid='+currentUid+'&pid='+currentPid+'&rid='+currentRid+'&a='+dropAlbum+'&action=grab_this_photo';
    if($('no-albums'))
    	url += '&na=1';
    	    	
    sendXMLHttpRequest(url, 'grabPhotoHandler');    
}


var photolistUrl = 'http://' +window.location.host + '/photolist_ajax.php';
var transitionSpeed = 200;//in milliseconds

//new Ajax(photolistUrl, {data: '&uid=' + photoList.uid + '&page=' + ++currentPage, onComplete: nextPicBatchHandler}).request();
function preloadAlbum(array)
{
    for(var i = 0; i < array.length; i++)
    {
        array[i].cachedPic = new Image();
        array[i].cachedPic.src = array[i].url;
    }
    return array;
}

var PhotoRpc = {
    queue : [],
    active : {},
    url : 'http://' + window.location.host + '/photolist_ajax.php',
    retry_params:[],
    getPage : function(uid, aid, page, callback, authcode) {
    	PhotoRpc.retry_params=[uid, aid, page, callback];
        var ticketNum = PhotoRpc.queue.length; 
        PhotoRpc.queue[ticketNum] = {
            req : function() { 
                new Ajax(PhotoRpc.url, {
                	method: 'get', 
                	data: 'uid=' + uid + '&a='+ aid +'&page=' + page + '&ver=1&authcode=' + authcode, 
                	onComplete: PhotoRpc.processGetPage
                }).request();             
            },
            callback : callback
        }//end of PhotoRpc.queue[ticketNum]
        
        if(!PhotoRpc.active.req)
            PhotoRpc.processQueue();
    },
    processQueue : function() {
        if(PhotoRpc.queue.length <= 0) {
            PhotoRpc.active = {};
            return;
        }
        PhotoRpc.active = PhotoRpc.queue.pop();
        PhotoRpc.active.req();
    },
    processGetPage : function(data) {
    
    	if(data.length <= 0) return;
    	eval('newPSet=' + data);
    
        if(newPSet && newPSet.photos && newPSet.photos.length && typeof Album[newPSet['page']] == "undefined") {
			Album[newPSet['page']] = newPSet['photos'];
			PhotoRpc.active.callback();
			//$('mainphoto').effect('opacity', {duration: transitionSpeed,transition: Fx.Transitions.Quad.easeInOut, fps: 100}).start(1, 0);
			PhotoRpc.processQueue();
        } else {
        	//alert("bomb...")
        	//PhotoRpc.getPage.apply(this,[PhotoRpc.retry_params]);
        }
    }
}

var Slideshow = {
    currentSlide : 0,
    page : 0,
    maxPage : 0,
    prevFlag : 0,
    firstLoad: 1,
    next : function(onAjax) {
        if(!onAjax) {
            Slideshow.currentSlide++;
            
            var nextPage = ((Slideshow.page + 1) > Slideshow.maxPage - 1) ? 0 : (Slideshow.page + 1);
            var nextPageToCache = ((nextPage + 1) > Slideshow.maxPage - 1) ? 0 : (nextPage + 1);
            
            if(Slideshow.currentSlide > Album[Slideshow.page].length - 1 && Slideshow.maxPage > 1) {
            
                Slideshow.currentSlide = 0;
                Slideshow.page = nextPage;

                if(!Album[nextPage]) {
                	$('previous_button').onclick = function() {};
                    $('next_button').onclick = function() {};
                    $('photoleftarrow').onclick = function() {};
                    $('photorightarrow').onclick = function() {};                                              
                    $('playLink1').href = 'javascript:;';
                    var callBack = function() { Slideshow.next(1); }
                    $('mainphoto').src = imagesURL + 'ajax-loader.gif';
                    PhotoRpc.getPage(Album.uid, Album.aid, nextPage, callBack, Album.authcode);
                    getPhotoListForCache(Album.uid, Album.aid, nextPageToCache, Album.authcode);
				   	return;
                } else {
                	Album[Slideshow.page][Slideshow.currentSlide].url = cachePhoto(Album[Slideshow.page][Slideshow.currentSlide].url);
                }
                
            } else if(Slideshow.currentSlide > Album[Slideshow.page].length - 1 && Slideshow.maxPage <= 1) {
                Slideshow.currentSlide = 0;
                Album[Slideshow.page][Slideshow.currentSlide].url = cachePhoto(Album[Slideshow.page][Slideshow.currentSlide].url);
			}

			Slideshow.currentSlide = Math.abs(Slideshow.currentSlide);			
            Slideshow.changeCommon(Slideshow.page, Slideshow.currentSlide, 1);
            
        } else { 
        	// Cache the first image of the fetched page
			Album[Slideshow.page][Slideshow.currentSlide].url = cachePhoto(Album[Slideshow.page][Slideshow.currentSlide].url);
            Slideshow.changeCommon(Slideshow.page, Slideshow.currentSlide, 1);
            $('previous_button').onclick = prevbtn;
            $('next_button').onclick = nextbtn;
			$('photoleftarrow').onclick = prevbtn;
			$('photorightarrow').onclick = nextbtn; 	                   
            $('playLink1').href = 'javascript:play()';
        }

    },
    prev : function(onAjax) {
        if(!onAjax) {
        	
            Slideshow.currentSlide--;
            
            var prevPage = ((Slideshow.page - 1) < 0) ? Slideshow.maxPage - 1 : (Slideshow.page - 1);
            var nextPageToCache = ((prevPage - 1) < 0) ? 0 : (prevPage - 1);  
                      
            if(Slideshow.currentSlide < 0 && Slideshow.maxPage > 1) {
                Slideshow.page = prevPage;
                if(!Album[prevPage]) {
                
                    $('previous_button').onclick = function() {};
                    $('next_button').onclick = function() {};
                    $('photoleftarrow').onclick = function() {};
                    $('photorightarrow').onclick = function() {};                     
                    $('playLink1').href = 'javascript:;';
                    var callBack = function() { Slideshow.prev(1); }
                    $('mainphoto').src = imagesURL + 'ajax-loader.gif';                 
                    PhotoRpc.getPage(Album.uid, Album.aid, prevPage, callBack, Album.authcode);                    
                    getPhotoListForCache(Album.uid, Album.aid, nextPageToCache, Album.authcode);
                    return;
                } else {
            		Album[Slideshow.page][Album[Slideshow.page].length - 1].url = cachePhoto(Album[Slideshow.page][Album[Slideshow.page].length - 1].url);
                }

                Slideshow.currentSlide = Album[Slideshow.page].length - 1;
            } else if(Slideshow.currentSlide < 0 && Slideshow.maxPage <= 1) {
                Slideshow.currentSlide = Album[Slideshow.page].length - 1;
            	Album[Slideshow.page][Slideshow.currentSlide].url = cachePhoto(Album[Slideshow.page][Slideshow.currentSlide].url);
            }
            
            Slideshow.changeCommon(Slideshow.page, Slideshow.currentSlide, -1);

        } else {

            Slideshow.currentSlide = Album[Slideshow.page].length - 1;
          	// Cache the last image of the fetched page
            Album[Slideshow.page][Slideshow.currentSlide].url = cachePhoto(Album[Slideshow.page][Slideshow.currentSlide].url);
            Slideshow.changeCommon(Slideshow.page, Slideshow.currentSlide, -1);
            $('previous_button').onclick = prevbtn;
            $('next_button').onclick = nextbtn;
			$('photoleftarrow').onclick = prevbtn;
			$('photorightarrow').onclick = nextbtn; 	                   
            $('playLink1').href = 'javascript:play()';
        }
    },
    
    changeCommon : function(cPage, slide, direction) {
    
        //for legacy code sake
        currentPos = slide;
        currentPage = cPage;

        //var photo = Album[cPage][slide];
        var photo = Album[cPage][slide];
        var mainPhotoObj = $('mainphoto');
        
		// for removing the status message box
		if($('photos-statusbox')) {
			$('photos-statusbox').remove();
		}
		
		// Clear comment section
		$('photocomments').innerHTML = '';
		// Clear comment count
		$('comment_count').innerHTML = '';
		
		//if we can't use the ajax slideshow
		if(!useAjaxSlideshow) {
			if(albumPrivacy == 1)
				var newLoc = (window.location.protocol + "//" + window.location.host + ("/photos/" + photo.uid + "/private_" + photo.guid));			
			else 
				var newLoc = (window.location.protocol + "//" + window.location.host + ("/photos/" + photo.uid + "/" + photo.pid  + "/" + photo.rid));
			window.location.href = newLoc;
			return;
		}
		
        //var fxCall = function() {        
        	// Replace current photo with next in queue
            //mainPhotoObj.src = imagesUrl + 'ajax-loader.gif';
            /*
            	removing the cache retry stuff- we should just to try to display the photo whether its cached or not. 
            */
			if (1 /*PhotoIsReady*/) {
				mainPhotoObj.src = photo.url.src;
				cacheNextPhoto(cPage, (slide + direction));						
			} else {
				//self.defaultStatus = 'Failed loading '+photo.url.src+', trying again.';
				// alert('Not Ready???? '+ photo.url.src);
				// Black hole?
				
				// Or try again
				// Retry caching the current photo
				//cacheNextPhoto(cPage, slide);				
				//downloadPhoto(cPage, slide);
				//mainPhotoObj.src = photo.url.src;
				//cacheNextPhoto(cPage, (slide + direction));	
			}
			
            //$('mainphoto').effect('opacity', {duration: transitionSpeed,transition: Fx.Transitions.Quad.easeInOut, fps: 100}).start(0, 1);
	        mainPhotoObj.title = mainPhotoObj.alt = (photo.caption.length > 0) ? photo.caption : '';
	            
            // Replace photo URL   
            var newloc = location.href.replace(/#pic=\w+/, "");
			if(isSlideshow) {
				newloc += "#pic=" + photo.pid + photo.rid;
			} else {
				newloc += (photo.isPrivate == 0) ? "#pic=" + photo.album_id + photo.pid + photo.rid : "#pic=" + photo.album_id + photo.guid;
			}
			            
            self.location.replace(newloc);
            
            // Photo Caption
            if(pageViewerID == photo.uid) {
            	if(albumPrivacy == 1) {
	            	var suffix = photo.album_id + '_' + photo.guid;
	            	$('caption_form').setAttribute('action', '/photodetails.php?uid=' + photo.uid + '&a=' + photo.album_id + '&ppid=' + photo.guid);
            	} else {
                	var suffix = photo.album_id + '_' + photo.pid + '_' + photo.rid;
                	$('caption_form').setAttribute('action', '/photodetails.php?uid=' + photo.uid + '&a=' + photo.album_id + '&pid=' + photo.pid + '&rid=' + photo.rid);
                }
                $('caption_id').value = (photo.caption.length > 0) ? photo.caption : Locale.getString('editTitle');
                $('caption_id').name = 'newcaption_' + suffix;
                $('caption_hidden').name = 'currcaption_' + suffix;
             } else
                $('caption_text_id').innerHTML = (photo.caption.length > 0) ? photo.caption : '';

            //Set As Primary and Delete Photo Link
            if(viewer_is_owner == true) {
            
            	// Delete link
            	if(albumPrivacy==1)
    	            $('deletePhotoLink').setAttribute('href','/photodetails.php?uid=' + photo.uid + '&a=' + photo.album_id + '&ppid=' + photo.guid + '&action=delete');
            	else
	                $('deletePhotoLink').setAttribute('href','/photodetails.php?uid=' + photo.uid + '&a=' + photo.album_id + '&pid=' + photo.pid + '&rid=' + photo.rid + '&action=delete');            	            	
                
                // Set as Primary link
                var sapplObj = $('setAsPrimaryPhotoLink');
                var prime = $('primaryphotoel'); // primary photo actions list element
                if(parseInt(photo.isPrimary)) {
                    if(prime){
                    	prime.style.display = 'inline';
                    	prime.className = 'primary';
                    }
                    sapplObj.href = '#nogo';
                    sapplObj.innerHTML = Locale.getString('primaryPhoto');
                } else {
                	if(photo.t != 4 && photo.isPrivate == 0){
                    	if(prime){
                    		prime.style.display = 'inline';
	                    	prime.className = 'setasprimary';
	                    }
	                    sapplObj.setAttribute('href', '/photodetails.php?uid=' + photo.uid + '&a=' + photo.album_id + '&pid=' + photo.pid + '&rid=' + photo.rid + '&action=setprimary');
	                    sapplObj.innerHTML = Locale.getString('setPrimaryPhoto');
                    }
                    else{
                    	if(prime) prime.style.display = 'none';
                    }
                }
            }

            //Photo Link and Embed Code
            if('1degree' != photoType && '2degree' != photoType && photo.t != 4 && photo.isPrivate == 0) {
                var cPhotoUrl = 'http://' + window.location.host + '/photos/' + photo.uid + '/' + photo.pid + '/' + photo.rid;
                
                var thumbnailUrl = photo.raw_url + 'l.jpg';
				$('photoEmbedLink').style.display = 'block';
            	$('photoEmbedCode').style.display = 'block';                  
                $('photoEmbedURL').innerHTML = '<a href="' + thumbnailUrl + '">' + thumbnailUrl + '</a>';
                $('photoEmbedCodeArea').value = '<a href="' + cPhotoUrl + '"><img border="0" src="' + thumbnailUrl + '"/></a>';
            } else {
            	$('photoEmbedLink').style.display = 'none';
            	$('photoEmbedCode').style.display = 'none';            	
            }

			// Photo comments
			if($('getAllCommentsLink'))
				$('getAllCommentsLink').remove();
            if((photo.cancomment=='true' || photo.cancomment==1) && !isSlideshow && !viewer_is_anonymous) {
                if($('comments_input')){
                	$('comments_input').style.display = '';
                }
                $('commentTextArea').disabled = 0;
                $('submitCommentButton').disabled = 0;
                $('submitCommentButton').onclick = clickPhotoComment;
                setPhotoCommentItems();
            } else {
                $('comments_input').style.display = 'none';
                setPhotoCommentItems();
            }
            
            // Photo ratings
            if(page.ratings && !isSlideshow)
                setPhotoRatingItems();
            
            // Restore caption "label" on photo change
            restoreCaptionBorders();
            
            // Photo counter
            $('photonumber1').innerHTML = ((cPage * 20) + slide) + 1;
            
            // Extra labels for grabbed and submitted photos
            var uploadedByText = Locale.getString('uploadedBy') + ' <a href=' + profileURL + photo.uid + ' />' + photo.firstname + '</a>'; 
            if(photo.t == 4)
                uploadedByText = Locale.getString('grabbedFrom') + ' <a href=' + profileURL + photo.oid + ' />' + photo.ofirstname + '</a>'; 
            else if(photo.uploader_id)
                uploadedByText = Locale.getString('uploadedBy') + ' <a href=' + profileURL + photo.uploader_id + ' />' + photo.uploader_firstname + '</a>';

            $('uploadedby').innerHTML = uploadedByText;
            
            // show grabbed from in public photos, and in submitted photos. hide otherwise.
            /*
            if(photo.t == 4 || photo.uploader_id){
            	$('uploadedby').style.display = 'block';
            }
            else{
            	$('uploadedby').style.display = 'none';
            }
            */
            // share this profile
            if(photoType == '1degree' || photoType == '2degree'){
	            var shareProfileText = '<a href=' + profileURL + photo.uid + ' />'+Locale.getString('shareProfile')+'</a>'; 
	            if(photo.oid)
	                shareProfileText = '<a href=' + profileURL + photo.oid + ' />'+Locale.getString('shareProfile')+'</a>'; 
	            else if(photo.uploader_id)
	                shareProfileText = '<a href=' + profileURL + photo.uploader_id + ' />'+Locale.getString('shareProfile')+'</a>';
	            $('shareprofile_span').innerHTML = shareProfileText;            
	        }
            
            // SEO page title
            document.title = 'Friendster - ' + photo.firstname;            
            if(photo.caption.length > 0)
            	document.title += ' - ' + photo.caption;
            
            // Do not show following links if viewer is owner or anonymous
            if (viewer_is_owner || viewer_is_anonymous)
                return;
            
            try 
            {
                $('userinfoname').innerHTML = photo.firstname;
                $('userinfolink').href = profileURL + photo.uid;
                $('forwardlink').href = '/referafriend.php?refer=' + photo.uid;
                $('reportlink').href = '/flagprofile.php?uid=' + photo.uid;
            }
            catch(e) {}
            //Grab this Photo link
            if (photo.cangrab == 1 && photo.t != 4) {
              currentPid = photo.pid;
              currentRid = photo.rid;
              currentUid = photo.uid;
              currentAid = photo.album_id;
              showGrabLink();
            } else {
            	if($('grabthisphoto_li'))
            		$('grabthisphoto_li').style.display = 'none';
            }
        //}
        //$('mainphoto').effect('opacity', {duration: transitionSpeed,transition: Fx.Transitions.Quad.easeInOut, fps: 100, onComplete: fxCall }).start(1, 0);
    }//end of changeCommon : function(page, slide)
}

function togglePhotoDetails()
{
    if($('photo-det-toggle').className != 'hide') {
        $('photo-det-toggle').className = 'hide';
        $('photo-det-toggle').innerHTML = Locale.getString('hideDetails');
        $('photo-det-cont').className = 'hideContainer';
    }else {
        $('photo-det-toggle').className = '';
        $('photo-det-toggle').innerHTML = Locale.getString('showDetails');
        $('photo-det-cont').className = '';
    }
}
        
function init()
{

    for(var i= 0; i <= Album[currentPage].length - 1; i++) {
    	if(albumPrivacy == 1) {
	        if(currentGuid == Album[currentPage][i].guid) 
	            currentPos = i;    	
	    } else {
	    	if(currentPid == Album[currentPage][i].pid && currentRid == Album[currentPage][i].rid) 
	            currentPos = i;	    	
	    }
    }

    setPhotoCommentItems();
    setPhotoRatingItems();
    $('submitCommentButton').onclick = clickPhotoComment;
    $('photo-det-toggle').onclick = togglePhotoDetails;
    thumbs.pageLoaded = {};
    thumbs.pageLoaded[currentPage] = thumbs.photo.length;
    Slideshow.currentSlide = currentPos;
    Slideshow.page = currentPage;
    Slideshow.maxPage = totalPages;
    $('photonumber1').innerHTML = ((currentPage * 20) + currentPos) + 1;
    $('previous_button').onclick = prevbtn;
    $('next_button').onclick = nextbtn;
	$('photoleftarrow').onclick = prevbtn;
	$('photorightarrow').onclick = nextbtn;       
    $('playLink1').href = 'javascript:play()';
    if(playNow) play();
	
	// Cache the current, next, and previous images
    Album[currentPage][currentPos].url = cachePhoto(Album[currentPage][currentPos].url);
    cacheNextPhoto(currentPage, (currentPos + 1));
    cacheNextPhoto(currentPage, (currentPos - 1));
    
	var prevPageToCache = ((currentPage - 1) < 0) ? 0 : (currentPage - 1);
	var nextPageToCache = ((currentPage + 1) > Slideshow.maxPage - 1) ? 0 : (currentPage + 1);	 
	
	if(!isSlideshow)
	{
		//the point of this call is to cache the next page's worth of json
		getPhotoListForCache(pageOwnerID, Album.aid, nextPageToCache, Album.authcode);
		//the point of this call is to cache the next page's worth of json
		getPhotoListForCache(pageOwnerID, Album.aid, prevPageToCache, Album.authcode);	    
	}
    
}

function attachStickyText(textAreaObj, text)
{
	if(typeof(textAreaObj) == "string"){
		textAreaObj = $(textAreaObj);
	}
	textAreaObj.value = text;	
	textAreaObj.onclick = function()
	{
		textAreaObj.style.borderTop = "1px solid #CCC";
		textAreaObj.style.borderLeft = "1px solid #CCC";
		textAreaObj.style.borderRight = "1px solid #EAEAEA";
		textAreaObj.style.borderBottom = "1px solid #EAEAEA";	
		textAreaObj.style.background = "#FFFDCE";		
		textAreaObj.style.cursor = "text";	
		if(textAreaObj.value == text){
			textAreaObj.value = '';		
		}	
	}	
}

// FUNCTIONS USED IN EDITING CAPTIONS IN BOTH LANDING AND PHOTO DETAILS PAGE
//PHOTO LANDING PAGE...
function restoreCaptionBox(textAreaObj,defaultText)
{
	textAreaObj.style.border = "0px";
	textAreaObj.style.background = "#FFFFFF";		
	textAreaObj.value = textAreaObj.value.trim();
	textAreaObj.style.cursor = "pointer";			
	if(textAreaObj.value.length == 0){
		textAreaObj.value = defaultText;
	}
}

// PHOTO DETAILS
function showCaptionBorders(){
	pause();
	if($('caption_id')){
		$('caption_id').style.cursor = 'text';
		$('caption_id').style.borderTop = "1px solid #CCC";
		$('caption_id').style.borderLeft = "1px solid #CCC";
		$('caption_id').style.borderRight = "1px solid #EAEAEA";
		$('caption_id').style.borderBottom = "1px solid #EAEAEA";
		$('caption_id').style.background = "#FFFDCE";		
		$('caption_id').select();
		
		// show save cancel buttons
		showCaptionButtons();
		shortenBox();
	}
}
function restoreCaptionBorders(){
	if($('caption_id')){			
		$('caption_id').style.cursor = 'pointer';				
		$('caption_id').style.border = "0px";
		$('caption_id').style.background = "#FFFFFF";
			
		// hide save cancel buttons
		hideCaptionButtons();
		restoreBox();
	}
}	
function showCaptionButtons(){
	if($('captionButtons')){
		$('captionButtons').style.display = "inline";	
	}
}
function hideCaptionButtons(){
	if($('captionButtons')){
		$('captionButtons').style.display = "none";	
	}
}
function shortenBox(){
	if($('caption_id')){
		$('caption_id').style.width = "520px";
	}
}
function restoreBox(){
	if($('caption_id')){
		$('caption_id').style.width = "630px";
	}
}

/*
	Cache the next photo. Depending on the value of nextSlide, 
	this will work for both next and previous photo. 
	The idea is	to replace the 'url' attribute of Album[<current page>][<current position>]
	with an Image object using the original string 'url' attribute. This
	way we can check if an image has already been "cached". 
	We should cache a particular image only once.
*/
function cacheNextPhoto(cPage, nextSlide) 
{
	if ((Album[cPage][nextSlide]) && 
		((typeof Album[cPage][nextSlide].url == 'string') || (Album[cPage][nextSlide].url.src == 'undefined')))
	{	
		//PhotoIsReady = false;
		Album[cPage][nextSlide].url = cachePhoto(Album[cPage][nextSlide].url);
		//downloadPhoto(cPage, nextSlide);
	}
	return true;
}	
	
/* 
	"Cache" a photo by creating an image object
	with the image url string provided
*/
function cachePhoto(imgUrl) 
{ 
	if(typeof imgUrl == 'string') {
		var img = new Image();
		img.src = imgUrl;
		return img;
	} else {
		return imgUrl;
	}
}

/*
	grab the pic first
*/
function processURLCacheCall(data) {
	
	eval('var newPSet=' + data);
	if(newPSet && newPSet.photos && newPSet.photos.length) {
		//cache the pics on edge
		cachePhoto(newPSet.photos[0].url);
		cachePhoto(newPSet.photos[newPSet.photos.length-1].url);
	}
		
}

function getPhotoListForCache(uid, aid, nextpage, authcode) {                
	//the point of this call is to cache the next page's worth of json
	setTimeout(function(){
		new Ajax(PhotoRpc.url, {
			method: 'get', 
			data: 'uid=' + uid + '&a='+ aid +'&page=' + nextpage + '&ver=1' + '&authcode='+ authcode, 
			onComplete: function(data){processURLCacheCall(data);}
		}).request();
	},2000);  
}

/*
	Check if photo has completed loading. Try "downloading"
	again and again until complete.
*/
/*
function downloadPhoto(cPage, nextSlide) 
{
	//if (Album[cPage][nextSlide].url.complete) {
	//	PhotoIsReady = true;
	//} else {
	//	setTimeout("downloadPhoto("+cPage+","+nextSlide+")", 50);
	//}
	//return true;
}
*/


function getPhotoPingHandler(xml) {
    return false;
}
