
function trim(s)
{
	s =  s.replace( /^\s*/, "" );
	s =  s.replace( /\s*$/, "" );
	return s;
}
function validateEmail(src)
{
	if(src.indexOf(',') != -1 || src.indexOf(';')  != -1 || src.indexOf(' ')  != -1 || src.indexOf(':')  != -1)
	{
		return false;
	}
	if(src.indexOf('.') == -1 )
	return false;
	var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
	var regex = new RegExp(emailReg);
	return regex.test(src);
}
function CheckForEmpty(objItem,strAlertText)
{
	if(trim(objItem)=="")
	{
		alert(strAlertText)
		return false;
	}
	return true;
}

function ShowAlert(objItem,strAlertText)
{
	if(trim(strAlertText)!="")
	{	
		alert(strAlertText);
	}	
}

function CheckForSplCharAndMaxLength(objItem,intMinLength,intMaxLength,strMaxText,strInvalidSplChar,strInvalidText)
{
	var strValue=objItem;
	
	if(trim(strValue)!="")
	{	
		if(strValue.length>intMaxLength || strValue.length<intMinLength)
		{	
			ShowAlert(objItem,strMaxText);
			return false;
		}
	}
	if(strValue!="" && strInvalidSplChar != "")
	{
		for(var intSplChar=0; intSplChar<strInvalidSplChar.length; intSplChar++)
		{
			if(strValue.indexOf(strInvalidSplChar.charAt(intSplChar))!=-1)
			{
				ShowAlert(objItem,strInvalidText);
				return false;
			}
		}		
	}
	return true;
}

function isValidString(StrValue)
{
	if(StrValue.indexOf('www') != -1)
	{
		return false;
	}
	return true;
}

function chkWbEmail(fldname,str,notchar)
{
	var x = str;
	var filter  = /([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})/;
	if (filter.test(x)) 
	{
		alert(fldname + ' should not contains Email Address');
		return true;
	}
	filter  = /([a-zA-Z0-9_\.\-])+\.(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})/;	
	if (filter.test(x)) 
	{
		alert(fldname + ' should not contains WebSite Name');
		return true;
	}
	filter  = notchar;	
	if (filter.test(x)) 
	{
		alert(fldname + ' should not contains Special characters.');
		return true;
	}
	if (x.length>50)
	{
		alert(fldname + ' should be 50 character Max.');
		return true;
	}
	return false;
}


function chekUserCountryPhNo(phno)
{
	if (! chekSplCharInCountry(phno))
	{
		return false;
	}
	else
	{
		if ( (phno.length <= 4) && (phno.substring(0,3)!= "000" ) )
		{
			return true;
		}
		else
		{
			alert("Invalid Country Code!!!");
			return false;
		}
	}
		
}

function chekUserAreaPhNo(phno)
{
	if (! chekSplCharInArea(phno))
	{
		return false;
	}
	else
	{
		if ( (phno.length <= 6) && (phno.substring(0,3)!= "000" ) )
		{
			return true;
		}
		else
		{
			alert("Invalid Area Code!!!");
			return false;
		}
	}
		
}

function chekSplCharInPhone(str)
{
	var numericExpression = /^[0-9]+$/;
	if(str.match(numericExpression))
	{
		return true;
    }
    else
    {
		alert("Invalid Phone Number!!! No Space/Special character.");
        return false;    
    }
	
}

function chekUserPhNo(phno)
{
	if (! chekSplCharInPhone(phno))
	{
		return false;
	}
	else
	{
		if ( (phno.length >= 5) && (phno.substring(0,3)!= "000" ) )
		{
			return true;
		}
		else
		{
			alert("Invalid Phone Number!!!");
			return false;
		}
	}		
}

function chekSplCharInCountry(str)
{
	var numericExpression = /^[0-9]+$/;
	if(str.match(numericExpression))
	{
		return true;
    }
    else
    {
		alert("Invalid Country Code!!! No Space/Special character.");
        return false;    
    }	
}

function chekSplCharInArea(str)
{
	var numericExpression = /^[0-9]+$/;
	if(str.match(numericExpression))
	{
		return true;
    }
    else
    {
		alert("Invalid Area Code!!! No Space/Special character.");
        return false;    
    }	
}

function randgen()
{
	chars = new Array ('1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'); 
	var charCount = chars.length; 
	stringLength = 6; 
	var outputString;
	var curchar; 
	i = 0;
	j = 0; 
	for(i=0;i<stringLength;i++)
	{
		random = Math.floor(Math.random()*35); 
		random = chars[random]; 
		if(j!=0)
		{
			outputString += random;  
		}
		else
		{
			outputString=random;
			j=1;
		}
	}
	
	var code= outputString;
	document.getElementById('verficode').src="/verificationcode.aspx?code="+code;
	document.getElementById('verficcode').value=code;		
}


/* New Format*/
function CheckEmpty(objItem,strAlertText,ErrItem,blnClear,blnFocus)
{
	if(trim(objItem.value)=="")
	{
		ShowAlertMsg(objItem,strAlertText,ErrItem,blnClear,blnFocus)				
		return false;
	}
	return true;
}

function ShowAlertMsg(objItem,strAlertText,ErrItem,blnClear,blnFocus)
{
	if(trim(strAlertText)!="")
	{	
		document.getElementById(ErrItem).innerHTML =strAlertText;
	}
	if(blnClear)
	{
		objItem.value="";
	}
	if(blnFocus)
	{
		objItem.focus();
	}
}

function CheckSplCharAndMaxLength(objItem,intMinLength,intMaxLength,strMaxText,ErrItem,blnClear,blnFocus,strInvalidSplChar,strInvalidText)
{
	var strValue=objItem.value;	
	if(trim(strValue)!="")
	{	
		if(strValue.length>intMaxLength || strValue.length<intMinLength)
		{	
			ShowAlertMsg(objItem,strMaxText,ErrItem,blnClear,blnFocus);
			return false;
		}
	}
	if(trim(strValue)!="" && strInvalidSplChar != "")
	{
		for(var intSplChar=0; intSplChar<strInvalidSplChar.length; intSplChar++)
		{
			if(strValue.indexOf(strInvalidSplChar.charAt(intSplChar))!=-1)
			{
				ShowAlertMsg(objItem,strInvalidText,ErrItem,blnClear,blnFocus);
				return false;
			}
		}
		
	}
	return true;
}
function CheckSplChar(objItem,ErrItem,blnClear,blnFocus,strInvalidSplChar,strInvalidText)
{
	var strValue=objItem.value;	
	
	if(trim(strValue)!="" && strInvalidSplChar != "")
	{
		for(var intSplChar=0; intSplChar<strInvalidSplChar.length; intSplChar++)
		{
			if(strValue.indexOf(strInvalidSplChar.charAt(intSplChar))!=-1)
			{
				ShowAlertMsg(objItem,strInvalidText,ErrItem,blnClear,blnFocus);
				return false;
			}
		}
		
	}
	return true;
}


function chkForWbEmail(fldname,str,notchar,ErrItem)
{
	var x = str;
	var filter  = /([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})/;
	if (filter.test(x)) 
	{
		document.getElementById(ErrItem).innerHTML =fldname + ' should not contains Email Address';
		return true;
	}
	filter  = /([a-zA-Z0-9_\.\-])+\.(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})/;	
	if (filter.test(x)) 
	{
		document.getElementById(ErrItem).innerHTML =fldname + ' should not contains WebSite Name';
		return true;
	}
	filter  = notchar;	
	if (filter.test(x)) 
	{
		document.getElementById(ErrItem).innerHTML =fldname + ' should not contains Special characters.';
		return true;
	}
	if (x.length>50)
	{
		document.getElementById(ErrItem).innerHTML =fldname + ' should be 50 character Max.';
		return true;
	}
return false;
}

function chkFordtWbEmail(fldname,str,ErrItem)
{
	var x = str;
	var filter  = /([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})/;
	if (filter.test(x)) 
	{
		document.getElementById(ErrItem).innerHTML =fldname + ' should not contains Email Address';
		return true;
	}
	filter  = /([a-zA-Z0-9_\.\-])+\.(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})/;	
	if (filter.test(x)) 
	{
		document.getElementById(ErrItem).innerHTML =fldname + ' should not contains WebSite Name';
		return true;
	}	
return false;
}

function chekCountryPhNo(phno,ErrItem)
{
	if (! chekSplCharCountry(phno,ErrItem))
	{
		return false;
	}
	else
	{
		if ( (phno.length <= 4) && (phno.substring(0,3)!= "000" ) )
		{
			return true;
		}
		else
		{
			document.getElementById(ErrItem).innerHTML ="Invalid Country Code!!!";
			return false;
		}
	}
		
}

function chekAreaPhNo(phno,ErrItem)
{
	if (! chekSplCharArea(phno,ErrItem))
	{
		return false;
	}
	else
	{
		if ( (phno.length <= 6) && (phno.substring(0,3)!= "000" ) )
		{
			return true;
		}
		else
		{
			document.getElementById(ErrItem).innerHTML ="Invalid Area Code!!!";
			return false;
		}
	}
		
}

function checkSplCharPhone(str,ErrItem)
{
	var numericExpression = /^[0-9]+$/;
	if(str.match(numericExpression))
	   {
		  return true;
       }
       else
       {
		  document.getElementById(ErrItem).innerHTML ="Invalid Phone Number!!! No Space/Special character.";
          return false;    
       }
	
}


function chekSplCharMobile(str,ErrItem)
{
	var numericExpression = /^[0-9]+$/;
	if(str.match(numericExpression))
	   {
		  return true;
       }
       else
       {
		  document.getElementById(ErrItem).innerHTML ="Invalid Mobile Number!!! No Space/Special character.";
          return false;    
       }
	
}

function chekSplCharCountry(str,ErrItem)
{
	var numericExpression = /^[0-9]+$/;
	if(str.match(numericExpression))
	   {
		  return true;
       }
       else
       {
		  document.getElementById(ErrItem).innerHTML ="Invalid Country Code!!! No Space/Special character.";
          return false;    
       }
	
}

function chekSplCharArea(str,ErrItem)
{
	var numericExpression = /^[0-9]+$/;
	if(str.match(numericExpression))
	   {
		  return true;
       }
       else
       {
		  document.getElementById(ErrItem).innerHTML ="Invalid Area Code!!! No Space/Special character.";
          return false;    
       }
	
}

function chekPhNo(country, phno,ErrItem)
{
	if (! checkSplCharPhone(phno,ErrItem))
	{
		return false;
	}
	else
	{
		if ( (phno.length >= 5) && (phno.substring(0,3)!= "000" ) )
		{
			return true;
		}
		else
		{
			document.getElementById(ErrItem).innerHTML ="Invalid Phone Number!!!";
			return false;
		}
	}		
}

function chekMobileNo(country, phno,ErrItem)
{
	if (! chekSplCharMobile(phno,ErrItem))
	{
		return false;
	}
	else
	{
		if ( (phno.length >7) && (phno.substring(0,3)!= "000" ) )
		{
			return true;
		}
		else
		{
			document.getElementById(ErrItem).innerHTML ="Invalid Mobile Number!!!";
			return false;
		}
	}
}

function checkWordcnt(fldname,str,ErrItem)
{
	var spkey=str.split(' ');
	for (var i=0;i<spkey.length;i++)
	{
		if (spkey[i].length>30)
		{
			document.getElementById(ErrItem).innerHTML ='Each word length in '+fldname+' Should not be greater than 30 characters';
			return true;
		}
	}
	return false;
}

/*
function checkisvalfunction(StrValue)
{
	var regex= /(www|w ww|w w w|ww w|www (dot)|(dot) com|www.|.com)$/;
	if(StrValue.match(regex))
	{
		//alert('Words found!');
		return false;
	}
	else
	{
		//alert('Words not found!');
		return true;
	} 
}*/

function checkisvalfunction(StrValue)
{
	if(StrValue.indexOf('www') != -1)
	{
		return false;
	}
	if(StrValue.indexOf('w ww') != -1)
	{
		return false;
	}
	if(StrValue.indexOf('w w w') != -1)
	{
		return false;
	}
	if(StrValue.indexOf('ww w') != -1)
	{
		return false;
	}
	if(StrValue.indexOf('www (dot)') != -1)
	{
		return false;
	}
	if(StrValue.indexOf('(dot) com') != -1)
	{
		return false;
	}
	if(StrValue.indexOf('www.') != -1)
	{
		return false;
	}
	if(StrValue.indexOf('.com') != -1)
	{
		return false;
	}
	if(StrValue.indexOf('www,') != -1)
	{
		return false;
	}
	if(StrValue.indexOf(',com') != -1)
	{
		return false;
	}

	return true;
}

function CheckForSplCharOnlyNew(objItem,ErrItem,blnClear,blnFocus,strInvalidSplChar,strInvalidText)
{
	var strValues=objItem.value;
	var strrrval;
			
	if(strValues!="" && strInvalidSplChar != "")
	{
		var strSplCharSplit=strInvalidSplChar.split(",");
		for(var c=0;c<strSplCharSplit.length;c++)
		{
			strrrval=strSplCharSplit[c];
			if(strValues.indexOf(strSplCharSplit[c])!=-1)
			{
				ShowAlertMsg(objItem,strInvalidText,ErrItem,blnClear,blnFocus);
				return false;
			}
		}		
	}
	return true;
}

function CheckForSplCharOnly(objItem,strInvalidSplChar,strInvalidText)
{
	var strValue=objItem.value;
	var strrrval;
	
	if(strValue!="" && strInvalidSplChar != "")
	{
		var strSplCharSplit=strInvalidSplChar.split(",");
		for(var intSplChar=0; intSplChar<strSplCharSplit.length; intSplChar++)
		{
			strrrval=strSplCharSplit[intSplChar];
			if(strValue.indexOf(strrrval)!=-1)
			{
				ShowAlert(objItem,strInvalidText);
				return false;
			}
		}		
	}
	return true;
}

