//----start-----Common function add here---------

function Trim(TRIM_VALUE){
           
			if(TRIM_VALUE.length < 1){
			return"";
			}
			TRIM_VALUE = RTrim(TRIM_VALUE);
			TRIM_VALUE = LTrim(TRIM_VALUE);
			if(TRIM_VALUE==""){
			return "";
			}
			else{
			
			return TRIM_VALUE;
			}
			} //End Function

			function RTrim(VALUE){
			var w_space = String.fromCharCode(32);
			var v_length = VALUE.length;
			var strTemp = "";
			if(v_length < 0){
			return"";
			}
			var iTemp = v_length -1;

			while(iTemp > -1){
			if(VALUE.charAt(iTemp) == w_space){
			}
			else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
			}
			iTemp = iTemp-1;

			} //End While
			return strTemp;

			} //End Function

			function LTrim(VALUE){
			var w_space = String.fromCharCode(32);
			if(v_length < 1){
			return"";
			}
			var v_length = VALUE.length;
			var strTemp = "";

			var iTemp = 0;

			while(iTemp < v_length){
			if(VALUE.charAt(iTemp) == w_space){
			}
			else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
			}
			iTemp = iTemp + 1;
			} //End While
			return strTemp;
			} //End Function


/*function CommonValidate(ArrCrtName,ArrCtrAlertStr)
{
	alert();
	var count=ArrCrtName.lenght;
	var ctrName;
	for(int i=0;i<parseInt(count);i++)
	{
		if(Trim(document.getElementById(ArrCrtName[i]).value)=="")
		{
			alert(ArrCtrAlertStr[i]);
			document.getElementById(ArrCrtName[i]).focus();
			return false;
		}
		
	}
	return true;
}*/

//----end -----Common function add here------





//------start-----add template for page name mcMailingTemplate.aspx------
function addtemplate()
{
	if(Trim(document.getElementById("dropTemplate").value)=="0")
	{
		alert("please select Template Type.");
		document.getElementById("dropTemplate").focus();
		return false;
	}
	if(Trim(document.getElementById("txtSubject").value)=="")
	{
		alert("please enter subject.");
		document.getElementById("txtSubject").focus();
		return false;
	}
	if(Trim(FCKeditorAPI.GetInstance("FCKeditor1").GetXHTML())=="")
	{
		alert("Please enter mailbody portion.");
		FCKeditorAPI.GetInstance("FCKeditor1").Focus();
		return false;
	}
	
	return true;
	
}


//------end ----add template for page name mcMailingTemplate.aspx------

//----------Email Validation-----------------
function validEmail(email_str)
		{
		   
			if(Trim(email_str)!="")
			{
				with (Trim(email_str))
				{
				apos=email_str.indexOf("@");
				dotpos=email_str.lastIndexOf(".");
				lastpos=email_str.length-1;
				//alert(apos + " " + dotpos + " " + lastpos);
				
				if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2)
					{
						return false;
					}
				 else return true;
				   
				
				}
			}
			 
		}
//End Email Validation----------------------