function isalphanumeric(thisform)
		{	
			if ((event.keyCode == 32) || (event.keyCode >= 48 && event.keyCode <= 57 )  || (event.keyCode >=65 && event.keyCode <=90 )|| (event.keyCode >=97 && event.keyCode <=122)) 
			{
				event.returnValue = true;
			}
			else
			{
				
				event.returnValue = false;
			}
			
		}






function isAlphabeticCharacter(thisform)
		{
			if((event.keyCode >=65 && event.keyCode <=90)|| (event.keyCode >=97 && event.keyCode <=122) || (event.keyCode == 32))
			{
				event.returnValue=true;
			}
			else
			{
				//alert("Only Characters are allowed");
				event.returnValue=false;
			}
		}



function SpCharCheck(val)
{
	var char1,vals,fla;
	vals = val;
	for (var i=0;i<vals.length;i++)
		{	
		char1 = vals.substring(i,i+1); 
		
		if ((char1=='>')||(char1=='"')||(char1=="'")||(char1=='<')||(char1=='@')||(char1=='!')||(char1=='~')||(char1=='#')||(char1=='$')||(char1=='%')||(char1=='&')||(char1=='*'))
		{
			fla=1;
			break;	
		}	
		else
		{
			fla=0;
		}	
		}		
	if (fla == 1)
	{
		val.focus();
		return false;
	}
	else
	{
		return true;
	}
} 










function blockspecialchar(e,txt)
{
var len=txt.value.length

var isNS4 = (navigator.appName=="Netscape")?1:0;

if(!isNS4)
{
if(len==0 && (event.keyCode >= 47 && event.keyCode < 57 )) 
{
	//alert("First Letter Should Always Be Alphabet");
	event.returnValue=false
}
if ((event.keyCode > 32 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 65) || (event.keyCode > 90 && event.keyCode < 97) || (event.keyCode > 122 && event.keyCode < 127)) event.returnValue = false;
}
else
{
if(len==0 && (e >= 47 && e < 57 )) return false
if ((e > 32 && e < 48) || (e > 57 && e < 65) || (e > 90 && e < 97)) return false;

}
}

function search_keyword()
{
	if(trim(document.frmconsumer_mag.searchkeyword.value)=="")
	{
		alert("Please enter any keyword to search.");
		document.frmconsumer_mag.searchkeyword.focus();
		return false;
	}
	document.frmconsumer_mag.method="post";
	document.frmconsumer_mag.action="Home_SearchKeyword.asp?WhichTable=1";
	document.frmconsumer_mag.submit();
	//return false;
}

function clicksubmit()
{	
		
	if (event.keyCode == 13)
	{
		event.returnValue = true;
		search_keyword()
		return false;
	}
	
}

function isEmail( theValue )
{
	var chk_mail = "true"
	var ch = ""
	var at = ""
	var dot=""
	theValue = trim(theValue) ;  /* ------  removes leading & trailing spaces ------ */
	var theLen = theValue.length 
	
									
	if(theValue.indexOf('@', 0) == -1)  /*---- if @ is not present ---- */
	{
		alert("Email must contain domain name");
		return(false) ;
	}
	if(theValue.charAt(0)=='@' || theValue.charAt(theLen)=='@' || theValue.charAt(theLen-1)=='@')
	{
		alert("@ not allowed at start or end of email") ;
		return false ;
	}
	
	/* ------  no dot allowed at start, end  ------ */
	if(theValue.charAt(0)=='.' || theValue.charAt(theLen)=='.' || theValue.charAt(theLen-1)=='.')
	{
		alert("dot(.) not allowed at start or end of email") ;
		return false ;
	}
	/*----------no _ allowed at the start or end-----------*/
	if(theValue.charAt(0)=='_' || theValue.charAt(theLen)=='_' || theValue.charAt(theLen-1)=='_')
	{
		alert("_ not allowed at start or end of email") ;
		return false ;
	}
	/*-----------no - allowed at the start or end----------*/
	if(theValue.charAt(0)=='-' || theValue.charAt(theLen)=='-' || theValue.charAt(theLen-1)=='-')
	{
		alert("No special characters allowed at start or end of email") ;
		return false ;
	}
	
	at = theValue.indexOf('@', 0) ;

	dotat=theValue.indexOf('.',0) ;	

	if( theValue.charAt(dotat+1) == '.' || theValue.charAt(dotat+1) == '@' )
	{
		alert("Dot and @ are not allowed immediately following the dot in email") ;
		return false ;
	}

	/*  ----  no @ or dot allowed following @ ----  */
	if( theValue.charAt(at+1) == '.' || theValue.charAt(at+1) == '@' )
	{
		alert("Dot and @ are not allowed immediately following the @ in email") ;
		return false ;
	}
		
	if ((theValue.indexOf('@', at+1))!=-1)  /* ---  multiple @ in email-id  ---  */
	{
		alert("Multiple @ are not allowed in email ");
		return false ;
	}	
	
	/* ------  no @ allowed at start, end  ------ */
	
				
	if(theValue.indexOf(" ",0) != -1)  /* ---- blank spaces present in email-id  ----  */
	{
		alert("Blank spaces are not allowed in email") ;
		return false ;
	}

	for (k = 0 ; k < theLen ; ++k)
	{
		ch =  theValue.substring(k, k+1)
		if (ch =="@")
		{
			if(theValue.substring(k, theLen)=='@')
			{
				return false ;
			}
			if(theValue.indexOf('.', k) == -1) /* --- dot not present after @ ---  */
			{
				alert("Invalid Email Id")
				return false ;
			}
		}
		
		/*  ------  no dot allowed immediately following @  ------  */
		if ((ch == '.')&&(theValue.substring(k+1, k+2) == "."))
		{
			alert("Consecutive dots are not allowed in email") ;
			dot = k
			return false ;					
		}

		if (!( (ch >= 'a' && ch <= "z") || (ch >= 'A' && ch <= "Z") || (ch >= '0' && ch <= "9") || ch =="@" || ch =="." || ch =="_" || ch =="-" ))
		{
			alert("No special characters allowed except @, dot(.)") ;
			return false ;					
		}
	}  /* ---  end of for loop  ---  */

	for(var j=theValue.indexOf('.', at);j<=theLen;++j)
	{
		if(theValue.charAt(j)>='0' && theValue.charAt(j)<='9')
		{
			alert("Invalid domain name  ");
			return false;
			break;
		}
	}

	return true            /*  ------ if no above condition found to be true ------  */
}  //   end of isEmail()

// -----------The Function trim() is used to trim the balnk Spaces ----------------
function trim(str)
{
	var strReturn = str ;
	var i = 0 ;
	for(i = 0;i< strReturn.length;i++)
	{
		if(!(strReturn.charAt(i)==' '))
			break ;
	}
	strReturn = strReturn.substring(i);
	for(i = strReturn.length ; i>0 ; i--)
	{
		if(!(strReturn.charAt(i-1)==' '))
			break;
	}
	strReturn = strReturn.substring(0,i);
	return strReturn;
}

//-----------------------END of Function trim ------------------------------------------
//-----------------------Is Alphabetic-----------------------
function isAlphabetic(str)
	// returns true if str is alphabetic
	// that is only A-Z a-z or space
	// returns false otherwise
	// returns false if empty
	{
		var len= str.length;
		if (len==0)
		return false;
		//else
		var p=0;
		var ok= true;
		var ch= "";
		while (ok && p<len)
		{
		ch= str.charAt(p);
		if (  ('A'<=ch && ch<='Z')
		||('a'<=ch && ch<='z')
		||(ch==" ")
		)
		p++;
		else
		ok= false;
		}
		return ok;
	}	


//--------------------End Alphabetic Function----------------------




function loadTwistees()
{
	//****LOAD THE TWISTEE IMAGES
	closetwistee = new Image()
	opentwistee = new Image
	closetwistee.src = "../images/right_arrow_close.gif"
	opentwistee.src = "../images/right_arrow_open.gif"

}
function loadTwistees1()
{
	//****LOAD THE TWISTEE IMAGES
	closetwistee = new Image()
	opentwistee = new Image
	nutraltwistee = new Image 
	closetwistee.src = "images/TwistyPlus.gif"
	opentwistee.src = "images/TwistyMinus.gif"
	nutraltwistee.src = "images/TwistyNeutral.gif"
}
	//-----------------------Nischal 31/03/04-------------------
function isnumeric(thisform)
{	

	var ch=thisform.value.indexOf('.');
	
	if ((event.keyCode < 48 || event.keyCode > 57 ) && event.keyCode != 46) 
	{
	event.returnValue = false;
	}
	else if(thisform.value.indexOf('.',ch+1)!=-1)
	{ 
	   event.returnValue = false;
	}
}

function isInt()
{	
	
	if ((event.keyCode < 48 || event.keyCode > 57 ) && event.keyCode!=46) 
	{
	event.returnValue = false;
	}
}

//-----------------------END of Function isnumeric() ------------------------------------------


 function isphone(thisform) 
{	
		if ((event.keyCode < 47 || event.keyCode > 57)&& event.keyCode!=45 && event.keyCode !=44) 
	 	event.returnValue = false;
	
}

 function isfax(thisform) 
{	
		if ((event.keyCode < 47 || event.keyCode > 57)&& event.keyCode!=45 && event.keyCode !=44) 
	 	event.returnValue = false;
	
}
//-----------------------END of Function isphone() ------------------------------------------



function textcounter(field, countfield, maxlimit)
	{
	if (field.value.length > maxlimit)  
	field.value = field.value.substring(0, maxlimit); 
	else 
	countfield.value = maxlimit - field.value.length; 
	}
	
	
function formatDecimal(argvalue, addzero, decimaln) {
  var numOfDecimal = (decimaln == null) ? 2 : decimaln;
  var number = 1;

  number = Math.pow(10, numOfDecimal);

  argvalue = Math.round(parseFloat(argvalue) * number) / number;
  // If you're using IE3.x, you will get error with the following line.
  // argvalue = argvalue.toString();
  // It works fine in IE4.
  argvalue = "" + argvalue;

  if (argvalue.indexOf(".") == 0)
    argvalue = "0" + argvalue;

  if (addzero == true) {
    if (argvalue.indexOf(".") == -1)
      argvalue = argvalue + ".";

    while ((argvalue.indexOf(".") + 1) > (argvalue.length - numOfDecimal))
      argvalue = argvalue + "0";
  }

  return argvalue;
}

	
function SpCharCheck(val)
{
	var char1,vals,fla;
	vals = val;
	for (var i=0;i<vals.length;i++)
		{	
		char1 = vals.substring(i,i+1); 
		
		if ((char1=='>')||(char1=='"')||(char1=="'")||(char1=='<')||(char1=='@')||(char1=='!')||(char1=='~')||(char1=='#')||(char1=='$')||(char1=='%')||(char1=='&')||(char1=='*'))
		{
			fla=1;
			break;	
		}	
		else
		{
			fla=0;
		}	
		}		
	if (fla == 1)
	{
		val.focus();
		return false;
	}
	else
	{
		return true;
	}
} 
//---------------------Function for Zip Code-------------------------------
function alphanumeric(val)
{
var ch;

for (k = 0 ; k < val.length ; ++k)
	{
		ch =  val.substring(k, k+1);
if (!( (ch >= 'a' && ch <= "z") || (ch >= 'A' && ch <= "Z") || (ch >= '0' && ch <= "9") || ch =="-"  ))
		{
			alert("No special characters allowed in Zip Code") ;
			return true ;
			break;					
		}
	}
}
//--------------------End of Function for Zip Code--------------------------




//NUMERIC KEY PRESS WITHOUT POINT(.)
function NumericKeyPress1(e) 
{  
	var keynum ;
	var keychar ;
	var numcheck ;
	if(window.event) // IE 
	{ 
		keynum = e.keyCode ;
		keychar = String.fromCharCode(keynum) ;
		numcheck = /\d/ ;
		if( numcheck.test(keychar)) 
		{ 
			return true; 
		} 
		else 
		{ 
			return false; 
		} 
	} 
	else if(e.which) // Netscape/Firefox/Opera 
	{ 
		keynum = e.which;
		keychar = String.fromCharCode(keynum); 
		numcheck = /\d/; 
		
		if(keychar=='\b') 
			return true; 
		if( numcheck.test(keychar)) 
		{
			return true; 
		} 
		else 
		{ 
			return false; 
		} 
	} 
 } 


//NUMERIC KEY PRESS WITH POINT(.)
function NumericKeyPress()
{
	if (event.keyCode < 45 || event.keyCode > 57) 
	event.returnValue = false;
}

			
  
  //For Checking the height and width of the url image
  
	function checkHeight(val,obj,width,height)
	{
 
		var index=val.indexOf("src=");
		var indexEnd=val.indexOf("</a>");
		var str=(val.substring(index+5,indexEnd-2 ));
		
		obj.style.display="";
		obj.src=str;
 
		if(obj.width>width)
		{
			obj.style.display="none";
			alert("Image Size Should Be "+width+"X"+height);
			return false;
		}
		if(obj.height>height)
		{
			obj.style.display="none";
			alert("Image Size Should Be "+width+"X"+height);
			return false;
		}
		
	}
	
	
	function isValidURL(url)
{ 
    
    var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/; 
    if(RegExp.test(url))
    { 
        return true; 
    }
    else
    { 
        return false; 
    } 
} 
function isValidLink(theValue)
{ 
 
    if(theValue.substring(0,2)!='<a')
    { 
       //alert("please enter corect link");
        return false; 
    }
    else
    { 
        return true; 
    } 
	
} 



function isAlphabetStart( theValue )
{
	
	if( theValue.charAt(0)=='@' || theValue.charAt(0)=='.' || theValue.charAt(0)=='-' || theValue.charAt(0)==',' || theValue.charAt(0)==':' || theValue.charAt(0)==';' || theValue.charAt(0)=='"' || theValue.charAt(0)=='+' || theValue.charAt(0)=='_' || theValue.charAt(0)=='?' || theValue.charAt(0)=='>' || theValue.charAt(0)=='<' || theValue.charAt(0)=='[' || theValue.charAt(0)==']' )
	{
		
		return false;
		
	}
	else
	{
		return true;
	}
	
}