$('html').addClass('js');
$(document).ready(function() {	
     $('#contact').click(function(event) {              
               event.preventDefault();
               $('#contact-form-container').animate({
                    height: 'toggle'
               }, {
                    duration: 950,
                    easing: 'easeInOutCirc'
               });
          }
     );
     
     $('#contact-form input[type=text]').css({
          backgroundColor: '#000', opacity: 0.4, color: '#fff'
     });
     
     $('#contact-form textarea').css({
          backgroundColor: '#000', opacity: 0.4, color: '#fff'
     });     
     
     $('#contact-form input[type=text]').focus(function() {
          $(this).css({ backgroundColor: '#000', opacity: 1, color: '#fff' });
     });   
     
     $('#contact-form input[type=text]').blur(function() {
          $(this).css({ backgroundColor: '#000', opacity: 0.4, color: '#e3e3e3' });
     });
     
     $('#contact-form textarea').focus(function() {
          $(this).css({ backgroundColor: '#000', opacity: 1, color: '#fff', border: '1px solid #fb9e65' });
     });   
     
     $('#contact-form textarea').blur(function() {
          $(this).css({ backgroundColor: '#000', opacity: 0.4, color: '#e3e3e3' });
     });           
          
     // Initialize TransMenu, if we're not stuck with internet exploder (no, that is not a typo).
     if ( ! $.browser.msie )
     {
          init();
     }
     
     // Initialize the accordion menu
     $("#accordion-menu").accordion({
          active: '.selected', 
          selectedClass: 'active', 
          header: "dt" 
     });
     
     $('#promo_accordion').accordion({
          active: '.active',
          header: 'dt'
     });

     // Animations appearing over patient/physician CTA buttons
     $(".menu2 a").append("<em></em>");
     
     $(".menu2 a").hover(function() {
          $(this).find("em").animate({opacity: "show", top: "-100"}, "slow");
          var hoverText = $(this).attr("title");
          $(this).find("em").text(hoverText);
     }, function() {
          $(this).find("em").animate({opacity: "hide", top: "-90"}, "fast");
     });

     // Get rid of those stupid borders around links in FF, IE when links are clicked
     $('a, dt').focus(function() {
        $(this).blur();
     });

     // Add file-type icons to links (PDF, MS Word, etc.)
     //Apply CSS class to all A links that end in .pdf
     $("a[href$='.pdf']").addClass("PDF");
     
     // Force all links to PDF documents to load in a new window
     $("a[href$='.pdf']").attr('target', '_blank');

     //Apply CSS class to all A links that end in .doc
     $("a[href$='.doc']").addClass("DOC");
     
     //Apply CSS class to all A links that end in .xls
     $("a[href$='.xls']").addClass("XLS");
     
     //Apply CSS class to all A links that end in .ppt
     $("a[href$='.ppt']").addClass("PPT");
     
     //Apply CSS class to all A links that end in .jpg
     $("a[href$='.jpg']").addClass("Image");
     
     //Apply CSS class to all A links that end in .gif
     $("a[href$='.gif']").addClass("Image");
     
     //Apply CSS class to all A links that end in .png
     $("a[href$='.png'").addClass("Image");     
     
     //Apply CSS class to all A links that start with http://
     $("a[href^='http://']").addClass("ExternalLink");
     
     $("a[href*='cine-med.com/fsdds']").removeClass("ExternalLink");
     
     //Remove CSS class to all A links that start with http://www.YOURDOMAINHERE.co.uk
     $("a[href^='http://www.fsdds.com']").removeClass("ExternalLink");
     
     //Remove CSS class to all A links that start with http://www.YOURDOMAINHERE.co.uk
     $("a[href^='http://fsdds.dyndns.org']").removeClass("ExternalLink");
     
     //Remove CSS class from all A links within the carousel
     $("#carousel > li > a").removeClass("ExternalLink");
     
     // Remove PDF class from all anchors that contain an image tag
     $("a[href$='.pdf']:has(img)").removeClass('PDF');
     
     $("#promo .promo_accordion_link").removeClass("ExternalLink");
     
     //Remove CSS class from meeting promo image link
     $("#2009-meeting-promo").removeClass("ExternalLink");
     $("#2009-sbs-promo").removeClass("ExternalLink");
     
     //Apply CSS class to all A links that start with mailto:
     $("a[href^='mailto:']").addClass("Mail");

     // Reload the CAPTCHA image when the reload link is clicked
     $('#reload-captcha').click(function() {
          $('#captcha').attr({
               "src": '/lib/securimage/securimage_show.php?' + eval( Math.random() )
          });
     });
     
     $('#doctorSearchCity').focus(function() {
          if ( $(this).val() == 'City' ) {
               $(this).val('');
          }
     });
     
     $('#doctorSearchCity').blur(function() {
          if ( $(this).val() == '' ) {
               $(this).val('City');
          }
     });     

     $('#doctorSearchZip').focus(function() {
          if ( $(this).val() == 'Zip Code' ) {
               $(this).val('');
          }
     });
     
     $('#doctorSearchZip').blur(function() {
          if ( $(this).val() == '' ) {
               $(this).val('Zip Code');
          }
     });   
	
	// Display 'enter invoice number' in the text input field of the Pay Membership Dues form (sidebar)
	$('#invoice_no').val('Enter Member ID Number');
     $('#invoice_no').focus(function() {
          if ( $(this).val() == 'Enter Member ID Number' ) {
               $(this).val('');
          }
     });
     
     $('#invoice_no').blur(function() {
          if ( $(this).val() == '' ) {
               $(this).val('Enter Member ID Number');
          } else {
          	$(this).val( $(this).val() );
          }
     });   
     
     $('.listing div').hide();
     $('.listing:odd').css('background-color', '#fbf7ee');
     $('.listing h2').css('cursor', 'pointer').click(function() {
          $(this).next().slideToggle( 85 );
     });
     
     $('form.standard tbody tr:odd').css({
          backgroundColor: '#efefe3'
     });

     $('#back-the-pac').hover(
          function() {
               $(this).attr('src', '/images/back_the_pac_on.png');
          },
          function() {
               $(this).attr('src', '/images/back_the_pac.png');
          }
     );
});
