//====================================================================================================
//	Function Name	:	Validate_Form
//----------------------------------------------------------------------------------------------------
function validate_comment_frm(frm,validate_url)
{
	with(frm)
    {	
		if(!IsEmpty(bcomment_author_name, 'Please enter Name.'))
		{
			return false;
		}
		else if(!IsEmpty(bcomment_author_email, 'Please enter Email Address.'))
		{
			return false;
		}
		else if(!IsEmail(bcomment_author_email, 'Oppsss!!! Invalid Email Address specified.'))
		{
			return false;
		}
		else if(!IsEmpty(bcomment_content, 'Please enter Messag.'))
		{
			return false;
		}
		else if ( validate_url != "1" )
		{
			 var theurl = bcomment_content.value;
			 var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/;
			 var tomatch1= /\.[A-Za-z]{3}/;
			 if (tomatch.test(theurl) || tomatch1.test(theurl) )
			 {
				 window.alert("URL Not Allowed");
				 bcomment_content.focus();
				 return false;
			 }
		}
	}
	return true;
}

function reply(authId, commentId, commentBox) {
//	var author = document.getElementById(authId).innerHTML;
//	var insertStr = '<a href="#' + commentId + '">@' + author.replace(/\t|\n|\r\n/g, "") + '</a> \n\n';

//	appendReply(insertStr, commentBox);

	document.getElementById(commentBox).focus();
}

function appendReply(insertStr, commentBox) {
	if( document.getElementById(commentBox) != null ) {
		field = document.getElementById(commentBox);
	} else {
		alert("The comment box does not exist!");
		return false;
	}

	if (field.value.indexOf(insertStr) > -1) {
		alert("You've already appended this reply!");
		return false;
	}

	if (field.value.replace(/\s|\t|\n/g, "") == '') {
		field.value = insertStr;
	} else {
		field.value = field.value.replace(/[\n]*$/g, "") + '\n\n' + insertStr;
	}
	field.focus();
}

function quote(authorId, commentId, commentBodyId, commentBox) {
	var author = document.getElementById(authorId).innerHTML;
	var comment = document.getElementById(commentBodyId).innerHTML;

	var insertStr = '<blockquote cite="#' + commentBodyId + '">';
	insertStr += '<strong><a href="#' + commentId + '">' + author.replace(/\t|\n|\r\n/g, "") + '</a> :</strong>';
	insertStr += comment.replace(/\t/g, "");
	insertStr += '</blockquote>\n';

	insertQuote(insertStr, commentBox);
}

function insertQuote(insertStr, commentBox) {
	if( document.getElementById(commentBox) != null ) {
		field = document.getElementById(commentBox);
	} else {
		alert("The comment box does not exist!");
		return false;
	}

	if(document.selection) {
		field.focus();
		sel = document.selection.createRange();
		sel.text = insertStr;
		field.focus();

	} else if (field.selectionStart || field.selectionStart == '0') {
		var startPos = field.selectionStart;
		var endPos = field.selectionEnd;
		var cursorPos = startPos;
		field.value = field.value.substring(0, startPos)
					+ insertStr
					+ field.value.substring(endPos, field.value.length);
		cursorPos += insertStr.length;
		field.focus();
		field.selectionStart = cursorPos;
		field.selectionEnd = cursorPos;

	} else {
		field.value += insertStr;
		field.focus();
	}
}

function show_comment_box()
{
	document.getElementById("comment-title").innerHTML = 'Write a Comment';	
	document.getElementById("comment-box").style.display = '';	
	document.getElementById("register-box").style.display = 'none';	
	document.getElementById("register-content").style.display = 'none';	
}
function show_update_profile_box()
{
	document.getElementById("comment-title").innerHTML = 'Update Profile';	
	document.getElementById("comment-box").style.display = 'none';	
	document.getElementById("register-content").style.display = '';	
	document.getElementById("register-box").style.display = '';	
	document.getElementById("register").value = 'Update Profile';
}


