/**********************************************************
Open a new window with static text drawn from the db.

Pass the key value from the db.
**********************************************************/
function static_popup(blurb) {
	blurb = window.open("/index.php?_action=static_popup&blurb=" + blurb,"blurb_win","width=408,height=500,scrollbars=yes");
}

function flag_popup(type, id) {
	blurb = window.open("/index.php?_action=flag_content&type=" + type + "&id=" + id, "flag_win", "width=400,height=200,scrollbars=no");
}
function doChangeType(myForm, myName, myURL) {
	myForm.action = myURL;
	myForm.submit();
}
/*****************************************************************************/
/* Change Begins							     */
/* Added by Infosys on 29-Sep-08					     */
/* For Instant Tag Update Functionality					     */
/*****************************************************************************/

var tag="";
var span_id=""
function tagupdate(id,span) {    
	var photoid= id;
	tag = escape(document.getElementById('text_'+photoid).value);
	span_id= span;
	receiveReq.open("GET", '/populate.php?_action=tagupdate&tag='+tag+'&photoid='+id, true);
	receiveReq.onreadystatechange = tagupdate2; 
	receiveReq.send(null);						
}
function tagupdate2() {
	if (receiveReq.readyState == 4) {
		var re = receiveReq.responseText;
		if (re == '1') {			
            span_id.innerHTML="<a href=\"blog/photo/browse/keywordSearch/"+tag+"\">"+unescape(tag)+"</a>";           
			
		}
		else {
			alert('Tag update Failed');			
		}
	}
		
}
/*****************************************************************************/
/* Change Ends								     */
/*****************************************************************************/
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}

function checkCode(accStatus) {
	if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
		accStatus = (typeof accStatus == 'undefined') ? 0 : accStatus;
		if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
			/******************************************************/
			/* Modified by Infosys on 13-June-08 		      */
			/* Change Begins				      */
			/* to enhance captcha code validation method          */
			/* Modified on 19-Mar-09 for User verification	      */
			/******************************************************/
			if (accStatus==1){
				var code=0;
			}
			else{				
				var code = escape(document.getElementById('code').value);
			}
			receiveReq.open("GET", '/populate.php?_action=checkCode&code='+code+'&acc='+accStatus, true);
			/******************************************************/
			/* Change Ends 							              */
			/******************************************************/
			receiveReq.onreadystatechange = checkCode2; 
			receiveReq.send(null);
		}				
	}
}
function checkCode2() {
	if (receiveReq.readyState == 4) {
		var re = receiveReq.responseText;
		if (re == 1) {
		/******************************************************/
		/* Modified by Infosys on 13-June-08 		      */
		/* Change Begins				      */
		/* to enhance captcha code validation method          */
		/* Modified on 19-Mar-09 for User verification	      */
		/******************************************************/
		
var code = escape(document.getElementById('code').value);
			document.getElementById('code').value = code;
			document.form2.submit();
		} 
		else if(re == 2){

			document.form2.submit();
		}
		else {
			alert('Wrong verification code!');			
		}
		/******************************************************/
		/* Change Ends 				              */
		/******************************************************/
	}
}

function checkSearch() {
	var searchField = document.form1.keywordSearch.value;
	if (searchField.length < 3)
	{
		alert("Please enter at least 3 characters");
		return false;
	}
	return true;
}

function emailFriend(){	
	var subobj = document.getElementById('email');
	subobj.style.display=(subobj.style.display!="block")? "block" : "none";	
}

/******************************************************/
/* Modified by Infosys on 22-Apr-09 		      */
/* Change Begins				      */
/* For Explicit content Warning      		      */
/******************************************************/
function explicitConfirm(){
	var subobj = document.getElementById('explicitconfirm');
	subobj.style.display=(subobj.style.display!="block")? "block" : "none";
}
function divExplicitClose(){
	document.getElementById('explicitconfirm').style.display="none";
}
function getExplicitChoice(userid,item){
 
 if(item == 'blog')
 	{
		for(var i=0; i < document.profileFormBlock1.explicitradio.length; i++)
		  {
		   if(document.profileFormBlock1.explicitradio[i].checked)
		      {
		      var rad_val = document.profileFormBlock1.explicitradio[i].value;
		      }
		  }
	}
else
	{
		for(var i=0; i < document.profileFormBlock.explicitradio.length; i++)
			  {
			   if(document.profileFormBlock.explicitradio[i].checked)
			      {
			      var rad_val = document.profileFormBlock.explicitradio[i].value;
			      }
		  }
	}
	  
var url = '/populate.php?_action=explicitsettings&choice='+rad_val+'&uid='+userid;

receiveReq.open("GET", url, true);
receiveReq.send(null);

   if(item != 'profile')
   {
	if (rad_val == 1)
	{
		if (item == 'blog')
		{document.location.href ='/index.php?_action=blog_list';}
		else if(item == 'survey')
		{document.location.href ='/index.php?_action=survey_list';}
		else if(item == 'poll')
		{document.location.href ='/index.php?_action=poll_list';}
	}
	else
	{
		divExplicitClose();
		document.getElementById('item').style.display='';
		//document.getElementById('ask').style.display='none';
	}
   }

}

/******************************************************/
/* Change Ends 					      */
/******************************************************/

/******************************************************/
/* Modified by Infosys on 23-Mar-09 		      */
/* Change Begins				      */
/* For Unflagging items          		      */
/******************************************************/
function unFlag(Type,itemId){	
	var itemType = escape(Type);
	var url = '/populate.php?_action=unflagitem&id='+itemId+'&type='+itemType;
	receiveReq.open("GET", url, true);
	receiveReq.send(null);
	window.location.reload();
}
/******************************************************/
/* Change Ends 					      */
/******************************************************/
/******************************************************/
/* Modified by Infosys on 07-Jan-09 			      */
/* Change Begins						              */
/* For Member Permissions          */
/******************************************************/
function specialDelete(){	
	var subobj = document.getElementById('spldelete');
	subobj.style.display=(subobj.style.display!="block")? "block" : "none";	
}
function specialDeleteComment(divid){
	divid.style.display=(divid.style.display!="block")? "block" : "none";	
}
function divClose(){
	document.getElementById('spldelete').style.display="none";
}
function divCloseComment(divid){
	divid.style.display="none";
}
//For post/user deletion
function ConfirmedPost()
{	
	var reasonCaptured = escape(document.getElementById('drpReason').value);
	var itemTitle = escape(document.getElementById('title').value);
	var itemId = escape(document.getElementById('id').value);
	var userId = escape(document.getElementById('userid').value);
	var postType = escape(document.getElementById('posttype').value);
	
	var url = '/populate.php?_action=specialedits&reason='+reasonCaptured+'&title='+itemTitle+'&id='+itemId+'&uid='+userId+'&posttype='+postType;
	
	receiveReq.open("GET", url, true);
	receiveReq.send(null);
	document.getElementById('spldelete').style.display="none";
	window.location.reload();
}
//For comments and polls deletion
function ConfirmedCommentPost(itemId,Title,drpId,divId)
{	
	var reasonCaptured = escape(drpId.value);
	var userId = escape(document.getElementById('userid_comments').value);
	var postType = escape(document.getElementById('posttype_comments').value);
	var rawTitle = escape(Title);
	var itemTitle = rawTitle.substring(0,150);
	var url = '/populate.php?_action=specialedits&reason='+reasonCaptured+'&title='+itemTitle+'&id='+itemId+'&uid='+userId+'&posttype='+postType;
	
	receiveReq.open("GET", url, true);
//Modified on 26-Mar-09 for Comment Tracker
	receiveReq.onreadystatechange = function_state_Change;
	receiveReq.send(null);
	divId.style.display="none";
}
function function_state_Change()
{
	if (receiveReq.readyState==4)
  	{
	  if (receiveReq.status==200)
	    {
		    var postType = escape(document.getElementById('posttype_comments').value);
		    if(postType == 'poll_post')
			{
			    window.location.reload('/index.php?_action=poll_list&code=1');
			}
			else
			{
			    var locationURL = window.location;
				window.location.href = locationURL;
			}
	    }
	}
}
//Change Ends
//For Banning User
function ConfirmedBanPost()
{	
	var reasonCaptured = escape(document.getElementById('drpReason1').value);
	var itemTitle = escape(document.getElementById('title1').value);
	var itemId = escape(document.getElementById('id1').value);
	var userId = escape(document.getElementById('userid1').value);
	var postType = escape(document.getElementById('posttype1').value);
	
	var url = '/populate.php?_action=specialedits&reason='+reasonCaptured+'&title='+itemTitle+'&id='+itemId+'&uid='+userId+'&posttype='+postType;
	
	receiveReq.open("GET", url, true);
	receiveReq.send(null);
	document.getElementById('spldelete1').style.display="none";
	window.location.reload();
}
function Ban(){	
	var subobj = document.getElementById('spldelete1');
	subobj.style.display=(subobj.style.display!="block")? "block" : "none";	
}
function divBanClose(){
	document.getElementById('spldelete1').style.display="none";
}
//For Putting Users on WatchList
function ConfirmedWatchListPost()
{	
	var reasonCaptured = escape(document.getElementById('drpReason2').value);
	var itemTitle = escape(document.getElementById('title2').value);
	var itemId = escape(document.getElementById('id2').value);
	var userId = escape(document.getElementById('userid2').value);
	var postType = escape(document.getElementById('posttype2').value);
	
	var url = '/populate.php?_action=specialedits&reason='+reasonCaptured+'&title='+itemTitle+'&id='+itemId+'&uid='+userId+'&posttype='+postType;
	
	receiveReq.open("GET", url, true);
	receiveReq.send(null);
	document.getElementById('spldelete2').style.display="none";
	window.location.reload();
}
function WatchList(){	
	var subobj = document.getElementById('spldelete2');
	subobj.style.display=(subobj.style.display!="block")? "block" : "none";	
}
function divWatchListClose(){
	document.getElementById('spldelete2').style.display="none";
}


/******************************************************/
/* Change Ends 							              */
/******************************************************/
/******************************************************/
/* Modified by Infosys on 26-Aug-08                   */
/* Change Begins						              */
/* to display trackback error information             */
/******************************************************/
function disptbinfo(){	
	var trackobj = document.getElementById('trackback');
	trackobj.style.display=(trackobj.style.display!="block")? "block" : "none";	
}

function validateTBURL(){
  	  var numi = document.getElementById('inputCount').value;
	  var errorFlag = 0;
	  var blankCounter = 0;
  	  var regExp = new RegExp();
 	  regExp.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$"); 	  
	  var firstVal = document.getElementById('trackback0').value;
  	  if (!regExp.test(firstVal) && firstVal.trim() != "")
  	  {
   		errorFlag = 1;
  	  }
	  if (numi > 0)
	  {
		  for (var counter=0; counter <= numi; counter++)
		  {
			  	var inputvalue = "trackback"+counter;
			  	var urlValue = document.getElementById(inputvalue).value;
			  	if (!regExp.test(urlValue) || urlValue.trim() == "")
			  	{
			   		errorFlag = 1;
			   		break;
			  	}
	  	  }
  	  }
  	  if (errorFlag)
	  {
		  	alert("Please enter a valid Trackback URL"); 
		  	return false;
	  }
	  else
	  {
			return true;
	  }
}
/******************************************************/
/* Change Ends 							              */
/******************************************************/

/******************************************************/
/* Modified by Infosys on 17-Mar-09                   */
/* Change Begins						              */
/* to populate xml by ajax call            */
/******************************************************/
function submitMe()
{	
	var waitMsg1 = "<table width=\"250px\"align=\"center\">"+
				"<tr align=\"center\">"+
					"<td><b>";
	var waitMsg2 = "</b></td>"+
				"</tr>"+
				"<tr align=\"center\">"+
					"<td><img align=\"center\" src=\"images/loading.gif\"></img></td>"+
				"</tr>"+
			"</table>";
	
	document.getElementById('photoprint_div').style.display = 'none';
	document.getElementById('dvwaitbox').style.display = 'block';
	document.getElementById('dvwaitbox').style.zIndex = 1500;
	document.getElementById('dvwaitbox').innerHTML = waitMsg1 + "It may take upto 30 seconds.<BR>Please wait while we redirect you to moo.com..." + waitMsg2;  
  
	userID  = escape(document.getElementById('userid').value);
	albumID = escape(document.getElementById('albumid').value);
	if(userID  != "")
	{
			
		var url = '/populate.php?_action=printPhotos&userid='+userID;
		if(albumID == "")
		{
			//alert('inside none album id');
			receiveReq.open("GET", url, true);
		}
		else
		{	
			receiveReq.open("GET", '/populate.php?_action=printAlbum&albumID='+albumID+'&userid='+userID, true);

		}
   	}     
	receiveReq.onreadystatechange = checkPrintResponse; 
	receiveReq.send(null);
	
}

function checkPrintResponse()
{
	if (receiveReq.readyState == 4)
	{
		var re = receiveReq.responseText;
		document.getElementById('xml').value = re;
		document.getElementById('printPhotoForm').action="http://www.moo.com/api/api.php";
		document.getElementById('printPhotoForm').submit();
	}
}

/******************************************************/
/* Change Ends 							              */
/******************************************************/
/******************************************************/
/* Modified by Infosys on 13-June-08 & 7-July-08      */
/* Change Begins						              */
/* to enhance captcha code validation method          */
/* and to validate second captcha code                */
/* Modified by Infosys on 19-Mar-09 for user verification */
/******************************************************/
var type;
var elementId;
var friendEmail;
var friendName;
var yourName;
var code;

function doEmail(accStatus)
{	
	accStatus = (typeof accStatus == 'undefined') ? 0 : accStatus;
	friendEmail = document.getElementById('friendEmail').value;
	friendName = document.getElementById('friendName').value;
	yourName = document.getElementById('yourName').value;
	if(accStatus!=1){
		code = escape(document.getElementById('code').value);
	}
	else{
		code = 100;
	}
	type = document.getElementById('type').value;
	elementId = document.getElementById('elementId').value;

	if (friendEmail == "" || friendName == "" || yourName == "" || code == "")
	{
		alert('Please fill all required fields');
		return false;
	}
	var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
	    if (friendEmail.search(emailRegEx) == -1)
	    {
		    alert("Please enter a valid email address");
		    return false;
	    }
	    if (yourName.length > 15)
	    {
		alert ('Your name should contain less than 15 characters');
		return false;
	    } 
	if (receiveReq.readyState == 4 || receiveReq.readyState == 0)
	{
		if(accStatus!=1){
			code = escape(document.getElementById('code').value);
		}
		else{
			code = 100;
		}
		receiveReq.open("GET", '/populate.php?_action=checkThirdCaptchaCode&code='+code+'&acc='+accStatus, true);
		receiveReq.onreadystatechange = checkSmallCaptcha; 
		receiveReq.send(null);
	}
}

function checkSmallCaptcha()
{
	var code ;
	
	if (document.getElementById('code') != null &&
					(typeof(document.getElementById('code')) != "undefined"))

	{ 
		code = escape(document.getElementById('code').value);
	}
	else
	{
		code = '100';
		
	}
	if (receiveReq.readyState == 4)
	{
		var re = receiveReq.responseText;
		if (re == 1 || re==2)
		{
			/*var friendEmail = document.getElementById('friendEmail').value;
			var friendName = document.getElementById('friendName').value;
			var yourName = document.getElementById('yourName').value;
			var code = escape(document.getElementById('code').value);*/
			new Ajax.Updater(
				"email",				
				("/populate.php?_action=emailFriend&friendEmail=" + friendEmail + "&friendName=" + friendName + "&yourName=" + yourName + "&type=" + type + "&id=" + elementId + "&code=" + code),{}
			);
			/*alert ('submitting the form');
			document.emailToFriendForm.submit();
			alert ('form submitted');*/

		}
		else
		{
			alert('Wrong verification code!');
		}
	}
}
/******************************************************/
/* Change Ends 					      */
/******************************************************/

function sendMore(type,id,name,status) {
	
	/******************************************************/
	/* Modified by Infosys on 17-June-08 			      */
	/* Change Begins						              */
	/* Implemented images instead of buttons	          */
	/******************************************************/
	/* Modified the table alignment  */
	var accStatus=status;
	
	if(accStatus==0){
		document.getElementById('email').innerHTML = '<div><table cellspacing="0" cellpadding="0"><tr><td style="padding-top:2px" class="font_small" align="left">Friend\'s Email <span style="color:red">*</span></td><td style="padding-top:2px">&nbsp;&nbsp;<input type="text" name="friendEmail" id="friendEmail"></td></tr><tr><td style="padding-top:2px" class="font_small" align="left">Friend\'s Name <span style="color:red">*</span></td><td style="padding-top:2px">&nbsp;&nbsp;<input type="text" name="friendName" id="friendName"></td></tr><tr><td style="padding-top:2px" class="font_small" align="left">Your Name <span style="color:red">*</span></td><td style="padding-top:2px">&nbsp;&nbsp;<input type="text" name="yourName" id="yourName" value="'+name+'"></td></tr><tr><td style="padding-top:2px" class="font_small" align="left">Security code&nbsp;<span style="color:red">*</span></td><td style="padding-top:2px">&nbsp;&nbsp;<input type="text" name="code" id="code" autocomplete="off"></td></tr><tr><td></td><td style="padding-top:2px;padding-left:8px;"><div><img id="secondCaptchaImage2" src="/showThirdCaptcha.php?id={{1|mt_rand:100000}}"></div><a style="text-decoration:none; cursor: pointer" onclick="javascript: refreshImage(\'4\');"><span class="font_small">Refresh Image</span></a></td></tr><tr><td></td><td style="padding-top:2px">&nbsp;&nbsp;<input type="image" src="/images/Button_Send.gif" value="" onclick="doEmail(\''+type+'\','+id+')">&nbsp;&nbsp;<input type="image" src="/images/Button_Close.gif" value="" onclick="emailFriend()"></td></tr></table></div>';
	}
	else{
		document.getElementById('email').innerHTML = '<div><table cellspacing="0" cellpadding="0"><tr><td style="padding-top:2px" class="font_small" align="left">Friend\'s Email <span style="color:red">*</span></td><td style="padding-top:2px">&nbsp;&nbsp;<input type="text" name="friendEmail" id="friendEmail"></td></tr><tr><td style="padding-top:2px" class="font_small" align="left">Friend\'s Name <span style="color:red">*</span></td><td style="padding-top:2px">&nbsp;&nbsp;<input type="text" name="friendName" id="friendName"></td></tr><tr><td style="padding-top:2px" class="font_small" align="left">Your Name <span style="color:red">*</span></td><td style="padding-top:2px">&nbsp;&nbsp;<input type="text" name="yourName" id="yourName" value="'+name+'"></td></tr><tr><td></td><td style="padding-top:2px">&nbsp;&nbsp;<input type="image" src="/images/Button_Send.gif" value="" onclick="doEmail('+accStatus+')">&nbsp;&nbsp;<input type="image" src="/images/Button_Close.gif" value="" onclick="emailFriend()"></td></tr></table></div>';
	}
	
	if ((receiveReq.readyState == 4 || receiveReq.readyState == 0) && accStatus!=1)
	{
	   //Get a reference to CAPTCHA image
	   img = document.getElementById('captchaImage');
	   img.src = "images/loading.gif";
	   //Change the image
	   img.src = "/show_captcha.php?id=" + Math.random();
	}
	/******************************************************/
	/* Change Ends 							              */
	/******************************************************/
}
/******************************************************/
/* Added by Infosys on 03-July-08   			      */
/* Change Begins						              */
/* Added variable which will be used in invite frends */
/******************************************************/
var bInviteFriends = false;
/******************************************************/
/* Change Ends 							              */
/******************************************************/

function ThinkThis(url, feedback) {
	var thoughtsURL = '/index.php?_action=thinkthis&feedback='  + feedback;
	var thinkthis = document.getElementById('thinkthisfromthoughtsdotcom');		
	document.location = thoughtsURL + '&feedback=1&link=' + escape(url); 			
}
		
function ThinkThisAjax(linkid,url, uid, feedback) {
	var thoughtsURL = '/index.php?_action=thinkthisajax';
	aURL = thoughtsURL + '&feedback=1&link=' + escape(url);
	postBody = "link=" + url + "&userid=" + uid + "&feedback=" + feedback;			
	thinkThisLink = document.getElementById('thinkthislink' + linkid);
	
	new Ajax.Request (aURL, {
		method: 'post',
		postBody: postBody,
		onComplete:function(originalRequest) {
			//update the on-page score
			thisScore = document.getElementById('score'+linkid);
			score = thisScore.innerHTML;
			if (feedback == 1) {
				score = parseInt(score) + 1;
				thinkThisLink.innerHTML = 'Thought!';
			}
			else {
				score = parseInt(score) - 1;
				thinkThisLink.innerHTML = 'Forgotten!';
			}
			
			thisScore.innerHTML = score;	
					
			//Remove the think this link
			
			
		}
	});	
}

/******************************************************/
/* Modified by Infosys on 16-Dec-08 		      */
/* Change Begins				      */
/* to enhance captcha code validation method and for  */
/* email a friend captcha feature		      */
/* Modified by Infosys on 19-Mar-09 user verification */
/******************************************************/
function checkSecurityCode(accStatus) {
	accStatus = (typeof accStatus == 'undefined') ? 0 : accStatus;
	if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
		if(accStatus!=1){
			var securityCode = escape(document.getElementById('securityCode').value);
		}
		else{
			var securityCode = 0;
		}
		receiveReq.open("GET", '/populate.php?_action=checksScondCaptchaCode&code='+securityCode+'&acc='+accStatus, true);
		receiveReq.onreadystatechange = checkCommentCode2;
		receiveReq.send(null);
	}					
}

function checkCommentCode2() {
	if (receiveReq.readyState == 4) {
		var re = receiveReq.responseText;
		if (re == 1 || re==2) {
			if (window.sendItems) {
				sendItems();
			}
			else{
					if(removeSpacesMessage(document.getElementById('body').value) == '')
					{
						alert('Comment cannot be left empty');
						return 0;
					}
					else
					{
						var commentBody = escape(document.getElementById('body').value);
						document.getElementById('submit_but').value='1';
						document.getElementById('body').value = commentBody;
						document.commentform.submit();
					}
			}
		}
		else {
			alert('Wrong verification code!');
		}
	}					
}
function removeSpacesMessage(inputtext) { 	
 	inputtext=inputtext.split('\n').join('');
 	inputtext=inputtext.split('\r').join('');
 	inputtext=inputtext.split('\t').join('');
 	inputtext=inputtext.split('\f').join('');
 	return inputtext.split(' ').join('');
}
//Added on 18-Mar-09 for Comment Tracker
function checkReplySecurityCode(accStatus) {
	accStatus = (typeof accStatus == 'undefined') ? 0 : accStatus;
	if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
		if(accStatus!=1){
			var replySecurityCode = escape(document.getElementById('replySecurityCode').value);
		}
		else{
			var replySecurityCode = 0;
		}
		receiveReq.open("GET", '/populate.php?_action=checkReplyCaptchaCode&code='+replySecurityCode+'&acc='+accStatus, true);
		receiveReq.onreadystatechange = checkReplyCommentCode;
		receiveReq.send(null);
	}					
}

function checkReplyCommentCode() {
	if (receiveReq.readyState == 4) {
		var userId = escape(document.getElementById('comment_userid').value);
		var relatedBlogID = escape(document.getElementById('related_BlogID').value);
		var parentCommentID = escape(document.getElementById('parent_CommentID').value);
		var re = receiveReq.responseText;
		if (re == 1 || re==2) {
			if (window.sendItems) {
				sendItems();
			}
			else{
				if(removeSpacesMessage(document.getElementById('repbody').value) == '')
				{
					alert('Comment cannot be left empty');
					return 0;
				}
				else
				{
					var commentBody = escape(document.getElementById('repbody').value);
					document.getElementById('reply_submit_but').value='1';
					document.getElementById('repbody').value = commentBody;
					document.replyCommentForm.submit();
				}
			}
		}
		else {
			alert('Wrong verification code!');
		}
	}					
}
//Change Ends
function refreshImage(val)
{
	if (receiveReq.readyState == 4 || receiveReq.readyState == 0)
	{
		if (val == '2')
		{
		   //Get a reference to CAPTCHA image
		   img = document.getElementById('secondCaptchaImage');
		}
		else if (val == '1')
		{
		   //Get a reference to CAPTCHA image
		   img = document.getElementById('smallCaptchaImage');
		}
		else if (val == '4')
		{
		   //Get a reference to CAPTCHA image
		   img = document.getElementById('secondCaptchaImage2');
		}
		else if (val == '3')
		{
		   //Get a reference to CAPTCHA image
		   img = document.getElementById('largeCaptchaImage');
		}
		//Added on 18-Mar-09 for Comment Tracker
		else if (val == '5')
		{
		   //Get a reference to CAPTCHA image
		   img = document.getElementById('replyCaptchaImage');
		}
		//Change Ends
	   img.src = "images/loading.gif";
	   //Change the image
	   img.src = "/refresh_captcha.php?type="+val+"&id=" + Math.random();		
	}
}
/******************************************************/
/* Change Ends 							              */
/******************************************************/