function blocking(nr,show,kind){
         if(document.layers){
                 current=(show==1) ? 'block':'none';
                 current=(show==1&&kind!=undefined) ? kind:current;document.layers[nr].display=current;
         }
         else if(document.all){
                 current=(show==1) ? 'block':'none';
                 current=(show==1&&kind!=undefined)?kind:current;document.all[nr].style.display=current;
         }
         else if(document.getElementById){
                 vista=(show==1)?'block':'none';
                 vista=(show==1&&kind!=undefined)?kind:vista;document.getElementById(nr).style.display=vista;
         }
}
function str_replace(search,replace,subject,count){
         var i=0,j=0,temp='',repl='',sl=0,fl=0,f=[].concat(search),r=[].concat(replace),s=subject,ra=r instanceof Array,sa=s instanceof Array;s=[].concat(s);
         if(count){
                 this.window[count]=0;
         }
         for(i=0,sl=s.length;i<sl;i++){
                 if(s[i]===''){
                         continue;
                 }
                 for(j=0,fl=f.length;j<fl;j++){
                         temp=s[i]+'';
                         repl=ra?(r[j]!==undefined?r[j]:''):r[0];s[i]=(temp).split(f[j]).join(repl);
                         if(count&&s[i]!==temp){
                                 this.window[count]+=(temp.length-s[i].length)/f[j].length;
                         }
                 }
         }
         return sa?s:s[0];
}
function round (value, precision, mode) {
         var m, f, isHalf, sgn;
         m = Math.pow(10, precision);
         value *= m;
         sgn = (value>0)|-(value<0);
         isHalf = value % 1 === 0.5 * sgn;
         f = Math.floor(value);
         if(isHalf){
                 switch(mode){
                         case 'PHP_ROUND_HALF_DOWN':
                                 value = f + (sgn < 0);
                                 break;
                         case 'PHP_ROUND_HALF_EVEN':
                                 value = f + (f % 2 * sgn);
                                 break;
                         case 'PHP_ROUND_HALF_ODD':
                                 value = f + !(f % 2);
                                 break;
                         default:
                                 value = f + (sgn > 0);                }
         }
         return (isHalf ? value : Math.round(value)) / m;
}
var $k = jQuery.noConflict();
$k(document).ready(function() {
        //When page loads...
        $k(".tab_content").hide(); //Hide all content
        $k("ul.tabs li:first").addClass("active").show(); //Activate first tab
        $k(".tab_content:first").show(); //Show first tab content

        //On Click Event
        $k("ul.tabs li").click(function() {

                $k("ul.tabs li").removeClass("active"); //Remove any "active" class
                $k(this).addClass("active"); //Add "active" class to selected tab
                $k(".tab_content").hide(); //Hide all tab content

                var activeTab = $k(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
                $k(activeTab).fadeIn(); //Fade in the active ID content
                return false;
        });

});
function tab_change(neu, alt){
                $k('#tabh' + alt).removeClass("active"); //Remove any "active" class
                $k('#tabh' + neu).addClass("active"); //Add "active" class to selected tab
                $k('#tab' + alt).hide(); //Hide all tab content
                $k('#tab' + neu).fadeIn(); //Fade in the active ID content
}
/**
*
*
* bxSlider: Content slider / fade / ticker using the jQuery javascript library.
*
* Author: Steven Wanderski
* Email: wandoledzep@gmail.com
* URL: http://bxslider.com
*
*
**/
var $jj = jQuery.noConflict();
jQuery.fn.bxSlider = function(options){

        /////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Declare variables and functions
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////
        var defaults = {
                mode: 'slide',
                speed: 500,
                auto: false,
                auto_direction: 'left',
                pause: 2500,
                controls: true,
                prev_text: 'prev',
                next_text: 'next',
                width: $j(this).children().width(),
                prev_img: '',
                next_img: '',
                ticker_direction: 'left',
                wrapper_class: 'container'
        };

        options = $j.extend(defaults, options);

        if(options.mode == 'ticker'){
                options.auto = true;
        }

        var $jthis = $j(this);

        var $jparent_width = options.width;
        var current = 0;
        var is_working = false;
        var child_count = $jthis.children().size();
        var i = 0;
        var j = 0;
        var k = 0;

        function animate_next(){

                is_working = true;

                $jthis.animate({'left':'-' + $jparent_width * 2 + 'px'}, options.speed, function(){

                        $jthis.css({'left':'-' + $jparent_width + 'px'}).children(':first').appendTo($jthis);

                        is_working = false;

                });

        }

        function animate_prev(){

                is_working = true;

                $jthis.animate({'left': 0}, options.speed, function(){

                        $jthis.css({'left':'-' + $jparent_width + 'px'}).children(':last').insertBefore($jthis.children(':first'));

                        is_working = false;

                });

        }

        function fade(direction){

                if(direction == 'next'){

                        var last_before_switch = child_count - 1;
                        var start_over = 0;
                        var incr = k + 1;

                }else if(direction == 'prev'){

                        var last_before_switch = 0;
                        var start_over = child_count -1;
                        var incr = k - 1;

                }

                is_working = true;

                if(k == last_before_switch){

                        $jthis.children().eq(k).fadeTo(options.speed, 0);
                        $jthis.children().eq(start_over).fadeTo(options.speed, 1, function(){

                        is_working = false;

                        k = start_over;

                        });

                }else{

                        $jthis.children().eq(k).fadeTo(options.speed, 0);
                        $jthis.children().eq(incr).fadeTo(options.speed, 1, function(){

                        is_working = false;

                        k = incr;

                        });

                }

        }

        function add_controls(){

                /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Check if user selected images to use for next / prev
                /////////////////////////////////////////////////////////////////////////////////////////////////////////////

                if(options.prev_img != '' || options.next_img != ''){

                        $jthis.parent().append('<a class="slider_prev" href=""><img src="' + options.prev_img + '" alt=""/></a><a class="slider_next" href=""><img src="' + options.next_img + '" alt="" /></a>');

                }else{

                        $jthis.parent().append('<a class="slider_prev" href="">' + options.prev_text + '</a><a class="slider_next" href="">' + options.next_text + '</a>');

                }

                $jthis.parent().find('.slider_prev').css({'outline':'0'});
                $jthis.parent().find('.slider_next').css({'outline':'0'});


                /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Accomodate padding-top for controls when elements are absolutely positioned (only in fade mode)
                /////////////////////////////////////////////////////////////////////////////////////////////////////////////

                if(options.mode == 'fade'){

                        $jthis.parent().find('.slider_prev').css({'paddingTop' : $jthis.children().height()})
                        $jthis.parent().find('.slider_next').css({'paddingTop' : $jthis.children().height()})

                }

                /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Actions when user clicks next / prev buttons
                /////////////////////////////////////////////////////////////////////////////////////////////////////////////

                $jthis.parent().find('.slider_next').click(function(){

                        if(!is_working){

                                if(options.mode == 'slide'){

                                        animate_next();

                                        if(options.auto){

                                                clearInterval($j.t);

                                                $j.t = setInterval(function(){animate_next();}, options.pause);

                                        }

                                }else if(options.mode == 'fade'){

                                        fade('next');

                                        if(options.auto){

                                                clearInterval($j.t);

                                                $j.t = setInterval(function(){fade('next');}, options.pause);

                                        }


                                }

                        }

                        return false;

                });

                $jthis.parent().find('.slider_prev').click(function(){

                        if(!is_working){

                                if(options.mode == 'slide'){

                                        animate_prev();

                                        if(options.auto){

                                                clearInterval($j.t);

                                                $j.t = setInterval(function(){animate_prev();}, options.pause);

                                        }

                                }else if(options.mode == 'fade'){

                                        fade('prev');

                                        if(options.auto){

                                                clearInterval($j.t);

                                                $j.t = setInterval(function(){fade('prev');}, options.pause);

                                        }

                                }

                        }

                        return false;

                });

        }


        function ticker() {

                if(options.ticker_direction == 'left'){

                        $jthis.animate({'left':'-' + $jparent_width * 2 + 'px'}, options.speed, 'linear', function(){

                                $jthis.css({'left':'-' + $jparent_width + 'px'}).children(':first').appendTo($jthis);

                                ticker();

                        });

                }else if(options.ticker_direction == 'right'){

                        $jthis.animate({'left': 0}, options.speed, 'linear', function(){

                                $jthis.css({'left':'-' + $jparent_width + 'px'}).children(':last').insertBefore($jthis.children(':first'));

                                ticker();

                        });

                }

        }



        /////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Create content wrapper and set CSS
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////

        $jthis.wrap('<div class="' + options.wrapper_class + '"></div>');

        //console.log($jthis.parent().css('paddingTop'));

        if(options.mode == 'slide' || options.mode == 'ticker'){

                $jthis.parent().css({
                        'overflow' : 'hidden',
                        'position' : 'relative',
                        'width' : options.width + 'px'
                });

                $jthis.css({
                        'width' : '999999px',
                        'position' : 'relative',
                        'left' : '-' + $jparent_width + 'px'
                });

                $jthis.children().css({
                        'float' : 'left',
                        'width' : $jparent_width
                });

                $jthis.children(':last').insertBefore($jthis.children(':first'));

        }else if(options.mode == 'fade'){

                $jthis.parent().css({
                        'overflow' : 'hidden',
                        'position' : 'relative',
                        'width' : options.width + 'px'
                        //'height' : $jthis.children().height()
                });

                if(!options.controls){
                        $jthis.parent().css({'height' : $jthis.children().height()});
                }

                $jthis.children().css({
                        'position' : 'absolute',
                        'width' : $jparent_width,
                        'listStyle' : 'none',
                        'opacity' : 0
                });

                $jthis.children(':first').css({
                        'opacity' : 1
                });

        }

        /////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Check if user selected "auto"
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////

        if(!options.auto){

                add_controls();

        }else{

                if(options.mode == 'ticker'){

                        ticker();

                }else{

                        /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        // Set a timed interval
                        /////////////////////////////////////////////////////////////////////////////////////////////////////////////

                        if(options.mode == 'slide'){

                                if(options.auto_direction == 'left'){

                                        $j.t = setInterval(function(){animate_next();}, options.pause);

                                }else if(options.auto_direction == 'right'){

                                        $j.t = setInterval(function(){animate_prev();}, options.pause);

                                }

                        }else if(options.mode == 'fade'){

                                if(options.auto_direction == 'left'){

                                        $j.t = setInterval(function(){fade('next');}, options.pause);

                                }else if(options.auto_direction == 'right'){

                                        $j.t = setInterval(function(){fade('prev');}, options.pause);

                                }

                        }

                        if(options.controls){

                                add_controls();

                        }

                }

        }

}
