/**
 * Home Module JS Files
 * @author Pathfinder Solutions India
 * @link http://www.pathfindersolutions.biz
 * @version 1.0
 * @package justmeans
 * @subpackage home
 */
 	var ajaxObjects = new Array();
	function fnCheckCharCnt()
	{
		var strText;
		var intFlag =0;
		strText = document.getElementById('id_txtWhatAreUWorking').value;
		if(intFlag==0)
			elementid.style.height = elementid.scrollHeight + 'px';
		// \s Matches any white-space character.
		// \s is equivalent to [ \f\n\r\t\v].
		// removes white spaces \n etc
		/*if(140 - strText.length > 0)
		{
			document.getElementById('id_chartextcnt').innerHTML = 140 - strText.length;
		}
		else
		{*/
			
			if(140 - strText.length > 0)
			{
				document.getElementById('id_chartextcnt').innerHTML = 140 - strText.length;
			}
			else
			{
				document.getElementById('id_chartextcnt').innerHTML = 0;
			}	
			document.getElementById('id_txtWhatAreUWorking').value = strText.substring(0, 140);
		/*}*/
		
	}

	function fnValidateInputForComment(loginuserid,competitionid,parentid)
	{
		var strErrorMessage = "";
		var strCommentText = "";
		
		var extparam;
		if(parentid != 0)
		{
			extparam = "_"+parentid;
		}
		else
		{
			extparam = "";
		}
	
		strIdeaText = document.getElementById('id_txtShareIdea'+extparam).value;
		
		if(strIdeaText == "")
		{
			alert("Write a Idea");
			document.getElementById('id_txtShareIdea').focus();
			return false;
		}
		else
		{
			// ajax call to set variables
			strIdeaText = escape(strIdeaText);
	 		strIdeaText = strIdeaText.replace(/\r?\n/g,'<br/>');
			//fnAjaxCaller("", "setunsetsessionvars", "setsessionparams", "&settoparams=forcomments&type="+type+"&typeid="+typeid+"&parentid="+parentid+"&companypageid="+companypageid+"&commenttext="+strCommentText,"","");
			var ajaxIndex = ajaxObjects.length;	
			ajaxObjects[ajaxIndex] = new sack();
			ajaxObjects[ajaxIndex].requestFile = sitename+"/index.php?action=setunsetsessionvars&mode=ajax&ajax_action=setsessionparams&settoparams=forideas&competitionidid="+competitionid+"&parentid="+parentid+"&ideatext="+strIdeaText;
			ajaxObjects[ajaxIndex].onCompletion = function(){
																if(loginuserid == 0 || loginuserid == "")
																{
																	//Lightbox.showBoxByID('divRegisterLogin', 550,345);
																	Lightbox.showBoxByID('divRegisterLogin', 650, 420);
																	return false;
																}
																else
																{
																	url=  sitename+"/submitcompetitionidea?competitionidid="+competitionid+"&isidea="+1;
																	location.href = url;
																	return true;
																}
															};	// Specify function that will be executed after file has been found
			ajaxObjects[ajaxIndex].runAJAX();
			
			
		}
	}
	
	
	
	
	
	
	
	

	
	
	
	function fnHideShowCommentBox(loginuserid,statusid)
	{
		isLoad = false;
		/*if(loginuserid == 0 || loginuserid == "")
		{
			Lightbox.showBoxByID('divRegisterLogin', 550,345);
		}
		else
		{*/
			//alert("Open Box");
			//id_CommentBoxTd
			document.getElementById("id_CommentBoxTd_"+statusid).innerHTML=""; 
			document.getElementById('issetfocus').value = "id_txtShareIdea"+statusid;
			fnAjaxCaller("id_CommentBoxTd_" + statusid,"showallcomment","showreplytocomment","&suserid=" + loginuserid + "&statusid=" + statusid + "&strredirectaxn=showallwruwo","","");
		/*}*/
	}
	
	function fnShowCommentBoxer(statusid)
	{
		var extparam;
		if(statusid)
		{
			extparam = "_"+statusid;
		}
		else
		{
			extparam = "";
		}
		
		if(document.getElementById("id_txtShareIdea"+extparam).value == "" || document.getElementById("id_txtShareIdea"+extparam).value == "Share your idea here...")
		{
			document.getElementById("id_txtShareIdea"+extparam).style.height = "85px";
			document.getElementById("id_txtShareIdea"+extparam).value = "";
			document.getElementById("btnaddidea"+extparam).style.display = "";
			document.getElementById("id_txtShareIdea"+extparam).focus();
		}
	}
	
	function fnViewAllComment(commentcnt,statusid)
	{
		for(i=2;i<=commentcnt;i++)
		{
			document.getElementById("id_tr_" + i + "_" + statusid).style.display="";
		}
		
		document.getElementById("id_maintr_" + statusid).style.display="none";
		
	}
	
	function fnIncreaseHieghtofTA(elementid)
	{
		elementid.style.height = elementid.scrollHeight + 'px';
	}
	
	function fnIdeaCommentDiv(ideaid)
	{
		var elem = document.getElementById("id_comdiv_" + ideaid);
		if(elem.style.display=="")
		{
				elem.style.display = "none";
		}
		else
		{
				elem.style.display = "";
		}
	}
	
	function fnDeleteComptIdea(intideaid,intcomptid,strcompttype)
{
	var strErrorMessage = "";
	var status = confirm( "Remove this idea?");
	if(status)
	{
		if(strErrorMessage == "")
		{
			
			var ajaxIndex = ajaxObjects.length;	
				ajaxObjects[ajaxIndex] = new sack();
				ajaxObjects[ajaxIndex].requestFile = sitename+"/listcompetitionidea?mode=ajax&ajax_action=deletecomptidea&idea_id="+intideaid+"&compt_id="+intcomptid+"&compt_type="+strcompttype;
				
				ajaxObjects[ajaxIndex].onCompletion = function(){
					
																	if(ajaxObjects[ajaxIndex].response != "")
																	{
																		document.getElementById("idea_" + intideaid).style.display="none";
																		document.getElementById("div_error").innerHTML=ajaxObjects[ajaxIndex].response; 
																	}
																	
																};	// Specify function that will be executed after file has been found
				ajaxObjects[ajaxIndex].runAJAX();
				
		}
		else
		{
			alert(strErrorMessage);
			return false;
		}
	}
	
}
	
	
	