//   Randomized Header
//   Copyright Cquent Ltd 2008-2010
//   
 
 
var images = new Array(23);
var weight = new Array(23);
 
 
images[0]   = "http://www.waterfordairport.ie/images/headers/girl_and_mum.jpg";           // 'The sky's the limit'
images[1]   = "http://www.waterfordairport.ie/images/headers/big_ben.jpg";                // '(London) Time's on your side'
images[2]   = "http://www.waterfordairport.ie/images/headers/girl_sunglasses.jpg";        // 'The future looks bright'
images[3]   = "http://www.waterfordairport.ie/images/headers/stress_free_travel.jpg";     // 'Stress free travel'
images[4]   = "http://www.waterfordairport.ie/images/headers/harvey_nicks.jpg";           // 'Manchester - From Hennes...'
images[5]   = "http://www.waterfordairport.ie/images/headers/red_devils.jpg";             // 'Manchester - Two more red devils'
images[6]   = "http://www.waterfordairport.ie/images/headers/premiership.jpg";            // 'Birmingham - Watch the premiership live'
images[7]   = "http://www.waterfordairport.ie/images/headers/bargain_hunter.jpg";         //  NOW Luton - Time is on your side/Bargain hunter
images[8]   = "http://www.waterfordairport.ie/images/headers/brittany.jpg";               // 'Brittany - just 90 mins...'
images[9]   = "http://www.waterfordairport.ie/images/headers/bridge_kilkenny.jpg";        // 'Bridge - Now we're even closer... Kilkenny'
images[10]  = "http://www.waterfordairport.ie/images/headers/clear_skies_boy.jpg";        // 'Clear skies all the way'
images[11]  = "http://www.waterfordairport.ie/images/headers/mother_child.jpg";           // 'Family friendly travel...'
images[12]  = "http://www.waterfordairport.ie/images/headers/new_business_man.jpg";       // 'New Business Man (time travelling)
images[13]  = "http://www.waterfordairport.ie/images/headers/connecting_you_new.jpg";     // 'Connecting You... (new)
images[14]  = "http://www.waterfordairport.ie/images/headers/cleared_for_take_off.jpg";   // 'Cleared for Take Off
images[15]  = "http://www.waterfordairport.ie/images/headers/bridge_tipperary.jpg";       // 'Bridge - Now we're even closer... Tipp'
images[16]  = "http://www.waterfordairport.ie/images/headers/bridge_wexford.jpg";         // 'Bridge - Now we're even closer... Wexford'
images[17]  = "http://www.waterfordairport.ie/images/headers/tall_ships.jpg";             // 'Tall Ships'


 
var numberImages = 23;   // ##### Important to update this when adding images ####
 
weight[0]  =   6;   // 'The sky's the limit'
weight[1]  =   5;   // '(London) Time's on your side'
weight[2]  =   5;   // 'The future looks bright'
weight[3]  =   5;   // 'Stress free travel'
weight[4]  =   5;   // 'Manchester - From Hennes...'
weight[5]  =   5;   // 'Manchester - Two more red devils'
weight[6]  =   6;   // 'Birmingham - Watch the premiership live'
weight[7]  =   6;   //  NOW Luton - Time is on your side/Bargain hunter
weight[8]  =   6;   // 'Brittany - just 90 mins...'
weight[9]  =   6;   // 'Bridge - Now we're even closer...'
weight[10] =   5;   // 'Clear skies all the way'
weight[11] =   5;   // 'Family friendly travel...'
weight[12] =   5;   // 'New Business Man (time travelling)
weight[13] =   6;   // 'Connecting You... (new)
weight[14] =   6;   // 'Cleared for Take Off
weight[15] =   6;   // 'Bridge - Now we're even closer... Tipp'
weight[16] =   6;   // 'Bridge - Now we're even closer... Wexford'
weight[17] =   6;   // 'Tall Ships'
weight[18] =   0;   
weight[19] =   0;   
weight[20] =   0;   
weight[21] =   0;   
weight[22] =   0;   
 
 
// Weights are percentage therefore must total 100
 
var total_weight = weight[0]  +  weight[1]  + weight[2]  + weight[3]  + weight[4]  + weight[5]  + weight[6]  +  weight[7]  + weight[8]  + weight[9]  + weight[10] + weight[11] + weight[12] +  weight[13] + weight[14] + weight[15] + weight[16] + weight[17]  + weight[18]  + weight[19]  + weight[20]  + weight[21]  + weight[22]; 
 
var choice       =  0;
 
function RandomPic(range)
{
  if (Math.random)
    return Math.round(Math.random() * (100));   /* 'range-1' changed to '100' */
  else
  {
    var now = new Date();
    return (now.getTime() / 1000) % 100;        /*  'range' changed to '100'  */
  }
}
 
var cumWeight = 0;
var choice_position = RandomPic(0);
 
for (loop =0; loop <= numberImages; loop++){
  cumWeight += weight[loop];
  if (cumWeight >= choice_position){
    choice = loop;
    break;
  }
 
}
 
