jQuery.noConflict( )

jQuery(document).ready(function() {
  
  // Show and hide "More Info" footer content
  
  jQuery("#footer").mouseover(function(){
    if(jQuery("#footerContainer").height() == 50){
      jQuery("#footerContainer").animate({
        height: "150px"}, 300);
      jQuery("#footerContainer img")[0].src = "/img/footer_slideDown.gif";
    }
  }),
    jQuery("#footer").mouseleave(function(){
      jQuery("#footerContainer").animate({
        height: "50px"}, 200);
      jQuery("#footerContainer img")[0].src = "/img/footer_slide.gif";
      
  }),
    jQuery('.expand').click(function() {
      jQuery(this).next('.item').toggle("fast");
      jQuery(this).nextAll('.summary').toggle();
      
      if(jQuery(this).nextAll('.summary').css('display') != 'none'){
        jQuery(this).css({'background-image' : 'url(/img/bullet.gif)'});
      }else{
        jQuery(this).css({'background-image' : 'url(/img/bulletExpand.gif)'});
      }
    }),
    jQuery('.donateNow input[type=text]').focus(function() {
      jQuery(this).prevAll('input[type=radio]').attr('checked','checked');
    }),
    jQuery('.donateNow input[type=submit]').click(function() {
        return validateValue(this.form);
    }),
  // jQuery('.projectGoals .popup').each(function() // This lets us use jQuery(this) to refer to each element in the loop
  // {
  //    jQuery(this).qtip( // Create tooltips on the current .tips element
  //    { 
  //       content: jQuery(this).next('.item'), // Grab the element next to (after) the element
  //       style: {
  //         padding: 0,
  //         background: "none",
  //         width: 400,
  //         border: {
  //           width: 0
  //         }
  //       },
  //       position: {
  //         corner: {
  //           target: "rightMiddle",
  //           tooltip: "leftMiddle"
  //         }
  //       }
  //     });
  //   });

  jQuery('.whatsthis').each(function() // This lets us use jQuery(this) to refer to each element in the loop
  {
     jQuery(this).qtip( // Create tooltips on the current .tips element
     { 
        content: jQuery(this).next('.item'), // Grab the element next to (after) the element
        style: {
          padding: 0,
          background: "none",
          width: 400,
          border: {
            width: 0
          }
        },
        position: {
          corner: {
            target: "leftMiddle",
            tooltip: "rightMiddle"
          }
        }
      });
    });
  
  jQuery('.login .popup').each(function() // This lets us use jQuery(this) to refer to each element in the loop
  {
     jQuery(this).qtip( // Create tooltips on the current .tips element
     { 
        content: jQuery(this).next('.item'), // Grab the element next to (after) the element
        style: {
          padding: 0,
          background: "none",
          border: {
            width: 0
          }
        },
        position: {
          corner: {
            target: "bottomRight",
            tooltip: "topRight"
          }
        },
        show: {
          delay: 0,
          effect: {
            type: "slide",
            length: "200"
          }
        }
     });
    });
   jQuery('.about .popup').each(function() // This lets us use jQuery(this) to refer to each element in the loop
   {
      jQuery(this).qtip( // Create tooltips on the current .tips element
      { 
         content: jQuery(this).next('.item'), // Grab the element next to (after) the element
         style: {
           padding: 0,
           background: "none",
           width: 400,
           border: {
             width: 0
           }
         },
         position: {
           corner: {
             target: "bottomMiddle",
             tooltip: "topMiddle"
           }
         },
         hide: {
           fixed: true
         },
         show: {
           delay: 0,
           effect: {
             type: "slide",
             length: "200"
           }
         }
    });
  });
  jQuery('h1').each(function() // This lets us use jQuery(this) to refer to each element in the loop
    {
       jQuery(this).qtip( // Create tooltips on the current .tips element
       { 
          content: jQuery(this).nextAll('.item'), // Grab the element next to (after) the element
          style: {
            padding: 0,
            background: "none",
            width: 780,
            border: {
              width: 0
            }
          },
          position: {
            corner: {
              target: "topRight",
              tooltip: "topLeft"
            },
            adjust: {
              y: -7
            }
          },
          hide: {
            fixed: true
          },
          show: {
            delay: 0,
            effect: {
              length: "200"
            }
          }
     });
  });
 
  /* Disable the submit button after a submit and show the Processing message*/
  // jQuery('#confirmPaymentSubmit').click(function(){
  //   jQuery('#confirmPaymentSubmit').attr("value","Processing...");     
  //   jQuery('#confirmPaymentSubmit').attr("disabled","true");     
  // });
 
  /*Donate form email testor */
  // jQuery("#DonationformEmail").blur(function () {
  //      jQuery(this).next('.test').text('email blur');
  // });
 
});

function checkLastRadio(curForm){
  if (curForm.DonationValue.length > 1) {
    curForm.DonationValue[curForm.DonationValue.length-1].checked = true;
  }
}

function validateValue(curForm){
  if(curForm.DonationValue[curForm.DonationValue.length-1].checked == true){
    if(!(curForm.DonateDonationOther.value >= 10)){
      alert('A minimum of $10 is required to process a donation.');
      return false;
    }
    // round the value to two decimals if more than two provided.
    var result=Math.round(curForm.DonateDonationOther.value*100)/100;
    curForm.DonateDonationOther.value=result;
  }
  return true;
}

function logoutFB(){
	window.location = '/users/logout';
}
