// validation for b2b_trade_add.asp start
function validation_b2b_trade_add()
{
if(document.all.txtName.value=="")
	{
		alert("Enter Name.");
		document.all.txtName.focus();
		return false;
	}

	
if(FunScriptTagValidation(document.all.txtName.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.all.txtName.focus();
	return false;	
}
else
{
	document.all.txtName.value=replaceunwantedcharacters(document.all.txtName.value);
}



if(FunScriptTagValidation(document.all.txtOrganization.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.all.txtOrganization.focus();
	return false;	
}
else
{
	document.all.txtOrganization.value=replaceunwantedcharacters(document.all.txtOrganization.value);
}

	
if(document.all.txtEmail.value=="")
	{
		alert("Enter Email.");
		document.all.txtEmail.focus();
		return false;
	}
	
	else
	{
	if((document.all.txtEmail.value.indexOf("@")==-1)||(document.all.txtEmail.value.indexOf(".")==-1))
		{
			alert("Enter the valid email address");
			document.all.txtEmail.focus();
			return false;
		}
	}
	
	
if(FunScriptTagValidation(document.all.txtEmail.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.all.txtEmail.focus();
	return false;	
}
else
{
	document.all.txtEmail.value=replaceunwantedcharacters(document.all.txtEmail.value);
}

if(FunScriptTagValidation(document.all.txtCountry.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.all.txtCountry.focus();
	return false;	
}
else
{
	document.all.txtCountry.value=replaceunwantedcharacters(document.all.txtCountry.value);
}
	
	if(document.all.txtDesc.value=="")
	{
		alert("Enter Description.");
		document.all.txtDesc.focus();
		return false;
	}
	
if(FunScriptTagValidation(document.all.txtDesc.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.all.txtDesc.focus();
	return false;	
}
else
{
	document.all.txtDesc.value=replaceunwantedcharacters(document.all.txtDesc.value);
}
		
	if(document.all.txtTradeLeads.value=="")
	{
		alert("Enter Trade Leads.");
		document.all.txtTradeLeads.focus();
		return false;
	}
		
if(FunScriptTagValidation(document.all.txtTradeLeads.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.all.txtTradeLeads.focus();
	return false;	
}
else
{
	document.all.txtTradeLeads.value=replaceunwantedcharacters(document.all.txtTradeLeads.value);
}
	
	return true;

}

// validation for b2b_trade_add.asp end


// validation for b2b_trade_Reply.asp start
function validation_b2b_trade_Reply()
{
if(document.all.txtName.value=="")
	{
		alert("Enter Name.");
		document.all.txtName.focus();
		return false;
	}
	
if(FunScriptTagValidation(document.all.txtName.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.all.txtName.focus();
	return false;	
}
else
{
	document.all.txtName.value=replaceunwantedcharacters(document.all.txtName.value);
}
	
if(document.all.txtEmail.value=="")
	{
		alert("Enter Email.");
		document.all.txtEmail.focus();
		return false;
	}
	
	else
	{
	if((document.all.txtEmail.value.indexOf("@")==-1)||(document.all.txtEmail.value.indexOf(".")==-1))
		{
			alert("Enter the valid email address");
			document.all.txtEmail.focus();
			return false;
		}
	}
	
if(FunScriptTagValidation(document.all.txtEmail.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.all.txtEmail.focus();
	return false;	
}
else
{
	document.all.txtEmail.value=replaceunwantedcharacters(document.all.txtEmail.value);
}
	
	if(document.all.txtReply.value=="")
	{
		alert("Enter Reply.");
		document.all.txtReply.focus();
		return false;
	}
	
if(FunScriptTagValidation(document.all.txtReply.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.all.txtReply.focus();
	return false;	
}
else
{
	document.all.txtReply.value=replaceunwantedcharacters(document.all.txtReply.value);
}

	return true;
}

// validation for b2b_trade_Reply.asp end


//validation for b2b-trade.asp start
function validation_b2b_trade_search()
{
	
if(FunScriptTagValidation(document.frmb2btradeleads.txtsearchb2btradeleads.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.frmb2btradeleads.txtsearchb2btradeleads.focus();
	return false;	
}
else
{
	document.frmb2btradeleads.txtsearchb2btradeleads.value=replaceunwantedcharacters(document.frmb2btradeleads.txtsearchb2btradeleads.value);
}
document.frmb2btradeleads.submit();

return true;
}
//validation for b2b-trade.asp end

//validation for smecheckup start
function validation_smecheckup()
{
if (document.frmUserInfo.txtuser.value ==""){ 
alert("Please provide a User Name.");
document.frmUserInfo.txtuser.focus();
return false;
}

if(FunScriptTagValidation(document.frmUserInfo.txtuser.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.frmUserInfo.txtuser.focus();
	return false;	
}
else
{
	document.frmUserInfo.txtuser.value=replaceunwantedcharacters(document.frmUserInfo.txtuser.value);
}


if (document.frmUserInfo.txtpass.value ==""){
alert("Please provide a Password.");
document.frmUserInfo.txtpass.focus();
return false;
}

if(FunScriptTagValidation(document.frmUserInfo.txtpass.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.frmUserInfo.txtpass.focus();
	return false;	
}
else
{
	document.frmUserInfo.txtpass.value=replaceunwantedcharacters(document.frmUserInfo.txtpass.value);
}
return  true;
}
//validation for smecheckup end

//validation for b2bcheckup start
function validation_b2bcheckup()
{
if (document.frmUserInfo.txtuser.value ==""){ 
alert("Please provide a User Name.");
document.frmUserInfo.txtuser.focus();
return false;
}

if(FunScriptTagValidation(document.frmUserInfo.txtuser.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.frmUserInfo.txtuser.focus();
	return false;	
}
else
{
	document.frmUserInfo.txtuser.value=replaceunwantedcharacters(document.frmUserInfo.txtuser.value);
}


if (document.frmUserInfo.txtpass.value ==""){
alert("Please provide a Password.");
document.frmUserInfo.txtpass.focus();
return false;
}

if(FunScriptTagValidation(document.frmUserInfo.txtpass.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.frmUserInfo.txtpass.focus();
	return false;	
}
else
{
	document.frmUserInfo.txtpass.value=replaceunwantedcharacters(document.frmUserInfo.txtpass.value);
}
return  true;
}
//validation for b2bcheckup end


//validation for resmecheck start
function validation_resmecheck()
{
if (document.frmUserInfo.txtuser.value ==""){ 
alert("Please provide a User Name.");
document.frmUserInfo.txtuser.focus();
return false;
}

if(FunScriptTagValidation(document.frmUserInfo.txtuser.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.frmUserInfo.txtuser.focus();
	return false;	
}
else
{
	document.frmUserInfo.txtuser.value=replaceunwantedcharacters(document.frmUserInfo.txtuser.value);
}


if (document.frmUserInfo.txtpass.value ==""){
alert("Please provide a Password.");
document.frmUserInfo.txtpass.focus();
return false;
}

if(FunScriptTagValidation(document.frmUserInfo.txtpass.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.frmUserInfo.txtpass.focus();
	return false;	
}
else
{
	document.frmUserInfo.txtpass.value=replaceunwantedcharacters(document.frmUserInfo.txtpass.value);
}
return  true;

}

//validation for resmecheck end


//validation for memberdisp.asp start
function validation_members_search()
{

if(FunScriptTagValidation(document.frmbsearchmembers.txtsearchmembers.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.frmbsearchmembers.txtsearchmembers.focus();
	return false;	
}
else
{
	document.frmbsearchmembers.txtsearchmembers.value=replaceunwantedcharacters(document.frmbsearchmembers.txtsearchmembers.value);
}
document.frmbsearchmembers.submit();

return true;
}
//validation for memberdisp.asp end


// validation for validation_marketing_Intelligence_services_form start
function validation_marketing_Intelligence_services_form()
{
if(document.all.txtNameofCompany.value=="")
	{
		alert("Enter Name of Company");
		document.all.txtNameofCompany.focus();
		return false;
	}

	
if(FunScriptTagValidation(document.all.txtNameofCompany.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.all.txtNameofCompany.focus();
	return false;	
}
else
{
	document.all.txtNameofCompany.value=replaceunwantedcharacters(document.all.txtNameofCompany.value);
}




if(FunScriptTagValidation(document.all.txtNameofCEO_MD.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.all.txtNameofCEO_MD.focus();
	return false;	
}
else
{
	document.all.txtNameofCEO_MD.value=replaceunwantedcharacters(document.all.txtNameofCEO_MD.value);
}

if(document.all.txtAddress.value=="")
	{
		alert("Enter Address");
		document.all.txtAddress.focus();
		return false;
	}
if(FunScriptTagValidation(document.all.txtAddress.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.all.txtAddress.focus();
	return false;	
}
else
{
	document.all.txtAddress.value=replaceunwantedcharacters(document.all.txtAddress.value);
}

if(FunScriptTagValidation(document.all.txtCity.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.all.txtCity.focus();
	return false;	
}
else
{
	document.all.txtCity.value=replaceunwantedcharacters(document.all.txtCity.value);
}

if(FunScriptTagValidation(document.all.txtState.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.all.txtState.focus();
	return false;	
}
else
{
	document.all.txtState.value=replaceunwantedcharacters(document.all.txtState.value);
}

if(FunScriptTagValidation(document.all.txtPin.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.all.txtPin.focus();
	return false;	
}
else
{
	document.all.txtPin.value=replaceunwantedcharacters(document.all.txtPin.value);
}

if(document.all.txtEmail.value=="")
	{
		alert("Enter Email.");
		document.all.txtEmail.focus();
		return false;
	}
	
	else
	{
	if((document.all.txtEmail.value.indexOf("@")==-1)||(document.all.txtEmail.value.indexOf(".")==-1))
		{
			alert("Enter the valid email address");
			document.all.txtEmail.focus();
			return false;
		}
	}
	
	
if(FunScriptTagValidation(document.all.txtEmail.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.all.txtEmail.focus();
	return false;	
}
else
{
	document.all.txtEmail.value=replaceunwantedcharacters(document.all.txtEmail.value);
}


if(FunScriptTagValidation(document.all.txtWebsite.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.all.txtWebsite.focus();
	return false;	
}
else
{
	document.all.txtWebsite.value=replaceunwantedcharacters(document.all.txtWebsite.value);
}

if(FunScriptTagValidation(document.all.txtTelphone_no.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.all.txtTelphone_no.focus();
	return false;	
}
else
{
	document.all.txtTelphone_no.value=replaceunwantedcharacters(document.all.txtTelphone_no.value);
}

if(FunScriptTagValidation(document.all.txtMobile_no.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.all.txtMobile_no.focus();
	return false;	
}
else
{
	document.all.txtMobile_no.value=replaceunwantedcharacters(document.all.txtMobile_no.value);
}

if(FunScriptTagValidation(document.all.txtFax_no.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.all.txtFax_no.focus();
	return false;	
}
else
{
	document.all.txtFax_no.value=replaceunwantedcharacters(document.all.txtFax_no.value);
}


if(document.all.txtProducts_Services.value=="")
	{
		alert("Enter Product(s)/Services");
		document.all.txtProducts_Services.focus();
		return false;
	}


if(FunScriptTagValidation(document.all.txtProducts_Services.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.all.txtProducts_Services.focus();
	return false;	
}
else
{
	document.all.txtProducts_Services.value=replaceunwantedcharacters(document.all.txtProducts_Services.value);
}

if(FunScriptTagValidation(document.all.txtInformation_Sought.value)==false)
{	
	alert("Please do not use Single quote, Semi colon, --  characters.");
	document.all.txtInformation_Sought.focus();
	return false;	
}
else
{
	document.all.txtInformation_Sought.value=replaceunwantedcharacters(document.all.txtInformation_Sought.value);
}
	
	return true;

}


// validation for validation_marketing_Intelligence_services_form end





// script tag validation function start
function FunScriptTagValidation(data)
	{
		str=data.toLowerCase();
		str=removespacesfromstring(str);
		var flag=true;
		if(str.indexOf("<script>")!=-1 || str.indexOf("</script>")!=-1 || str.indexOf("<script")!=-1 || str.indexOf("script>")!=-1
		|| str.indexOf("</script")!=-1)
		{
			flag=false;				
		}
		return flag;
		
		/*var bool=true;
		var bool1=true;
		var returnBool=true;
		var charval;
		
		data=data.toLowerCase();
				
		charval=data.indexOf("<");
		if(bool==true)
		{
			if(eval(charval)!=-1)
			{
				bool=false;
			}
		}
		charval=data.indexOf(">");
		if(bool==false)
		{
			if(eval(charval)!=-1)
			{
				bool1=false;
			}
		}
		charval=data.indexOf("script");
		if(bool1==false)
		{
			if(eval(charval)!=-1)
			{
				returnBool=false;
			}
		}
		
		if(returnBool==true)
		{
			return true;
		}
		else
		{
			return false;
		}*/		
	}
// script tag validation function end

// function to remove spaces from string start
function removespacesfromstring(str)
{
var tempstr;
tempstr=str;
tempstr=tempstr.replace (/\s+/g, '');
return tempstr;
}
// function to remove spaces from string end


// function replace function for unwanded character start
function replaceunwantedcharacters(str)
{
	/*var tempstr=str;
	tempstr=replaceSubstring(str, "'", "`")
	return tempstr;
	*/	
	var tempstr;
	tempstr=str;
	tempstr=tempstr.replace (/'+/g, '`');
	return tempstr;
}

function replaceSubstring(inputString, fromString, toString) 
{
   // Goes through the inputString and replaces every occurrence of fromString with toString
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      // Find a string that doesn't exist in the inputString to be used
      // as an "inbetween" string
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      } // Keep on going until we build an "inbetween" string that doesn't exist
      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      // Next, replace the "inbetween" string with the "toString"
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } // Ends the check to see if the string being replaced is part of the replacement string or not
   return temp; // Send the updated string back to the user
} // Ends the "replaceSubstring" function
// function replace function for unwanded character end







