/**
 * fnCommentLogin function
 * @param strReturnLink
 * @return 
 */	
function fnCommentLogin(strReturnLink)
{
	//alert(strReturnLink);	
	strCommentText = document.getElementById("id_txtCommentText").value;
	
	if(strCommentText == "")
	{
		return fnValidateForm(document.getElementById("id_debatefrmComment"));
	}
	else
	{
		var browser=navigator.appName;
		
		var myarry = new Array();
		pattern = /(\w+)\s+(\w+)/;
		
		if(browser == "Microsoft Internet Explorer")
			myarry = strCommentText.split(" ");
		else
			myarry = strCommentText.split(pattern);
		
		for (i=0;i<myarry.length;i++)
		{
			if((myarry[i].length) >= 20)
			{	
				if((!myarry[i].match("http://")) && (!myarry[i].match("www")) && (!myarry[i].match("http://www")) && (!myarry[i].match("https://")))
				{
					alert("Single word limit exceeded. Please make sure that a single word is not more than 20 characters.");
					return false;
				}		
			}
			/*else
			{
				if(document.forms["frmPostComment"].action != "")
				{
					document.forms["frmPostComment"].submit();
				}
			}*/
		}
		
		strReturnLink  = Base64.decode(strReturnLink) + "&content=" + Base64.encode(strCommentText);
		strReturnLink  = Base64.encode(strReturnLink);
		
		strFormAction = sitename + "/login?goto=" + strReturnLink;
	
		strRegeAction = sitename + "/signup?goto=" + strReturnLink;
		//strFogtAction = sitename + "/forgotpassword?goto=" + strReturnLink;
		
		document.frmPopupLogin.action = strFormAction;
		document.getElementById("id_RegisterLink").href = strRegeAction;
		//document.getElementById("id_ForgotLink").href = strFogtAction;
		
		Lightbox.showBoxByID('id_LoginBox',530,360);
		
		return false;
	}
}

/*
function fnSubmitListLogin(strReturnLink)
{
	strItemImageText = document.getElementById("txtImageFile").value;
	
	strReturnLink  = Base64.decode(strReturnLink) + "&content=" + Base64.encode(strItemImageText);
	strReturnLink  = Base64.encode(strReturnLink);
	
	strFormAction = sitename + "/login?goto=" + strReturnLink;
	
	strRegeAction = sitename + "/signup?goto=" + strReturnLink;
	//strFogtAction = sitename + "/forgotpassword?goto=" + strReturnLink;
	
	document.frmPopupLogin.action = strFormAction;
	document.getElementById("id_RegisterLink").href = strRegeAction;
	//document.getElementById("id_ForgotLink").href = strFogtAction;
	
	Lightbox.showBoxByID('id_LoginBox',530,360);
	
	return false;
}


function fnAddImages(Id)
{
	if(document.getElementById(Id).style.display=="")
	{
		document.getElementById(Id).style.display="none";
	}
	else
	{
		document.getElementById(Id).style.display="";
	}
}

function fnProfileMenuUrl(tab)
{
	document.getElementById("id_taburl").value = tab;
	document.frmItemProfile.submit();
	return false;
}
*/

function fnItemCommentWordLength()
{
	strCommentText = document.getElementById("id_txtCommentText").value;
	
	if(strCommentText == "")
	{
		return fnValidateForm(document.getElementById("id_debatefrmComment"));
	}
	else
	{
		var browser=navigator.appName;
		
		var myarry = new Array();
		pattern = /(\w+)\s+(\w+)/;
		
		if(browser == "Microsoft Internet Explorer")
			myarry = strCommentText.split(" ");
		else
			myarry = strCommentText.split(pattern);
		
		for (i=0;i<myarry.length;i++)
		{
			if((myarry[i].length) >= 20)
			{	
				if((!myarry[i].match("http://")) && (!myarry[i].match("www")) && (!myarry[i].match("http://www")) && (!myarry[i].match("https://")))
				{
					alert("Single word limit exceeded. Please make sure that a single word is not more than 20 characters.");
					return false;
				}		
			}
			/*else
			{
				if(document.forms["frmPostComment"].action != "")
				{
					document.forms["frmPostComment"].submit();
				}
			}*/
		}
		if(document.forms["frmPostComment"].action != "")
		{
			document.forms["frmPostComment"].submit();
		}
	}
}
