            var set_div = '';
            set_product_information_panel_height = function (div){
                set_div = div;
                for (var b=0;b<3;b++){
                    $('#btn_'+b).removeClass('tab_button_active');                
                }
                $('#btn_'+set_div.substr(set_div.length-1,1)).addClass('tab_button_active');
            }
            set_active_div = function (){
                var desc_height = 50+$('#'+set_div).height();
                var info_height = $('#general_info_area').height();
                var page_height = (info_height > desc_height) ? info_height : desc_height;
                $('#lower_page_container').height( page_height );
                $('#'+set_div).css( 'position: absolute' );
                setTimeout('set_active_div()', 200);
            }
            set_active_div();

            $('document').ready( function () {

                $('.restock').change( function () {
                    $('.gallery_stock_report').each( function (index, element){
                        $(this).html("<span class='mainbold'>Checking Stock</span>");
                        var manufacturers_id = $(this).attr('manufacturers_id');
                        var part_code        = $(this).attr('partcode');
                        part_code = part_code + $('.restock option[value='+$('.restock').val()+']').text();

                        in_stock({
                            target           : $(this), 
                            id               : $(this).attr('id'),
                            manufacturers_id : manufacturers_id,
                            part_code        : part_code,
                            span_type        : 'div',
                            sizes            : 0
                        });
                    });
                });
            
                $('.tab_button').hover(
                    function () {
                        $(this).addClass('tab_button_hover');
                    },
                    function () {
                        $(this).removeClass('tab_button_hover');                    
                    }
                );
            
                var panelLoaded = new Array();
                panelLoaded['panel_0'] = 1;
                panelLoaded['panel_1'] = 0;
                panelLoaded['panel_2'] = 1;

                loadAllReviews = function () {
                    panelLoaded['panel_2'] = 0;
                    $('#btn_2').click();    
                }
            
                $('.gallery_stock_report').each( function (index, element){
                    var manufacturers_id = $(this).attr('manufacturers_id');
                    var part_code        = $(this).attr('partcode');
                    if (initial_part_code_addendum) {
                        part_code = part_code + initial_part_code_addendum;
                        initial_part_code_addendum = null;
                    }

                    in_stock({
                        target           : $(this), 
                        id               : $(this).attr('id'),
                        manufacturers_id : manufacturers_id,
                        part_code        : part_code,
                        span_type        : 'div',
                        sizes            : $(this).attr('sizes')
                    });
                });
                
                var fadeIn  = 500;
                var fadeTo  = 250;
                var opacity = 1;
                $('.gallery_list').addClass('gallery');
                $('ul.gallery').galleria({
                    history   : false,
                    insert    : '#product_head_image',
                    onImage   : function(image,caption,thumb) { 
                        if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) {
                            image.css('display','none').fadeIn(fadeIn);
                        }
                        caption.css('display','none').fadeIn(fadeIn);
                        var _li = thumb.parents('li');
                        _li.siblings().children('img.selected').fadeTo(fadeTo, opacity);
                        thumb.fadeTo('fast', 1);
                        thumb.addClass('selected');
                    },
                    onThumb : function(thumb) {
                        var _li = thumb.parents('li');
				        var _fadeTo = _li.is('.active') ? '1' : opacity;
				        thumb.css(  {display:'none',opacity:_fadeTo}  ).fadeIn(fadeIn);
                        thumb.click( function (event){
                        });
                        thumb.hover( function() { 
                            thumb.fadeTo('fast', 1);
                        },
				        function() { 
                            _li.not('.active').children('img').fadeTo('fast', opacity); 
                        });
                    }
                });


                $('.tab_button').click( function () {
                    for (var n=0; n<=2; n++){
                        if ($(this).attr('id') != 'btn_'+n){
                            $('#panel_'+n).fadeOut('slow');
                        }
                        else {
                            if ( panelLoaded['panel_'+n] == 1){
                                $('#panel_'+n).fadeIn('slow');
                                set_product_information_panel_height('panel_'+n);
                            }
                            else {
                                switch (n){
                                    case 1:
                                        $.ajax({
                                            url: 'includes/_product_info.php',
                                            type: 'POST',
                                            data: "cPath="+cPath+"&products_id="+products_id+"&section=details",
                                            dataType: 'html',
                                            success: function(result){
                                                document.getElementById('panel_1').innerHTML = result;
                                                panelLoaded['panel_1'] = 1;
                                                $('#panel_1').fadeIn('slow');
                                                set_product_information_panel_height('panel_1');
                                            }
                                        });
                                        break;
                                    case 2:
                                        $.ajax({
                                            url: 'includes/_products_reviews2010.php?show_all=1',
                                            type: 'POST',
                                            data: "cPath="+cPath+"&manufacturers_id="+manufacturers_id+"&products_id="+products_id+"&section=detail&site="+referer_id,
                                            dataType: 'html',
                                            success: function(result){
                                                document.getElementById('panel_2').innerHTML = result;
                                                panelLoaded['panel_2'] = 1;
                                                $('#panel_2').fadeIn('slow');
                                                set_product_information_panel_height('panel_2');

                                                register_review_thumbs();
                                            }
                                        });
                                        break;
                                    default:
                                        break;
                                }
                            }
                        }
                    }
                });
                
                var allowScroll = true;
                var testemonialScroll = 0;
                scroll_testemonial = function (){
                    var maximum = $('#testemonial_scroll').height();

                    testemonialScroll = testemonialScroll + 1.5;
                    if (testemonialScroll > maximum) testemonialScroll = -80;
                    $('#testemonial_scroll').css('top',-testemonialScroll+'px');
                    if (allowScroll) setTimeout('scroll_testemonial();', 120);
                }
                scroll_testemonial();
                if (product_general_info){
                    $.ajax({
                        url: product_general_info,
                        type: 'POST',
                        data: "products_id="+products_id,
                        dataType: 'html',
                        success: function(result){
                            document.getElementById('general_info_area').innerHTML = result;
                            $('#general_info_area').fadeIn('fast');
                            $('.testemonial_area').hover ( function () {
                                allowScroll = false;
                            }
                            , function () {
                                if (!allowScroll){
                                    allowScroll = true;
                                    scroll_testemonial();
                                }
                            });
    if (consumer_review_area == 1) {
        if (document.getElementById('original_testemonials') && document.getElementById('consumer_review_area')) {
            document.getElementById('original_testemonials').style.display = 'none';
            document.getElementById('consumer_review_area').style.display = 'block';
        }
    }
                        }
                   });
                }

                set_product_information_panel_height('panel_0');

                send_review = function(){
                    var faq=$('#reviewstext').val();
                    var score=$('input[@name=\"group1\"]:checked').val();
                    var customer_name_field = $('#customer_name_field').val();
                    $.ajax({
                        type:'POST',
                        url:'includes/_faq_review_process.php',
                        data:'review='+faq+'&customer_id='+customers_id+'&products_id='+products_id+'&score='+score+'&customer_name_field='+customer_name_field,
                        success:function (){
                             $('#reviewarea').html('<legend>Thank You</legend>We have received your review and will display it, good or bad, after it has been checked for spam.');
                        }
                   });
                }


                review_thumb = function (reviewid,thumb) {
                    $('.thumbs').each( function () {
                        if ( reviewid == $(this).attr('reviewid') ){
                            $(this).removeClass('thumbs_up');
                            $(this).removeClass('thumbs_down');
                            if ( $(this).attr('vote_hide') ) $(this).css('display','none');
                        }
                    });
            
                    $.ajax({
                        url: '/includes/_products_reviews2010_ajax.php',
                        type: 'POST',
                        data: 'review_id='+reviewid+'&score='+thumb,
                        dataType: 'html',
                        success: function(result){
                            $('#reviewthumbs_'+reviewid).html( result );
                        }
                    });
              }

                register_review_thumbs = function () {
                    $('.thumbs_up').click( function () {
                        var reviewid = $(this).attr('reviewid');
                        review_thumb (reviewid,1); 
                    });
                    $('.thumbs_down').click( function () {
                        var reviewid = $(this).attr('reviewid');
                        review_thumb (reviewid,-1);
                    });
                }
                register_review_thumbs();
            });
