function emailing(emailurl)
{
	jQuery.ajax({
	url : emailurl,
	success : function (data) {
	jQuery("#contentArea").html(data+'<input type="button" value=" x " id="no">');
	/*jQuery.blockUI.defaults.css.border = '1px solid black'; 
	 jQuery.blockUI.defaults.css.width="410px";
	 jQuery.blockUI.defaults.css.top="20px";
	 jQuery.blockUI.defaults.css.cursor='default';
	jQuery.blockUI({ message:  '<span style="padding-left:380px;"><input type="button" value=" x " id="no"></span>'+data });*/
	jQuery('#no').click(function() {jQuery("#contentArea").hide('slow');}); 
	}
	});
}
function cheerToon(val,author)
{

var user="";
var imgPath="";
var action_data="toonId="+val;
if (userName=="")
{
	jQuery.blockUI({css: { backgroundColor: '#d88f8f', border:'1px solid #000' }, message: "<span class='bigred'><br><br>Please Login to cheer!<br><br></span>"});
	setTimeout(jQuery.unblockUI, 1000);
}
else if(author==userName)
{
	jQuery.blockUI({css: { backgroundColor: '#fff', border:'1px solid #000' }, message: "<span class='bigblue'><br><br>You can't cheer your ToonDoo!<br><br></span>"});
	setTimeout(jQuery.unblockUI, 1000);
}
else
{
	jQuery.blockUI({css: { backgroundColor: '#fff', border:'1px solid #000'}, message: "<span class='bigblue'><br><br>Processing...<br><img src='../images/processing.gif'><br><br></span>"});
	jQuery.ajax({ 
		type: "POST",
		url: 'addCheers.toon', 
		cache: false, 
		data: action_data,
		success: function()
		{
			var cheers=parseInt(jQuery("#cheercount").text())+1;	
			setTimeout("jQuery('#cheercount').text("+cheers+");",3000);
		},
		complete: function() { 			
			// unblock when remote call returns 			
			jQuery.blockUI({css: { backgroundColor: '#fff', border:'1px solid #000'}, message: "<span class='bigblue'><br><br>Thanks for cheering this one up!<br> Time to feel good!<br><br><br></span>"});	
			setTimeout(jQuery.unblockUI, 1000); 
		}
	 }); 	
} 

}
function favToon(val,author)
{
var action_data="toonId="+val;
var div="favorites";
/*jQuery('#message').show('slow');
jQuery("#message").html("<b>Processing...</b><br><img src='images/processing.gif'>");	
if(userName=="guest")
{
	jQuery('#message').show('slow');
	jQuery("#message").html("<b>Please login to add it to your favorites!</b>");	
	setTimeout("jQuery('#message').hide('slow');",3000);
}
else if(author==userName)
{
	jQuery('#message').show('slow');
	jQuery("#message").html("<b>You can't add your toon to your favorites</b>");	
	setTimeout("jQuery('#message').hide('slow');",3000);

}
else
{
	jQuery.ajax
	(
		{
			type: "POST",
			url: "/addFavorites.toon",
			data: action_data,
			success: function(msg)
			{		
				var favs=parseInt(jQuery("#favcount").text())+1;	
				setTimeout("jQuery('#favcount').text("+favs+");",3000);
				jQuery('#message').show('slow');
				jQuery("#message").html("<b>We have added this ToonDoo to your favourites!</b>");	
				setTimeout("jQuery('#message').hide('slow');",3000);
			}
			
		}
	);
}
*/
if (userName=="")
{
	jQuery.blockUI({css: { backgroundColor: '#d88f8f', border:'1px solid #000' }, message: "<span class='bigred'><br><br>Please login to add it to your favorites!<br><br></span>"});
	setTimeout(jQuery.unblockUI, 2000);
}
else if(author==userName)
{
	jQuery.blockUI({css: { backgroundColor: '#fff', border:'1px solid #000' }, message: "<span class='bigblue'><br><br>You can't add your toon to your favorites!<br><br></span>"});
	setTimeout(jQuery.unblockUI, 2000);
}
else
{
	jQuery.blockUI({css: { backgroundColor: '#fff', border:'1px solid #000' }, message: "<span class='bigblue'><br><br>Processing...<br><img src='../images/processing.gif'><br><br></span>"});
	jQuery.ajax({ 
	type: "POST",
	url: 'addFavorites.toon', 
	cache: false, 
	data: action_data,
	success: function()
	{
		var favs=parseInt(jQuery("#favcount").text())+1;	
		setTimeout("jQuery('#favcount').text("+favs+");",3000);
	},
	complete: function() { 
		// unblock when remote call returns 
		jQuery.blockUI({css: { backgroundColor: '#fff', border:'1px solid #000' }, message: "<span class='bigblue'><br><br>We have added this ToonDoo to your favourites!<br><br><br></span>"});	
		setTimeout(jQuery.unblockUI, 2000); 
	}
 });
}
 
}
function flagInapp(val,imgPath,author)
{
var user="";
var action_data="toonId="+val+"&user="+user+"&imgPath="+imgPath;
if (userName=="")
{
	jQuery.blockUI({css: { backgroundColor: '#d88f8f', border:'1px solid #000' }, message: "<span class='bigred'><br><br>Please login to flag it as mature!<br><br></span>"});
	setTimeout(jQuery.unblockUI, 2000);
}
else if(author==userName)
{
	jQuery.blockUI({css: { backgroundColor: '#fff', border:'1px solid #000' }, message: "<span class='bigblue'><br><br>You can't flag your ToonDoo as mature!<br><br></span>"});
	setTimeout(jQuery.unblockUI, 2000);
}
else
{
	jQuery.blockUI({css: { backgroundColor: '#fff', border:'1px solid #000' }, message: "<span class='bigblue'><br><br>Processing...<br><img src='../images/processing.gif'><br><br></span>"});
	jQuery.ajax({ 
		type: "POST",
		url: 'flagInapp.toon', 
		cache: false, 
		data: action_data,
		complete: function() { 
			// unblock when remote call returns 
			jQuery.blockUI({css: { backgroundColor: '#fff', border:'1px solid #000' }, message: "<span class='bigblue'><br><br>Thanks! The editors at ToonDoo have been alerted about this!<br><br><br></span>"});	
			setTimeout(jQuery.unblockUI, 2000); 
		}
	 });
}
}

function redooToon(val,author)
{
	var user="";
	if(userName=="guest")
	{
		jQuery('#message').show('slow');
		jQuery("#message").html("<b>Please login to Redoo this ToonDoo!</b>");	
		setTimeout("jQuery('#message').hide('slow');",3000);
	}
	else if(userName==author)
	{
		jQuery('#message').show('slow');
		jQuery("#message").html("<b>You can't ReDoo your own ToonDoo!</b>");	
		setTimeout("jQuery('#message').hide('slow');",3000);
	}
	else
	{
		jQuery('#message').hide('slow');
	}
}
function addComment(form)
{
  var toonId = form.toonId.value;
  var toonAuthor = form.toonAuthor.value;
  var toonStatus = form.toonStatus.value;
  var commentText = form.commentsText.value;
  res='';
  if(commentText.length <1){
	commentText = 'Default - Comment';
	}
	else
	{
		commentText = commentText.split("\n");		
		for(var i = 0; i < commentText.length; i++)
		{
			res += commentText[i]+'\\n';
		}
		commentText = res;
	}
	document.getElementById("comment").disabled=true;							
	document.getElementById("comment").value="Sending...";
	jQuery.post("addComment.toon",{'toonId':toonId,'commentText':commentText,'toonAuthor':toonAuthor, 'toonStatus':toonStatus},function(msg)
	{
		
		document.getElementById("comment").disabled=false;		
		document.getElementById("comment").value="Submit";
		form.commentsText.value="";
		document.getElementById("showyourcomment").innerHTML += msg;
		
	});		
}
/** add book comment **/
function addBookComment(form)
{
  var toonId = form.bookId.value;
  var commentText = form.commentsText.value;  
  var bookAuthor = form.bookAuthor.value;
  res='';
  if(commentText.length <1){
	commentText = 'Default - Comment';
	}
	else
	{
		commentText = commentText.split("\n");		
		for(var i = 0; i < commentText.length; i++)
		{
			res += commentText[i]+'\\n';
		}
		commentText = res;
	}
	document.getElementById("comment").disabled=true;							
	document.getElementById("comment").value="Sending...";
	jQuery.post("addBookComment.toon",{'bookId':toonId,'commentText':commentText, 'bookAuthor':bookAuthor},function(msg)
	{
		document.getElementById("comment").disabled=false;		
		document.getElementById("comment").value="Submit";
		form.commentsText.value="";
		document.getElementById("showyourcomment").innerHTML += msg;
	});		
}
/** ends here **/

function deleteComment()
{
	var delCom = document.getElementById('delcommentid').value;
	
	//jQuery.blockUI({css: { backgroundColor: '#fff', border:'1px solid #000' }, message: "<span class='bigblue'><br><br>Are you sure you want to delete this comment?<br><br><input type='button' name='areyes' id='areyes' value=' Yes ' onClick='jQuery.unblockUI();delComment();'> &nbsp; <input type='button' name='no' id='no' value=' No ' onClick=jQuery.unblockUI();><br><br></span>"});
	//showPopUp("<span class='bigblue'><br><br><b>Are you sure you want to delete this comment?<br><br><input type='button' name='areyes' id='areyes' value=' Yes ' onClick='closePopUp();delComment();'> &nbsp; <input type='button' name='no' id='no' value=' No ' onClick='closePopUp();'></b><br><br></span>","default");
	jQuery("#popupmgs").html("<span class='bigblue'><br><br><b>Are you sure you want to delete this comment?<br><br><input type='button' name='areyes' id='areyes' value=' Yes ' onClick='closeBubble();delComment();'> &nbsp; <input type='button' name='no' id='no' value=' No ' onClick='closeBubble();'></b><br><br></span>");
	//jQuery("#popupmgs").html('<form onsubmit="return ToondooScript.ajaxLogin(document.ajaxloginform)" target="temp" method="post" name="ajaxloginform">  <table width="255" cellspacing="0" cellpadding="5" border="0" align="center" id="ajaxlogin">    <tbody><tr>      <td width="99"></td>      <td width="2"></td>      <td width="124"></td>    </tr>    <tr>    <td height="10" class="logintxtStyle" colspan="3"></td>    </tr>	<tr>	<td class="logintxtStyle" colspan="3">		<div align="center" style="display: none;" class="errortext" id="invalid">Invalid Login </div>	</td>    </tr>	<tr>      <td class="logintxtStyle">Username</td>      <td></td>      <td><input type="text" onkeyup="alphaNumericOnly(document.ajaxloginform.j_username)" maxlength="15" class="submenu" name="j_username"></td>    </tr>    <tr>      <td class="logintxtStyle">Password</td>      <td></td>      <td><input type="password" maxlength="15" class="submenu" name="j_password">      </td>    </tr>    <tr>      <td></td>      <td></td>      <td align="right"><input type="submit" value="Sign In" class="submenu" id="signin" name="btn"></td>    </tr>	 <input type="hidden" value="http://testbed.localtoondoo.com/cartoon/33305" name="redirect">	 <!--<tr>      <td colspan="3">	  <div align="center"></div>              <div align="center"><a href="javascript:ajaxSignup();" onclick="ajaxRegFocus();" class="bluetext">New to ToonDoo?</a></div>	  <div align="center"></div>	  </td>      </tr>-->	   </tbody></table></form>');
	showBubble();
}	
function loadVcfcr(toonId,toonAuthor,dirString)
{
	var userLength=toonAuthor.length;
	var lcaseuname = toonAuthor.toLowerCase();
	var imgPath="";
	if(userLength > 2)
	{
		imgPath = "public/"+lcaseuname.substring(0,1)+"/"+lcaseuname.substring(1,2)+"/"+lcaseuname.substring(2,3)+"/"+toonAuthor+"/toons/cool-cartoon-"+toonId+".png";
	}
	
	
	var dirPath = "http://www.toondoo.com/webincludes/"+dirString+"/toondata-"+toonId+".inc";

	var imagePath = 
	/*jQuery.post(dirPath,{'toonId':toonId},function(msg)
	{
		var result=msg;
		result=result.replace(/&vcfcr=/,"");
		vcfcrArray=result.split(",") ;
		document.getElementById('viewcount').innerHTML=vcfcrArray[1];
		document.getElementById('cheercount').innerHTML=vcfcrArray[2];
		document.getElementById('favcount').innerHTML=vcfcrArray[3];
		document.getElementById('commentscount').innerHTML=vcfcrArray[4];
		//document.getElementById('redoocount').innerHTML=vcfcrArray[5];
		jQuery("#bgcheering").click(function() {cheerToon(toonId,toonAuthor);});
		jQuery("#favorites").click(function() {favToon(toonId,toonAuthor);});
		jQuery("#flagToon").click(function() {flagInapp(toonId,imagePath,toonAuthor);});
		jQuery("#print").click(function() {fullScreenMode('printToon.jsp?toonlink='+imgPath,2); return false;});			
	});
	*/
	
	jQuery.ajax({
	url: dirPath,
	data: { 'toonId':toonId},
	type: "POST",
	//beforeSend: function(){disableSubmitButton();},
	//complete: function(){enableSubmitButton();},
	error: function(xhr, statusText, errorThrown){
			// Work out what the error was and display the appropriate message
			//alert("xhr "+xhr.status);
			//if(xhr.status == 400)
			//{
				//alert("inside");
				//document.getElementById('viewcount').innerHTML=0;
				//document.getElementById('cheercount').innerHTML=0;
				//document.getElementById('favcount').innerHTML=0;
				//document.getElementById('commentscount').innerHTML=0;
			//}
		},
	    success: function(msg){
			//displayUserCreatedMessage();
			//refreshUserList();
		var result=msg;
		result=result.replace(/&vcfcr=/,"");
		vcfcrArray=result.split("±") ;
		document.getElementById('viewcount').innerHTML=vcfcrArray[1];
		document.getElementById('cheercount').innerHTML=vcfcrArray[2];
		document.getElementById('favcount').innerHTML=vcfcrArray[3];
		document.getElementById('commentscount').innerHTML=vcfcrArray[4];
		//document.getElementById('redoocount').innerHTML=vcfcrArray[5];		
		},
		complete: function() {
			//alert("inside complete");
			jQuery("#bgcheering").click(function() {cheerToon(toonId,toonAuthor);});
			jQuery("#favorites").click(function() {favToon(toonId,toonAuthor);});
			jQuery("#flagToon").click(function() {flagInapp(toonId,imagePath,toonAuthor);});
			jQuery("#print").click(function() {fullScreenMode('printToon.jsp?toonlink='+imgPath,2); return false;});	
		}
	});
}
/*
function highResMsg(status,toonAuthor,toonTitle)//for toondoo shop
{
	//alert(status);
	
	if(status=="signin")
	{
		jQuery.blockUI({css: { backgroundColor: '#fff', border:'1px solid #000',cursor: 'default' }, message: "<span><div class='highres1'><img style='float:left;' src='../images/shopicon.png'/><div style='float:left;'>Oops!</div><span style='float:right;'><img src='../images/close.png' onclick='jQuery.unblockUI();'/></span></div><br><br><div class='highres2'>Please login to download this Toon!<br><br></div></span>"});
	}	
	else if(status==0)
	{		
		jQuery.blockUI({css: { backgroundColor: '#fff', border:'1px solid #000',cursor: 'default' }, message: "<span><div class='highres1'><img style='float:left;' src='../images/shopicon.png'/><div style='float:left;'>You need Tookens!</div><span style='float:right;'><img src='../images/close.png' onclick='jQuery.unblockUI();'/></span></div><br><br><div class='highres2'>Want to download high-resolution Toons? <br><br>Start by visiting the ToonDooshop and purchasing some Tookens <a href='http://www.toondoo.com/shop/about.jsp'>here!</a><br><br></div></span>"});
	}
	else if(status>0)
	{
		jQuery.blockUI({css: { backgroundColor: '#fff', border:'1px solid #000',cursor: 'default' }, message: "<span><div class='highres1'><img style='float:left;' src='../images/shopicon.png'/><div style='float:left;'>Oops!</div><span style='float:right;'><img src='../images/close.png' onclick='jQuery.unblockUI();'/></span></div><br><br><div class='highres2'>Sorry, you do not have sufficient balance to download a higher resolution version of this Toon. <br><br>Please purchase more Tookens <a href='http://www.toondoo.com/PurchaseHighRes.do'>here!</a><br><br></div></span>"});
	}
	else if(status=="purchase_allow")
	{
		jQuery.blockUI({css: { backgroundColor: '#fff', border:'1px solid #000',cursor: 'default' }, message: "<span><div class='highres1'><img style='float:left;' src='../images/shopicon.png'/><div style='float:left;'>Oops!</div><span style='float:right;'><img src='../images/close.png' onclick='jQuery.unblockUI();'/></span></div><br><br><div class='highres2'>Sorry, the author of this Toon has not allowed purchase of high-resolution images. <br><br>We are sending them an email for permission and will get back to you once we receive their go-ahead.!<br><br></div></span>"});
	}
	else if(status=="success")
	{
		jQuery.blockUI({css: { backgroundColor: '#fff', border:'1px solid #000',cursor: 'default' }, message: "<span><div class='highres1'><img style='float:left;' src='../images/shopicon.png'/><div style='float:left;'>Success!</div><span style='float:right;'><img src='../images/close.png' onclick='jQuery.unblockUI();'/></span></div><br><br><div class='highres2'>Thanks for ordering a high-resolution version of <b>"+toonTitle+"</b> by <b>"+toonAuthor+"</b>. <br><br>The high-resolution image will be available for download in your Bubble Bauble as soon as it is ready.!<br><br></div></span>"});
	}
	else
	{
		jQuery.blockUI({css: { backgroundColor: '#fff', border:'1px solid #000',cursor: 'default' }, message: "<span><div class='highres1'><img style='float:left;' src='../images/shopicon.png'/><div style='float:left;'>Oops!</div><span style='float:right;'><img src='../images/close.png' onclick='jQuery.unblockUI();'/></span></div><br><br><div class='highres2'>Sorry, Your session has been Expired! Please re-login and try again.<br><br></div></span>"});
	}
} */

function vcfcr() {}
