//*****Replace align attribute with class**************************************************//
function replaceAlign() {
  if (!document.getElementsByTagName('img')) return false;
  $('img[align="left"]').addClass('left').removeAttr('align');
	$('img[align="right"]').addClass('right').removeAttr('align');
	$('img[align="middle"]').addClass('middle').removeAttr('align');
}
//*****Replace target attribute with class**************************************************//
function replaceTarget() {
  if (!document.getElementsByTagName('a')) return false;
  $('a[target]').addClass('newwindow').removeAttr('target');
}
//*****The following function make it possible to have web standard popups**************************************************//
function strictNewWindow() {
  if (!document.getElementsByTagName('a')) return false;
  $('.newwindow').click(function() {
		window.open($(this).attr('href'));
    return false;
	});
}
//*****Toggle Wordpress Resources********************************************************//
function toggleSomething() {
  $('.menuToggle').hide();
  $('.menuWrap h4').addClass('inactive');
  $('.menuWrap h4').click(function () {
    $(this).toggleClass('inactive');
    $(this).toggleClass('active');
  	$(this).parent().find('.menuToggle').slideToggle();
  });
}
  /***** Menu Fade *****/
function imageFade() {
  $('.menuCallouts img').animate({"opacity": .8 }); 
  $('.menuCallouts img').hover(function() {
    $(this).stop().animate({ "opacity": 1 }); 
  }, function() { 
    $(this).stop().animate({ "opacity": .8 }); 
  });
  
  $('.ngg-albumoverview img').animate({"opacity": .8 }); 
  $('.ngg-albumoverview img').hover(function() {
    $(this).stop().animate({ "opacity": 1 }); 
  }, function() { 
    $(this).stop().animate({ "opacity": .8 }); 
  });
  
  $('.ngg-galleryoverview img').animate({"opacity": .8 }); 
  $('.ngg-galleryoverview img').hover(function() {
    $(this).stop().animate({ "opacity": 1 }); 
  }, function() { 
    $(this).stop().animate({ "opacity": .8 }); 
  });
  
}

  /***** Clear Inputs *****/
function clearInputs() {
  $('#cf_field_2').focus(function() {
    if ($(this).val() == 'Name') {
      $(this).val('');
    }
  });
  $('#cf_field_2').blur(function() {
    if ($(this).val() == '') {
      $(this).val('Name');
    }
  });
  $('#cf_field_3').focus(function() {
    if ($(this).val() == 'Email') {
      $(this).val('');
    }
  });
  $('#cf_field_3').blur(function() {
    if ($(this).val() == '') {
      $(this).val('Email');
    }
  });
  $('#cf_field_4').focus(function() {
    if ($(this).val() == 'Message...') {
      $(this).val('');
    }
  });
  $('#cf_field_4').blur(function() {
    if ($(this).val() == '') {
      $(this).val('Message...');
    }
  });
  
  $('#1a').focus(function() {
    if ($(this).val() == 'STREET') {
      $(this).val('');
    }
  });
  $('#1a').blur(function() {
    if ($(this).val() == '') {
      $(this).val('STREET');
    }
  });
  
  $('#1c').focus(function() {
    if ($(this).val() == 'CITY') {
      $(this).val('');
    }
  });
  $('#1c').blur(function() {
    if ($(this).val() == '') {
      $(this).val('CITY');
    }
  });
  
  $('#1s').focus(function() {
    if ($(this).val() == 'STATE') {
      $(this).val('');
    }
  });
  $('#1s').blur(function() {
    if ($(this).val() == '') {
      $(this).val('STATE');
    }
  });
  
  $('#1z').focus(function() {
    if ($(this).val() == 'ZIP') {
      $(this).val('');
    }
  });
  $('#1z').blur(function() {
    if ($(this).val() == '') {
      $(this).val('ZIP');
    }
  });
  
  $('#name').focus(function() {
    if ($(this).val() == 'Name') {
      $(this).val('');
    }
  });
  $('#name').blur(function() {
    if ($(this).val() == '') {
      $(this).val('Name');
    }
  });
  
  $('#xqtkt-xqtkt').focus(function() {
    if ($(this).val() == 'Email') {
      $(this).val('');
    }
  });
  $('#xqtkt-xqtkt').blur(function() {
    if ($(this).val() == '') {
      $(this).val('Email');
    }
  });
}

  /***** Lightbox *****/
  
function lightbox() {
  $('a.lightbox').fancybox();
}

//*****Load all functions**************************************************//
$(document).ready(function(){
  replaceAlign();
  replaceTarget();
  strictNewWindow();
  toggleSomething();
  clearInputs();
  imageFade();
  lightbox();
});
