
function myAppend(number){  
    elements = $('.leftThumbs:last').find('.tab_item:gt('+number+')');
    $('.leftThumbs:last > .tab_item:gt('+number+')').remove();
            
    $('.leftThumbs:last').after('<div class="leftThumbs">');
    $('.leftThumbs:last').append(elements);
}
  
function slideThumbs() {
 
    //we calculate the number of rows 
    var h_content = $(window).height()-$(".bottom_details").height()-$(".refe_title").height()-130;
    var h_pic = $(".tab_item").height()+18;
    var rows_tabs = h_content/h_pic; 
    var nb_tabs = 3 * parseInt(rows_tabs);
    var total_tabs = $(".tab_item").size();
    var total_pages = Math.ceil(total_tabs/nb_tabs);      
    
    $('.tabs').animate({marginLeft:10},500);
    var j = 1;//total_tabs/nb_tabs;
    $(".tab_item").hide();             
    
    // show the current/total page
    $(".thumb_total_page").html(total_pages);
    
    //forrige // neste
    
    $("#forrige").hide();

    if(total_tabs<=nb_tabs) {
        $("#neste").hide();
    }

    $("#forrige").click(function(){

        $("#neste").show();
        
        
        $(".tabs").animate({marginLeft:0-$(".tabs").width()*1.2},500,function(){
            
                $(".tab_item").hide();
                j=parseInt($("#neste").attr("name")/nb_tabs)+1;   
                $(".thumb_current_page").html(j-2);
                var next = $("#neste").attr("name")-nb_tabs;
                var prev = next-nb_tabs;
                $("#neste").attr("name",next); 
                var i = prev; 
                if(i==1) $("#forrige").hide();

                var k = 1;
                $(".tab_item").each(function(){
                    if(k>=i && k<next) {
                        $(this).show();    
                    } 
                    k++;   
                });     
            
        });  
        
        //$(".tabs").animate({marginLeft:200},0); 
        $(".tabs").animate({marginLeft:10},500);       
    });
    var i = $("#neste").attr("name");
   
    var k = 1;
    $(".tab_item").each(function(){
        if(k>=i && k<=nb_tabs*j) {
            $(this).show();    
        } 
        k++;   
    });
    $("#neste").attr("name",nb_tabs+1);   
    
    $("#neste").click(function(){
        $("#forrige").show();  
                      
        $(".tabs").animate({marginLeft:0-$(".tabs").width()*1.2},500,function(){ 
                $(".tab_item").hide();
                
                j=parseInt($("#neste").attr("name")/nb_tabs)+1;
                $(".thumb_current_page").html(j); 
                
                var i = $("#neste").attr("name");
                var k = 1;
                    $(".tab_item").each(function(){
                        if(k>=i && k<=nb_tabs*j) {
                            //$(this).css({"display":"block"}); 
                            $(this).show();
                            //$(".tabs").css("margin-left",0-$("#subbody").width());   
                        } 
                        k++;   
                    });
                $("#neste").attr("name",nb_tabs*j+1);
                if($("#neste").attr("name") > total_tabs) {   // =
                    $("#neste").hide();
                } 
        });
        //$(".tabs").animate({marginLeft:100},0);          
        $(".tabs").animate({marginLeft:10},500);
  
    });
          
      
}


//check to see if we have a scrollbar
function checkScroll() {
    //var hContent = $("#content").height(); 
    var hContent = $("#getTheHeight").offset().top;
    var hWindow = $(window).height();
    var right = 0;   
    if(hContent>hWindow) {
        right = 17;    
    }
    return right; 
    
}

// change the padding top of the menu so that he will be vertically align center
function change_padding_top() {

    var rmHeightTop = $(window).height()-$(".white_bg_logo img").height()-$(".space").height()-$(".ulmenu").height();
    rmHeightTop = rmHeightTop / 2;
    $(".white_bg_logo").animate({ marginTop: rmHeightTop+"px"},500);    
} 
function change_padding_top2() {

    var rmHeightTop = $(window).height()-$(".white_bg_logo img").height()-$(".space").height()-$(".ulmenu").height();
    rmHeightTop = rmHeightTop / 2;
    $(".white_bg_logo").css("margin-top",rmHeightTop);   
} 

$(document).ready(function() { 

    // add clearfix before read more button
    $('.more-link').before('<div class="clearfix"></div>');
    
    if($.browser.opera) {
        //stop scrolling
        $('body').bind('mousewheel',function(){
            return false;    
        });
    } 
    $(document).keypress(function(event) {
        
        if(event.which == 0 || event.which == 40 || event.which == 39) {
            return false;
        }
      if (event.which == 32) {
        if(event.target.nodeName == 'INPUT' || event.target.nodeName == 'TEXTAREA') {
            return true;    
        } else {
            return false;
        }        
      } 
    });   
        $('.scaler div img').attr('src',first_org);   
/*    
    // contact form default values
    ///var active_color = '#000'; // Colour of user provided text
    //var inactive_color = '#ccc'; // Colour of default text

  //$("input.default-value").css("color", inactive_color);
  var default_values = new Array();
  $("input.default-value").focus(function() {
    if (!default_values[this.id]) {
      default_values[this.id] = this.value;
    }
    if (this.value == default_values[this.id]) {
      this.value = '';
      //this.style.color = active_color;
    }
    $(this).blur(function() {
      if (this.value == '') {
       // this.style.color = inactive_color;
        this.value = default_values[this.id];
      }
    });
  }); 
            
  //$("textarea.default-value").css("color", inactive_color);
  var default_values2 = new Array();
  $("textarea.default-value").focus(function() {
    if (!default_values2[this.id]) {
      default_values2[this.id] = this.value;
    }
    if (this.value == default_values2[this.id]) {
      this.value = '';
      //this.style.color = active_color;
    }
    $(this).blur(function() {
      if (this.value == '') {
        //this.style.color = inactive_color;
        this.value = default_values2[this.id];
      }
    });
  });    
    */
    
   var w = $("#subbody").width();
   var h = $("#body").height(); 
 
    // put all the posts picture in the background // hidden
    $(".post_pic a").click(function(){
        var nextPic = $(this).attr('name');
        var currentPic =  $(".scaler div img").attr('src');
        if(nextPic != currentPic) {
            $("#loading").show();
            $(".scaler div img").fadeOut(0);
            
            $(".scaler div img").attr('src',nextPic).bind("load",function(){
                 
                $(".scaler div img").fadeIn(1000); 
                $("#loading").hide();      
            });   
        }                
    });  

    // put all the posts picture in the background // hidden
    $(".gallery-item a").click(function(){
        if($(this).attr('name') == '') {
            var nextPic = $(this).attr('href');
            //$(this).attr('href','#');
            var currentPic =  $(".scaler div img").attr('src');
            if(nextPic != currentPic) {
                $("#loading").show();
                $(".scaler div img").fadeOut(0);
                
                $(".scaler div img").attr('src',nextPic).bind("load",function(){
                     
                    $(".scaler div img").fadeIn(1000); 
                    $("#loading").hide();      
                });   
            }
        
            return false;
        }               
    }); 
    /*
    var get_bgs = $(".post_bgs").html();
    var get_current_bg = $('.scaler').html();
    $(".scaler").html(get_current_bg+' '+get_bgs);
    
    $('.post_pic a').click(function(){
        var nextPic = $(this).attr('id');
        var nextBigPic = $(".scaler div img");
        nextBigPic.each(function(){
            var bigPic = $(this).attr('class');
            
            // hide the current background
            var currentDiv = $(this).parents(".scaler div");
            if(currentDiv.css("display")!="none")
                if(bigPic!=nextPic)
                    currentDiv.hide();
            // fade in the background choosen
            if(bigPic==nextPic)
                $(this).parents(".scaler div").fadeIn(1000);
        });         
    }); */   
        
    //show/hide the background on hover logo right
    $(".head_logo_single").mouseover(function(){
        $(".hover_hl").fadeIn(500);     
    });
    $(".head_logo_single").mouseleave(function(){
        $(".hover_hl").fadeOut(500);        
    });
    
    //positionate the pics from news
    var h_post_pic = $(".post_pic").width(); 
    if(h_post_pic==2) h_post_pic = 195;   
    $(".post_pic").css("right",0-h_post_pic-74);
    
    change_padding_top2();    

    var r = checkScroll(); 
    var wVP = $(".view_pics").width();
    $(".view_pics").css("right",r);      // 0 <-> r
    $(".head_logo").css("right",r+4); 
    
    // hide/show the design
    
    $(".view_pics").click(function() { 
        $(this).animate({right:0-2*w},1000);
        $("#right_menu").animate({left:0-w},1000);
        $("#bg_content").animate({left:0-w},1000);
        $("#subbody").animate({marginLeft:0-w},1000);
        $("#body_only_logo").animate({marginLeft:0},2000);
        $(".movie_centered").animate({left:0-w},1000);   
    });
    $("#logo_small a").click(function() {
        $("#body_only_logo").animate({marginLeft:0-w},1000); 
        $("#subbody").animate({marginLeft:0},1000); 
        $("#right_menu").animate({left:0},1000);
        $("#bg_content").animate({left:160},1000);
        $(".view_pics").animate({right:r},1000);
        $(".refe_title").animate({bottom:130},1000);  
        $(".bottom_details").animate({bottom:0},1000);  
        $(".view_pics_big").animate({bottom:0},1000); 
        $(".movie_centered").animate({left:padLeft});     
    });

   
   // slide menu/submenu
   // this is for the first submenu
   $(".ulmenu>li>p:first-child").click(function(){ 
           
        var parent = $(this).parents(".ulmenu>li"); 
        var index  = $("li").index(parent);
        parent.addClass("i"+index);
        
        var submenu = $(".ulmenu>li.i"+index+">ul");
        
        if(submenu.css("display")=="none") {
              
            // close all the submenu's that are opened
            //$(".ulmenu li ul").stop(true,true).slideUp(500,change_padding_top);
            $(".ulmenu li").removeClass("current_page_parent");
            $(".ulmenu li").addClass("page_item_parent"); 
            
            //change the arrow up/down
            $(".arrow_up").css("display","none");
            $(".arrow_down").css("display","block");    
            $(".ulmenu>li.i"+index+">ul>li>ul").hide();
            
            parent.addClass("current_page_parent");
            parent.removeClass("page_item_parent");   
            submenu.stop(true,true).slideDown(500,change_padding_top);  
             
        } else {       
            submenu.stop(true,true).slideUp(500,change_padding_top);
            parent.addClass("page_item_parent");
            parent.removeClass("current_page_parent");   
        }                        
   });
   
   //this is for the second submenu
   $(".ulmenu>li>ul>li>p:first-child").click(function(){   
       
        //change the up/down arrow
        var getCurrentArrow = $(".arrow_up",this);
        if(getCurrentArrow.css("display")=='none') {
            $(".arrow_down",this).css("display","none");
            getCurrentArrow.css("display","block");
        } else {
            getCurrentArrow.css("display","none");
            $(".arrow_down",this).css("display","block");    
        }
         
        var parent = $(this).parents(".ulmenu>li>ul>li"); 
        var index  = $("li").index(parent);
        parent.addClass("si"+index);
       
        var submenu = $(".ulmenu>li>ul>li.si"+index+">ul");  
        submenu.stop(true,true).slideToggle(500,change_padding_top);  
         
   });   


    slideThumbs();

      // change the background when we click a thumb pic   
    $(".bg_small_pic a").click(function(){
        var nextPic = $(this).attr('name');
        var currentPic =  $(".scaler div img").attr('src');
        if(nextPic != currentPic) {
            $("#loading").show();
            $(".scaler div img").fadeOut(0);
            
            $(".scaler div img").attr('src',nextPic).bind("load",function(){
                 
                $(".scaler div img").fadeIn(1000); 
                $("#loading").hide();      
            });   
        }
    /*  
        var nextPic = $(this).attr('name');
        var nextBigPic = $(".scaler div img");
        nextBigPic.each(function(){
            var bigPic = $(this).attr('src');
            
            // hide the current background
            var currentDiv = $(this).parents(".scaler div");
            if(currentDiv.css("display")!="none")
                if(bigPic!=nextPic)
                    currentDiv.hide();
            // fade in the background choosen
            if(bigPic==nextPic)
                $(this).parents(".scaler div").fadeIn(1000);
        }) 
        */                
    });
    
    $(".scaler div img").hide(); 
    $(window).bind("load",function(){  
        $(".scaler > div > img").fadeIn(1000); 
        $("#loading").hide(); 
    });

    
    
    /* MOUSEOVER PICTURE & SHOW HEADLINE/TITLE */
    var title = $(".small_pics:first").attr('desc');
    $(".refe_title").html(""+title+"");
    $(".info_thumb").mouseover(function(){
        var pic_title_w = $(".show_pic_title_hid",this).width(); 
        $(".show_pic_title").css("width",pic_title_w+8+"px");
        var left_pic_title = ($(".tab_item").width() - pic_title_w+4-11) / 2;
        $(".show_pic_title").css("left",left_pic_title);
    });
    $(".bg_small_pic").mouseover(function() {
        var id = $("img",this).attr('name');
        var title = $("img",this).attr('desc'); 
        //$("div #"+id).stop(true,true).fadeIn(500);
        $(".show_pic_title",this).stop(true,true).fadeIn(500);
        $(".refe_title").html(""+title+"");
    });
    $(".bg_small_pic").click(function(){
        title = $("img",this).attr('desc'); 
    });
     
    $(".bg_small_pic").mouseleave(function() { 
        $(".show_pic_title").stop(true,true).fadeOut(0);   
        $(".refe_title").html(""+title+"");    
    });
    
   
   /* WE SHOW/HIDE THE DESIGN */  

   $(".view_pics_big").css("right",0);  
   $(".bottom_details").css("right",150+0);
       
    $(".view_pics_big").click(function() {
        $(this).animate({bottom:0-h},1000);
        $(".bottom_details").animate({bottom:0-h});
        $(".refe_title").animate({bottom:0-h});
        $("#right_menu").animate({left:0-w},1000);
        $("#bg_content").animate({left:0-w},1000);
        $("#subbody").animate({marginLeft:0-w},1000);
        $("#body_only_logo").animate({marginLeft:0},2000);  
    });
    
    // make the parents menu current
    $(".ulmenu li ul li ul .current_page_item2").parents(".ulmenu li").addClass('current_page_parent') ;  
    $(".ulmenu li ul li ul .current_page_item2").parents(".ulmenu li").removeClass('page_item_parent') ;  
    $(".ulmenu li ul li ul .current_page_item2").parents(".ulmenu li ul").css("display","block") ;  
    $(".ulmenu li ul li ul .current_page_item2").parents(".ulmenu li ul li").addClass('current_page_parent2') ;  
    $(".ulmenu li ul li ul .current_page_item2").parents(".ulmenu li ul li").removeClass('page_item_parent2') ;  
    $('.current_page_parent2 .arrow_down').css('display','none');  
    $('.page_item_parent2 .arrow_up').css('display','none');  
    $(".ulmenu li ul li ul .current_page_item2").parents(".ulmenu li ul li ul").css('display','block') ; 
    
    change_padding_top2();
    
            //center video
            var stageW = 560;//"100%";
            var stageH = 350;//"100%";
            var menuW = $("#right_menu").width();
            var padTop = (h-stageH)/2; 
            var padLeft = (w-stageW+menuW)/2;
            $(".movie_centered").css({top:padTop, left:padLeft});   
});

function filmASPlayer() {
/*************** FILM ***********/ 
     // JAVASCRIPT VARS
            // cache buster
            var cacheBuster = "?t=" + Date.parse(new Date());        
            
            // stage dimensions
            var stageW = 560;//"100%";
            var stageH = 350;//"100%";
            
            
            // ATTRIBUTES
            var attributes = {};
            attributes.id = 'FlabellComponent';
            attributes.name = attributes.id;
            
            // PARAMS
            var params = {};
            params.allowfullscreen = "true";
            params.allowScriptAccess = "always";            
            params.bgcolor = "#000000";
            //params.wmode = "transparent";
            

            /* FLASH VARS */
            var flashvars = {};                
            
            /// path to the content folder(where the xml files, images or video are nested)
            /// if you want to use absolute paths(like "http://domain.com/images/....") then leave it empty("")
            flashvars.pathToFiles = "";            
            
            // player dimensions
            flashvars.componentWidth = stageW;
            flashvars.componentHeight = stageH;            
            // player settings xml path
            var themePath = $("#themePath").attr("value");
            flashvars.xmlPath = themePath+"/deploy/videoplayer/xml/playersettings.xml";
            // video title
            flashvars.videoTitle = $('#videoTitle').val();
            // video path
            flashvars.videoPath = $("#videoPath a").attr("href");
            flashvars.streamer = "";
            // preview path
            flashvars.previewPath = $("#videoPath a img").parents("a").attr("href");
                        
            /** EMBED THE SWF**/
            swfobject.embedSWF(themePath+"/deploy/preview.swf"+cacheBuster, attributes.id, stageW, stageH, "9.0.124", themePath+"/deploy/js/expressInstall.swf", flashvars, params);    


/************************* end FILM ******************/    
    
}

