// ready state
$(document).ready(function() {
			   
	//add overlabel class on page load
	$("label.overlabel").overlabel();
	
	//hide all accordion content except first one
	$(".accordion div").hide();
	$('.accordion div:eq(0)').slideDown(0);
	
	//accordion button action
	$('.accordion h3').click(function() {
		$('.accordion div').slideUp('fast');	
		$(this).next().slideDown('fast');
	});
	
	//hide inactive gallery images & show all tabs
	$("#product_gallery img").hide();
	$("#product_gallery img:first").show();
	$("#product_gallery .tab").css('display','block');
	
	//gallery click function
	$("#product_gallery a").click(function(){
		$("#product_gallery a img").hide();
		$('#product_gallery a').removeClass("active");
		$(this).addClass("active").children('img').toggle();	   
	});
 
});
//PNG Fix
//$(function(){ 
  //  $(document).pngFix(); 
//}); 

//Menu
$(function(){

    $("ul#listMenuRoot li").hover(function(){
        $(this).addClass("hover");
        $('ul:first',this).css('top', '0px');
    
    }, function(){
        $(this).removeClass("hover");
        $('ul:first',this).css('top', '-999em');
    });
    
    $("ul#listMenuRoot li ul li:has(ul)").find("a:first").append(" &raquo; ");

});
  
// Compact Forms - positions labels inside text fields
( function( $ ) {
 
    // plugin definition
    $.fn.overlabel = function( options ) {
 
        // build main options before element iteration
        var opts = $.extend( {}, $.fn.overlabel.defaults, options );
 
        var selection = this.filter( 'label[for]' ).map( function() {
 
            var label = $( this );
            var id = label.attr( 'for' );
            var field = document.getElementById( id );
 
            if ( !field ) return;
 
            // build element specific options
            var o = $.meta ? $.extend( {}, opts, label.data() ) : opts;
 
            label.addClass( o.label_class );
 
            var hide_label = function() { label.css( o.hide_css ) };
            var show_label = function() { this.value || label.css( o.show_css ) };
 
            $( field )
                 .parent().addClass( o.wrapper_class ).end()
                 .focus( hide_label ).blur( show_label ).each( hide_label ).each( show_label );
 
            return this;
 
        } );
 
        return opts.filter ? selection : selection.end();
    };
 
    // publicly accessible defaults
    $.fn.overlabel.defaults = {
 
        label_class:   'overlabel-apply',
        wrapper_class: 'compact_form',
        hide_css:      { 'text-indent': '-10000px' },
        show_css:      { 'text-indent': '0px', 'cursor': 'text' },
        filter:        false
 
    };
 
} )( jQuery );
