function element(id) {
 if(document.getElementById != null) {
  return document.getElementById(id);
 }
 else if(document.all != null) {
  return document.all[id];
 }
 else if(document.layers != null) {
  return document.layers[id];
 }
 else {
  return null;
 }
}


function unhideSEO()
{
  ;
}


setInterval('rotatePressTicker();', 4000);
var currentItem = 0;

function rotatePressTicker() {
  var oldItem = element("tickerItem" + currentItem);
  currentItem++;
  var newItem = element("tickerItem" + currentItem);
  if (!newItem) {
    newItem = element("tickerItem0");
    currentItem = 0;
  }
  newItem.style.display = "block";
  oldItem.style.display = "none";
  newItem.style.display = "block";
}



function changeBT(){
 element('btcat_form').submit();
}

function submitSelect(){
 this.submit();
}

function swapOffBg(id) {
  var id = element(id);
  id.style.background = '#fff';
}

function swapOnBg(id,image) {
  var id = element(id);
  if (!id.value) {
    id.style.background = '#fff';
    id.style.backgroundColor = '#fff';
    id.style.backgroundImage = 'url(http://www.sayfiereview.com/images/'+ image +')';
    id.style.backgroundRepeat = 'no-repeat';
    id.style.backgroundPosition = '2px 2px';
  }
}


function toggle_ticker_form(field_id, disable_field_id) {
	element = document.getElementById(field_id);
	element.disabled = false;
	element.focus();
	document.getElementById(disable_field_id).disabled = true;
}


$(document).ready(function(){
  $("body").delegate('a', 'click', function(e){
    e.preventDefault();
    e.stopPropagation();
    return false;
  });
  
  $("html").delegate('a', 'mousedown', function(e) {
    console.log(e.which);
    if (this.href && this.href != '#') {
      var href = this.href
      var matches = this.href.match(/https?:\/\/([^\/]*)/)
      if (matches.length > 0 && matches[1] != window.location) {
        e.preventDefault()
        e.stopPropagation()
        if (this.text) {
          $.ajax({
            type: 'POST',
            url: '/outlinks.json',
            data: { name: this.text, url: this.href },
            complete: function(){
              console.log(e)
              console.log(href)
              if (e.which == 1){
                window.location = href
              }
            }
          });
        } else {
          if (e.which == 1){
            window.location = href
          }
        }
      }
    }
    return false;
  });

  $('a[data-share-link]').superShare({url: 'http://flguru.sayfiereview.com'});
})

$(document).ready(function set_scoring_cookie(){
  var now = new Date();
  var time = now.getTime();
  time += 3600 * 1000;
  now.setTime(time);
  document.cookie = 'visitedsite=1;' + 'expires=' + now.toGMTString() + '; path=/; domain=.sayfiereview.com';
})

