var html;
var timers = [];
var spinner = '<div class="spinner"></div>';

function closeBrowsersPanel(){
  setCookie('SCANWORD_OLD', 1, {
    expires: 604800
  });
  $('#old-browser-panel').hide('fast');
}

$(document).ready(function(){
  
  var browser = $.browser;
  var version = parseInt(browser.version);
  
  if (browser.msie && version < 8) {
    $("#old-browser-panel").show();    
  }
  
  $("a#fancybox_link").fancybox({
    autoDimensions: false,
    hideOnOverlayClick: false,
    showCloseButton: false,
    enableEscapeButton: false,
    transitionIn : 'fade',
    transitionOut : 'fade',
    height: 450,
    onClosed: function(){
      $('#fancybox_dialog').empty();
    }
  });

  $(".scroll").click(function(event){
    //prevent the default action for the click event
    event.preventDefault();

    //get the full url - like mysitecom/index.htm#home
    var full_url = this.href;

    //split the url by # and get the anchor target name - home in mysitecom/index.htm#home
    var parts = full_url.split("#");
    var trgt = parts[1];

    //get the top offset of the target anchor
    var target_offset = $("#"+trgt).offset();
    var target_top = target_offset.top;

    //goto that anchor by setting the body scroll top to anchor top
    $('html, body').animate({
      scrollTop:target_top
    }, 500);
  });


});

function callFancybox(text){
  $('#fancybox_dialog').empty().append(text);
  $('#fancybox_link').click();
}

// уcтанавливает cookie
function setCookie(name, value, props) {
  props = props || {}
  var exp = props.expires
  if (typeof exp == "number" && exp) {
    var d = new Date()
    d.setTime(d.getTime() + exp*1000)
    exp = props.expires = d
  }
  if(exp && exp.toUTCString) {
    props.expires = exp.toUTCString()
  }

  value = encodeURIComponent(value)
  var updatedCookie = name + "=" + value
  for(var propName in props){
    updatedCookie += "; " + propName
    var propValue = props[propName]
    if(propValue !== true){
      updatedCookie += "=" + propValue
    }
  }
  document.cookie = updatedCookie
}
