function hansalogIFsize(s) {
    $('#hansalog').css('height', s+'px');
}

(function($) {
    $.fn.slideMenu = function(menuBg){
        $(this).find('ul:first').addClass('sMenu');
        var timer, navOpen, pauseHide = false;
        
        if(menuBg) {
            mBg = $(menuBg);
        }
        
        $(this).find('ul:first').children('li').hover(function(){
            if(timer) { clearTimeout(timer); }
            if(navOpen && navOpen.find('ul:first').children('li').get(0) !== $(this).find('ul:first').children('li').get(0)) {
                navOpen.find('ul:first').slideUp(200);
                if(pauseHide !== false) { pauseHide.blur(); }
            }
            
            var self = $(this).find('ul:first').slideDown(250);
            navOpen = $(this);
            
            if(menuBg) {
                mBg.animate({height:((self.children('li').length*self.children('li').height())+10)+'px'},{queue:false, duration:250});
            }
        },function(){
            if(pauseHide === false) {
                timer = setTimeout(function(){
                    navOpen.find('ul:first').slideUp(250);
                    if(menuBg) {
                        mBg.animate({height:'0px'},{queue:false, duration:250});
                    }
                }, 500);
            }
        });
        
        $(this).find("input[type='text'],input[type='password']").focus(function(){
            if(timer) { clearTimeout(timer); }
            pauseHide = this;
        }).blur(function(){
            var b = navOpen;
            pauseHide = false;
            timer = setTimeout(function(){ b.find('ul:first').slideUp(250); }, 100);
        });
    };    
})(jQuery);

(function($) {    
    $.fn.imagestageAni = function(){
        var current = 0, t = $('#imgstageBox'), tw = $('#imgstage').width(), items = t.find('.imgstageItem'), itemCount = items.length, navItems = $('#imgstageNav').children('a'), left = 0, timer;

        function next() {
            var n = (current + 1 === itemCount) ? 0 : current + 1;
            moveTo(n);
        }
        
        function moveTo(index) {
            var moveEnd = function() {
                t.append($(t.find('.isaIdx_'+index).prevAll().remove().toArray().reverse())).css('left', 0);
                navItems.eq(current).removeClass('current');
                navItems.eq(index).addClass('current');
                current = index;
                timer = window.setTimeout(next, 5000);
            };

            if(index > current) {
                left = (index-current)*tw;
            } else {
                left = (index === 0) ? ((current + 1 === itemCount) ? tw : (itemCount-current)*tw) : (itemCount-index)*tw;
            }

            t.animate({left: '-'+left+'px'}, 1000, moveEnd);
        }

        items.each(function(i) {
            $(this).addClass('isaIdx_'+i);
        });
        navItems.click(function() {
            if(timer) { window.clearTimeout(timer); } 
            moveTo(navItems.index($(this)));
            return false;
        }).eq(0).addClass('current');

        timer = window.setTimeout(function() {
            next();
        }, 5000);
    };
})(jQuery);

(function($) {    
    $.fn.productInfo = function(ttId) {
        var timer = null;
        $(this).find('div.piButton').hover(function(){
            if(timer) {
                clearTimeout(timer);
                $(ttId).hide();
            }
            var offset = $(this).offset();
            $(ttId).html('');
            $(this).parent().find('div.piText').clone().prependTo(ttId);
            $(ttId).css({top:(offset.top+17)+'px', left:offset.left+'px'}).show(300);
        }, function() {
            timer = setTimeout(function(){
                $(ttId).hide(250).html('');
            }, 1000);
        });
        
        $(ttId).hover(function(){
            if(timer) { clearTimeout(timer); }
        }, function() {
            timer = setTimeout(function(){
                $(ttId).hide(250).html('');
            }, 1000);
        });
    };
})(jQuery);

(function($) {    
    $.doBoxImage = function() {
        var items = [];
        items.push(
            'a_1','a_2','a_3','a_4','a_5','a_6','a_7','a_8','a_9','a_10','a_11','a_12','a_13',
            'a_14_1','a_14_1_w','a_14_2','a_14_2_w','a_15_1','a_15_1_w','a_15_2','a_15_2_w','a_15_3','a_15_3_w','a_15_4','a_15_4_w',
            'a_16','a_16_w','a_17','a_17_w','a_18_1','a_18_1_w','a_18_2','a_18_2_w','a_18_3','a_18_3_w','a_19','a_19_w','a_20','a_20_w',
            'a_21','a_21_w','a_22','a_22_w','a_23','a_23_w','a_24','a_24_w','a_25','a_25_w','a_26','a_26_w','a_27','a_27_w','a_28','a_28_w',
            'a_29','a_29_w','a_30','a_30_w','a_31','a_31_w','a_32','a_32_w','a_33','a_33_w','a_34','a_34_w','a_35','a_35_w','a_36','a_36_w','a_37','a_37_w',
            'v_38','v_39','v_40','v_41','v_42','v_43','v_44','v_45',
            'a_46',
            'v_47','v_48'
        );
        
        for(var i = 0; i < items.length; i++) {
            $("input[name='"+items[i]+"']").boxImage();
        }
    };
})(jQuery);

(function($) {    
    $.fn.boxImage = function() {
    
        var img_box = "/images/checkbox.png";
        var img_box_c = "/images/checkbox_c.png";
        var img_radio = "/images/radio.png";
        var img_radio_c = "/images/radio_c.png";
        var img_class = "box_" + Math.round((Math.random()+1*571773)*Math.random());
        
        $(this).each(function() {
            var obj = $(this);
            var type = obj.attr('type'); // radio or checkbox
            var id = obj.attr('id');

            obj.css('display','none');

            if(type == 'radio'){
                
                if(id.indexOf('_w') > 0) {
                    img_radio = '/images/radio2.png';
                    img_radio_c = '/images/radio2_c.png';
                }
                
                obj.before('<img src="' + img_radio + '" alt="'+type+'" class="' + img_class + '" id="box_img_' + id + '" style="cursor:pointer;vertical-align:middle;" />');
                
                if(obj.attr('checked')){
                    $("#box_img_" + id).attr('src', img_radio_c);
                }
                
                $("#box_img_"+id).click(function(){
                    $("." + img_class).attr('src', img_radio);
                    $("#" + id).trigger("click");
                    $(this).attr('src', img_radio_c);
                });

            } else if(type == 'checkbox'){
                obj.before('<img src="' + img_box + '" alt="'+type+'" class="' + img_class + '" id="box_img_' + id + '" style="cursor:pointer;vertical-align:middle;" />');
                
                if(obj.attr('checked')){
                    $("#box_img_" + id).attr('src', img_box_c);
                }
                
                $("#box_img_" + id).click(function(){
                    $("#" + id).trigger("click");
                    if($(this).attr('src') == img_box){
                        $(this).attr('src', img_box_c);
                    }
                    else {
                        $(this).attr('src', img_box);   
                    }
                });
            }
        });
    };
})(jQuery);

/* 
 * Copyright (c) 2008 David Lynch, http://davidlynch.org
 * licensed under MIT
*/
(function($) {
    var has_VML, create_canvas_for, add_shape_to, clear_canvas, shape_from_area,
        canvas_style, fader, hex_to_decimal, css3color, is_image_loaded, activearea;
    has_VML = document.namespaces;
    has_canvas = document.createElement('canvas');
    has_canvas = has_canvas && has_canvas.getContext;
    
    if(!(has_canvas || has_VML)) {
        $.fn.maphilight = function() { return this; };
        return;
    }
    
    if(has_canvas) {
        fader = function(element, opacity, interval) {
            if(opacity <= 1) {
                element.style.opacity = opacity;
                window.setTimeout(fader, 10, element, opacity + 0.1, 10);
            }
        };
        
        hex_to_decimal = function(hex) {
            return Math.max(0, Math.min(parseInt(hex, 16), 255));
        };
        css3color = function(color, opacity) {
            return 'rgba('+hex_to_decimal(color.substr(0,2))+','+hex_to_decimal(color.substr(2,2))+','+hex_to_decimal(color.substr(4,2))+','+opacity+')';
        };
        create_canvas_for = function(img) {
            var c = $('<canvas style="width:'+img.width+'px;height:'+img.height+'px;"></canvas>').get(0);
            c.getContext("2d").clearRect(0, 0, c.width, c.height);
            return c;
        };
        add_shape_to = function(canvas, shape, coords, options) {
            var i, context = canvas.getContext('2d');
            context.beginPath();
            if(shape == 'rect') {
                context.rect(coords[0], coords[1], coords[2] - coords[0], coords[3] - coords[1]);
            } else if(shape == 'poly') {
                context.moveTo(coords[0], coords[1]);
                for(i=2; i < coords.length; i+=2) {
                    context.lineTo(coords[i], coords[i+1]);
                }
            } else if(shape == 'circ') {
                context.arc(coords[0], coords[1], coords[2], 0, Math.PI * 2, false);
            }
            context.closePath();
            if(options.fill) {
                context.fillStyle = css3color(options.fillColor, options.fillOpacity);
                context.fill();
            }
            if(options.stroke) {
                context.strokeStyle = css3color(options.strokeColor, options.strokeOpacity);
                context.lineWidth = options.strokeWidth;
                context.stroke();
            }
            if(options.fade) {
                fader(canvas, 0);
            }
        };
        clear_canvas = function(canvas, area) {
            canvas.getContext('2d').clearRect(0, 0, canvas.width,canvas.height);
        };
    } else {
        if(document.documentMode && document.documentMode >= 8) {
            var ss = document.createStyleSheet();
            ss.addRule("v\\:shape", "behavior:url(#default#VML); display:inline-block; antialias:true");
            ss.addRule("v\\:shape", "behavior:url(#default#VML); display:inline-block; antialias:true");
            ss.addRule("v\\:group", "behavior:url(#default#VML); display:inline-block; antialias:true");
            ss.addRule("v\\:polyline", "behavior:url(#default#VML); display:inline-block; antialias:true");
            ss.addRule("v\\:stroke", "behavior:url(#default#VML); display:inline-block; antialias:true");
            ss.addRule("v\\:fill", "behavior:url(#default#VML); display:inline-block; antialias:true");
            ss.addRule("v\\:rect", "behavior:url(#default#VML); display:inline-block; antialias:true");
            ss.addRule("v\\:oval", "behavior:url(#default#VML); display:inline-block; antialias:true");
        } else {
            document.createStyleSheet().addRule("v\\:*", "behavior: url(#default#VML); antialias: true;");
            document.namespaces.add("v", "urn:schemas-microsoft-com:vml");
        }

        
        create_canvas_for = function(img) {
            return $('<var style="zoom:1;overflow:hidden;display:block;width:'+img.width+'px;height:'+img.height+'px;"></var>').get(0);
        };
        add_shape_to = function(canvas, shape, coords, options) {
            var fill, stroke, opacity, e;
            fill = '<v:fill color="#'+options.fillColor+'" opacity="'+(options.fill ? options.fillOpacity : 0)+'" />';
            stroke = (options.stroke ? 'strokeweight="'+options.strokeWidth+'" stroked="t" strokecolor="#'+options.strokeColor+'"' : 'stroked="f"');
            opacity = '<v:stroke opacity="'+options.strokeOpacity+'"/>';
            if(shape == 'rect') {
                e = $('<v:rect filled="t" '+stroke+' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+coords[0]+'px;top:'+coords[1]+'px;width:'+(coords[2] - coords[0])+'px;height:'+(coords[3] - coords[1])+'px;"></v:rect>');
            } else if(shape == 'poly') {
                e = $('<v:shape filled="t" '+stroke+' coordorigin="0,0" coordsize="'+canvas.width+','+canvas.height+'" path="m '+coords[0]+','+coords[1]+' l '+coords.join(',')+' x e" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:0px;left:0px;width:'+canvas.width+'px;height:'+canvas.height+'px;"></v:shape>');
            } else if(shape == 'circ') {
                e = $('<v:oval filled="t" '+stroke+' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+(coords[0] - coords[2])+'px;top:'+(coords[1] - coords[2])+'px;width:'+(coords[2]*2)+'px;height:'+(coords[2]*2)+'px;"></v:oval>');
            }
            e.get(0).innerHTML = fill+opacity;
            $(canvas).append(e);
        };
        clear_canvas = function(canvas) {
            $(canvas).empty();
        };
    }
    shape_from_area = function(area) {
        var i, coords = area.getAttribute('coords').split(',');
        for (i=0; i < coords.length; i++) { coords[i] = parseFloat(coords[i]); }
        return [area.getAttribute('shape').toLowerCase().substr(0,4), coords];
    };
    
    is_image_loaded = function(img) {
        if(!img.complete) { return false; } // IE
        if(typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) { return false; } // Others
        return true;
    }

    canvas_style = {
        position: 'absolute',
        left: 0,
        top: 0,
        padding: 0,
        border: 0
    };
    
    $.fn.maphilight = function(opts) {
        opts = $.extend({}, $.fn.maphilight.defaults, opts);
        var csl = $('#saleslist').clone(true), io = $(this).offset();
        csl.css({top:io.top, left:io.left});
        $('#saleslist').remove();
        $('body').append(csl);
        
        return $(this).each(function() {
            var t, img, wrap, options, map, canvas, canvas_always, mouseover, sl;
            sl = $('#saleslist').hide();
            img = $(this);
            if(!is_image_loaded(this)) { return window.setTimeout(function() { img.maphilight(opts); }, 200); }
            options = $.metadata ? $.extend({}, opts, img.metadata()) : opts;
            t = img.attr('usemap').substring(img.attr('usemap').indexOf('#')+1);
            map = $('map[name="'+t+'"]');
 
            if(!(img.is('img') && img.attr('usemap') && map.size() > 0 && !img.hasClass('maphilighted'))) { return; }
            wrap = $('<div>').css({display:'block',background:'url('+this.src+')',position:'relative',padding:0,width:this.width,height:this.height});
            img.before(wrap).css('opacity', 0).css(canvas_style).remove();
            if($.browser.msie) { img.css('filter', 'Alpha(opacity=0)'); }
            wrap.append(img);
            
            canvas = create_canvas_for(this);
            $(canvas).css(canvas_style);
            canvas.height = this.height;
            canvas.width = this.width;
            
            mouseover = function(e) {
                if(activearea !== this) {
                    var shape, area_options;
                    area_options = $.metadata ? $.extend({}, options, $(this).metadata()) : options;
                    if(!area_options.alwaysOn) {
                        shape = shape_from_area(this);
                        add_shape_to(canvas, shape[0], shape[1], area_options);
                    }
                }
            };
            
            mouseclick = function(e) {
                var o = $($(this).attr('rel')); //h = $('#saleslist > h2').show(), 
                if(activearea !== this) {
                    $($(activearea).attr('rel')).hide();
                    clear_canvas(canvas);
                }
                
                var shape = shape_from_area(this);
                var area_options = area_options = $.metadata ? $.extend({}, options, $(this).metadata()) : options;
                add_shape_to(canvas, shape[0], shape[1], area_options);
                activearea = this;
                sl.expose({opacity:0, onClose: function(){ o.hide(); sl.fadeOut(250); }, api:true}).load();
                o.show();
                sl.fadeIn(250);
                
            };
            $(map).find('area[rel]').click(mouseclick);
            $(map).find('area[rel]').each(function() { $($(this).attr('rel')).hide() }); //.overlay({target:'#saleslist', expose:'#000000', top:'15%', close:'.salesRel'});
            //$('#saleslist > h2').hide();
            
            if(options.alwaysOn) {
                $(map).find('area[coords]').each(mouseover);
            } else {
                if($.metadata) {
                    // If the metadata plugin is present, there may be areas with alwaysOn set.
                    // We'll add these to a *second* canvas, which will get around flickering during fading.
                    $(map).find('area[coords]').each(function() {
                        var shape, area_options;
                        area_options = $.metadata ? $.extend({}, options, $(this).metadata()) : options;
                        if(area_options.alwaysOn) {
                            if(!canvas_always) {
                                canvas_always = create_canvas_for(img.get());
                                $(canvas_always).css(canvas_style);
                                canvas_always.width = img.width();
                                canvas_always.height = img.height();
                                img.before(canvas_always);
                            }
                            shape = shape_from_area(this);
                            add_shape_to(canvas_always, shape[0], shape[1], area_options);
                        }
                    })
                }
                $(map).find('area[coords]').mouseover(mouseover).mouseout(function(e) {
                    clear_canvas(canvas);
                    if(activearea) {
                        var shape = shape_from_area(activearea);
                        var area_options = area_options = $.metadata ? $.extend({}, options, $(this).metadata()) : options;
                        add_shape_to(canvas, shape[0], shape[1], area_options);
                    }
                });
            }
            
            img.before(canvas); // if we put this after, the mouseover events wouldn't fire.
            img.addClass('maphilighted');
        });
    };
    $.fn.maphilight.defaults = {
        fill: true,
        fillColor: 'F47920',
        fillOpacity: 0.65,
        stroke: false,
        strokeColor: 'ffffff',
        strokeOpacity: 1,
        strokeWidth: 1,
        fade: false,
        alwaysOn: false
    };
})(jQuery);
