/* Fixes the scope of the search form to the relevant service
   Search auto-scopes by the referer URI, which under /blogs, reverts to English
 */  
  gloader.load(["glow", "1", "glow.dom"], {
          onLoad: function(glow) {
              glow.ready(function() {
                  var servicesMap = {
                      'turkce': 'turkish',
                      'mundo': 'spanish'
                  };
                            
                  var currentLocation = location.href;                                                      
                  if (currentLocation.match('/blogs/')) {                                                      
                    var urlServiceName = currentLocation.match(/bbc\.co\.uk\/blogs\/(.*?)\//i) || currentLocation.match(/bbc\.co\.uk\/blogs\/(.*?)/i);
                    
                    var serviceName = urlServiceName[1];
                    
                    serviceName = servicesMap[serviceName] || serviceName;                                                        
                    glow.dom.get('#blq-mast > form').attr('action', 'http://search.bbc.co.uk/search');
                    glow.dom.create('<input type="hidden" name="scope" value="'+serviceName+'"/>').prependTo('#blq-mast > form fieldset');
                    glow.dom.create('<input type="hidden" name="tab" value="'+serviceName+'"/>').prependTo('#blq-mast > form fieldset');
                  }                            
              });
          }
      }
  );