﻿ $(document).ready(function(){
 //Start code ******************************************

    //audio events in Primary navigation
    
	
    
    
    /*PNG fix for IE*/
    jQuery(document).pngFix();
    
    /*little hover class to cover IE6 - else backed up in common.css for all other browsers*/
    jQuery("#primaryNavigation li").hover(
      function () {
        var soundId = jQuery(this).find("a").attr("id");
        jQuery(this).addClass("ieHover");
        soundManager.play(''+soundId+'');
      }, 
      function () {
        jQuery(this).removeClass("ieHover");
        }
    );
    
    /*hover class to change the colour of the image borders in galleryMajor*/
    jQuery("#galleryMajor li img").hover(
      function () {
        $(this).addClass("hover");
      }, 
      function () {
        $(this).removeClass("hover");
        }
    );
    
    /*function to equalize column height*/
    jQuery.fn.verticalJustify=function() {
        var maxHeight=0;
        this.each(function(){
            if (this.offsetHeight>maxHeight) {maxHeight=this.offsetHeight;}
        });
        this.each(function(){
            $(this).height(maxHeight + "px");
            if (this.offsetHeight>maxHeight) {
                $(this).height((maxHeight-(this.offsetHeight-maxHeight))+"px");
            }
        });
    };
    /*Now Thomas, equalize the column heights of ecardList*/
    jQuery("#ecardList > li ").verticalJustify();
    
    //Start Gallery function
		jQuery("#galleryList").find("img").each(function(i){
		
		    //Get the alt and src of the image in the list
            var altText = jQuery(this).attr("alt");
            var theSrc = jQuery(this).parent().attr("href");
            
            //set the link title attribute using the images alt text 
            jQuery(this).parent().attr("title",altText);
            
            //Start click function
            jQuery(this).parent().click(
              function () {
                //fade out any existing caption
                jQuery("#galleryMajor #galleryImageContainer p.caption").remove(); 
                
                                            
                //Chained actions for galleryImage (visually stacked up so you can read them)
                jQuery("#galleryImage")
                    .hide()
                    .attr("src", theSrc)
                    .attr("alt", altText)
                    .fadeIn("normal")
                ;
                
                //Chained actions for #galleryMajor to shpw a caption below the main image
                jQuery("#galleryMajor #galleryImage")
                    .hide()
                    .attr("src", theSrc)
                    .attr("alt", altText)
                    .fadeIn("normal")
                    .after("<p class='caption'><span>" + altText + "</span><span class='visualEffect'></span></p>")
                ;
                
                //Chained caption animation
                jQuery("#galleryMajor #galleryImageContainer p.caption")
                    .hide()
                    .fadeIn("slow")
                ;
                
                soundManager.play('navHome');
                
                //stop the link working
                return false;
              }
            );
            //end click function
            
        });
        //end gallery function
    
        //Zebra  for table
        
        jQuery(".zebra tr td:odd").addClass("price");
        jQuery(".zebra tr th").addClass("header");
        
        /*add some print buttons to the stories*/
        jQuery(".neutralPointOfReference").before("<p id=\"printYourEcard\" class=\"floatRight\"><img src=\"../SiteImages/Buttons/btnPrint.gif\" width=\"254\" height=\"50\" alt=\"Print your E-Card\" /></p>")
        jQuery("#printYourEcard").click(function(){
            javascript:window.print();
        });
        
        //This is a hack to override the default border stylings of an asp:image
        jQuery("#ecardPreview img").removeAttr("style");
        
       
       
        
       
     
 //end code ******************************************
 });


