function verify(searchTheme,lang){
    
    searchThemeCheck = getSearchTheme();
    
    if(searchTheme == "Street" && searchThemeCheck == "Street"){        

       if(!(document.MapForm.searchStreetName.value.length>0 && (document.MapForm.searchCityName.value.length > 0 || document.MapForm.searchPCCode.value.length >0))){
            //City, province and/or postal code and street name must be provided by the user !
            if(lang=="E"){
            openDoc('./html/messageProvideCity_e.html','425','105');
            }else{
            openDoc('./html/messageProvideCity_f.html','425','105');
            }       
            return false;
        }else if(document.MapForm.searchPCCode.value.length>0){ // if there is some input in postal code box.
            
            pc = document.MapForm.searchPCCode.value;

            if(pc.length!=6){
                //Invalid postal code entered! The expected format is  [a-z][0-9][a-z][0-9][a-z][0-9]
                if(lang=="E"){
                openDoc('./html/messageInvalidPC_e.html','425','115');
                }else{
                openDoc('./html/messageInvalidPC_f.html','425','115');
                }    
                return false;
            }
            pc = pc.toUpperCase();

            pcSplit=pc.split("");

            if(pcSplit[0]>="A"&&pcSplit[0]<="Z")
                if(pcSplit[2]>="A"&&pcSplit[2]<="Z")
                    if(pcSplit[4]>="A"&&pcSplit[4]<="Z")
                        if(pcSplit[1]>="0"&&pcSplit[1]<="9")
                            if(pcSplit[3]>="0"&&pcSplit[3]<="9")
                                if(pcSplit[5]>="0"&&pcSplit[5]<="9"){
                                    document.MapForm.searchPCCode.value = pc;
                                    return true;
                                    }
            //Invalid postal code entered! The expected format is  [a-z][0-9][a-z][0-9][a-z][0-9]                        
            if(lang=="E"){
            openDoc('./html/messageInvalidPC_e.html','425','115');
            }else{
            openDoc('./html/messageInvalidPC_f.html','425','115');
            }    
             return false;   
          }else {
            //if there is no input in postal code box.
            //document.MapForm["entered"].value="true";                     
            //document.MapForm.submit();
              return true;

            }     
    }else if(searchTheme == "StreetIntersection" && searchThemeCheck == "StreetIntersection"){
        
     //if there is no input for streetName and cityName
     //if(document.MapForm.searchStreetName1.value.length < 1 || document.MapForm.searchCityName.value.length <1 || document.MapForm.searchStreetName2.value.length < 1){
          if(!(document.MapForm.searchStreetName1.value.length>0 && document.MapForm.searchStreetName2.value.length>0 && (document.MapForm.searchCityName.value.length > 0 || document.MapForm.searchPCCode.value.length >0))){

            //City, province and/or postal code and street name must be provided by the user !
            if(lang=="E"){
            openDoc('./html/messageProvideCity_e.html','425','105');
            }else{

            openDoc('./html/messageProvideCity_f.html','425','105');
            }  
        return false;
        }else if(document.MapForm.searchPCCode.value.length>0){ // if there is some input in postal code box.


                pc = document.MapForm.searchPCCode.value;
                if(pc.length!=6){

                //Invalid postal code entered! The expected format is  [a-z][0-9][a-z][0-9][a-z][0-9]
                if(lang=="E"){
                openDoc('./html/messageInvalidPC_e.html','425','105');
                }else{
                openDoc('./html/messageInvalidPC_f.html','425','105');
                }
                    return false;
                }
                pc = pc.toUpperCase();
                
                pcSplit=pc.split("");
                
                if(pcSplit[0]>="A"&&pcSplit[0]<="Z")
                    if(pcSplit[2]>="A"&&pcSplit[2]<="Z")
                        if(pcSplit[4]>="A"&&pcSplit[4]<="Z")
                            if(pcSplit[1]>="0"&&pcSplit[1]<="9")
                                if(pcSplit[3]>="0"&&pcSplit[3]<="9")
                                    if(pcSplit[5]>="0"&&pcSplit[5]<="9"){
                                        document.MapForm.searchPCCode.value = pc;
                                        return true;
                                        }
                //Invalid postal code entered! The expected format is  [a-z][0-9][a-z][0-9][a-z][0-9]                        
                if(lang=="E"){
                openDoc('./html/messageInvalidPC_e.html','425','105');
                }else{
                openDoc('./html/messageInvalidPC_f.html','425','105');
                }
                 return false;   
              }else {
                //if there is no input in postal code box.
                
                  return true;
                  
                } 
    }else if(searchTheme == "PostalCode" && searchThemeCheck == "PostalCode"){
 
        pc = document.MapForm.searchPCcode.value;
        
        if (document.MapForm.searchPCcode.value.length != 6){ 
             //Postal code must have all six characters !
             if(lang=="E"){
                openDoc('./html/messageSixCaracPC_e.html','425','70');
                }else{
                openDoc('./html/messageSixCaracPC_f.html','425','70');
                }
            return false;
        }

        pc = pc.toUpperCase();
                
        pcSplit=pc.split("");
                
            if(pcSplit[0]>="A"&&pcSplit[0]<="Z")
                if(pcSplit[2]>="A"&&pcSplit[2]<="Z")
                    if(pcSplit[4]>="A"&&pcSplit[4]<="Z")
                        if(pcSplit[1]>="0"&&pcSplit[1]<="9")
                            if(pcSplit[3]>="0"&&pcSplit[3]<="9")
                                if(pcSplit[5]>="0"&&pcSplit[5]<="9"){
                                    document.MapForm.searchPCcode.value = pc;                                    
                                    return true;
                                    }
                //Invalid postal code entered! The expected format is  [a-z][0-9][a-z][0-9][a-z][0-9]                    
                if(lang=="E"){
                openDoc('./html/messageInvalidPC_e.html','425','105');
                }else{
                openDoc('./html/messageInvalidPC_f.html','425','105');
                }
                 return false;   
        	
    }else if(searchTheme == "Locality" && searchThemeCheck == "Locality"){
        
        if (document.MapForm.searchLocalityName.value.length < 1){ 

            //Locality name must have minimum one character !
             if(lang=="E"){
                openDoc('./html/messageOneCaracLocality_e.html','425','105');
                }else{
                openDoc('./html/messageOneCaracLocality_f.html','425','105');
                }
            return false;
        }
        
        lenghtSrch=document.MapForm.searchLocalityName.value.length
        
            emptyStr="                                                                                                                              "
            emptyStr = emptyStr.substring(0,lenghtSrch)
            if (emptyStr == document.MapForm.searchLocalityName.value){
         
                //Locality name must have minimum one character !
                if(lang=="E"){
                openDoc('./html/messageOneCaracLocality_e.html','425','105');
                }else{
                openDoc('./html/messageOneCaracLocality_f.html','425','105');
                }
                    document.MapForm.searchLocalityName.value = "";                    
                    return false;
            }
           
                    return true;
          
    }/*end if(searchTheme == "Locality")*/    
}/*end of function verify()*/

function getSearchTheme(){
 var url = document.MapForm.action;
    
    q=url.split("?");
    
    if (q[1]) {
        //Get all Name/Value pairs from the QueryString
        var pairs = q[1].split('&');
        for (i=0;i<pairs.length;i++) {

            //Get the Name from given Name/Value pair
            var keyval = pairs[i].split('=');

            if (keyval[0] == 'searchTheme') {
            //Get the Value from given Name/Value pair and set to the return ID
            var searchTheme= keyval[1];                
            return searchTheme;
            }
            
        }        
        return "nothing";
    }   
}
