jQuery.noConflict();
//ZOUB FIX - Add the backstrech
jQuery.backstretch("./bp_con/themes/bitpulse/images/background.jpg");

jQuery(document).ready(function(){
//    jQuery("li.widget_categories>ul").addClass("sf-menu sf-vertical");
    jQuery("#horizontal_menu").addClass("sf-menu");
    jQuery("ul.sf-menu").supersubs({
//    jQuery("li.widget_categories>ul").supersubs({
        minWidth:    1,                                // minimum width of sub-menus in em units
        maxWidth:    12,                                // maximum width of sub-menus in em units
        extraWidth:  1                                  // extra width can ensure lines don't sometimes turn over 
                                                        // due to slight rounding differences and font-family 
    }).superfish({ 
        delay:       400,                               // delay on mouseout
        animation:   {height:'show'},    // fade-in and slide-down animation
        speed:       'fast'                            // faster animation speed
//        autoArrows:  false,                             // disable generation of arrow mark-up
//        dropShadows: false                              // disable drop shadows
    });
    // categories sidebar menu
    jQuery("li.cat-item>a").mouseover(function () {
        imgsrc = jQuery(this).children("img").attr("src");
        if(imgsrc) {
            matches = imgsrc.match(/_over/);
            if (!matches) {
                imgsrcON = imgsrc.replace(/.png$/gi, "_over.png");
                jQuery(this).children("img").attr("src", imgsrcON);
            }
        }
    });

    jQuery("li.cat-item>a").mouseout(function () {
        jQuery(this).children("img").attr("src", imgsrc);
    });

    // pages sidebar menu
    jQuery("li.page_item>a").mouseover(function () {
        imgsrc = jQuery(this).children("img").attr("src");
        if(imgsrc) {
            matches = imgsrc.match(/_over/);
            if (!matches) {
                imgsrcON = imgsrc.replace(/.png$/gi, "_over.png");
                jQuery(this).children("img").attr("src", imgsrcON);
            }
        }
    });

    jQuery("li.page_item>a").mouseout(function () {
        jQuery(this).children("img").attr("src", imgsrc);
    });

    jQuery('#right_side_panel').css({'min-height' : (jQuery('#content').height()-jQuery('#right_side_panel').height()-15)+"px"});
//
//    alert('content height ' + jQuery('#content').height());
//    alert('right_side_panel height ' + jQuery('#right_side_panel').height());

    //move the #right_side_panel div before the #content div
    jQuery('#content').before(jQuery('#right_side_panel'));
    jQuery('#content').before(jQuery('#searchform'));
    jQuery('#content').before(jQuery('#complex_search'));
    jQuery('#content').before(jQuery('#google_translate'));

    //position them properly
    var param_1 = jQuery('#right_side_panel').offset();
    var param_2 = jQuery('#content').offset();
    jQuery('#content').offset({top: param_1.top, left: param_2.left});
    jQuery('#right_side_panel').offset({top: param_1.top + 10, left: param_1.left});

    jQuery('#searchform').offset({top: param_1.top + 10, left: param_2.left + 600});
    jQuery('#complex_search').offset({top: param_1.top + 10 + 40 + 10, left: param_2.left + 600});
    jQuery('#google_translate').offset({top: param_1.top + 10 + 40 + 10 + 40 + 10, left: param_2.left + 600});

    //a method to overcome the non css3 rounded corners for ie
    if(jQuery.browser.msie){
        //for the content div
        jQuery('#content').before('<span id="content_top"></span>');
        jQuery('#content_top').offset({top: param_1.top, left: param_2.left});
        jQuery('#content').offset({top: param_1.top+10, left: param_2.left});

        jQuery('#content').after('<span id="content_bot"></span>');
        var param_3 = jQuery('#content').offset();
        var param_4 = jQuery('#content_bot').offset();
        jQuery('#content_bot').offset({top: param_4.top-(param_2.top - param_3.top)-10,left: param_2.left});

        //for the right_side_panel div
        var param_5 = jQuery('#right_side_panel').offset();
        jQuery('#right_side_panel').before('<span id="right_side_panel_top"></span>');
        jQuery('#right_side_panel_top').offset({top: param_5.top+10+10, left: param_5.left});
        jQuery('#right_side_panel').offset({top: param_5.top+20+10, left: param_5.left});

        var param_6 = jQuery('#right_side_panel').offset();
        jQuery('#right_side_panel').after('<span id="right_side_panel_bot"></span>');
        jQuery('#right_side_panel_bot').offset({top: param_6.top+jQuery('#right_side_panel').height()+16, left: param_6.left});
    }

    jQuery('#container').css({'height' : (jQuery('#container').height() - jQuery('#right_side_panel').height())+"px", 'min-height':500, 'overflow': 'visible'});
    
});
