/**
 * fnCommentLogin function
 * @param strReturnLink
 * @return 
 */	
function fnCommentLogin(strReturnLink)
{
	strCommentText = document.getElementById("id_txtUserComment").value;
	if(strCommentText == "")
	{
		return fnValidateForm(document.getElementById("id_frmAddComment"));
	}
	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["frmAddComment"].action != "")
				{
					document.forms["frmAddComment"].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 fnAddImages(Id)
{
	if(document.getElementById(Id).style.display=="")
	{
		document.getElementById(Id).style.display="none";
	}
	else
	{
		document.getElementById(Id).style.display="";
	}
}

function fnProfileMenuUrl(sorttype)
{
	document.getElementById("id_rankingurl").value = sorttype;
	document.frmUserProfile.submit();
	return false;
}


function setFrmAction(action){
	alert(action);
	if(document.frmAddPhoto.action != ""){
		document.frmAddPhoto.submit();
	}
	else{
		document.frmAddPhoto = action;
		document.frmAddPhoto.submit();
		
	}
}

function fnUpload()
{
	var arrAllowExt  = new Array("jpg","jpeg","gif","png");
	var strErrorMsg  = "";
	
	strImageName = document.getElementById("id_txtImageFile").value;
	strImageName = strImageName.toLowerCase();
	arrImageName = strImageName.split(".")
	
	intLastKey = (arrImageName.length)-1;
	
	strImageExt = arrImageName[intLastKey];
	if (arrAllowExt.indexOf(strImageExt) == -1)
	{
		strErrorMsg = strImageExt+" Image type not allow.";
	}
	if (strErrorMsg == "")
	{
			if(document.frmAddPhoto.action != "")
			{
				document.frmAddPhoto.submit();
			}
			else
			{
				document.frmAddPhoto.action = document.frmAddPhoto.action;
				document.frmAddPhoto.submit();
			}
	}
	else
	{
		alert(strErrorMsg);
		//fnLightBoxError(strErrorMsg,3);
		return false;
	}
}

function fnCommentWordLength()
{
	strCommentText = document.getElementById("id_txtUserComment").value;
	if(strCommentText == "")
	{
		return fnValidateForm(document.getElementById("id_frmAddComment"));
	}
	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["frmAddComment"].action != "")
				{
					document.forms["frmAddComment"].submit();
				}
			}*/
		}
		if(document.forms["frmAddComment"].action != "")
		{
			document.forms["frmAddComment"].submit();
		}
	}
}

