function edhUrl() {
  var edhPage = $('#edh-url').val();
  var edhMatch = /everydayhero.com.au/;
  if (edhPage.match(edhMatch)) {
    $('#edh-warning').css('display', 'none');
    $('#catcustomcontentbutton').fadeTo(200, 1);
  } else {
    $('#edh-warning').css('display', 'block');
    $('#catcustomcontentbutton').css('display', 'none');
  }
}

$(document).ready(function() {

  $('.img-rotator').cycle();
 
  var targetWeight = $('#target-weight').html();
  var currentWeight = $('#weight-1').html();
  var firstWeight = $('.weights:last').html();
  var weightLost = firstWeight - currentWeight;
  var weightToLose = firstWeight - targetWeight;
  var weightLeft = currentWeight - targetWeight;
  if (weightLeft < 0) {
    weightLeft = 0;
  }
  var weightProgress = Math.round(weightLeft / weightToLose * 100);
  if (weightProgress == 0 && weightLeft == 0) {
    weightProgress = 100;
  }
  if (firstWeight == null) {
    weightProgress = 0;
  }
  
  $('#weight-bar-in').css('width', weightProgress + '%');
  
  var today = Math.round(new Date().getTime()/1000.0);
  if (today < 1278288000) {
    /* $('#weight-loss-side').css('display', 'none');*/
  }
  $('#goal-target').html(targetWeight);
  $('#goal-progress').html(weightProgress);
  $('#goal-left').html(weightLeft);
  $('#goal-lost').html(weightLost);
  
  
  /* Turn off group if the user hasnt defined on*/
  if ($('#profile-group').text() == '') {
    $('#profile-group-cont').css('display', 'none');
  }
  
  /* Turn off social networking links if they aren't entered in profile*/
  if ($('#profile-facebook').attr('href') == '') {
    $('#profile-facebook').css('display', 'none');
  }
  if ($('#profile-twitter').attr('href') == '') {
    $('#profile-twitter').css('display', 'none');
  }
  if ($('#profile-twitter').attr('href') == '' && $('#profile-facebook').attr('href') == '') {
    $('#profile-social').css('display', 'none');
  }
  
  var dWeight = $('#dash-event-weight').html();
  if (dWeight == ''){
    $('#dash-event-weight').css('display', 'none');
    $('.dash-weight-loss-challenge2').css('display', 'none');
  } else {
    $('#dash-join-weight').css('display', 'none');
    $('.dash-weight-loss-challenge').css('display', 'block');
    $('.dash-tips').css('display', 'list');
  }
  
  var dRunning = $('#dash-event-running').html();
  if (dRunning == ''){
    $('#dash-event-running').css('display', 'none');
    $('.dash-running-team2').css('display', 'none');
  } else {
    $('#dash-join-running').css('display', 'none');
    $('.dash-running-team').css('display', 'block');
    $('.dash-tips').css('display', 'list');
  }
  
  
  /* Add here an IF for every type of event to hide heading if all have No items found.*/
  if (dWeight == '' && dRunning == '') {
    $('#your-events').html('Not in any events');
    $('.dash-tips').css('display', 'none');
  }
  
  if (dWeight !== '' && dRunning !== '') {
    $('#join-event').css('display', 'none');
  }
  
  /* Everyday Hero signup stuff*/
  $('.edh-link').css('display', 'none');
  
  $('#edh-have').click(function() {
    $('.edh-link').fadeTo(600, 1);
    $('#footer').css('clear', 'both');
  });
  
  $('#edh-launch').click(function() {
    window.open('http://www.everydayhero.com.au/events/register/759?event=1452','_blank','left=20,top=20,width=990,height=600,toolbar=1,resizable=1,scrollbars=1,menubar=1,titlebar=1');
  });
  
  
  /* $('#slide-events').hover(function() {
    // $('#wrap-slideout').stop().animate({left: '224'}, 300);
    // $('#slideout-events').stop().fadeTo(200, 1);
  // }, function() {
    // $('#wrap-slideout').stop().animate({left: '0'}, 300);
    // $('#slideout-events').stop().fadeTo(200, 0);
  // });
  
  // $('#slide-cycle').hover(function() {
    // $('#wrap-slideout').stop().animate({left: '224'}, 300);
    // $('#slideout-cycle').stop().fadeTo(200, 1);
  // }, function() {
    // $('#wrap-slideout').stop().animate({left: '0'}, 300);
    // $('#slideout-cycle').stop().fadeTo(200, 0);
  // });
  
  // $('#slide-team').hover(function() {
    // $('#wrap-slideout').stop().animate({left: '224'}, 300);
    // $('#slideout-team').stop().fadeTo(200, 1);
  // }, function() {
    // $('#wrap-slideout').stop().animate({left: '0'}, 300);
    // $('#slideout-team').stop().fadeTo(200, 0);
  // });
  
  // $('#slide-weight').hover(function() {
    // $('#wrap-slideout').stop().animate({left: '224'}, 300);
    // $('#slideout-weight').stop().fadeTo(200, 1);
  // }, function() {
    // $('#wrap-slideout').stop().animate({left: '0'}, 300);
    // $('#slideout-weight').stop().fadeTo(200, 0);
  // });

  // $('#slide-ride').hover(function() {
    // $('#wrap-slideout').stop().animate({left: '224'}, 300);
    // $('#slideout-ride').stop().fadeTo(200, 1);
  // }, function() {
    // $('#wrap-slideout').stop().animate({left: '0'}, 300);
    // $('#slideout-ride').stop().fadeTo(200, 0);
  // });
  
  // $('#slide-tickets').hover(function() {
    // $('#wrap-slideout').stop().animate({left: '224'}, 300);
    // $('#slideout-tickets').stop().fadeTo(200, 1);
  // }, function() {
    // $('#wrap-slideout').stop().animate({left: '0'}, 300);
    // $('#slideout-tickets').stop().fadeTo(200, 0);
  // });
  
  // $('#slide-info').hover(function() {
    // $('#wrap-slideout').stop().animate({left: '224'}, 300);
    // $('#slideout-info').stop().fadeTo(200, 1);
  // }, function() {
    // $('#wrap-slideout').stop().animate({left: '0'}, 300);
    // $('#slideout-info').stop().fadeTo(200, 0);
  // });*/
  
  $(function() {
    $('.imgbox').lightBox({fixedNavigation:true});
  });
  
  $('#tab-newsletter').hover(function() {
    $('#tab-newsletter').attr('src', '/images/template/but-newsletter-hv.jpg');
  }, function() {
    $('#tab-newsletter').attr('src', '/images/template/but-newsletter.jpg');
  });
  
});
