function show_box(box_id) {
    jQuery(box_id).css('display','block');
};

function hide_box(box_id) {
    jQuery(box_id).css('display','none');
};

function clearText(field) {
    if (field.defaultValue == field.value) field.value = '';
}
    
function restoreText(field) {
    if (field.value == '') field.value = field.defaultValue;
}

function highlight(sel) {
    jQuery(sel).addClass('bor');
}

function highlight_off(sel) {
   jQuery(sel).removeClass('bor');       
}

function fleXcrollTo(id,x,y,relative) {
	var scrollDiv = document.getElementById(id);
	if (scrollDiv == null) return;
	if(scrollDiv.fleXcroll) scrollDiv.fleXcroll.setScrollPos(x,y,relative);
} 
 
jQuery(document).ready(function() { 
    jQuery('.star').bind("mouseover", function(e) {
        listh = jQuery('.list_hover');
        for(i=0;i<listh.length;i++) {
            jQuery(listh[i]).css('display','none');            
        }        
        jQuery(this).next('span.list_hover').css('display','block');
    });
	
	listh = jQuery('#t1 li'); 
	var list_lenght = listh.length * (listh.width() + 13);
	jQuery('#lyr1').css('width',list_lenght);
		              
    jQuery('.team_leaders:first').css('display','block');    
    jQuery('.team_list_box:first').addClass('active_link');
    jQuery('.bg_post_wisdom:last').addClass('last');   
          
    jQuery('.teamslider #t1 li').bind("mouseover", function(e) {
        listh = jQuery('#t1 li'); 
		
		big_box = jQuery('.big_leaders_box .team_leaders');
        for(i=0;i<listh.length;i++) {
            jQuery(listh[i]).removeClass('active_link');
        }
        jQuery(this).addClass('active_link');
        ind = jQuery(this).attr('id').substr(5);
        for(i=0;i<big_box.length;i++) {
            jQuery(big_box[i]).css('display','none');
        }
        jQuery('.profile'+ind).css('display','block');
    });
	
    jQuery('.sm_tooltip').find('a:first').before('<div class="clear"></div>');
	jQuery('.list_post').find("li:last").addClass("bg_none");
    var gal_items_count = jQuery('#mycustomscroll .scroll-content-item').length;
	var width_of_all_items = gal_items_count * 116;
	jQuery('#horizontalwrap').css('width',width_of_all_items);
	
		
    ols = jQuery('ol');    
    for(i=0;i<ols.length;i++) {    
        elms = jQuery(ols[i]).find('li');        
        for(e=0;e<elms.length;e++) {    
        txt = jQuery(elms[e]).html();
        jQuery(elms[e]).prepend('<b>'+(e+1)+'</b>')+txt;
        }
    }
    
    jQuery('.wpcf7-form').removeClass('wpcf7-form').addClass('niceform');
    
    cs = jQuery('.case_study .text span');    
    for(t=0;t<cs.length;t++) {    
        txt = jQuery(cs[t]).html();
        jQuery(cs[t]).prepend('<b>'+(t+1)+'</b>')+txt;
    }
   
    jQuery('.team_leaders .gray_but').click(function() {
        if (jQuery(this).next('.opis').css("display") == "block") {                        
            jQuery(this).prev('.excerpt').show('slow');
            jQuery(this).next('.opis').hide('slow');            
            jQuery(this).html('<b>+</b>More');            
        } else {            
            jQuery(this).prev('.excerpt').hide('slow');
            jQuery(this).next('.opis').show('slow');            
            jQuery(this).html('<b>-</b>Close');
        }        
    });  
	
	var cs_box = jQuery('.case_study_box');
	
	for(z=0;z<cs_box.length;z++) {    
        jQuery(cs_box[z]).click(function() {
			if (jQuery(this).find('.case_hover').css("display") == "none") {                        
				jQuery(this).find('.case_hover').css("display","block");                
				jQuery(this).css("z-index","100"+z++); 				
			} 
		});        		
    }
	
    jQuery('.case_study_box .case_hover .gray_but').click(function(event) {
        event.stopPropagation();                 
        jQuery(this).parent().parent().hide();             
        jQuery(this).parent().parent().parent().css("z-index","0");                		
    }); 
	
	
});

jQuery(window).load(function() {
	
	setTimeout(function() {
		var cur_rel = jQuery('#mycustomscroll .active_link').attr('rel');
		var items_count = jQuery('#mycustomscroll .scroll-content-item').length;
		if(cur_rel) {
			if(cur_rel == items_count-2) {
				var scroll_pos = (cur_rel * 116)-470;
				fleXcrollTo("mycustomscroll",scroll_pos+"px","0px",false);
			} else if(cur_rel == items_count-1) {
				var scroll_pos = (cur_rel * 116)-580;
				fleXcrollTo("mycustomscroll",scroll_pos+"px","0px",false);
			} else {			
				if((cur_rel == 0) || (cur_rel == 1)) {
					var scroll_pos = cur_rel * 116;		
				} else {		
					var scroll_pos = (cur_rel * 116)-232;
				}
				fleXcrollTo("mycustomscroll",scroll_pos+"px","0px",false);					
			}
		}
	}
	,500);
	
});
