function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function isWhitespace (s)
{ 
  var i;
  var whitespace = " \t\n\r";

    if (isEmpty(s)) return true;

    for (i = 0; i < s.length; i++)
    {   
		
        var c = s.charAt(i);
        if (whitespace.indexOf(c) == -1)
		{
			 return false;
		}
    }
    return true;
}

function RemoveSpace()
{
	var zip,i;
	zip=document.form2aa.zip.value;
	for (i = 0; i < zip.length; i++)
	{
		zip = zip.replace(" ","");
	}
	document.form2aa.zip.value=zip;
}

function ValidateForm()
{ 
//Validation for country, city and zip

var checking;
var country;
var zip;
var city;
var mikExp = /[\"\;\:\/\?\<\>\.\,\!$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\|]/;	

country=document.form2aa.lstcountry.value;
city=document.form2aa.txtcity.value;
zip=document.form2aa.zip.value;

checking=true;

	 var zp=document.form2aa.zip;
	 
	if((country =="0"))
	{		
		alert ("Select a Country");
		document.form2aa.lstcountry.focus();			
		return false;
	}	

	if((city == "") && (zip==""))
	{
		alert ("Enter a City name or a Zip code");
		document.form2aa.lstcountry.focus();			
		checking=false;
		return false;	
	}	

	if(isWhitespace(city))
	{
		if (zp.value.length <1)
		{
			alert("City name has Spaces in");
			document.form2aa.txtcity.focus();
			document.form2aa.txtcity.select();
			checking=false;
			return false;	
		}
	}	
	
	if ((country!="0") && (city=="") && (zip==""))
	{
		alert("Select Country and enter a City or Zip");
		document.form2aa.txtcity.focus();	
		document.form2aa.txtcity.select();
		checking=false;
		return false;					
	}
	
	if((country!="0") && (city != ""))
	{		
		document.form2aa.zip.value="";		
		document.form2aa.submit();
		return true;
	}	
	/*
	if (zp.value.length < 2)
	{
	    alert("<%=Mes(182)%>");
		zp.select();
		zp.focus();
		return false;
	}
	*/
	if (zp.value.search(mikExp)!=-1)			
	{
		alert("Invalid Zip");
		zp.select();										 	    		    
		zp.focus();
		return false;
	}
	
	if((country!="0") && (zip!=""))
	{		
		document.form2aa.txtcity.value="";		
		document.form2aa.submit();
		return true;
	}	
	
	if((country!="0") && (city != "") && (zip!=""))
	{		
		document.form2aa.zip.value="";		
		document.form2aa.submit();
		return true;
	}	
					
	return true;
}