// Contact Banner

// Number of times to load per session
var load_per_session = 2;

function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if(document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if(offset != -1) { // if cookie exists
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1)
        end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
  }
  return returnvalue;
}

function load_contact(){
  setTimeout( function() {
    $('#contact_msg').slideToggle();
  }, 3000);
}

$(document).ready(function(){
  var i = 0;
  var val = get_cookie("contact_banner");
  if(val !== '') {
    i = val;
  }
  if(get_cookie("no_banner")!=1){
    if(i != load_per_session){
      i++;
      load_contact()
      document.cookie="contact_banner="+i
    }
  }
  $('#contact_msg a.close').click(function () { 
    $('#contact_msg').hide();
    document.cookie="no_banner=1";
    return false;
  });
});