var expand_once = 0;
var expand_count = 0;
var total_comments = 0;
var photo_info_vis = 0;
var prevCoordX = -1;
var prevCoordY = -1;
var photo_code = "";
var index_X = 0;
var index_Y = 0;
var activeTour = false;
var hotspotIndex = 0;
var friends_visible = false;
var user_visible = false;
var user_uploading = 0;

function fromFlash(xCoord,yCoord) {
    index_X = Math.floor(xCoord / cellSizeX) + 1;
    index_Y = Math.floor(yCoord / cellSizeY) + 1;
	if( (prevCoordX != index_X || prevCoordY != index_Y || photo_info_vis == 0 )  ) {
		$.ajax({
  			url: "get_photo.php",
  			type: "POST",
			data: {
				index_X: index_X,
				index_Y: index_Y,
				fb_id: fb_id,
				fname: fname,
				lname: lname,
				email: email,
				source: source,
				embed: embed_type,
				mosaic: pmPath
    		},
  			dataType: "html",
			beforeSend: ajaxLoadingPhoto,
			success: function(data) {
    			ajaxCompletedPhoto(data);
    		}
		});
	}
}
function updatePhotoInfo(){
	if(index_X){
		$.ajax({
  			url: "get_photo.php",
  			type: "POST",
			data: {
				index_X: index_X,
				index_Y: index_Y,
				fb_id: fb_id,
				fname: fname,
				lname: lname,
				email: email,
				source: source,
				embed: embed_type,
				mosaic: pmPath
    		},
  			dataType: "html",
			beforeSend: ajaxLoadingPhoto,
			success: function(data) {
    			ajaxCompletedPhoto(data);
    		}
		});
	}
}
function ajaxLoadingPhoto() {
    var f = document.getElementById('photo_info');
    f.innerHTML = '<div style="vertical-align:middle; text-align:center; padding-top:80px;"><img src="images/small_loader.gif" alt="loading photo info"/></div>';
}
function ajaxCompletedPhoto(data) {
	var e = document.getElementById('valid_search');
    var f = document.getElementById('photo_info');
	var string_split = data.split("|||",5);
    prevCoordX = parseInt(string_split[0]);
    prevCoordY = parseInt(string_split[1]);
	if(string_split[2] != '0'){
    	photo_code = string_split[2];
    	//e.innerHTML = string_split[3];
		urchinTracker('Mosaic_photo_click/' + photo_code);
    	f.innerHTML = string_split[4];
		FB.XFBML.parse(f);
	}else{
		f.innerHTML = string_split[4];
	}
	if(photo_info_vis == 0){
		$('#photo_info').slideToggle('slow');
		photo_info_vis = 1;
	}
}
function refreshViewerSearch() {
	var searchValue =  document.getElementById('keyword_input').value;
	urchinTracker('UserSearch/' + searchValue);
	viewX = viewX_orig;
	viewY = viewY_orig;
	zoomLevel = zoomLevel_orig;
	activeTour = true;
    hotspotIndex = -1;
	$.ajax({
		url: "viewer.php",
		type: "POST",
		data: {
			keyword_input: searchValue,
			photo_box: photo_box,
			fb_id: fb_id,
			fname: fname,
			lname: lname,
			email: email,
			source: source,
			embed: embed_type
		},
		dataType: "html",
		beforeSend: ajaxLoadingViewer,
		success: function(data) {
			ajaxCompletedViewer(data);
		}
	});
}
function refreshViewerLink(key) {
	viewX = viewX_orig;
	viewY = viewY_orig;
	zoomLevel = zoomLevel_orig;
	activeTour = true;
    hotspotIndex = -1;
	$.ajax({
		url: "viewer.php",
		type: "POST",
		data: {
			keyword_input: key,
			photo_box: photo_box
		},
		dataType: "html",
		beforeSend: ajaxLoadingViewer,
		success: function(data) {
			ajaxCompletedViewer(data);
		}
	});
}
function ajaxLoadingViewer() {
	/*
	document.getElementById('pm_viewer_holder').innerHTML = "<div id='pm_viewer'></div>";
    var e = document.getElementById('pm_viewer');
    e.innerHTML = '<div style="vertical-align:middle; text-align:center; padding-top:100px;"><img src="images/loading.gif" alt="Loading Viewer"/></div>';
	*/
	document.getElementById('loading_search').style.display = 'block';
}
function ajaxCompletedViewer(data) {
	document.getElementById('loading_search').style.display = 'none';
	var f = document.getElementById('valid_search');
	var string_split = data.split("|||",3);
	f.innerHTML = string_split[0];
	pmParams = string_split[1];
	if(string_split[0] != '<span>No photos found for this search.</span>'){
		viewX = viewX_orig;
		viewY = viewY_orig;
		zoomLevel = zoomLevel_orig;
		activeTour = true;
		hotspotIndex = -1;
		if(hasFlash){
			createViewer();
		}else{
			var hotspotX = new Array();
			var hotspotY = new Array();
			var hotspotZ = new Array();
			var hotspotCount = 0;
			$.ajax({
				type: "GET",
				url: string_split[2],
				dataType: "xml",
				success: function(xml) {
					$(xml).find('HOTSPOT').each(function(){
						hotspotX[hotspotCount] = $(this).attr('X');
						hotspotY[hotspotCount] = $(this).attr('Y');
						hotspotZ[hotspotCount] = ($(this).attr('ZOOM'));
						hotspotCount++;
					});
					if(html5Active){
						Z.Viewport.setView(parseFloat(hotspotX[0]),parseFloat(hotspotY[0]),(parseFloat(hotspotZ[0])/100));
					}else{
						zoomLocation = '&zInitialX='+hotspotX[0]+'&zInitialY='+hotspotY[0]+'&zInitialZoom='+hotspotZ[0];
						embedHTML5();
					}
				}
			});
		}
	}else{
		if(!flashActive && hasFlash){
			createViewer();
		}
	}
}
function updateView() {
    ajaxCompletedUpdateView();
}
function ajaxCompletedUpdateView() {
    setSize();
    createViewer();
}
function removePhotoInfo() {
	if(photo_info_vis == 1){
        $('#photo_info').slideToggle('slow');
        photo_info_vis = 0;
    }
}
function viewerPosition(X,Y,zoom) {
    viewX = X;
    viewY = Y;
    zoomLevel = zoom;
}
function viewerTourState(X,Y,zoom,index,active) {
    viewX = X;
    viewY = Y;
    zoomLevel = zoom;
    hotspotIndex = index;
    activeTour = active;
}
function photoLiked(url_liked){
	$.ajax({
		url: "photo_liked.php",
		type: "POST",
		data: {
			url_liked: url_liked
		},
		dataType: "html"
	});
}
function photoUnliked(url_unliked){
	$.ajax({
		url: "photo_unliked.php",
		type: "POST",
		data: {
			url_unliked: url_unliked
		},
		dataType: "html"
	});
}
function registerUser(){
	$.ajax({
		url: "register.php",
		type: "POST",
		data: {
			fb_id: fb_id,
			perm_status: permStatus
		},
		dataType: "html",
		success: function(data) {
			ajaxUserRegistered(data);
		}
	});
}
function ajaxUserRegistered(data){
	var string_split = data.split("|||",6);
	fb_id = string_split[0];
	fname = string_split[1];
	lname = string_split[2];
	email = string_split[3];
	gender = string_split[4];
	friends = string_split[5];
	if(embed_type != 'search'){
		displayFriends();
		checkHasPhotos();
	}
	if(user_uploading){
		appUpload();
	}
}
function checkHasPhotos(){
	if(source == 'web'){
		var g = document.getElementById('fblogin');
		g.innerHTML = '<div style="text-align:center;"><table style="text-align:center; border-top:#FFF solid 1px; width:209px; margin:14px auto 0 auto;"><tr><td style="text-align:left; width:154px;"><span class="white_11">Welcome '+fname+'</span></td><td style="text-align:right; width:55px;"><a class="white_11_hover" href="#" onclick="fbLogout(); return false;"><img class="click" style="vertical-align:middle;" src="images/fb_logout.png" alt="" /><span class="white_11_hover click" style="vertical-align:-10%;"> Logout</span></a></td></tr></table></div><div id="has_photos" style="text-align:center;"><table style="text-align:center; border-bottom:#FFF solid 1px; width:209px; margin:0 auto;"><tr><td style="width:100%; text-align:center;"><img src="images/like_loader.gif" alt=""/></td></tr></table></div>';
	}
	$.ajax({
		url: "has_photos.php",
		type: "POST",
		data: {
			fb_id: fb_id
		},
		dataType: "html",
		success: function(data) {
			ajaxCompletedCheckHasPhotos(data);
		}
	});
}
function hasPhotos(){
	var g = document.getElementById('fblogin');
	var f = document.getElementById('has_photos');
	if(source != 'fb' ){
		g.innerHTML = '<div style="text-align:center;"><table style="text-align:center; border-top:#FFF solid 1px; width:209px; margin:14px auto 0 auto;"><tr><td style="text-align:left; width:154px;"><span class="white_11">Welcome '+fname+'</span></td><td style="text-align:right; width:55px;"><a class="white_11_hover" href="#" onclick="fbLogout(); return false;"><img class="click" style="vertical-align:middle;" src="images/fb_logout.png" alt="" /><span class="white_11_hover click" style="vertical-align:-10%;"> Logout</span></a></td></tr></table></div>';
		f.innerHTML = '<table style="text-align:center; border-bottom:#FFF solid 1px; width:209px; margin:0 auto;"><tr><td style="width:100%; text-align:center;"><img src="images/like_loader.gif" alt=""/></td></tr></table>';
	}else{
		g.innerHTML = '<table style="text-align:center; border-bottom:#FFF solid 1px; width:209px; margin:0 auto;"><tr><td style="width:100%; text-align:center;"><img src="images/like_loader.gif" alt=""/></td></tr></table>';
	}
	ajaxCompletedCheckHasPhotos(1);
}
function ajaxCompletedCheckHasPhotos(data){
	var f = document.getElementById('has_photos');
	var g = document.getElementById('fblogin');
	if(data){
		if(source != 'fb' ){
			f.innerHTML = '<table style="text-align:center; border-bottom:#FFF solid 1px; width:209px; height:18px; margin:0 auto;"><tr><td style="width:98px; text-align:left;"><a class="white_10_hover click" href="#" onclick="refreshViewerLink('+fb_id+'); return false;">Tour My Photo(s)</a></td><td style="width:111px; text-align:right; vertical-align:middle;"><span class="white_10" style="vertical-align:18%;">Share My Tour:</span><img class="click" onclick="javascript:window.open(\'https://www.facebook.com/sharer.php?u=https://www.meowmosaic.com/stour.php?key='+fb_id+'&t=Tour+photos+of+my+cat+in+the+Meow+Mosaic!\',\'sharer\',\'left=20,top=20,width=626,height=436,toolbar=0,scrollbars=0,statusbar=0,resizable=0\');" style="margin:0 4px 0 4px;" src="images/share/facebook_12.png" /><a href="http://twitter.com/intent/tweet?status=Tour%20photos%20of%20my%20cat%20in%20the%20%23MeowMosaic!%20Support%20a%20great%20cause%20and%20win%20a%20personalized%20photo%20mosaic%20of%20your%20cat.%20http%3A%2F%2Fwww.moewmosaic.com%3Fkey%3D'+fb_id+'" title="Twitter" target="_blank"><img class="click" src="images/share/twitter_12.png" /></a></td></tr></table>';
		} else{
			g.innerHTML = '<table style="text-align:center; border-top:#FFF solid 1px; border-bottom:#FFF solid 1px; width:209px; height:18px; margin:14px auto 0 auto;"><tr><td style="width:98px; text-align:left;"><a class="white_10_hover click" href="#" onclick="refreshViewerLink('+fb_id+'); return false;">Tour My Photo(s)</a></td><td style="width:111px; text-align:right; vertical-align:middle;"><span class="white_10" style="vertical-align:18%;">Share My Tour:</span><img class="click" onclick="javascript:window.open(\'https://www.facebook.com/sharer.php?u=https://www.meowmosaic.com/stour.php?key='+fb_id+'&t=Tour+photos+of+my+cat+in+the+Meow+Mosaic!\',\'sharer\',\'left=20,top=20,width=626,height=436,toolbar=0,scrollbars=0,statusbar=0,resizable=0\');" style="margin:0 4px 0 4px;" src="images/share/facebook_12.png" /><a href="http://twitter.com/intent/tweet?status=Tour%20photos%20of%20my%20cat%20in%20the%20%23MeowMosaic!%20Support%20a%20great%20cause%20and%20win%20a%20personalized%20photo%20mosaic%20of%20your%20cat.%20http%3A%2F%2Fwww.moewmosaic.com%3Fkey%3D'+fb_id+'" title="Twitter" target="_blank"><img class="click" src="images/share/twitter_12.png" /></a></td></tr></table>';
		}
	} else {
		if(source != 'fb' ){
			f.innerHTML = '<table style="text-align:center; border-bottom:#FFF solid 1px; width:209px; height:18px; margin:0 auto;"><tr><td style="width:98px; text-align:left;"><a class="grey_10 click" href="#" onclick="alert(\'You currently have no photos in the mosaic, if you have already uploaded please wait 24-36 hours for you photo to be incorporated into the mosaic.\'); return false;">Tour My Photo(s)</a></td><td style="width:111px; text-align:right; vertical-align:middle;"><a class="grey_10 click" href="#" onclick="alert(\'You currently have no photos in the mosaic, if you have already uploaded please wait 24-36 hours for you photo to be incorporated into the mosaic.\'); return false;"><span style="vertical-align:18%;">Share My Tour:</span></a><img class="click" onclick="alert(\'You currently have no photos in the mosaic, if you have already uploaded please wait 24-36 hours for you photo to be incorporated into the mosaic.\');" style="margin:0 4px 0 4px;" src="images/share/facebook_12grey.png" /><img class="click" onclick="alert(\'You currently have no photos in the mosaic, if you have already uploaded please wait 24-36 hours for you photo to be incorporated into the mosaic.\');" src="images/share/twitter_12grey.png" /></td></tr></table>';
		} else {
			g.innerHTML = '';
		}
	}
	user_visible = true;
	updatePhotoInfo();
}
function fbLoginConnect(){
	var g = document.getElementById('fblogin');
	g.innerHTML = '<div style="margin:18px 0 0 0;"><a href="#" onclick="basicConnect(); return false;"><img class="click" src="images/fb_connect_button.png" alt="" onmouseover="rollOver(this,\'images/fb_connect_button_invert.png\')" onmouseout="rollOver(this,\'images/fb_connect_button.png\')"/></a></div>';
	user_visible = false;
}
function storeFriends(friend_list){
	$.ajax({
		url: "friends_store.php",
		type: "POST",
		data: {
			fb_id: fb_id,
			friends: friend_list
		},
		dataType: "html"
	});
}
function displayFriends(){
	$.ajax({
		url: "friends_display.php",
		type: "POST",
		data: {
			friends: friends,
			fb_id: fb_id
		},
		dataType: "html",
		beforeSend: ajaxLoadingFriends,
		success: function(data) {
			ajaxCompletedFriends(data);
		}
	});
}
function ajaxLoadingFriends() {
    var f = document.getElementById('friends_container');
	f.innerHTML = '<div style="vertical-align:middle; text-align:center;"><img style="text-align:center; margin:2px auto 0 auto;" src="images/like_loader.gif" alt=""/></div>';
}
function ajaxCompletedFriends(data) {
    var f = document.getElementById('friends_container');
	var friend_data = data.split('|||');
	var friend_ids  = friend_data[0].split(',');
	var friend_names  = friend_data[1].split(',');
	var htmlFriends = '';
	if(friend_ids[0] == ''){
		htmlFriends += '';
		htmlFriends += '<div style="padding-top:2px;"><span class="white_11" style="text-align:center;">Currently none of your friends have cats in the Meow Mosaic.</span><a class="white-hover-bold" style="text-align:center;" href="#" onclick="javascript:window.open(\'fbinviting.php\',\'invite\',\'left=20,top=20,width=650,height=520,toolbar=0,scrollbars=0,statusbar=0,resizable=0\'); return false;"> Click here to invite your friends!</a></div>';
		f.innerHTML = htmlFriends;
	}else if(friend_ids.length > 0 && friend_ids.length < 3){
		htmlFriends += '<div style="padding-top:2px;"><a class="white-hover" style="margin-right:25px; margin-left:25px;" href="#" onclick="refreshViewerLink('+friend_ids[0]+'); return false;">'+friend_names[0]+'</a>';
		if(friend_ids.length > 1){
			htmlFriends += '<a class="white-hover" style="margin-right:25px;" href="#" onclick="refreshViewerLink('+friend_ids[1]+'); return false;">'+friend_names[1]+'</a>';
		}
		htmlFriends += '<a class="white-hover-bold" style="margin-right:25px;" href="#" onclick="javascript:window.open(\'fbinviting.php\',\'invite\',\'left=20,top=20,width=650,height=520,toolbar=0,scrollbars=0,statusbar=0,resizable=0\'); return false;">Click here to invite more friends!</a></div>';
		f.innerHTML = htmlFriends;
	}else{
		var friendCounter = 0;
		htmlFriends = '<ul id="friend_display" class="jcarousel-skin-meow-key">';
		for(i=0;i<friend_ids.length;i++){
			if( i==(friend_ids.length-1) && friend_ids.length < 6 ){
				htmlFriends += '<li><a class="white-hover" href="#" onclick="refreshViewerLink('+friend_ids[i]+'); return false;">'+friend_names[i]+'</a></li>';
				friendCounter++;
				htmlFriends += '<li><a class="white-hover-bold" href="#" onclick="javascript:window.open(\'fbinviting.php\',\'invite\',\'left=20,top=20,width=650,height=520,toolbar=0,scrollbars=0,statusbar=0,resizable=0\'); return false;">Click here to invite more friends!</a></li>';
				friendCounter++;
				while(friendCounter < 6){
					for(j=0;j<friend_ids.length;j++){
						htmlFriends += '<li><a class="white-hover" href="#" onclick="refreshViewerLink('+friend_ids[j]+'); return false;">'+friend_names[j]+'</a></li>';
						friendCounter++;
					}
				}
			}else{
				htmlFriends += '<li><a class="white-hover" href="#" onclick="refreshViewerLink('+friend_ids[i]+'); return false;">'+friend_names[i]+'</a></li>';
				friendCounter++;
			}
		}
		htmlFriends += '</ul>';
    	f.innerHTML = htmlFriends;
		jQuery(document).ready(function() {
			jQuery('#friend_display').jcarousel({
				wrap: 'circular',
				size: friendCounter,
				scroll: 1
			});
		});
		$('div.jcarousel-container-horizontal').css('width', (pmvWidth - 165)+'px');
		$('div.jcarousel-clip-horizontal').css('width', (pmvWidth - 165)+'px');
		friends_visible = true;
	}
}
function displayLikedCats(){
	$.ajax({
		url: "display_top_liked_cats.php",
		type: "POST",
		dataType: "html",
		beforeSend: ajaxLoadingLikedCats,
		success: function(data) {
			ajaxCompletedLikedCats(data);
		}
	});
}
function ajaxLoadingLikedCats() {
    var f = document.getElementById('cat_likes_container');
	f.innerHTML = '<div style="vertical-align:middle; text-align:center;"><img style="text-align:center; margin:19px auto 0 auto;" src="images/like_loader.gif" alt=""/></div>';
}
function ajaxCompletedLikedCats(data) {
    var f = document.getElementById('cat_likes_container');
	var cat_data = data.split('|||');
	var cat_codes  = cat_data[0].split(',');
	var cat_likes  = cat_data[1].split(',');
	var htmlCats = '';
	var catCounter = 0;
	htmlCats = '<ul id="cat_display" class="jcarousel-skin-meow-recent">';
	htmlCats += '<li><span></span></li>';
	htmlCats += '<li><div style="position:relative; width:60px; height:46px"><img class="winner-cat" onclick="refreshViewerLink(\'jet1\'); return false;" src="upload_flat_complete/thumbnail2/jet1.jpg" alt=""/><div class="click" style="background-color:#FFF; position:absolute; width:56px; height:11px; top:33px; left:2px; text-align:center;" onclick="refreshViewerLink(\'jet1\'); return false;"><span style="line-height:1.35em;" class="black_9">Jan. Winner</span></div></div></li>';
	for(i=0;i<cat_codes.length;i++){
		htmlCats += '<li><div style="position:relative; width:60px; height:46px"><img class="recent-cats" onclick="refreshViewerLink(\''+cat_codes[i]+'\'); return false;" src="upload_flat_complete/thumbnail2/'+cat_codes[i]+'.jpg" alt=""/><div class="click" style="background-color:#FFF; position:absolute; width:16px; height:11px; top:33px; left:42px; text-align:center;" onclick="refreshViewerLink(\''+cat_codes[i]+'\'); return false;"><span style="line-height:1.35em;" class="black_9">'+cat_likes[i]+'</span></div></div></li>';
		catCounter++;
	}
	htmlCats += '</ul>';
	f.innerHTML = htmlCats;
	jQuery(document).ready(function(){
		jQuery('#cat_display').jcarousel({
			wrap: 'circular',
			size: catCounter+2,
			scroll: 1
		});
	});
	$('div.jcarousel-container-horizontal').css('width', (pmvWidth - 165)+'px');
	$('div.jcarousel-clip-horizontal').css('width', (pmvWidth - 165)+'px');
	friends_visible = true;
}
function displayPopularKeywords() {
    var f = document.getElementById('popular_keyword_container');
	var popWords = pop_keywords.split(',');
	var htmlPop = '';
	var keyCounter = 0;
	htmlPop += '<ul style="overflow:hidden;" id="keyword_display" class="jcarousel-skin-meow-key">';
	for(i=0;i<popWords.length;i++){
		htmlPop += '<li style="display:inline-block;"><a class="white-hover" href="#" onclick="refreshViewerLink(\''+popWords[i]+'\'); return false;">'+popWords[i]+'</a></li>';
		keyCounter++;
	}
	for(i=0;i<popWords.length;i++){
		htmlPop += '<li style="display:inline-block;"><a class="white-hover" href="#" onclick="refreshViewerLink(\''+popWords[i]+'\'); return false;">'+popWords[i]+'</a></li>';
		keyCounter++;
	}
	htmlPop += '</ul>';
    f.innerHTML = htmlPop;
	jQuery(document).ready(function() {
		jQuery('#keyword_display').jcarousel({
			wrap: 'circular',
			size: keyCounter,
			scroll: 1
		});
	});
	$('div.jcarousel-container-horizontal').css('width', (pmvWidth - 165)+'px');
	$('div.jcarousel-clip-horizontal').css('width', (pmvWidth - 165)+'px');
}
function displayChatter(){
	$.ajax({
		url: "chatter_feed.php",
		type: "POST",
		dataType: "html",
		beforeSend: ajaxLoadingChatter,
		success: function(data) {
			ajaxCompletedChatter(data);
		}
	});
}
function ajaxLoadingChatter() {
    var f = document.getElementById('chatter_content');
	f.innerHTML = '<div style="text-align:center;"><img style="text-align:center; margin:19px auto 0 auto;" src="images/like_loader.gif" alt=""/></div>';
}
function ajaxCompletedChatter(data) {
    var f = document.getElementById('chatter_content');
    f.innerHTML = data;
	$('#chatter_content').vTicker({
		speed: 600,
		pause: 4400,
		showItems: 1,
		animation: 'fade',
		mousePause: false,
		height: 0,
		direction: 'up'
	});
}
function fullPermsGranted(){
	$.ajax({
		url: "full_perms.php",
		type: "POST",
		data: {
			fb_id: fb_id
		},
		dataType: "html"
	});
}
function appApproved(uid) {
	fb_id = uid;
	user_uploading = 0;
	permStatus = 0;
	registerUser();
}
function appApprovedUpload(uid) {
	fb_id = uid;
	user_uploading = 1;
	permStatus = 1;
	registerUser();
}
function appUpload() {
	if(embed_type != 'search'){
		$(document).ready(function () {
        	$.fancybox({
				'width': 474,
				'height': 735,
				'autoScale': false,
				'autoDimensions': true,
				'hideOnOverlayClick': false,
            	'transitionIn': 'fade',
            	'transitionOut': 'fade',
            	'type': 'iframe',
				'href': 'upload.php'
			});
		});
	}else{
		window.open('https://www.meowmosaic.com/upload.php','upload','left=40,top=40,width=474,height=735,toolbar=0,scrollbars=1,statusbar=0,resizable=1');
	}
}
function generateExpandContent(){
	if(expand_count){
		document.getElementById('expand_more').innerHTML = '<img style="margin:10px 10px 0 15px;" src="images/like_loader.gif" alt=""/>';
	}
	$.ajax({
		url: "expand_content.php",
		type: "POST",
		data: {
			start: expand_count,
			total_comments: total_comments
		},
		dataType: "html",
		success: function(data) {
			ajaxCompletedExpandContent(data);
		}
	});
}
function ajaxCompletedExpandContent(data) {
    var f = document.getElementById('expand_content');
	var string_split = data.split('|||');
	total_comments = string_split[1];
	if(!expand_once){
		expand_once++;
		expand_count = expand_count + 20;
    	f.innerHTML = string_split[0];
	}else{
		expand_count = expand_count + 20;
		if(total_comments > expand_count){
			document.getElementById('expand_more').innerHTML = '<a class="white_10_hover" href="#" onclick="generateExpandContent(); return false;">Show more</a>';
		}else{
			document.getElementById('expand_more').style.margin = '0 0 0 0';
			document.getElementById('expand_more').style.height = '0px';
			document.getElementById('expand_more').innerHTML = '';
		}
		f.innerHTML += string_split[0];
		$(function(){
			$('#scroll-pane').jScrollPane({showArrows: true, horizontalGutter: 10});
		});
	}
}
