
var rhModal = {
    selectorBtn: 'modalbox',
    darkDivId: 'mb-overlay',
    activeClass: 'modal-box-active',
    hideClass: 'modal',
    closeBtnClass: 'close',
    bodyIEClass: 'body-ie',
    overlayIEClass: 'mb-overlay-ie',
    idImgWin: 'mb-img-win',
    show: function(evt){
        var el = $(this);
        var id = el.attr('win');
        rhModal.showWin(id);
    },
    showWin: function(id){
        if($('#'+rhModal.darkDivId).length == 0){
            $('<div id="'+rhModal.darkDivId+'" class="dark '+($.browser.msie?rhModal.overlayIEClass:'')+'"></div>').appendTo('body');
            if($.browser.msie){
                $('body').addClass(rhModal.bodyIEClass);
                $('#'+rhModal.darkDivId).css('height',$(document).height()+'px');
            }
        }
        if($('.'+rhModal.activeClass).length == 0){
            $('#'+id).removeClass(rhModal.hideClass);
            $('#'+id).addClass(rhModal.activeClass);
            var elWidth =  $('#'+id).width();
            $('#'+id).css('left',(-1)*parseInt(elWidth/2));
            $('html, body').animate({scrollTop: 0}, 0);
            
            $('#'+rhModal.darkDivId).bind('click',rhModal.hide);            
            $('.'+rhModal.closeBtnClass).bind('click',rhModal.hide);
            $('.rbclose').bind('click',rhModal.hide);
        }
    },
    showImgWin: function(width, img){
       var html='<div id="'+rhModal.idImgWin+'" class="modal" style="width:'+width+'px;">';
       html+= '<div class="rb-blue">';
       html+= '<div class="rbtleft"></div>';
       html+= '<div class="rbtright">';
       html+= '<div class="rbclose"> </div>';
       html+= '</div>';
       html+= '<div class="rbcontent">';
       html+= '<div class="rblft">';
       html+= '<div class="rbrt">';
       html+= '<div class="body">';
       html+= '<div id="inquiry-modal-box">';
       html+= '<div class="bgimgwrap">';
       html+= '<img src="'+img+'"/>';
       html+= '</div>';
       html+= '</div></div></div></div>';
       html+= '</div>';
       html+= '<div class="rbbleft"></div>';
       html+= '<div class="rbbright"></div>';
       html+= '<div class="clear"></div>';
       html+= '</div>';
       html+= '</div>';
//       $(html).appendTo('body');
       $('body').append(html);
       rhModal.showWin(rhModal.idImgWin);
    },
    hide: function(){
        if($('#'+rhModal.darkDivId).length>0){
            $('#'+rhModal.darkDivId).remove();
            $('body').removeClass(rhModal.bodyIEClass);
        }
        if($('.'+rhModal.activeClass).length > 0){
            $('#'+rhModal.darkDivId).unbind('click');
            $('.'+rhModal.activeClass).addClass(rhModal.hideClass);
            $('.'+rhModal.activeClass).removeClass(rhModal.activeClass);
        }
        if($('#'+rhModal.idImgWin).length > 0){
            $('#'+rhModal.idImgWin).remove();
        }
    },
    init: function(){
         $('.' + rhModal.selectorBtn).each(function(index, domEl){
             var el = $(domEl);
             el.bind('click',rhModal.show);
         });
         $('.'+rhModal.closeBtnClass).bind('click',rhModal.hide);
    }
}


var rhExpandBlock = {
    containerSelector: '.rc-std-wide',
    openClass: 'open',
    hiddenContentClass: 'hidden',
    expand: function(evt){
        var h2 = $(this);
        var content = h2.next();
        if(h2.hasClass(rhExpandBlock.openClass)){
            h2.removeClass(rhExpandBlock.openClass);
            content.addClass(rhExpandBlock.hiddenContentClass);
        }else{
            h2.addClass(rhExpandBlock.openClass);
            content.removeClass(rhExpandBlock.hiddenContentClass);
        }
    },
    init: function(){
        $(rhExpandBlock.containerSelector+'>div>h2').each(function(index, domEl){
            var el = $(domEl);
             el.bind('click',rhExpandBlock.expand);
        })
    }
}

