var r={
  'special':/[\W]/g,
  'quotes':/['\''&'\"']/g,
  'notnumbers':/[^\d]/g
}

function valid(o,w){
  o.value = o.value.replace(r[w],'');
}

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 assign_value(tocontrol,valueto)
{
	tocontrol.value= valueto;
}
function Isalpha(strCharacter)
   //  check for valid numeric strings 
   {
   var strValidAlpha = " ABCDEFGHIJKLMNOPQRSTWXYZ.abcdefghijklmnopqrstuvwxyz.-";
   var strAlpha;
   var blnResult = true;

   if (strCharacter.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strCharacter.length && blnResult == true; i++)
      {
      strAlpha = strCharacter.charAt(i);
      if (strValidAlpha.indexOf(strAlpha) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
   
   function IsNumeric(strString)
   //  check for valid numeric strings 
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
   

function Email(str)
		{
			var supported = 0;
			if (window.RegExp)
			{
			var tStr = "a";
			var tReg = new RegExp(tStr);
			if (tReg.test(tStr)) supported = 1;
			}
			if (!supported)
			return (str.indexOf(".") <= 5) || (str.indexOf("@") < 0);
			var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
			var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
			return (r1.test(str) || !r2.test(str));
		}
function EmailAddr(str) 
		{
		    return str.match(/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/);
		}


//------------------------------------------------XXXX------------------------------------------------------////

 function select_cat(cat)
    {
	    document.frmhome.category.value= cat;
	} 
 
 

 
 	

 
 

/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Michael J. Damato | http://developing.damato.net/ */
// State lists

 
 //Div format new Rajiv
 function toggleLayer( whichLayer )
{
	var elem, vis;
	if( document.getElementById ) // this is the way the standards work
		elem = document.getElementById( whichLayer );
	else if( document.all ) // this is the way old msie versions work
		elem = document.all[whichLayer];
	else if( document.layers ) // this is the way nn4 works
		elem = document.layers[whichLayer];
	vis = elem.style;
	// if the style.display value is blank we try to figure it out here
	if( vis.display == '' && elem.offsetWidth != undefined && elem.offsetHeight != undefined )
		vis.display = ( elem.offsetWidth != 0 && elem.offsetHeight != 0 ) ? 'block':'none';
	vis.display = ( vis.display == '' || vis.display == 'block' ) ? 'none':'block';
}

function disableSubmit(whichButton)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		document.getElementById(whichButton).disabled = true;
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		document.all[whichButton].disabled = true;
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		document.layers[whichButton].disabled = true;
	}
}

function confirmDelete()
{
    var agree=confirm("Are you sure you wish to delete this entry?");
    if (agree)
        return true;
    else
        return false;
}

function returnObjById( id )
{
	if (document.getElementById)
		var returnVar = document.getElementById(id);
	else if (document.all)
		var returnVar = document.all[id];
	else if (document.layers)
		var returnVar = document.layers[id];
	return returnVar;
}

function setHandler( tagType, clsName, eventType, func )
{
	elements = document.getElementsByTagName( tagType );
	for( var t = 0; t < elements.length; t++ )
	{
		if( elements[t].className.indexOf( clsName ) >= 0 )
		{
			var code = "elements[t]." + eventType + " = " + func;
			eval( code );
		}
	}
}

function toggleColor( )
{
	var style2 = this.style;
	style2.backgroundColor = style2.backgroundColor? "":"#FFFF00";
}

function toggleBgColor( elem )
{
	var style2 = elem.style;
	style2.backgroundColor = style2.backgroundColor? "":"#FFFF00";
}

function externalLinks( )
{
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++)
	{
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
	}
}

function initpage( )
{
	setHandler( 'tr', 'toggle', 'onclick', 'toggleColor' );
	setHandler( 'span', 'heading', 'onmouseover', 'toggleColor' );
	setHandler( 'span', 'heading', 'onmouseout', 'toggleColor' );
	externalLinks( );
}
if( top.location != self.location )
		top.location = self.location;
window.onload = initpage;


//new js for category like that
// close layer when click-out
var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;
  
  // open hidden layer
  function m1open(id)
  {	
  	// cancel close timer
	
  	m1cancelclosetime();
  	// close old layer
  	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';  
  	// get new layer and show it
  	ddmenuitem = document.getElementById(id);
  	ddmenuitem.style.visibility = 'visible';
  
  }
  // close showed layer

function validation()
{

					if (document.frmcon.name.value==0)
					{
					alert("Please Enter the full name");
					document.frmcon.name.focus();
					document.frmcon.name.select();
					return false;
					}

				if (document.frmcon.contactno.value==0)
					{
					alert("Please Enter your Contact No");
					document.frmcon.contactno.focus();
					document.frmcon.contactno.select();
					return false;
					}					
					
					if (Email(document.frmcon.email.value))
					{
					alert("Please Enter email");
					document.frmcon.email.focus();
					document.frmcon.email.select();
					return false;
					}
					if (document.frmcon.subject.value==0)
					{
					alert("Please Enter the subject");
					document.frmcon.subject.focus();
					document.frmcon.subject.select();
					return false;
					}
					if (document.frmcon.description.value==0)
					{
					alert("Please Enter the your description/comments");
					document.frmcon.description.focus();
					document.frmcon.description.select();
					return false;
					}							
					document.frmcon.submit();
}
