var oldValue = '';
// when the DOM is ready:
$(document).ready(function () {
  // find the div.fade elements and hook the hover event
  $('div.fade').hover(function() {
    // on hovering over, find the element we want to fade *up*
    var fade = $('> div', this);

    // if the element is currently being animated (to a fadeOut)...
    if (fade.is(':animated')) {
      // ...take it's current opacity back up to 1
      fade.stop().fadeTo(250, 1);
    } else {
      // fade in quickly
      fade.fadeIn(250);
    }
  }, function () {
    // on hovering out, fade the element out
    var fade = $('> div', this);
    if (fade.is(':animated')) {
      fade.stop().fadeTo(3000, 0);
    } else {
      // fade away slowly
      fade.fadeOut(3000);
     }
  });

  $('#banner').fadeIn('slow', function() {
    // Animation complete
   });

  $('.l a').mouseover(function() {
         jQuery(this)
              .animate({backgroundPosition: '0px 0px',color: '#ffffff'},{duration:200});
  });

  $('.l a').mouseout(function() {
         jQuery(this)
              .animate({backgroundPosition: '0px 14px',color: '#C94386'},{duration:200});
  });

  $('.partner-image').each(function ()
                       {
                         var blurb = '#'+this.id+'-blurb';
                         this.onmouseover = function () {$(blurb).fadeIn('fast', function() {/*Animation complete*/});};
      //                   jQuery(blurb).fadeIn('slow', function() {// Animation complete});


                       });

  $('.footer-sm').each(function ()
                       {
                         this.onmouseover = function () {$(this).attr("src","/images/"+this.id+"-o.png");};
                         this.onmouseout = function () {$(this).attr("src","/images/"+this.id+".png");};
                       });
                       
  $('.side-nav').each(function ()
                       {
                         this.onmouseover = function () {$(this).attr("src","/images/"+this.id+"-o.jpg");};
                         this.onmouseout = function () {$(this).attr("src","/images/"+this.id+".jpg");};
                       });

  $('.h').each(function ()
                       {
                         this.onmouseover = function () {$(this).css({'background-color':'#ffffff'});};
                         this.onmouseout = function () {$(this).css({'background-color':''});};
                       });

  if($('#submit-btn').length!=0)
  {
    $('#submit-btn').mouseover(function() {
           $(this).attr("src","/images/btn-submit-o.jpg");
    });
    $('#submit-btn').mouseout(function() {
           $(this).attr("src","/images/btn-submit.jpg");
    });
  }
});

function close(id)
{
  /*jQuery('#'+id).hide();*/
  jQuery('#'+id).fadeOut('fast', function() {/*Animation complete*/});
}

function init_menus()
{
/*
  if(document.getElementById('sub-1'))
  {
    document.getElementById('top-1').onmouseover = function () {document.getElementById('sub-1').style.display = 'block';}
    document.getElementById('top-1').onmouseout = function () {document.getElementById('sub-1').style.display = 'none';}
  }

  if(document.getElementById('sub-2'))
  {
    document.getElementById('top-2').onmouseover = function () {document.getElementById('sub-2').style.display = 'block';}
    document.getElementById('top-2').onmouseout = function () {document.getElementById('sub-2').style.display = 'none';}
  }

  if(document.getElementById('sub-3'))
  {
    document.getElementById('top-3').onmouseover = function () {document.getElementById('sub-3').style.display = 'block';}
    document.getElementById('top-3').onmouseout = function () {document.getElementById('sub-3').style.display = 'none';}
  }

  if(document.getElementById('sub-4'))
  {
    document.getElementById('top-4').onmouseover = function () {document.getElementById('sub-4').style.display = 'block';}
    document.getElementById('top-4').onmouseout = function () {document.getElementById('sub-4').style.display = 'none';}
  }

  if(document.getElementById('sub-5'))
  {
    document.getElementById('top-5').onmouseover = function () {document.getElementById('sub-5').style.display = 'block';}
    document.getElementById('top-5').onmouseout = function () {document.getElementById('sub-5').style.display = 'none';}
  }

  var top_1 = document.getElementById('top-1-image').src;
  document.getElementById('top-1-image').onmouseover = function () {document.getElementById('top-1-image').src = '/images/home-hover.jpg';};
  document.getElementById('top-1-image').onmouseout = function () {document.getElementById('top-1-image').src = top_1;};

  var top_2 = document.getElementById('top-2-image').src;
  document.getElementById('top-2-image').onmouseover = function () {document.getElementById('top-2-image').src = '/images/about-hover.jpg';};
  document.getElementById('top-2-image').onmouseout = function () {document.getElementById('top-2-image').src = top_2;};

  var top_3 = document.getElementById('top-3-image').src;
  document.getElementById('top-3-image').onmouseover = function () {document.getElementById('top-3-image').src = '/images/services-hover.jpg';};
  document.getElementById('top-3-image').onmouseout = function () {document.getElementById('top-3-image').src = top_3;};

  var top_4 = document.getElementById('top-4-image').src;
  document.getElementById('top-4-image').onmouseover = function () {document.getElementById('top-4-image').src = '/images/work-hover.jpg';};
  document.getElementById('top-4-image').onmouseout = function () {document.getElementById('top-4-image').src = top_4;};

  var top_5 = document.getElementById('top-5-image').src;
  document.getElementById('top-5-image').onmouseover = function () {document.getElementById('top-5-image').src = '/images/get-in-touch-hover.jpg';};
  document.getElementById('top-5-image').onmouseout = function () {document.getElementById('top-5-image').src = top_5;};

  $('.menu_item').each(function ()
                       {
                         this.onmouseover = function () {this.style.backgroundColor = '#e79fc3';};
                         this.onmouseout = function () {this.style.backgroundColor = '#d03f88';};
                       });

  $('.menu_last_item').each(function ()
                       {
                         this.onmouseover = function () {this.style.backgroundColor = '#e79fc3';};
                         this.onmouseout = function () {this.style.backgroundColor = '#d03f88';};
                       });
*/
}

function init_portfolio()
{
  $(document).ready(function(){
    //Examples of how to assign the ColorBox event to elements
    $("a[rel='example1']").colorbox();});
  }
/*
    $("a[rel='example2']").colorbox({transition:"fade"});
    $("a[rel='example3']").colorbox({transition:"none", width:"75%", height:"75%"});
    $("a[rel='example4']").colorbox({slideshow:true});
    $(".example5").colorbox();
    $(".example6").colorbox({iframe:true, innerWidth:425, innerHeight:344});
    $(".example7").colorbox({width:"80%", height:"80%", iframe:true});
    $(".example8").colorbox({width:"50%", inline:true, href:"#inline_example1"});
    $(".example9").colorbox({
      onOpen:function(){ alert('onOpen: colorbox is about to open'); },
      onLoad:function(){ alert('onLoad: colorbox has started to load the targeted content'); },
      onComplete:function(){ alert('onComplete: colorbox has displayed the loaded content'); },
      onCleanup:function(){ alert('onCleanup: colorbox has begun the close process'); },
      onClosed:function(){ alert('onClosed: colorbox has completely closed'); }
    });
    //Example of preserving a JavaScript event for inline calls.
    $("#click").click(function(){
    $('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
    return false;
  });
*/