/**
 * Function that returns the language code form the received country code
 * obtained by the webservice http://j.maxmind.com/app/country.js
 *  
 * Return values:  
 * [1]- Portuguese
 * [2]- English (default)
 * [3]- Spanish
 * [4]- Nederlands
 * [11] - Brasilian    
 */ 
function getLangByIP(){

       try{
         //code of the received Country
          var countryCode = geoip_country_code(); 
       } catch (e){
          //if the websevice is unavailable the language is set by default to english
          var countryCode = 2;
       }
       
       switch (countryCode){
       
          //codes to set the language to [1] Portuguese
          case "PT": //Portugal
          case "CV": //Cape Verde
          case "GW": //Guinea-Bissau
          case "ST": //Sao Tome and Principe
          case "AO": //Angola
          case "MZ": //Mozambique
            return 1; 
          break;
              
           //codes to set the language to [3] Spanish
          case "ES": //Spain
          case "GQ": //Equatorial Guinea
          case "AR": //Argentina
  				case "BO": //Bolivia
  				case "CL": //Chile
  				case "CO": //Colombia
  				case "CR": //Costa Rica
  				case "CU": //Cuba					
          case "EC": //Ecuador
  				case "SV": //El Salvador
  				case "GT": //Guatemala
  				case "HN": //Honduras
  				case "MX": //Mexico
  				case "NI": //Nicaragua
  				case "PA": //Panama
  				case "PY": //Paraguay
  				case "PE": //Peru
  				case "PR": //Puerto Rico
  				case "DO": //Dominican Republic
  				case "UY": //Uruguay
  				case "VE": //Venezuela        
             return 3;  
          break; 
          
           //codes to set the language to [4] Nederlands
          case "NL": //Netherlands
          case "SR": //Suriname
          case "AW": //Aruba
          case "AN": //Netherlands Antilles    
            return 4;    
          break;          
          
          //codes to set the language to [11] Brasilian
          case "BR": //Brazil
            return 11;
          break;            
          
          //by default the language is set to [2] English
          default:       
             return 2;
          break;   
    }
}

/**
 * Function that returns the the received country code
 * obtained by the webservice http://j.maxmind.com/app/country.js
 *    
 */ 
function getCountryByIP(){

       try{
         //code of the received Country
          var countryCode = geoip_country_code(); 
       } catch (e){  }
       
       return countryCode;
}