/*
*
* Display alert for IE7 users
* 
*
*
*/

RTW.POPUP = 
{
  name : 'RTW.POPUP',
  contentText : "We have detected you are using Internet Explorer 7 or a lower version of IE. Whilst we develop our new site we have not yet completed making our site work fully yet for IE7 and you may experience corrupted layout on certain pages. If you have another browser installed such as Firefox, Chrome or a later version of IE please try this as the site is tested and working on these versions. If you do not have a compatible browser that allows you to use our website please call 0800 707 6010 to speak to one of our consultants so we can advise you further.",


  init: function() 
  {
    $(document).ready(function () {
      if($.browser.msie){
         var docMode = parseFloat(document.documentMode) || 0;
         if(parseFloat($.browser.version) < 8 && docMode < 8){
            //Versions of IE less than 8
            
            if(!RTW.POPUP.getCookie('browser')) {
              alert(RTW.POPUP.contentText);
              RTW.POPUP.setCookie('browser', $.browser.version);
            } 
         }
      }
    });
  },

  setCookie: function(key, value) {  
     var expires = new Date();  
     expires.setTime(expires.getTime() + (1*60*60*1000)); //1 hour   // (1*60*60*1000)
     document.cookie = key + '=' + value + ';expires=' + expires.toUTCString();  
   },  
  
  getCookie: function (key) {  
     var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)'); 
     //if(keyValue) { alert( keyValue[2]) } else { alert('null')};
     return keyValue ? keyValue[2] : null;
  }  
}
RTW.POPUP.init();
