$(document).ready( function() {
    createTabs('.live .link_tabs a', '.live', '.tab-container', 1);
    createTabs('.test_results .result_tabs_link a', '.test_results', '.tab-container', 0);
    createTabs('.top5 .link_tabs a', '.top5', '.tab-container', 1);
    createTabs('#result .result_tabs_link a', '#result', '.result-tab-container', 0); 

    var wio = location.hash.indexOf('_work');
    if (wio > -1) {
        wid = location.hash.substr(wio+5);

        cl = $('#workcommlink'+wid);
        wl = $('#worklink'+wid);
       	tl = $('#tab_task_result');
	if (cl && tl) {
		wl.click();
		tl.click();
		window.setTimeout("cl.click();", 500);
//		cl.click();
       	    	
	}
    } else {

    if (location.hash == '#send-task') {
        tl = $('#tab_send-task');
        if (tl) {
            tl.click();
            location.hash = location.hash;
        }
    }

    }

window.setInterval("checkAtab()", 100);


  	// Main Menu
    var badBrowser = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
    if (badBrowser) {
	if ($('.mmenu') != null) {
            $('.mmenu').after('<div id="subber"><!-- --></div>'); }
        if ($('.submenu') != null) {
            $('.submenu').css({'position':'absolute', 'top':'215px'}); }
    }

  if ($('.msmenu .mmenu_button') != null) {
    $('.msmenu .mmenu_button').click( function() {
        if ( !$(this).parent().hasClass('act') ) {
            $('.msmenu li').removeClass('act');
            $(this).parent().addClass('act');
            
            if (badBrowser) {
                $('#subber').height( $(this).parent().find('.submenu').height() );
            }
        }
        else {
            $('.msmenu li').removeClass('act');
            if (badBrowser) {
                $('#subber').height(0);
            }
        }
    });
  }


  customSelectInit();
    $('.post img[align=left]').addClass('left');
    $('.post img[align=right]').addClass('right');

})

function customSelectInit(){
	$('.custom_select a').click( function() {

       if($(this).parent().find('.custom_select_list').css('visibility') == 'hidden'){

	$(this).parent().parent().find('.custom_select a').removeClass('act');
     	$(this).parent().parent().find('.custom_select_list').css('visibility', 'hidden');
      	$(this).parent().parent().find('.indent div').css('visibility', 'hidden');


      	$(this).parent().find('.custom_select_list').css('visibility', 'visible');
      	$(this).parent().find('.indent div').css('visibility', 'visible');
      	
      	$(this).parent().find('.zoomdetectdiv').css('visibility', 'hidden');
      	$(this).parent().find('.hscrollerbase').css('visibility', 'hidden');
      	$(this).parent().find('.hscrollerbar').css('visibility', 'hidden');
      	$(this).parent().find('.scrollerjogbox').css('visibility', 'hidden');
      	$(this).parent().find('.hscrollerbarbeg').css('visibility', 'hidden');
      	$(this).parent().find('.hscrollerbarend').css('visibility', 'hidden');
      	$(this).parent().find('.hscrollerbasebeg').css('visibility', 'hidden');
      	$(this).parent().find('.hscrollerbaseend').css('visibility', 'hidden');
      	
      	$(this).addClass('act');

      } else {
      	$(this).parent().parent().find('.custom_select_list').css('visibility', 'hidden');
      	$(this).parent().parent().find('.indent div').css('visibility', 'hidden');
      	$(this).removeClass('act');
      }
      return false;

	});
	
	$('.custom_select li').click( function() {
		$(this).parent().parent().parent().parent().parent().parent().parent().parent().find('span').html($(this).html());
		if ($(this).attr('rel')) {
			var hid = $(this).attr('rel');
		} else {
			var hid = $(this).text();
		}
		var inp = $(this).parent().parent().parent().parent().parent().parent().parent().parent().find('input');
		inp.val(hid);
		if (inp.attr('id') == 'blog_id') {
			ajaxBlogInfo(hid, 0);
			if ($('#rubric_text_span')) {
				$('#rubric_text_span').html(' ');
			}
		}
		
		$(this).parent().parent().parent().parent().parent().parent().parent().parent().find('.custom_select_list').css('visibility', 'hidden');
      $(this).parent().parent().parent().parent().parent().parent().parent().parent().find('.indent div').css('visibility', 'hidden');
      $(this).parent().parent().parent().parent().parent().parent().parent().parent().parent().find('.custom_select a').removeClass('act');
	});
	
/*	
	$('.custom_select_list li').hover( function() {
   	$(this).css('background', '#ffe4ce');
    	$(this).css('color', '#373737');
	}, function() {
    	$(this).css('background', '#FFFFFF');
    	$(this).css('color', '#b6b6b6');
	}); 
	
*/	
$('.custom_select_list').css('visibility', 'hidden');
$('.custom_select_list').find('.indent div').css('visibility', 'hidden');
	setTimeout("$('.custom_select_list').css('visibility', 'hidden');$('.custom_select_list').find('.indent div').css('visibility', 'hidden');", 2000);
	     
}

function showShortInfo(){
	$('.short_info').slideToggle();
return true;
	if($('.short_info').css('display') == 'none'){
		$('.short_info').css('display', 'block');
	} else {
		$('.short_info').css('display', 'none');
	}
}

var program_open = 0;
function programOpen(id){
	if(program_open != id){
		$('#program_open_cur_'+program_open).css('display', 'none');
		$('#program_open_cur_'+id).css('display', 'block');
		program_open = id;
	} else {
		$('#program_open_cur_'+id).css('display', 'none');
		program_open = 0;
	}

}

function chooseColor(obj){
	$(obj).parent().find('a').removeClass('cur_color');
	$(obj).addClass('cur_color');
	$('#profile_settings_colors_'+$(obj).attr('rev')).val($(obj).attr('rel'));
}

var show_program_mess_id = 1;
function show_program_mess(str){
	document.getElementById('program_mess_cont').innerHTML = document.getElementById('program_mess_cont').innerHTML+'<div class="program_mess" id="program_mess_'+show_program_mess_id+'"><div class="program_mess1"><div class="program_mess2">'+str+'</div></div></div>';
//	setTimeout("document.getElementById('program_mess_"+show_program_mess_id+"').style.display='none';", 3000);
	setTimeout("$('#program_mess_"+show_program_mess_id+"').fadeOut('hide');", 3000);
	show_program_mess_id+=1;
}

