var site_url = "http://hivemodern.com";var swatches                = new Array();var swatch_prices           = new Array();var total_options_price     = 0;var option_prices           = new Array();var current_option_prices   = new Array();var available_selections    = new Array();var product_price;var total_price;var msie                    = false;var hive_product = {	init: function() {	        jQuery.each(jQuery.browser, function(i, val) {            if (i == 'msie' && val) {                msie = true;            }        });        preloadImages(site_url+'/images/basic_arrow_down.gif');        preloadImages(site_url+'/images/basic_arrow_up.gif');        preloadImages(site_url+'/images/orange_arrow_right.gif');        preloadImages(site_url+'/images/orange_arrow_left.gif');                $(".product_page_header").hover(            function () {                //$('.search_links').fadeIn();            },             function () {                $('.search_links').fadeOut();            }        );        $('.cl_1').click(function() {            if ($(this).next().css('display') != 'block') {                $('.cl_1').next().hide('slow');                $('.cl_2').next().hide('slow');                $('.cl_3').next().hide('slow');                $(this).next().toggle('slow');		    }		    $('.cl_2').removeClass('cat_on');		    $('.cl_1').removeClass('cat_on');		    $(this).addClass('cat_on');		    return false;	    });	    $('.cl_2').click(function() {		    $('.cl_2').removeClass('cat_on');		    $('.cl').removeClass('cat_on');	        if ($(this).next().css('display') != 'block') {                $('.cl_2').next().hide('slow');                $('.cl_3').next().hide('slow');                $(this).next().toggle('slow');		    }            		    $(this).addClass('cat_on');		    return false;	    });	    $('.cl_3').click(function() {		    if ($(this).next().css('display') != 'block') {                $(this).parent().parent().find('.cat_sub').hide('slow');		        $(this).next().toggle('slow');		    } else {		        $(this).next().toggle('slow');		    }		    $('.cl_3').css('color','#808080');		    $('.cl_4').css('color','#808080');		    $(this).css('color','#FCAF17');		    return false;	    });        $('.cl_4').click(function() {		    if ($(this).next().css('display') != 'block') {                $(this).parent().parent().parent().find('.cat_sub').hide('slow');		        $(this).next().toggle('slow');		    }		     else {		        $(this).next().toggle('slow');		    }		    $('.cl_4').css('color','#808080');		    $(this).css('color','#FCAF17');		    return false;	    });                var myFile = document.location.toString();        if (myFile.match('#')) { // the URL contains an anchor            // click the navigation item corresponding to the anchor            var myAnchor = '#'+myFile.split('#')[1];        }                        $('.cat_sub').hide();        	}}jQuery(document).ready(function() {	hive_product.init();});function change_product(sub_product_id) {    location.href = site_url+"/pages/products.php?view=sub_product&sid="+sub_product_id;}function load_products(category_id) {    $("#product_space").fadeOut(200,        function() {            $("#product_space").css("background", "#FFFFFF url('"+site_url+"/images/hive_animation.gif') no-repeat 0 0");            $("#product_space").load(site_url+"/ajax/ajax.functions.php", { category_id: category_id,action: 'load_products' }, function() {                $("#product_space").fadeIn(900);            });        }    );}function load_sub_product(sub_product_id) {    return false;    $("#product_space").fadeOut(200,        function() {            $("#product_space").css("background", "#FFFFFF url('"+site_url+"/images/hive_animation.gif') no-repeat 0 0");            $("#product_space").load(site_url+"/ajax/ajax.functions.php", { sub_product_id: sub_product_id, action: 'load_sub_product' }, function() {                $("#product_space").fadeIn(900);            });        }    );}function back_to_sub_product() {    $('#product_left_content_2').hide();    $('#product_left_content_1').fadeIn(1500);}function back_to_swatches() {    $('#product_left_content_1').fadeOut();    $('#product_left_content_2').fadeIn();}function update_main_sub_photo(photo_src) {    $('#product_left_content_2').fadeOut();    $('#product_left_content_1').fadeIn();    $('#mi').fadeOut(600, function () {        $('#mi').attr('src', photo_src);    }).fadeIn(700);}function load_swatches(swatch_index, sub_product_id, swatch_set_id) {    $('#product_left_content_2').html('');    $('#product_left_content_1').fadeOut();    $('#product_left_content_2').fadeIn();    $("#product_left_content_2").load(site_url+"/ajax/ajax.functions.php", {swatch_index: swatch_index, sub_product_id: sub_product_id, swatch_set_id: swatch_set_id, action: 'get_swatches'}, function() {        });}function update_swatch_prices() {    swatch_price = 0;    for (var i = 0; i < swatch_prices.length; i++) {        swatch_price += parseInt(swatch_prices[i]);    }}function swatch_choice_complete() {    if (num_swatch_sets) {        if (num_swatch_sets != swatches.length) {            open_warning("please complete your option choices by choosing a swatch.");            return false;        } else {            return true;        }    }}function open_modal_dialog(warning) {    var overlay         = $(jQuery('<div id="modal_overlay" style="display:none;"></div>'));    var container       = $(jQuery('<div id="modal_warning" style="display:none;padding-top:80px;"></div>'));    var logo            = $(jQuery('<div id="dialog_logo"><img src="../images/hive-modern-furniture.gif" border="0" /></div>'));    var close           = $(jQuery('<div style="padding-top:10px;"><a href="javascript:;" class="close_button"><div class="close-button"></div></a></div>'));    overlay.fadeTo(50, 0.5);    container.append(logo);    container.append(close);    container.prepend('<h2>'+warning+'</h2>');    $('body').append(overlay).append(container);    container.show().css({'top': Math.round((($(window).height() > window.innerHeight ? window.innerHeight : $(window).height()) - container.outerHeight()) / 2) + 'px', 'left': Math.round(($(window).width() - container.outerWidth()) / 2) + 'px', 'margin-top': 0, 'margin-left': 0}).hide();    var page_sizes = getPageSize();    overlay.css({				width:				page_sizes[2],				height:				page_sizes[1]			});    overlay.add(container).fadeIn('normal');    close.click(function(c) {        c.preventDefault();        overlay.add(container).fadeOut('normal');    });    overlay.click(function(c) {        c.preventDefault();        overlay.add(container).fadeOut('normal');    });        $(window).resize(function() {        // Get page sizes        var page_sizes = getPageSize();        // Style overlay and show it        overlay.css({            width:		page_sizes[0],            height:		page_sizes[1]        });    });}function set_choice_in_frame(image, swatch_name, price) {    $('#swatch_choice_2').html('<img src="'+image+'" border="0" />');    $('#swatch_description_local').html('current selection: '+swatch_name);    if (price > 0) {        $('#swatch_description_price').html('<span class="yellow">$'+price+' additonal</span>');    } else {        $('#swatch_description_price').html('');    }    $('#swatch_info_local').fadeIn(500);}function hover_swatch_info(swatch_line_id, name, price) {    if (price > 0) {        $('#swatch_info_'+swatch_line_id).html(name+' : $'+price+' additonal');    } else {        $('#swatch_info_'+swatch_line_id).html(name);    }}function reset_swatch_info(swatch_line_id) {    $('#swatch_info_'+swatch_line_id).html('');}function update_swatch_prices() {    swatch_price = 0;    for (var i = 0; i < swatch_prices.length; i++) {        swatch_price += parseInt(swatch_prices[i]);    }}function open_warning(warning_message) {    open_modal_dialog(warning_message);}function validate_choices() {        $complete = true;        $('.product_selection').each(        function() {            if (!$(this).val()) {                $complete = false;            }                    }    );        if (!$complete) {        open_warning("please complete your option choices.");        return false;    } else {        var total_swatch_choices = 0;        jQuery.each(chosen_swatches, function(i, val) {            total_swatch_choices++;        });        if (num_swatch_sets) {            if (num_swatch_sets != total_swatch_choices) {                open_warning('please complete your option choices by choosing a swatch.');                return false;            } else {                return true;            }        }    }}function set_swatch_choice(sub_product_id, swatch_index, xref_id, swatch_id, new_swatch_price) {    chosen_swatches[swatch_index] = swatch_id;    $('#xref_id_'+swatch_index).val(xref_id);    $('#swatch_id_'+swatch_index).val(swatch_id);    swatch_prices[swatch_index] = new_swatch_price;    $('#swatch_choice_'+swatch_index).load(site_url+"/ajax/ajax.functions.php", {action: 'load_swatch_choice', sub_product_id: sub_product_id, swatch_index: swatch_index, xref_id: xref_id, swatch_id: swatch_id}, function() {        update_price_layer();    });}function update_price_layer() {    var total_swatch_price = 0;    var total_options_price = 0;    var option_html = '';    jQuery.each(product_selections, function(i, selection_id) {        if (parseInt(option_prices[$('#selection_'+selection_id).val()]) > 0) {            this_option_price = parseInt(option_prices[$('#selection_'+selection_id).val()]);            total_options_price += this_option_price;            option_html += option_values[$('#selection_'+selection_id).val()]+' : add $'+this_option_price.toFixed(2)+'<br />';        }    });        jQuery.each(chosen_swatches, function(i, val) {        if (parseInt(swatch_prices[i]) > 0) {            total_swatch_price += parseInt(swatch_prices[i]);        }    });    if (total_swatch_price > 0) {        $('#swatch_price_layer').html('<span style="color:#5d5d5d;">swatch(es)</span><br />add $'+total_swatch_price.toFixed(2));    } else {        $('#swatch_price_layer').html('');    }    if (total_options_price > 0) {        $('#option_price_layer').html('<span style="color:#5d5d5d;">option(s)</span><br />'+option_html);    } else {        $('#option_price_layer').html('');    }    total = (parseInt(retail_price) + parseInt(total_options_price) + parseInt(total_swatch_price)).toFixed(2);    if (total > retail_price) {        $('#total_price_layer').html('total $'+total);    } else {        $('#total_price_layer').html('');    }    }function concstring(stringa, stringb) {    return stringa+stringb;}function hover_product(product_id, index) {    var hover_html = concstring('', '<div id="hov_'+product_id+'" style="position:relative;">');    if (index == 5) {        // change arrow direction        hover_html = concstring(hover_html, hoverdata[product_id][0]+' <img src="'+site_url+'/images/orange_arrow_right.gif" border="0" />');        hover_html = concstring(hover_html, '<div style="padding-top:3px;padding-right:10px;">');    } else {        hover_html = concstring(hover_html, '<img src="'+site_url+'/images/orange_arrow_left.gif" border="0" /> '+hoverdata[product_id][0]);        hover_html = concstring(hover_html, '<div style="padding-top:3px;padding-left:10px;">');    }    if (hoverdata[product_id][1] == 0) {        hover_html = concstring(hover_html, 'call for pricing 1.866.663.4483');    } else {        hover_html = concstring(hover_html, '$'+hoverdata[product_id][1]);    }        if (hoverdata[product_id][2] > 0) {        hover_html = concstring(hover_html, '<div class="shipping-hover">shipping $'+hoverdata[product_id][2])+'</div>';    } else {        hover_html = concstring(hover_html, '<div class="shipping-hover">free shipping</div>');    }        hover_html = concstring(hover_html, '</div>');    hover_html = concstring(hover_html, '</div>');    $('#hover_box_'+product_id).html(hover_html);    $('#hover_box_'+product_id).css('z-index','100000');    $('#hover_box_'+product_id).fadeIn(165);}function hover_product_out(product_id) {    $('#hover_box_'+product_id).fadeOut(165);}function getPageSize() {    var xScroll, yScroll;    if (window.innerHeight && window.scrollMaxY) {	        xScroll = window.innerWidth + window.scrollMaxX;        yScroll = window.innerHeight + window.scrollMaxY;    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac        xScroll = document.body.scrollWidth;        yScroll = document.body.scrollHeight;    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari        xScroll = document.body.offsetWidth;        yScroll = document.body.offsetHeight;    }    var windowWidth, windowHeight;    if (self.innerHeight) {	// all except Explorer        if(document.documentElement.clientWidth){            windowWidth = document.documentElement.clientWidth;         } else {            windowWidth = self.innerWidth;        }        windowHeight = self.innerHeight;    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode        windowWidth = document.documentElement.clientWidth;        windowHeight = document.documentElement.clientHeight;    } else if (document.body) { // other Explorers        windowWidth = document.body.clientWidth;        windowHeight = document.body.clientHeight;    }	    // for small pages with total height less then height of the viewport    if(yScroll < windowHeight){        pageHeight = windowHeight;    } else {         pageHeight = yScroll;    }    // for small pages with total width less then width of the viewport    if(xScroll < windowWidth){	        pageWidth = xScroll;		    } else {        pageWidth = windowWidth;    }    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);    return arrayPageSize;};
