function ShowBlockSlow(te, se, ClsNameOn, ClsNameOff){
    if(document.getElementById(se)){
        seE = $('#' + se);
        if(te.className == ClsNameOn){
            seE.slideUp('slow');
            te.className = ClsNameOff;
        } else {
            seE.slideDown('slow');
            te.className = ClsNameOn;
        }
    }
}
function ShowBlock(te, se, ClsNameOn, ClsNameOff){
    if(document.getElementById(se)){
        seE = $('#' + se);
        if(te.className == ClsNameOn){
            seE.hide();
            te.className = ClsNameOff;
        } else {
            seE.show();
            te.className = ClsNameOn;
        }
    }
}

var AnonsTimerS   = null;
var AnonsTimerH   = null;
var AnonsIsShow  = 1;

function HideAnons(){
	clearTimeout(AnonsTimerH);
	clearTimeout(AnonsTimerS);
	if(AnonsIsShow){
    $('#MainAnonsC').slideDown('slow');
	$('#MainAnons').slideDown('slow');
	AnonsIsShow = 0;
	}
}
function ShowAnons(){
	clearTimeout(AnonsTimerH);
	clearTimeout(AnonsTimerS);
	if(!AnonsIsShow){
    $('#MainAnonsC').slideUp('slow');
	$('#MainAnons').slideUp('slow');
	AnonsIsShow = 1;
	}
}
function ToggleAnons(show){
	if(show){
		clearTimeout(AnonsTimerS);
		clearTimeout(AnonsTimerH);
		if(!AnonsIsShow){
			AnonsTimerS = setTimeout('ShowAnons()', 500);
		}
	} else {
		if(AnonsIsShow){
			AnonsTimerH = setTimeout('HideAnons()', 500);
		} else {
			AnonsTimerS = setTimeout('ShowAnons()', 500);
		}
	}
}

function js_clock(){
	/*
	var clock_time = new Date();
	var clock_hours = clock_time.getHours();
	var clock_minutes = clock_time.getMinutes();
	var clock_seconds = clock_time.getSeconds();
	var clock_suffix = "AM";
	if (clock_hours > 11){clock_suffix = "PM"; clock_hours = clock_hours - 12;}
	if (clock_hours == 0){clock_hours = 12;}
	if (clock_hours < 10){clock_hours = "0" + clock_hours;}
	if (clock_minutes < 10){clock_minutes = "0" + clock_minutes;}
	if (clock_seconds < 10){clock_seconds = "0" + clock_seconds;}
	var clock_div = document.getElementById('Time');
	clock_div.innerHTML = clock_hours + ":" + clock_minutes;
	setTimeout("js_clock()", 1000);
	*/
}

$(function(){
	$("#MailFormLink").click(function(){
	popupWin = window.open("/form/","popup","width=640,height=530");
	popupWin.focus();
	});
	js_clock();
    var tabContainers = $('div.tabs > div');
    
    $('div.tabs ul.tabNavigation a').click(function () {
        tabContainers.hide().filter(this.hash).show();
        
        $('div.tabs ul.tabNavigation a').removeClass('selected');
        $(this).addClass('selected');
        
        return false;
    }).filter(':first').click();
});

function PopupBlock(b,c){this.container=$(b);this.link=$(c);this.keep=false;var d=this;if(this.container&&this.link){this.container.click(function(a){d.keep=true});this.link.click(function(a){d.toggle(a)})}}PopupBlock.prototype.toggle=function(a){a.preventDefault();a.stopPropagation();if(this.container.hasClass("hidden")){this.show(a)}else{this.hide(a)}return this};PopupBlock.prototype.show=function(b){this.container.removeClass("hidden");var c=this;this.documentClickHandler=function(a){c.hide(a)};this.documentKeyDownHandler=function(a){c.cancel(a)};$(document).click(this.documentClickHandler);$(document).keydown(this.documentKeyDownHandler)};PopupBlock.prototype.hide=function(a){if(this.keep){this.keep=false;return}this.container.addClass("hidden");$(document).unbind("click",this.documentClickHandler);$(document).unbind("keydown",this.documentKeyDownHandler)};PopupBlock.prototype.cancel=function(a){var b=a.keyCode?a.keyCode:a.which?a.which:null;if(b==27){this.hide(a)}};

function ToggleNewsImg(id){
	iNode = document.getElementById('s-img-' + id);
	lNode = document.getElementById('link-' + id);
	if(iNode){
		na = iNode.parentNode;
		for(i = 0; i < na.childNodes.length; i++){
			na.childNodes[i].style.display = (na.childNodes[i].id == 's-img-' + id)?'':'none';
		}
	}
	if(lNode){
		na = lNode.parentNode;
		for(i = 0; i < na.childNodes.length; i++){
			na.childNodes[i].className = (na.childNodes[i].id == 'link-' + id)?'active':'';
		}
	}
}