function showmenu(elmnt)
{
   document.all(elmnt).style.visibility="visible"
}

function hidemenu(elmnt)
{
   document.all(elmnt).style.visibility="hidden"
}
////////////////
function validatelistingRequired(form)  
{
        var myForm = document.AnyForm;

        // start of stateprov
        if ((myForm.sSelect.value==null)||(myForm.sSelect.value==""))
        {
                alert("Your province appears invalid.");
                myForm.sSelect.value=""
                myForm.sSelect.focus()
                return false;
        }
        // end of stateprov     

        // start of district
        if ((myForm.dSelect.value==null)||(myForm.dSelect.value==""))
        {
                alert("The District appears invalid.");
                myForm.dSelect.value=""
                myForm.dSelect.focus()
                return false;
        }
        // end of district      

        // start of City
        if ((myForm.ctSelect.value==null)||(myForm.ctSelect.value==""))
        {
                alert("The city appears invalid.");
                myForm.ctSelect.focus()
                return false;
        }
        // end of City

        // start of Organization
        if ((myForm.organization.value==null)||(myForm.organization.value==""))
        {
                alert("The Organization appears invalid.");
                myForm.organization.focus();
                return false;
        }
        else
        {
                        if ( myForm.organization.value.length < 3) 
                        {
                                alert("You MUST enter a company name.");
                                myForm.organization.focus();
                                return false;
                        }
        }
        // end of Company

        // start of Street Address
        if ((myForm.address.value==null)||(myForm.address.value==""))
        {
                alert("Your street address appears invalid.");
                myForm.address.focus()
                return false;
        }
        // end of Street Address

        // start of ZIP or Postal code
        if ((myForm.postalcode.value==null)||(myForm.postalcode.value==""))
        {
                alert("The Postal Code appears invalid.");
                myForm.postalcode.value=""
                myForm.postalcode.focus()
                return false;
        }
        // end of ZIP or Postal Code

        // start of listingtype
        if ((myForm.tmlistingid.value==null)||(myForm.tmlistingid.value==""))
        {
                alert("The Listing Type appears invalid.");
                myForm.tmlistingid.value=""
                myForm.tmlistingid.focus()
                return false;
        }
        // end of listingtype

        // start of primcategory
        if ((myForm.primcategory.value==null)||(myForm.primcategory.value==""))
        {
                alert("The 1st category appears invalid.");
                myForm.primcategory.value=""
                myForm.primcategory.focus()
                return false;
        }

        //slogan
        if ( myForm.slogan.value.length > 255 ) {
                alert("Make sure your Banner text is no longer than 255.");
                myForm.slogan.focus();
                return false;
        }

        // end of slogan


        // Email
        if ((myForm.email.value!=null)&&(myForm.email.value!=""))
        {
                if (emailcheck(myForm.email.value)==false)
                {
                        myForm.email.value=""
                        myForm.email.focus()
                        return false
                }
        }

        // start of firstname
        if ((myForm.firstname.value!=null)&&(myForm.firstname.value!=""))
        {
                if ( myForm.firstname.value.length < 2) {
                        alert("You MUST enter a first name.");
                        myForm.firstname.focus();
                        return false;
                }
        }
        // end of firstname

        // start of lastname
        if ((myForm.lastname.value!=null)&&(myForm.lastname.value!=""))
        {
                if ( myForm.lastname.value.length < 2) 
                {
                        alert("You MUST enter a last name.");
                        myForm.lastname.focus();
                        return false;
                }
        }
        // end of lastname

        // start of Phone
        if ((myForm.phone.value!=null)&&(myForm.phone.value!=""))
        {
                if (checkInternationalPhone(myForm.phone.value)==false)
                {
                        alert("Please Enter a Valid Phone Number")
                        myForm.phone.value=""
                        myForm.phone.focus()
                        return false;
                }
        }
        // end of Phone

        //start of secondphone
        if ((myForm.secondphone.value!=null)&&(myForm.secondphone.value!=""))
        {
                if (checkInternationalPhone(myForm.secondphone.value)==false)
                {
                        alert("Please Enter a Valid Next Phone Number")
                        myForm.secondphone.value=""
                        myForm.secondphone.focus()
                        return false;
                }
        }
        //end of secondphone

        //cellphone
        if ((myForm.cellphone.value!=null)&&(myForm.cellphone.value!=""))
        {
                if (checkInternationalPhone(myForm.cellphone.value)==false)
                {
                        alert("Please Enter a Valid Phone Number")
                        myForm.cellphone.value=""
                        myForm.cellphone.focus()
                        return false;
                }
        }
        //end cellphone

        //fax
        if ((myForm.fax.value!=null)&&(myForm.fax.value!=""))
        {
                if (checkInternationalPhone(myForm.fax.value)==false)
                {
                        alert("Please Enter a Valid fax Number")
                        myForm.fax.value=""
                        myForm.fax.focus()
                        return false;
                }
        }
        //end fax

        //imagecompany
        if ((myForm.imagecomp.value!=null)&&(myForm.imagecomp.value!=""))
        {
                var ext = myForm.imagecomp.value;
                ext = ext.substring(ext.length-3,ext.length);
                ext = ext.toLowerCase();

                if ((ext != "gif") && (ext !=  "jpg") && (ext !=  "png") && (ext !=  "peg" ))
                        {
                          alert("wrong company image file format ")     
                          myForm.imagecomp.value = " "
                          myForm.imagecomp.focus()              
                          return false;
                        }
        }
        //end imagecompany

        //directionmap
        if ((myForm.compdirectionmap.value!=null)&&(myForm.compdirectionmap.value!=""))
        {
                var ext = myForm.compdirectionmap.value;
                ext = ext.substring(ext.length-3,ext.length);
                ext = ext.toLowerCase();
                        
                if ((ext != "gif") && (ext !=  "jpg") && (ext !=  "png") && (ext !=  "peg" ))
                        {
                          alert("wrong direction map file format")      
                          myForm.compdirectionmap.value = " "
                          myForm.compdirectionmap.focus()               
                          return false;
                        }
        }
        //end directionmap

        if (myForm.canadianprofessionals.checked == true)
        {
                myForm.canadianprofessionals.value = "yes";
        }
        else
        {
                myForm.canadianprofessionals.value = "no";
        }
        if (myForm.canadianbuilders.checked == true)
        {
                myForm.canadianbuilders.value = "yes";
        }
        else
        {
                myForm.canadianbuilders.value = "no";
        }
        if (myForm.townandcity.checked == true)
        {
                myForm.townandcity.value = "yes";
        }
        else
        {
                myForm.townandcity.value = "no";
        }
        
        if (myForm.sicmember.checked == true)
        {
                myForm.sicmember.value = "yes";
        }
        else
        {
                myForm.sicmember.value = "no";
        }
        return true
}
//**************************************************//
function validateupdatelistingRequired(form)    
{
        var myForm = document.AnyForm;


        // start of Organization
        if ((myForm.organization.value==null)||(myForm.organization.value==""))
        {
                alert("The Organization appears invalid.");
                myForm.organization.focus();
                return false;
        }
        else
        {
                        if ( myForm.organization.value.length < 3) 
                        {
                                alert("You MUST enter a company name.");
                                myForm.organization.focus();
                                return false;
                        }
        }
        // end of Company

        // start of Street Address
        if ((myForm.address.value==null)||(myForm.address.value==""))
        {
                alert("Your street address appears invalid.");
                myForm.address.focus()
                return false;
        }
        // end of Street Address

        // start of ZIP or Postal code
        if ((myForm.postalcode.value==null)||(myForm.postalcode.value==""))
        {
                alert("The Postal Code appears invalid.");
                myForm.postalcode.value=""
                myForm.postalcode.focus()
                return false;
        }
        // end of ZIP or Postal Code

        // start of listingtype
        if ((myForm.tmlistingid.value==null)||(myForm.tmlistingid.value==""))
        {
                alert("The Listing Type appears invalid.");
                myForm.tmlistingid.value=""
                myForm.tmlistingid.focus()
                return false;
        }
        // end of listingtype


        // start of primcategory
        if ((myForm.primcategory.value==null)||(myForm.primcategory.value==""))
        {
                alert("The 1st category appears invalid.");
                myForm.primcategory.value=""
                myForm.primcategory.focus()
                return false;
        }
        //slogan
        if ( myForm.slogan.value.length > 255 ) {
                alert("Make sure your Banner text is no longer than 255.");
                myForm.slogan.focus();
                return false;
        }
        // end of slogan

        // Email
        if ((myForm.email.value!=null)&&(myForm.email.value!=""))
        {
                if (emailcheck(myForm.email.value)==false)
                {
                        myForm.email.value=""
                        myForm.email.focus()
                        return false
                }
        }

        // start of firstname
        if ((myForm.firstname.value!=null)&&(myForm.firstname.value!=""))
        {
                if ( myForm.firstname.value.length < 2) {
                        alert("You MUST enter a first name.");
                        myForm.firstname.focus();
                        return false;
                }
        }
        // end of firstname

        // start of lastname
        if ((myForm.lastname.value!=null)&&(myForm.lastname.value!=""))
        {
                if ( myForm.lastname.value.length < 2) 
                {
                        alert("You MUST enter a last name.");
                        myForm.lastname.focus();
                        return false;
                }
        }
        // end of lastname

        // start of Phone
        if ((myForm.phone.value!=null)&&(myForm.phone.value!=""))
        {
                if (checkInternationalPhone(myForm.phone.value)==false)
                {
                        alert("Please Enter a Valid Phone Number")
                        myForm.phone.value=""
                        myForm.phone.focus()
                        return false;
                }
        }
        // end of Phone

        //start of secondphone
        if ((myForm.secondphone.value!=null)&&(myForm.secondphone.value!=""))
        {
                if (checkInternationalPhone(myForm.secondphone.value)==false)
                {
                        alert("Please Enter a Valid Next Phone Number")
                        myForm.secondphone.value=""
                        myForm.secondphone.focus()
                        return false;
                }
        }
        //end of secondphone

        //cellphone
        if ((myForm.cellphone.value!=null)&&(myForm.cellphone.value!=""))
        {
                if (checkInternationalPhone(myForm.cellphone.value)==false)
                {
                        alert("Please Enter a Valid Phone Number")
                        myForm.cellphone.value=""
                        myForm.cellphone.focus()
                        return false;
                }
        }
        //end cellphone

        //fax
        if ((myForm.fax.value!=null)&&(myForm.fax.value!=""))
        {
                if (checkInternationalPhone(myForm.fax.value)==false)
                {
                        alert("Please Enter a Valid fax Number")
                        myForm.fax.value=""
                        myForm.fax.focus()
                        return false;
                }
        }
        //end fax

        //imagecompany
        if ((myForm.imagecomp.value!=null)&&(myForm.imagecomp.value!=""))
        {
                var ext = myForm.imagecomp.value;
                ext = ext.substring(ext.length-3,ext.length);
                ext = ext.toLowerCase();

                if ((ext != "gif") && (ext !=  "jpg") && (ext !=  "png") && (ext !=  "peg" ))
                        {
                          alert("wrong company image file format")
                          myForm.imagecomp.value = " "
                          myForm.imagecomp.focus()              
                          return false;
                        }
        }
        //end imagecompany

        //directionmap
        if ((myForm.compdirectionmap.value!=null)&&(myForm.compdirectionmap.value!=""))
        {
                var ext = myForm.compdirectionmap.value;
                ext = ext.substring(ext.length-3,ext.length);
                ext = ext.toLowerCase();
                        
                if ((ext != "gif") && (ext !=  "jpg") && (ext !=  "png") && (ext !=  "peg" ))
                        {
                          alert("wrong direction map file format")      
                          myForm.compdirectionmap.value = " "
                          myForm.compdirectionmap.focus()               
                          return false;
                        }
        }
        //end directionmap

        if (myForm.canadianprofessionals.checked == true)
        {
                myForm.canadianprofessionals.value = "yes";
        }
        else
        {
                myForm.canadianprofessionals.value = "no";
        }
        if (myForm.canadianbuilders.checked == true)
        {
                myForm.canadianbuilders.value = "yes";
        }
        else
        {
                myForm.canadianbuilders.value = "no";
        }
        if (myForm.townandcity.checked == true)
        {
                myForm.townandcity.value = "yes";
        }
        else
        {
                myForm.townandcity.value = "no";
        }
        if (myForm.sicmember.checked == true)
        {
                myForm.sicmember.value = "yes";
        }
        else
        {
                myForm.sicmember.value = "no";
        }

        return true
}
//**************************************************//
//*************************************************//
function getaCountry(what) 
{ 
    if (what.selectedIndex != '') 
        { 
        var country = what.value; 
        self.location.href= self.location + ('?cSel=' + country);
      } 
}
//*************************************************//

//*************************************************//

function getCountry(what) 
{ 
    if (what.selectedIndex != '') 
        { 
        var country = what.value; 
        self.location.href= self.location + ('?cSel=' + country);
      } 
}
//*************************************************//

function getStateprov(what) 
{ 

    if (what.selectedIndex != '') 
        { getCountry(document.AnyForm.cSelect);
        var country = document.AnyForm.cSelect.value;
        var agentid = document.AnyForm.agentid.value;
        var state = what.value; 
        self.location.href= self.location + ('?cSel=' + country + '&sSel=' + state + '&agentid=' + agentid);   
      } 
} 
//*************************************************//

function getDistrict(what) 
{ 

    if (what.selectedIndex != '') 
        { 
        var country = document.AnyForm.cSelect.value;
          var state = document.AnyForm.sSelect.value;
        var agentid = document.AnyForm.agentid.value;
        var district = what.value; 
        self.location.href= self.location + ('?cSel=' + country + '&sSel=' + state + '&dSel=' + district + '&agentid=' + agentid);
        } 
}
//*************************************************//
 
function getCity(what) 
{ 
    if (what.selectedIndex != '') 
        { 
        var country = document.AnyForm.cSelect.value;
          var state = document.AnyForm.sSelect.value;
          var district = document.AnyForm.dSelect.value;
        var agentid = document.AnyForm.agentid.value;
        var city = what.value; 
        self.location.href= self.location + ('?cSel=' + country + '&sSel=' + state + '&dSel=' + district + '&ctSel=' + city + '&agentid=' + agentid);
        } 
} 
//*************************************************//

function getCategory(what) 
{ 
    if (what.selectedIndex != '') 
        { 
        var country = document.AnyForm.cSelect.value;
          var state = document.AnyForm.sSelect.value;
          var district = document.AnyForm.dSelect.value;
          var city = document.AnyForm.ctSelect.value;
        var agentid = document.AnyForm.agentid.value;
        var category = what.value; 
        self.location.href= self.location + ('?cSel=' + country + '&sSel=' + state + '&dSel=' + district + '&ctSel=' + city + '&caSel=' + category + '&agentid=' + agentid);
        } 
} 


//*************************************************//
function emailcheck(str) {

                var at="@"
                var dot="."
                var lat=str.indexOf(at)
                var lstr=str.length
                var ldot=str.indexOf(dot)
                if (str.indexOf(at)==-1){
                   alert("Invalid E-mail ID")
                   return false
                }

                if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
                   alert("Invalid E-mail ID")
                   return false
                }

                if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
                    alert("Invalid E-mail ID")
                    return false
                }

                 if (str.indexOf(at,(lat+1))!=-1){
                    alert("Invalid E-mail ID")
                    return false
                 }

                 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
                    alert("Invalid E-mail ID")
                    return false
                 }

                 if (str.indexOf(dot,(lat+2))==-1){
                    alert("Invalid E-mail ID")
                    return false
                 }
                
                 if (str.indexOf(" ")!=-1){
                    alert("Invalid E-mail ID")
                    return false
                 }

                 return true                                    
        }

//*************************************//
function forcePostalcodeAndAgentid(form) {
        var myForm = document.AnyForm;

        // start of ZIP or Postal code
        if (validpostcode(document.AnyForm)==false)
        {
                myForm.postalcode.value=""
                myForm.postalcode.focus()
                return false;
        }
        else {myForm.postalcode.value = myForm.postalcode.value.toUpperCase();}

        // end of ZIP or Postal Code


// start of agentid
        if (isNaN(myForm.agentid.value))
        {
                alert("Agent ID must be numeric");
                myForm.agentid.value=""
                myForm.agentid.focus()
                return false;
        }
 
        // end of agentid

return true;
}
//*************************************//
function validpostcode(form){ //check Canadian postcode format is valid
var myForm = document.AnyForm;

 test = myForm.postalcode.value
 size = test.length
 test = test.toUpperCase(); //Change to uppercase
 while (test.slice(0,1) == " ") //Strip leading spaces
  {test = test.substr(1,size-1);size = test.length
  }
 while(test.slice(size-1,size)== " ") //Strip trailing spaces
  {test = test.substr(0,size-1);size = test.length
  }
 myForm.postalcode.value = test; //write back to form field
 if (size !=7){ //Code length rule
  alert(test + " is not a valid postcode - wrong length");
  myForm.postalcode.focus();
  return false;
  }
 if (!(isNaN(test.charAt(0)))){ //leftmost character must be alpha character rule
   alert(test + " is not a valid postcode - cannot start with a number");
   myForm.postalcode.focus();
   return false;
  }
 if (isNaN(test.charAt(size-3))){ //first character of inward code must be numeric rule
   alert(test + " is not a valid postcode - alpha character in wrong position");
   myForm.postalcode.focus();
   return false;
  }
 if (!(isNaN(test.charAt(size-2)))){ //second character of inward code must be alpha rule
   alert(test + " is not a valid postcode - number in wrong position");
   myForm.postalcode.focus();
   return false;
  }
 if ((isNaN(test.charAt(size-1)))){ //third character of inward code must be numeric rule
   alert(test + " is not a valid postcode - number in wrong position");
   myForm.postalcode.focus();
   return false;
  }
 if (!(test.charAt(size-4) == " ")){//space in position length-3 rule
   alert(test + " is not a valid postcode - no space or space in wrong position");
   myForm.postalcode.focus();
   return false;
   }
 count1 = test.indexOf(" ");count2 = test.lastIndexOf(" ");
 if (count1 != count2){//only one space rule
   alert(test + " is not a valid postcode - only one space allowed");
   myForm.postalcode.focus();
   return false;
  }
return true;
}
//*************************************//
// Declaring required variables for phone validation
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()-. ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
//*************************************//

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}
//*************************************//

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}
//*************************************//

function MM_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
//*************************************//

function MM_swapImage() {
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//*************************************//

function MM_swapImgRestore() { 
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
//*************************************//

function MM_preloadImages() { 
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//*************************************//
 function openmypage(mywindow)
 {
 window.open (mywindow,"openmypage","width=590,height=350,location=0,menubar=1,resizable=1,scrollbars=1,status=1,titlebar=1,toolbar=1,screenX=100,left=100,screenY=30,top=60");
 }
//*************************************//

function openpopup(){
var popurl="util/bookmark.php"
winpops=window.open(popurl,"","width=200,height=300,")
}
//*************************************//

function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if cookie exists
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1)
         end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}
//*************************************//

function loadornot()
{
        if (get_cookie('poppedup')=='')
        {
                openpopup()
                document.cookie="poppedup=yes"
        }
}
//*************************************//

function forceCategoryAndDescription(form) {
        var myForm = document.foobar;

        // start of category
        if ( myForm.category.value.length < 1) {
                alert("You MUST choose a category.");
                myForm.category.focus();
                return false;
        }
        if ( myForm.category.value.length > 80) {
                alert("Category name is too long.");
                myForm.category.focus();
                return false;
        }
        

        // end of category
        // Description
        /*
        if ( myForm.description.value.length <= 9 ) {
                alert("Make your description 10 characters or longer.");
                myForm.description.focus();
                return false;
        }
        */
        if ( myForm.description.value.length > 120 ) {
                alert("Description is longer than 120.");
                myForm.description.focus();
                return false;
        }

return true;
}
//*************************************//

// browser detection - load css file
function loadCSSFile() {
        /* this script determines the user browser and loads an appropriate external cascading style sheet.
           If the browser is an Internet Explorer browser then an IE compatible external css file is loaded.
           If the browser is a Netscape browser then a Netscape compatible external css file is loaded.
           If the browser is an Opera browser then an an Internet Explorer compatible external css file is loaded.
           If the browser is anything else no css file is loaded.
           You can add more browser types by adding another case and a related css file. Based on an analysis 
           of website traffic most surfers use recent browser versions. You can add specific versioning if you want
           but the traffic that will use it will be negligible.
           Richard Creech info@dreamriver.com http://www.dreamriver.com
        */
        var cssFileName = "";
        var browser = navigator.appName;
        switch(browser) {
                case "Microsoft Internet Explorer":
                        cssFileName = "../util/explorer.css";
                        break;
                case "Netscape":
                        //cssFileName = "../util/netscape.css";
                        cssFileName = "../util/explorer.css";
                        break;
                case "Opera":
                        cssFileName = "../util/explorer.css";           
                        break;  
                default:
                        /* if there is no switch(browser) match then no css file is loaded */
        }
        document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + cssFileName + "\">");
  }
//*************************************//
function agentvalidateLoginForm(form) {

        var myForm = document.agentloginForm;

        // Email
        if ( myForm.email.value.length < 6) {
                alert("You MUST submit a valid email address.");
                myForm.email.focus();
                return false;
                // needs better validation
        }

        // Password
        if ( myForm.password.value.length < 1) {
                alert("You MUST enter a password.");
                myForm.password.focus();
                return false;
        }
return true;
}
//*************************************//

function validate(form) {

        var myForm = document.foobar;

        // Email
        if ( myForm.email.value.length < 6) {
                alert("You MUST submit a valid email address.");
                myForm.email.focus();
                return false;
                // needs better validation
        }

        // Password
        if ( myForm.password.value.length < 1) {
                alert("You MUST enter a password.");
                myForm.password.focus();
                return false;
        }

        // start of Country
        // this has problems, so it is commented out - look at category processing for correct option handling
        /*
        var mycountryList = myForm.country;
        var mySelectedCountryIndex= mycountryList.selectedIndex;
        if( mycountryList.options[mySelectedCountryIndex].value ) {
                countryItem = mycountryList.options[mySelectedCountryIndex].value;
        }else{ // if it is null then give it a value to satisfy javascript
                countryItem = "*";
        }
        if(countryItem == "*") {
                alert("Choose a country.");
                mycountryList.focus();
                return false;
        }
        if(countryItem == "") {
                alert("Choose a country.");
                mycountryList.focus();
                return false;
        }
        // end of Country
        */

        // start of Website
        if( myForm.website.value.length >= 1 ) {
                if ( myForm.website.value.substring(0,7) != "http://" ) {
                        alert("You must enter a clickable link.\nThe link must begin with 'http://'");
                        myForm.website.focus();
                        return false;
                }
        }
        // end of Website

        // start of firstname
        if ( myForm.firstname.value.length < 2) {
                alert("You MUST enter a first name.");
                myForm.firstname.focus();
                return false;
        }
        // end of firstname

        // start of lastname
        if ( myForm.lastname.value.length < 2) {
                alert("You MUST enter a last name.");
                myForm.lastname.focus();
                return false;
        }
        // end of lastname

        // start of Company
        if ( myForm.organization.value.length < 3) {
                alert("You MUST enter a company name.");
                myForm.organization.focus();
                return false;
        }
        // end of Company

        // start of Phone
        if ( myForm.phone.value.length < 7 ) {
                alert("Your phone number must be at least 7 numbers or longer.\nEnter 7 spaces if not applicable.");
                myForm.phone.focus()
                return false;
                // needs validation for a number value, but allowing hyphens or dots
        }
        // end of Phone
        
        // start of Street Address
        if ( myForm.address.value.length < 6 ) {
                alert("Your street address appears invalid.\nEnter 6 spaces if not applicable.");
                myForm.address.focus()
                return false;
        }
        // end of Street Address

        // start of City
        if ( myForm.city.value.length < 3 ) {
                alert("The city appears invalid.\nEnter 3 spaces if not applicable.");
                myForm.city.focus()
                return false;
        }
        // end of City

        // start of ZIP or Postal code
        if ( myForm.postalcode.value.length < 7 ) {
                alert("Your ZIP or postal code must contain 7 characters.\nEnter 5 spaces if not applicable.");
                myForm.postalcode.focus()
                return false;
        }
        // end of ZIP or Postal Code

        
        return true
}


//*************************************//
function ValidateEmail(form){

        var myForm = document.foobar;

        // Email
        if ((myForm.email.value==null)||(myForm.email.value=="")){
                alert("Please Enter your Email ID")
                myForm.email.focus()
                return false
        }
        if (emailcheck(myForm.email.value)==false){
                myForm.email.value=""
                myForm.email.focus()
                return false
        }

        return true
 }

//*************************************//

function agentregistervalidate(form) {

        var myForm = document.foobar;

        // Email
        if ((myForm.email.value==null)||(myForm.email.value=="")){
                alert("Please Enter your Email ID")
                myForm.email.focus()
                return false
        }
        if (emailcheck(myForm.email.value)==false){
                myForm.email.value=""
                myForm.email.focus()
                return false
        }

        // Password
        if ( myForm.password.value.length < 1) {
                alert("You MUST enter a password.");
                myForm.password.focus();
                return false;
        }
      // Confirm Password
        if ( myForm.confirmPassword.value.length < 1) {
                alert("You MUST enter a confirming password.");
                myForm.confirmPassword.focus();
                return false;
        }
      if ( myForm.confirmPassword.value != myForm.password.value) {
                alert("You MUST enter the same password.");
                myForm.confirmPassword.focus();
                return false;
        }
      
        // start of Organization
        if ( myForm.organization.value.length < 3) {
                alert("You MUST enter a company name.");
                myForm.organization.focus();
                return false;
        }
        // end of Company
        
        
        // start of firstname
        if ( myForm.firstname.value.length < 2) {
                alert("You MUST enter a first name.");
                myForm.firstname.focus();
                return false;
        }
        // end of firstname

        // start of lastname
        if ( myForm.lastname.value.length < 2) {
                alert("You MUST enter a last name.");
                myForm.lastname.focus();
                return false;
        }
        // end of lastname

        // start of Phone
        if ((myForm.phone.value==null)||(myForm.phone.value=="")){
                alert("Please Enter your Phone Number")
                myForm.phone.focus()
                return false;
        }
        if (checkInternationalPhone(myForm.phone.value)==false){
                alert("Please Enter a Valid Phone Number")
                myForm.phone.value=""
                myForm.phone.focus()
                return false;
        }

        // end of Phone

        //start of secondphone
        if ((myForm.secondphone.value!=null)&&(myForm.secondphone.value!=""))
        {

                if (checkInternationalPhone(myForm.secondphone.value)==false){
                        alert("Please Enter a Valid Next Phone Number")
                        myForm.secondphone.value=""
                        myForm.secondphone.focus()
                        return false;
                }
        }
        //end of secondphone

        //cellphone
        if ((myForm.cellphone.value!=null)&&(myForm.cellphone.value!=""))
        {

                if (checkInternationalPhone(myForm.cellphone.value)==false){
                        alert("Please Enter a Valid Phone Number")
                        myForm.cellphone.value=""
                        myForm.cellphone.focus()
                        return false;
                }
        }
        //end cellphone

        //fax
        if ((myForm.fax.value!=null)&&(myForm.fax.value!=""))
        {

                if (checkInternationalPhone(myForm.fax.value)==false){
                        alert("Please Enter a Valid fax Number")
                        myForm.fax.value=""
                        myForm.fax.focus()
                        return false;
                }
        }
        //end fax

        // start of Street Address
        if ( myForm.address.value.length < 6 ) {
                alert("Your street address appears invalid.");
                myForm.address.focus()
                return false;
        }
        // end of Street Address

        // start of City
        if ( myForm.city.value.length < 3 ) {
                alert("The city appears invalid.");
                myForm.city.focus()
                return false;
        }
        // end of City

        // start of ZIP or Postal code
        if (validpostcode(document.foobar)==false)
        {
                myForm.postalcode.value=""
                myForm.postalcode.focus()
                return false;
        }
        else {myForm.postalcode.value = myForm.postalcode.value.toUpperCase();}
        // end of ZIP or Postal Code

        
        return true
}
//*************************************//


function cityStateprov(what) 
{ 

    if (what.selectedIndex != '') 
        { getCountry(document.AnyForm.cSelect);
        var country = document.AnyForm.cSelect.value;
        var goal    = document.AnyForm.task.value;
        var state = what.value; 
        self.location.href= self.location + ('?cSel=' + country + '&sSel=' + state + '&goal=' + goal);   
      } 
} 
//*************************************************//

function cityDistrict(what) 
{ 
    if (what.selectedIndex != '') 
        { 
        var country = document.AnyForm.cSelect.value;
        var state = document.AnyForm.sSelect.value;
        var goal  = document.AnyForm.task.value;
        var district = what.value; 
        self.location.href= self.location + ('?cSel=' + country + '&sSel=' + state + '&dSel=' + district + '&goal=' + goal);
        } 
}
//*************************************************//
function cityCity(what) 
{ 
    if (what.selectedIndex != '') 
        { 
        var country = document.AnyForm.cSelect.value;
        var state = document.AnyForm.sSelect.value;
        var district = document.AnyForm.dSelect.value;
        var goal    = document.AnyForm.task.value;
        var city = what.value; 
        self.location.href= self.location + ('?cSel=' + country + '&sSel=' + state + '&dSel=' + district + '&ctSel=' + city + '&goal=' + goal);
        } 
} 
//*************************************************//

function enteredCity(what) 
{ 
   var agentid = document.AnyForm.agentid.value;
   var city = what.value; 
   self.location.href= ('?ctSel=' + city + '&agentid=' + agentid);
       
} 
//*************************************************//
function Cityid(what) 
{ 
   var agentid = document.AnyForm.agentid.value;
   var city = document.AnyForm.nextcity.value;
   var cityid = what.value; 
   self.location.href= ('?ctiSel=' + cityid + '&agentid=' + agentid + '&ctSel=' + city);
       
} 
//*************************************************//
function enteredCategory(what) 
{ 
   var agentid = document.AnyForm.agentid.value;
   var cityid = document.AnyForm.ctSelect.value;
   var city = document.AnyForm.nextcity.value;
   var category = what.value; 
   self.location.href= ('?ctiSel=' + cityid + '&agentid=' + agentid + '&caSel=' + category + '&ctSel=' + city);
       
} 
//*************************************************//

function getPostalcode(what) 
{ 
   var agentid = document.AnyForm.agentid.value;
   var postalcode = what.value; 
   self.location.href= ('?postalcode=' + postalcode + '&agentid=' + agentid);
       
} 
//*************************************************//
function getcPostalcode(what) 
{ 
   var agentid = document.AnyForm.agentid.value;
   var customerid = document.AnyForm.customerid.value;
   var postalcode = what.value; 
   self.location.href= ('?postalcode=' + postalcode + '&agentid=' + agentid + '&customerid=' + customerid);
       
} 
//*************************************************//

