/**
 * fnCommentLogin function
 * @param strReturnLink
 * @return 
 */	
function fnCommentLogin(strReturnLink)
{
	strCommentText = document.getElementById("id_txtCommentText").value;
	
	if(strCommentText == "")
	{
		return fnValidateForm(document.getElementById("id_ItemfrmPostComment"));
	}
	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) >= 50)
			{	
				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 50 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 fnUpload()
{
	var arrAllowExt  = new Array("jpg","jpeg","gif","png");
	var strErrorMsg  = "";
	
	/*var myFSO = new ActiveXObject("Scripting.FileSystemObject");
	var filepath = document.frmAddPhoto.txtImageFile.value;
	var thefile = myFSO.getFile(filepath);
	var size = thefile.size;
	alert(size + " bytes");*/
	
	/*var filename = document.getElementById("id_txtImageFile").value;
	str = fileSize(filename);
	alert(str);*/
	
	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 = document.frmAddPhoto.action;
				document.frmAddPhoto.submit();
			}
	}
	else
	{
		alert(strErrorMsg);
		//fnLightBoxError(strErrorMsg,3);
		return false;
	}
}

var strMessage      = "";
var strAttachment   = "";
var strActionLinks  = "";

/*function fnPublishOnFacebook()
{
	alert('in hi');
	Lightbox.hideBox("id_FbAuthenticatePublish",328,240);
	alert("hi");
	if (strAttachment != "" && strActionLinks != "")
	{
		if (strMessage != "")
			strMessage = Base64.decode(strMessage);

		strMessage = "";

		FB.Connect.streamPublish(strMessage, strAttachment, strActionLinks);
	}
}*/

function fnItemCommentWordLength()
{
	strCommentText = document.getElementById("id_txtCommentText").value;
	
	if(strCommentText == "")
	{
		return fnValidateForm(document.getElementById("id_ItemfrmPostComment"));
	}
	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) >= 50)
			{	
				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 50 characters.");
					return false;
				}
			}
			/*else
			{
				if(document.forms["frmPostComment"].action != "")
				{
					document.forms["frmPostComment"].submit();
				}
			}*/
		}
		
		if(document.forms["frmPostComment"].action != "")
		{
			document.forms["frmPostComment"].submit();
		}
	}
}



