/**
 * Ny Content Module JS Files
 * @author Pathfinder Solutions India
 * @link http://www.pathfindersolutions.biz
 * @version 1.0
 * @package YouthActionNet
 * @subpackage Marketplace
 */

/**
 * fnAddRegion function
 * @param string type,string name,int ID,string cssclass,varchar value,bool checked
 * @return bool true or false
 */
function fnOpenCloseControl(strShowId, strHideId)
{
	if (document.getElementById(strShowId).style.display == "none")
	{
		document.getElementById(strShowId).style.display = "";
		document.getElementById(strHideId).style.display = "none";
	}
	else
	{
		document.getElementById(strShowId).style.display = "none";
	}
}



	function fnHideShowDiv(no,type,id)
	{
		var elem = document.getElementById(id);
		
		if(id=="id_div"+type+"Comment["+no+"]")
		{
			document.getElementById('id_div'+type+'Email['+no+']').style.display="none";	
		}
		else
		{
			document.getElementById('id_div'+type+'Comment['+no+']').style.display="none";	
		}

		if(elem.style.display=="")
		{
				elem.style.display = "none";
		}
		else
		{
				elem.style.display = "";
		}
	}




/**
 * fnEmailArticle function
 * @param no, type, divId, userid
 * @return fnEmailArticle
 */	
	function fnEmailArticle(no,type,username,articleid,strMultimediaType)
	{
		var strErrorMessage = "";
		if ( document.getElementById('id_txtFromEmail['+no+']').value == "")
		{
			strErrorMessage = strErrorMessage + "Enter Your Email Address. \n";
		}
		
		if ( document.getElementById('id_txtRecepient['+no+']').value == "")
		{
			strErrorMessage = strErrorMessage + "Enter Recepient Email Address. \n";
		}

		if(document.getElementById('id_txtFromEmail['+no+']').value != "")
		{
			var emailStr2 = document.getElementById('id_txtFromEmail['+no+']').value;
			
			if(!fnEmailCheck (emailStr2))
			{
				strErrorMessage = strErrorMessage + "Enter Your Valid  Email Address. \n";
			}
		}

		if(document.getElementById('id_txtRecepient['+no+']').value != "")
		{
			var emailStr2 = document.getElementById('id_txt'+type+'Recepient['+no+']').value;
			
			var emailArray = [];
			emailArray = emailStr2.split(",");
			for(var index=0;index<emailArray.length;index++)
			{
				if(!fnEmailCheck (emailArray[index]))
				{
					strErrorMessage = strErrorMessage + "Enter Valid Email Address of recepient. \n";
				}
			}
		}


	  var strFrom = document.getElementById("id_txtFromEmail["+no+"]").value;	
	  var strTo = document.getElementById("id_txtRecepient["+no+"]").value;	
	  //var strMessage = document.getElementById("id_txtMessage["+no+"]").value;	
	  var strSendCopy = "false";
	  if(document.getElementById("id_chkSendMeCopy["+no+"]").checked)
	  {
	  		strSendCopy = 'true';
	  }

	  if (strErrorMessage != "")
  	  {
		alert(strErrorMessage);
		return false;
	  }
 
	  var div = document.getElementById("id_divEmail["+no+"]");
	  div.style.display = "none";
	  Lightbox.hideBox();
      if(strMultimediaType=="PODCAST")
	  {     
	      var strSubject   = username+"\n  invited you to listen to this podcast.";
		  var strSubjectContent = username+"\n  invited you to listen to this podcast at the YouthActionNet Marketplace. ";
	  
	  }
	  if(strMultimediaType=="PICTURE")
	  {
		  var strSubject = username+"\n  has invited you to view this picture.";
		  var strSubjectContent = username+"\n  has invited you to view this picture at the YouthActionNet Marketplace.";
	  }
	  if(strMultimediaType=="VIDEO")
	  {                        
		var strSubjectContent = username+"\n  has invited you to watch this video at the YouthActionNet Marketplace";
		var strSubject = username+"\n has invited you to watch this video";
	  }
	//  var strSubject = username+"  invited you to view "+strMultimediaType;
	  
	  var strPerMessage = document.getElementById("id_txtMessage["+no+"]").value;	
	  //& creating problem to display whole content text so replacing it with 'and' word
 	  strPerMessage = strPerMessage.replace(/&/g, " and ");
	  strPerMessage = strPerMessage.replace(/\n/g, "<br>");
       
		if(strErrorMessage=="")
		{
			  fnAjaxCaller('id_divResponse['+no+']','multimediahome','emailmultimedia', '&sender='+strFrom+'&recepient='+strTo+'&subject='+strSubject+'&message='+strSubject+'&personalmsg='+strPerMessage+'&sendcopy='+strSendCopy+'&multimediaID='+articleid, '', '');	  
		}
	  
	}	
	
	/**
 * fnValidateNewsInput function
 * @param 
 * @return 
 */
	function fnValidateNewsInput()
	{
		var strErrorMessage = "";

		if(document.getElementById('txtNewsSearch').value=="")
		{
			strErrorMessage = "Please enter text to search.";
		}
		if(document.getElementById('txtNewsSearch').value.length==1)
		{
			strErrorMessage = "Please enter text more than one character.";
		}
		if(strErrorMessage!="")
		{
			alert(strErrorMessage);	
			return false;
		}
	}





	

