
function IAM_ajaxShowMore(postid, throbberurl, morepageurl, apea_fx, DEF_DUR, ter, permal) {
	try{		Element.hide('show-inline-more-' + postid);
		$('inline-more-notification-' + postid).innerHTML = throbberurl;
	
		if ($('inline-more-' + postid).innerHTML.length > 1)
			IAM_ajaxDisplayWhenLoaded(postid, apea_fx, DEF_DUR);
		else {
				ajaxedMore = 
					new Ajax.Updater(
						'inline-more-' + postid,
						morepageurl,
						{
							method: 'post',
							postBody: 'id=' + postid + '&ter=' + ter,
							onComplete: IAM_ajaxWaitForHide(postid, apea_fx, DEF_DUR, permal)
						}
					);
		}

	}catch(err){			//let the browser handle the click
			document.location.href = permal;
			return true;  	}
	//signal browser to not follow link
	return false;
}

function IAM_ajaxWaitForHide(postid, apea_fx, DEF_DUR, permal) {
		Element.hide('inline-more-' + postid);
		setTimeout("IAM_ajaxDisplayWhenLoaded(" + postid + ",'" + apea_fx + "'," + DEF_DUR + ",'"+permal+"')", 600);
}

function IAM_ajaxHideMore(postid, fade_fx, DEF_DUR) {
	more = ('inline-more-' + (postid));
	try{
		switch(fade_fx){
			case 'BlindUp':
				new Effect.BlindUp(more,{duration: DEF_DUR});
				break;
			case 'SlideUp':
				new Effect.SlideUp(more,{duration: DEF_DUR});
				break;
			case 'Squish':
				new Effect.Squish(more,{duration: DEF_DUR});
				break;
			case 'Fold':
				new Effect.Fold(more,{duration: DEF_DUR});
				break;
			case 'Shrink':
				new Effect.Shrink(more,{duration: DEF_DUR});
				break;
			case 'DropOut':
				new Effect.DropOut(more,{duration: DEF_DUR});
				break;
			case 'Puff':
				new Effect.Puff(more,{duration: DEF_DUR});
				break;
			case 'SwitchOff':
				new Effect.SwitchOff(more,{duration: DEF_DUR});
				break;
			case 'Fade':
			default:
				new Effect.Fade(more,{duration: DEF_DUR});
				break;
		}
		$(more).blur();
	
		setTimeout("Element.show('show-inline-more-" + postid + "')", (DEF_DUR*1000+100));
		Element.hide("hide-1-inline-more-" + postid);
		Element.hide("hide-2-inline-more-" + postid);

	}catch(err){	  		txt="There was the following javascript error trying to hide the post: '"+ err.description +"'\n";			txt+="Click OK to continue.\n\n";			alert(txt);
  	}
}

function IAM_ajaxDisplayWhenLoaded(postid, apea_fx, DEF_DUR, permal) {
	try{
		more = ('inline-more-' + (postid));
		if ($(more).innerHTML.length < 100)
			setTimeout("IAM_ajaxDisplayWhenLoaded(" + postid + ",'" + apea_fx + "',"+DEF_DUR + ",'"+permal+"')", 100);

		else{
		
			switch(apea_fx){
				case 'Shake':
					Element.show(more);
					new Effect.Shake(more,{duration: DEF_DUR})
					break;
				case 'Pulsate':
					Element.show(more);
					new Effect.Pulsate(more,{duration: DEF_DUR});
					break;
				case 'Highlight':
					Element.show(more);
					new Effect.Highlight(more,{duration: DEF_DUR});
					break;
				case 'BlindDown':
					new Effect.BlindDown(more,{duration: DEF_DUR});
					break;
				case 'SlideDown':
					new Effect.SlideDown(more,{duration: DEF_DUR});
					break;
				case 'Grow':
					new Effect.Grow(more,{duration: DEF_DUR});
					break;
				case 'Appear':
				default:
					new Effect.Appear(more,{duration: DEF_DUR});
					break;
			}
			
			$(more).blur();
			
			$('inline-more-notification-' + postid).innerHTML = '';
			setTimeout("Element.show('hide-1-inline-more-" + postid + "')", (DEF_DUR*1000+100));
			setTimeout("Element.show('hide-2-inline-more-" + postid + "')", (DEF_DUR*1000+100));
		}
	}catch(err){	  		txt="There was the following javascript error trying to display the post: '"+ err +"'\n";			txt+="Click OK to be forwarded to single post page.\n";			if (confirm(txt))
				document.location.href = permal;
  	}		
}