  var isdo=0;
 var isOpen = [];
 
 var isAuthFormOpen = 0;
 
 $(document).ready(function() {
	var contentTextHeadersCount = 4;
	for(i=1;i<=contentTextHeadersCount;i++) {
	
	/*switch (i){
	case 1: $('#content-text-header-' + i).mousedown(function(x) {	location.replace("/zastrah/memo/");});	break;
	case 2: $('#content-text-header-' + i).mousedown(function(x) {	location.replace("/strah/right/");});	break;
	case 3: $('#content-text-header-' + i).mousedown(function(x) {	location.replace("/strahmed/");});	break;
	case 4: $('#content-text-header-' + i).mousedown(function(x) {	location.replace("/med/");});	break;
	}*/
	
		isOpen[i] = false;
		$('#content-text-header-' + i).mouseenter(function(x) {
			return function() { ShowContentTextLinks(x) };
		}(i));
		
		$('#content-text-header-' + i).mouseleave(function(x) {
			return function() { HideContentTextLinks(x) };
		}(i));
	}
 });


 function fade(){ isdo=0; }
 
function ShowContentTextLinks(number) {
	var t=200; 
	setTimeout(fade, t); 
	if (isdo==0)
	{
	isdo=1;
	if (isOpen[number]) return false;
	isOpen[number] = true;
	
	
	 $('#' + 'content-text-header-' + number).animate({
    height: '+=112'
  }, 50, function() {
	if (isOpen[number]) {
		$('#' + 'content-text-links-' + number).fadeIn('fast');
		
	}
  });
 }
  
}

function HideContentTextLinks(number) {
	
	if (!isOpen[number]) { 
		$('#' + 'content-text-links-' + number).css('display','none');
		return false;
	}
	isOpen[number] = false;
	
	
	$('#' + 'content-text-links-' + number).css('display','none');
	$('#' + 'content-text-header-' + number).animate({
		//height: '-=112'
		height: '-=112'
		}, 50, function() {
	$('#' + 'content-text-links-' + number).css('display','none');
	
	
	});
	
}

function ShowHiddenItem(id) {
	switch (id){
	case 1: location.replace("/zastrah/memo/");
	break;
	case 3: location.replace("/strah/right/");
	break;
	case 4: location.replace("/strahmed/");
	break;
	case 5: location.replace("/med/");
	break;
	}

	//var ul = document.getElementById('left-strah-ul-' + id);
	//ul.style.display = "block";
}

function ShowHiddenItems(id) {
	var ul = document.getElementById('left-strah-ul-' + id);
	if (ul.style.display == "block")
	{
		ul.style.display = "none"
	}
	else
	{
		ul.style.display = "block";
	}
	
}

function ShowHiddenIts(id) {
	var ul = document.getElementById(id);
	if (ul.style.display == "block")
	{
		ul.style.display = "none"
	}
	else
	{
		ul.style.display = "block";
	}
	
}


function ShowAuthForm() {

	if (isAuthFormOpen) return;
	isAuthFormOpen = 1;

	$('#auth-form').animate({
		top: '+=143'
	}, 50, function() {
	});
}
		
function HideAuthForm() {

	if (!isAuthFormOpen) return;
	isAuthFormOpen = 0;

	$('#auth-form').animate({
		top: '-=143'
	}, 50, function() {
	});
}


function setAttr(prmName,val, text){
    var res = '';
	var d = location.href.split("#")[0].split("?");  
	var base = d[0];
	var query = d[1];
	if(query) {
		var params = query.split("&");  
		for(var i = 0; i < params.length; i++) {  
			var keyval = params[i].split("=");  
			if(keyval[0] != prmName) {  
				res += params[i] + '&';
			}
		}
	}
	res += prmName + '=' + val;
	window.location.href = base + '?' + res+'&'+text;
	return false;
} 
