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 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 adbox()
{
	if (document.adfrom.id.value.length == 0) 
	{
		alert("Enter Ad number!");
		return false
	} 
	else if (IsNumeric(document.adfrom.id.value) == false) 
	{
		alert("Ad # must be Number!");
		return false
	}
    document.adfrom.submit();
}

*/

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}$/);
		}
		
function shareidea()
{
		if (document.addrecipe.recipe_name.value==0)
		{
		alert("Please Enter Recipe Name");
		document.addrecipe.recipe_name.focus();
		document.addrecipe.recipe_name.select();
		return false;
		}
		
		if (document.addrecipe.recipe_description.value==0)
		{
		alert("Please Enter Recipe Name");
		document.addrecipe.recipe_description.focus();
		document.addrecipe.recipe_description.select();
		return false;
		}
		
		if (document.addrecipe.ingredients.value==0)
		{
		alert("Please Enter Recipe Name");
		document.addrecipe.ingredients.focus();
		document.addrecipe.ingredients.select();
		return false;
		}
		if (document.addrecipe.preparation.value==0)
		{
		alert("Please Enter Recipe Name");
		document.addrecipe.preparation.focus();
		document.addrecipe.preparation.select();
		return false;
		}
		
		if ( ( document.addrecipe.type[0].checked == false ) && ( document.addrecipe.type[1].checked == false ) )
		{
		alert ( "Please choose your Type: Veg or Nonveg" ); 
		return false; 
		}
		if (!EmailAddr(document.addrecipe.user_id.value))
		{
		alert("Please enter valid email id!");
		document.addrecipe.user_id.focus();
		document.addrecipe.user_id.select();
		return false;
		}
		
		document.addrecipe.submit();

}

function requestrecipe()
{
		if (document.reqrecipe.name.value==0)
		{
		alert("Please Enter Recipe Name");
		document.reqrecipe.name.focus();
		document.reqrecipe.name.select();
		return false;
		}
		
		if (!EmailAddr(document.reqrecipe.email.value))
		{
		alert("Please enter valid email id!");
		document.reqrecipe.email.focus();
		document.reqrecipe.email.select();
		return false;
		}
		
			if ( ( document.reqrecipe.type[0].checked == false ) && ( document.reqrecipe.type[1].checked == false ) )
		{
		alert ( "Please choose your Type: Veg or Nonveg" ); 
		return false; 
		}
		
		if (document.reqrecipe.country.value==0)
		{
		alert("Please Enter the Country");
		document.reqrecipe.country.focus();
		document.reqrecipe.country.select();
		return false;
		}
		
		
		if (document.reqrecipe.recipe_requirements.value==0)
		{
		alert("Please Enter the Recipe Like / Dislike");
		document.reqrecipe.recipe_requirements.focus();
		document.reqrecipe.recipe_requirements.select();
		return false;
		}
		if (document.reqrecipe.other_details.value==0)
		{
		alert("Please Enter Dinner Planning");
		document.reqrecipe.other_details.focus();
		document.reqrecipe.other_details.select();
		return false;
		}
		
	
		
		
		document.reqrecipe.submit();

}

function requestrecipe2()

{

	if ( ( document.frm_recipe.type[0].checked == false ) && ( document.frm_recipe.type[1].checked == false ) )
		{
		alert ( "Please choose your Type: Veg or Nonveg" ); 
		return false; 
		}

		if (document.frm_recipe.recipe_name.value==0)
		{
		alert("Please Enter the Recipe Name");
		document.frm_recipe.recipe_name.focus();
		document.frm_recipe.recipe_name.select();
		return false;
		}
				
		if (document.frm_recipe.ingredients.value==0)
		{
		alert("Please Enter the Ingredients");
		document.frm_recipe.ingredients.focus();
		document.frm_recipe.ingredients.select();
		return false;
		}
		
	/*	
		if (document.frm_recipe.prep_time.value==0)
		{
		alert("Please Enter the Preperation Time");
		document.frm_recipe.prep_time.focus();
		document.frm_recipe.prep_time.select();
		return false;
		}
		
		if (document.frm_recipe.cook_time.value==0)
		{
		alert("Please Enter the Cook Time");
		document.frm_recipe.cook_time.focus();
		document.frm_recipe.cook_time.select();
		return false;
		}
		*/
		
		if (document.frm_recipe.recipe_description.value==0)
		{
		alert("Please Enter the Recipe Description");
		document.frm_recipe.recipe_description.focus();
		document.frm_recipe.recipe_description.select();
		return false;
		}
		if (document.frm_recipe.preparation.value==0)
		{
		alert("Please Enter the Preparation Method");
		document.frm_recipe.preparation.focus();
		document.frm_recipe.preparation.select();
		return false;
		}
				
		
		document.frm_recipe.submit();

}




/*

function news_events_forms()
{			
if (document.news_events.news_title.value==0)
	{
	alert("Please Enter your Title");
	document.news_events.news_title.focus();
	document.news_events.news_title.select();
	return false;
	}
	if (document.news_events.news_details.value==0)
	{
	alert("Please Enter your Description");
	document.news_events.news_details.focus();
	document.news_events.news_details.select();
	return false;
	}
	document.news_events.submit();
}	
//------------------------------------------------XXXX------------------------------------------------------////
function business_listing()
{
if (document.directory.category.value==0)
 {
   alert("Please Select Your Business Category");
   document.directory.category.focus();
   document.directory.category.select();
   return false;
  } 
if (document.directory.business_name.value==0)
 {
   alert("Please enter Your Business Name");
   document.directory.business_name.focus();
   document.directory.business_name.select();
   return false;
  } 
  if (document.directory.name.value==0)
 {
   alert("Please enter Your  Name");
   document.directory.name.focus();
   document.directory.name.select();
   return false;
  } 
   if (document.directory.address1.value==0)
 {
   alert("Please enter Your  Address");
   document.directory.address1.focus();
   document.directory.address1.select();
   return false;
  } 
    if (document.directory.phone.value==0)
 {
   alert("Please enter Your Phone");
   document.directory.phone.focus();
   document.directory.phone.select();
   return false;
  } 
  if (document.directory.product_desc.value==0)
 {
   alert("Please enter Your Product/Servive");
   document.directory.product_desc.focus();
   document.directory.product_desc.select();
   return false;
  } 
  if (Email(document.directory.user_id.value))
 {
   alert("Please enter Your valid Email_id");
   document.directory.user_id.focus();
   document.directory.user_id.select();
   return false;
  } 
document.directory.submit();
}

 function select_cat(cat)
    {
	    document.frmhome.category.value= cat;
	} 

function mag_register(mode)
{		
 	if (document.mag_reg.first_name.value==0)
	{
		alert("Please enter your name");
		document.mag_reg.first_name.focus();
		document.mag_reg.first_name.select();
		return false;
	}
	 
	if (document.mag_reg.address1.value==0)
	{
		alert("Please enter your address!");
		document.mag_reg.address1.focus();
		document.mag_reg.address1.select();
		return false;
	}
	if (document.mag_reg.city.value==0)
	{
	alert("Please enter your city!");
	document.mag_reg.city.focus();
	document.mag_reg.city.select();
	return false;
	}
	
	if (document.mag_reg.pincode.value==0)
	{
	alert("Please enter your Postal Code!");
	document.mag_reg.pincode.focus();
	document.mag_reg.pincode.select();
	return false;
	}
	if (document.mag_reg.phone.value==0)
	{
		alert("Please enter your phone./mobile number");
		document.mag_reg.phone.focus();
		document.mag_reg.phone.select();
	return false;
	}
    if (document.mag_reg.email.value==0)
	{
		alert("Please enter your email!");
		document.mag_reg.email.focus();
		document.mag_reg.email.select();
	return false;
	}
	if (document.mag_reg.validator.value==0)
	{
		alert("Enter validation number shown in last!");
		document.mag_reg.validator.focus();
		document.mag_reg.validator.select();
	return false;
	}
	if (Email(document.mag_reg.email.value))
	{
	alert("Please enter valid email!");
	document.mag_reg.email.focus();
	document.mag_reg.email.select();
	return false;
	}
	
 
	document.mag_reg.submit();
}	

function new_register()
{	 
 
	if (document.new_reg.first_name.value==0)
	{
	alert("Please enter your name");
	document.new_reg.first_name.focus();
	document.new_reg.first_name.select();
	return false;
	}	

	if (!EmailAddr(document.new_reg.user_id.value))
	{
	alert("Please enter valid email id!");
	document.new_reg.user_id.focus();
	document.new_reg.user_id.select();
	return false;
	}		
	if (document.new_reg.address1.value==0)
	{
	alert("Please enter your address1");
	document.new_reg.address1.focus();
	document.new_reg.address1.select();
	return false;
	}
 	if (document.new_reg.adz_country.value==0)
	{
	alert("Please enter your Country");
	document.new_reg.adz_country.focus();
	document.new_reg.adz_country.select();
	return false;
	}
 	if (document.new_reg.validator.value==0)
	{
	alert("Enter the letters as are shown in the image above");
	document.new_reg.validator.focus();
	document.new_reg.validator.select();
	return false;
	}
  	if (document.new_reg.terms.checked==0)
	{
	alert("You must agree our user agreement to complete registration.");
	document.new_reg.terms.focus();
	document.new_reg.terms.select();
	return false;
	}
	document.new_reg.submit();
}



function share_ideas()
{	 
 
	if (document.addrecipe.recipe_name.value==0)
	{
	alert("Please enter Recipe Name");
	document.addrecipe.recipe_name.focus();
	document.addrecipe.recipe_name.select();
	return false;
	}	

	if (!EmailAddr(document.addrecipe.user_id.value))
	{
	alert("Please enter valid email id!");
	document.addrecipe.user_id.focus();
	document.addrecipe.user_id.select();
	return false;
	}		
	
	
	function checkForm(form) {
for (var i=0; i<form.button.length; i++) {
if (form.button.checked == false) {
alert("you have to choose a button");
return false;
}
}
alert("this is not working"); 



	if (document.addrecipe.type.checked== false)
	{
	alert("you have to choose a button");
	return false;
	}
 	if (document.new_reg.adz_country.value==0)
	{
	alert("Please enter your Country");
	document.new_reg.adz_country.focus();
	document.new_reg.adz_country.select();
	return false;
	}
 	if (document.new_reg.validator.value==0)
	{
	alert("Enter the letters as are shown in the image above");
	document.new_reg.validator.focus();
	document.new_reg.validator.select();
	return false;
	}
  	if (document.new_reg.terms.checked==0)
	{
	alert("You must agree our user agreement to complete registration.");
	document.new_reg.terms.focus();
	document.new_reg.terms.select();
	return false;
	}
	document.new_reg.submit();
}












function yellow_register()
{	
	if (document.yellow_registration.company_name.value==0)
	{
		alert("Please enter your Company or Business name!");
		document.yellow_registration.company_name.focus();
		document.yellow_registration.company_name.select();
		return false;
	}	
	if (document.yellow_registration.address1.value==0)
	{
		alert("Please enter your Company or Business address!");
		document.yellow_registration.address1.focus();
		document.yellow_registration.address1.select();
		return false;
	}	
	if (document.yellow_registration.yellow_city.value==0)
	{
		alert("Please enter your City!");
		document.yellow_registration.yellow_city.focus();
		document.yellow_registration.yellow_city.select();
		return false;
	}	
	if (document.yellow_registration.yellow_country.value==0)
	{
		alert("Please enter your Country!");
		document.yellow_registration.yellow_country.focus();
		document.yellow_registration.yellow_country.select();
		return false;
	}	
	if (document.yellow_registration.company_name.value==0)
	{
		alert("Please enter your Company or Business name!");
		document.yellow_registration.company_name.focus();
		document.yellow_registration.company_name.select();
		return false;
	}	
	if (document.yellow_registration.company_name.value==0)
	{
		alert("Please enter your Company or Business name!");
		document.yellow_registration.company_name.focus();
		document.yellow_registration.company_name.select();
		return false;
	}	
	if (document.yellow_registration.company_name.value==0)
	{
		alert("Please enter your Company or Business name!");
		document.yellow_registration.company_name.focus();
		document.yellow_registration.company_name.select();
		return false;
	}	
	
	document.yellow_registration.submit();
}
function publisher()
{
 
	if (document.frmpublisher.pubtitle.value=="")
	{
		alert("Please enter your blog title");
		document.frmpublisher.pubtitle.focus();
		document.frmpublisher.pubtitle.select();
		return false;
	}

	if (document.frmpublisher.category.value==0)
	{
		alert("Select blog category");
		document.frmpublisher.category.focus();
		document.frmpublisher.category.select();
		return false;
	}	
	if (document.frmpublisher.first_name.value==0)
	{
		alert("Please enter your name");
		document.frmpublisher.first_name.focus();
		document.frmpublisher.first_name.select();
		return false;
	}
	if (document.frmpublisher.pubcontent.value==0)
	{
		alert("Please enter blog content");
		document.frmpublisher.pubcontent.focus();
		document.frmpublisher.pubcontent.select();
		return false;
	}			
	if (!EmailAddr(document.frmpublisher.user_id.value))
	{
		alert("Please enter valid email id!");
		document.frmpublisher.user_id.focus();
		document.frmpublisher.user_id.select();
		return false;
	}
	if (document.frmpublisher.validator.value==0)
	{
		alert("Please enter corrrect value showed in the image");
		document.frmpublisher.validator.focus();
		document.frmpublisher.validator.select();
		return false;
	}
	if(!document.frmpublisher.agree.checked)
	{
		alert("Please Read the Terms & Condition and check the box below"); 
		return false;
 	}
	 
	document.frmpublisher.submit();
}
*/

function login1()
{		
	if (Email(document.frm_login.user_id.value))
	{
		alert("Please enter valid User Id");
		document.frm_login.user_id.focus();
		document.frm_login.user_id.select();
		return false;
	}
	if (document.frm_login.password.value==0)
	{
		alert("Your password should not be empty");
		document.frm_login.password.focus();
		document.frm_login.password.select();
		return false;
	}
	if(document.frm_login.password.value.length < 6)
	{ 
		alert('Invalid! Please enter your Correct Password');
		document.frm_login.password.focus();
		document.frm_login.password.select();
		return false;
	}	
    document.frm_login.submit();

}		


function changepwd1()
{		
   
	if(document.frmchangepwd.old_password.value==0)
	{ 
	alert('Please enter your old password.');
	document.frmchangepwd.old_password.focus();
	document.frmchangepwd.old_password.select();
	return false;
	}

	if(document.frmchangepwd.password.value==0)
	{ 
	alert('Please enter your new password.');
	document.frmchangepwd.password.focus();
	document.frmchangepwd.password.select();
	return false;
	}
	
	if (document.frmchangepwd.confirm_password.value==0)
	{
	alert("Please enter confirm Password");
	document.frmchangepwd.confirm_password.focus();
	document.frmchangepwd.confirm_password.select();
	return false;
	}
	if ((document.frmchangepwd.password.value) != (document.frmchangepwd.confirm_password.value))
	{
	alert("Password mismatch retype your password");
	document.frmchangepwd.confirm_password.focus();
	document.frmchangepwd.confirm_password.select();
	return false;
	}
	if(document.frmchangepwd.password.value.length < 6)
	{ 
	alert('Password should be 6 characters Long.!');
	document.frmchangepwd.password.focus();
	document.frmchangepwd.password.select();
	return false;
	}	
	document.frmchangepwd.submit();
}		

function forgotpassword()
{

	if (Email(document.frmforgot.user_id.value))
	{
		alert("Please enter valid email, which you used while registering.");
		document.frmforgot.user_id.focus();
		document.frmforgot.user_id.selected();
		return false()
	} 
 
	document.frmforgot.submit();
 	
}
  
function contactus()
{		
  	if (document.frmcontactus.cont_message.value==0)
	{
	alert("Please enter your message");
	document.frmcontactus.cont_message.focus();
	document.frmcontactus.cont_message.select();
	return false;
	}	
 	if (document.frmcontactus.cont_name.value==0)
	{
	alert("Please enter your full name");
	document.frmcontactus.cont_name.focus();
	document.frmcontactus.cont_name.select();
	return false;
	}	
 	if (Email(document.frmcontactus.cont_email.value))
	{
	alert("Please enter your email id");
	document.frmcontactus.cont_email.focus();
	document.frmcontactus.cont_email.select();
	return false;
	}
 	if (document.frmcontactus.cont_phone.value==0)
	{
	alert("Please enter your Phone No");
	document.frmcontactus.cont_phone.focus();
	document.frmcontactus.cont_phone.select();
	return false;
	}				 
	document.frmcontactus.submit();
}			
 	

 
 

/* 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
/*
var states = new Array();
states['India'] = new Array('Tamil Nadu','Karanataka','Kerala','Andhra Pradesh');
states['Canada'] = new Array('Alberta','British Columbia','Ontario');
states['Mexico'] = new Array('Baja California','Chihuahua','Jalisco');
states['United States'] = new Array('California','Florida','New York');

// City lists
var cities = new Array();
cities['Canada'] = new Array();
cities['Canada']['Alberta']          = new Array('Edmonton','Calgary');

cities['Canada']['British Columbia'] = new Array('Victoria','Vancouver');
cities['Canada']['Ontario']          = new Array('Toronto','Hamilton');
cities['Mexico'] = new Array();
cities['Mexico']['Baja California'] = new Array('Tijauna','Mexicali');
cities['Mexico']['Chihuahua']       = new Array('Ciudad Juárez','Chihuahua');
cities['Mexico']['Jalisco']         = new Array('Guadalajara','Chapala');
cities['United States'] = new Array();
cities['United States']['California'] = new Array('Los Angeles','San Francisco');
cities['United States']['Florida']    = new Array('Miami','Orlando');
cities['United States']['New York']   = new Array('Buffalo','new York');
cities['India'] = new Array();
cities['India']['Tamil Nadu'] = new Array('Chennai','Coimbatore','Vellore','Madurai');
cities['India']['Karanataka']    = new Array('Bengaluru / Bangalore','Mangalore','Mysoru / Mysore','Hubli');
cities['India']['Kerala']   = new Array('Calicut','Cochin','Ernakulam','Trivandrum');
cities['India']['Andhra Pradesh'] = new Array('Hyderabad / Secunderabad','Nellore','Vijayawada','Visakhapatnam');

function setStates() { 
  cntrySel = document.getElementById('country');
  stateList = states[cntrySel.value];
  changeSelect('state', stateList, stateList);
  setCities();
}
function setCities() {
  cntrySel = document.getElementById('country');
  stateSel = document.getElementById('state');
  cityList = cities[cntrySel.value][stateSel.value];
  changeSelect('city', cityList, cityList);
}
function changeSelect(fieldID, newOptions, newValues) {
  selectField = document.getElementById(fieldID);
  selectField.options.length = 0;
  for (i=0; i<newOptions.length; i++) {
    selectField.options[selectField.length] = new Option(newOptions[i], newValues[i]);
  }
}
// Multiple onload function created by: Simon Willison
// http://simonwillison.net/2004/May/26/addLoadEvent/
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } 
else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
addLoadEvent(function() {
  setStates();
});
 
 
 //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';
	//pgdiv = document.getElementById('pgpanel');
  	//pgdiv.style.visibility = 'visible';
	
  
  }
  // close showed layer
  function m1close()
  {
      if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
  }  
  function m1cancelclosetime()
  {
  	if(closetimer)
  	{
      	window.clearTimeout(closetimer);
  		closetimer = null;
  	}
  }
 */

