/*** Add opacity animation effect to NiO PhotoShelter RSS gallery ***/

var $a = jQuery.noConflict();

$a(document).ready(function(){
	// Parameters
	var fromOpac = 1.0, toOpac = 0.6, duration = 'normal';
	// Execution
	$a("img").fadeTo(duration, fromOpac);
	$a("img").hover(function(){
		$a(this).fadeTo(duration,toOpac); // ON HOVER EFFECT: SETS THE OPACITY TO 60% ON HOVER
	},function(){
   		$a(this).fadeTo(duration,fromOpac); // ON MOUSE OUT EFFECT: RESETS THE OPACITY TO 100% ON MOUSEOUT
	});
});

/*** Swaps search action ***/
function NiOonSubmit() {
  if(document.myform.x[0].checked == true)
  {
    document.myform.action ="http://www.dickberryphotography.com/";
  }
  else
  if(document.myform.x[1].checked == true)
  {
    var form = document.forms['myform'];
    var el1 = document.createElement("input");
    var el2 = document.createElement("input");
    var el3 = document.createElement("input");
   	el1.type = "hidden"; el1.name = "I_DSC"; el1.value = document.myform.s.value;
   	form.appendChild(el1);
   	el2.type = "hidden"; el2.name = "I_DSC_AND"; el2.value = "t";
   	form.appendChild(el2);
   	el3.type = "hidden"; el3.name = "_ACT"; el3.value = "search";
   	form.appendChild(el3);
    document.myform.action ="http://dickberryphotography.photoshelter.com/search"; 
  }
  return true;
}

/*** Clears a field ***/
function NiOclearBox(field_id, term_to_clear) {
	
	// Clear input if it matches default value
	if (document.getElementById(field_id).value == term_to_clear ) {
		document.getElementById(field_id).value = '';
	}
	
	// If the value is blank, then put back term
	else if (document.getElementById(field_id).value == '' ) {
		document.getElementById(field_id).value = term_to_clear;
	}
}

