/* - - - -  - - - - - -  - - -  - - - */
var alliluyaMenu=function(){
var krest_width=400;
var frame_num=7;
var cicle=1;
var curent_cicle=1;
var anim_curent_frame=1;
var last_menu_id=0;
var krest_pos=0;    
var played=false;    
function anim_krest(arr,callBack){
		krest_pos-=krest_width;
	if((typeof arr!='undefined')&&(arr=='ccw')){
	if(krest_pos!=0){
	cpos=-(krest_width*(frame_num))-krest_pos;    
	}else{
	cpos=krest_pos;
	}
	}else{
	cpos=krest_pos;
	}
	//alert(cpos);
	$("#alliluya_menu .megakrest").css({backgroundPosition:cpos+"px top"});    
	
	if((anim_curent_frame)==((curent_cicle*frame_num)-1)){
		if((curent_cicle)==cicle){
			
			krest_pos=krest_width;
		}else{
		//alert(curent_cicle);
		//alert(krest_pos);
		anim_curent_frame++;
			krest_pos=0;
		}
		curent_cicle++;
		//alert(curent_cicle);
		
	}
	if((anim_curent_frame)==cicle*frame_num){
		anim_curent_frame=1;
		curent_cicle=1;
		callBack();
	}else{
		setTimeout(function(){anim_krest(arr,callBack)},50);
	}
	anim_curent_frame++;
	
}
this.goto=function(menu_id){
	if(played) return;
	if(last_menu_id==menu_id) return;
	played=true;
	var cpos=-menu_id*64;
	//alert(cpos);
	cicle=1;
	//alert(last_menu_id-menu_id);
	
	if((last_menu_id-menu_id==1)||(last_menu_id-menu_id==-3)){
			var arr='cw';
	}else if((last_menu_id-menu_id==-1)||(last_menu_id-menu_id==3)){
			var arr='ccw';
	}else if((last_menu_id-menu_id==2)||(last_menu_id-menu_id==-2)){
			if(Math.random()>0.5){
			var arr='ccw';
			}else{
			var arr='cw';
			}
			cicle=2;
	}else{
	
	return;
	}
	if(!jQuery.support.opacity){
	$("#alliluya_menu .menu_cont").hide();
	}
	$("#alliluya_menu .menu_cont").animate({opacity:'0'},"slow",function(){
	//alert('1');
			$("#alliluya_menu .menu_cont").removeClass('pgdiagnostic');
		$("#alliluya_menu .menu_cont").removeClass('pgfast');
			$("#alliluya_menu .menu_cont").removeClass('pgstacionar');
			$("#alliluya_menu .menu_cont").removeClass('pgconsult');
		
		if(menu_id==0){
			$("#alliluya_menu .menu_cont").addClass("pgdiagnostic");
		}else if(menu_id==1){
			$("#alliluya_menu .menu_cont").addClass("pgfast");
		}else if(menu_id==2){
			$("#alliluya_menu .menu_cont").addClass("pgstacionar");
		}else if(menu_id==3){
			$("#alliluya_menu .menu_cont").addClass("pgconsult");
		}
	});
	$("#alliluya_menu .megaarrow").animate({opacity:'0'},"fast",function(){ 
																anim_krest(arr,function(){
																					   $("#alliluya_menu .megaarrow").css({backgroundPosition:cpos+"px top"});
																						played=false;
																						$("#alliluya_menu .menu_cont").animate({opacity:'1'});
																					   $("#alliluya_menu .megaarrow").animate({opacity:'1'});
																					   last_menu_id=menu_id;
																					  $("#alliluya_menu .loader").hide();
																					  if(!jQuery.support.opacity){
																						$("#alliluya_menu .menu_cont").show('fast',function(){
																						
																						});
																						
																					   }
																						
																					   });         
																		 
																		 });
	
}

}
/* - - - -  - - - - - -  - - -  - - - */
/* - - - -  - - - - - -  - - -  - - - */
var curent_screen='-1';
var mmm=new alliluyaMenu();
function setScreen(screen_num){
	if(screen_num!=undefined){
		if(screen_num==0){
			document.location.hash='#Diagnostic';
		}else if(screen_num==1){
			document.location.hash='#Ambulance';
		}else if(screen_num==2){
			document.location.hash='#Hospital';
		}else if(screen_num==3){
			document.location.hash='#Consultants';
		}
	}
	var screen=1;
	var path='/page/aj_index/diagnostic';
	c_class='';
	if(document.location.hash==''){
		document.location.hash='#Diagnostic';
	}
	var hs=document.location.hash;
	
	if(hs=='#Diagnostic' || hs=='#diagnostic'){
		path='/for_ajax/diagnostic.php';
		var c_class='diagnostic';
		screen=1;
	}else if(hs=='#Ambulance' || hs=='#ambulance'){
		var c_class='ambulance';
		screen=2;
	}else if(hs=='#Hospital' || hs=='#hospital'){
		var c_class='hospital';
		screen=3;
	}else if(hs=='#Consultants' || hs=='#consultants'){
		var c_class='consultants';
		screen=4;
	}
	var path='/page/aj_index/'+c_class;
   // alert(hs);
   if(5!=5 && jQuery.support.opacity){
		//$('#content .clear_content').animate({opacity:'hide'},function(){
		$('#content .clear_content').fadeOut(600,function(){
			$('#content .clear_content').html("<div class='loader'>Загрузка...</div>");
		})
   }else{
	   $('#content .clear_content').html("<div class='loader'>Загрузка...</div>");
   }
   
   $.post(path,'',function(r){
	   
	   $('#content').attr('class',c_class);
	   $('#content .clear_content').stop(true,true);
	   $('#content .clear_content').html(r);
		  if(jQuery.support.opacity){
			//$('#content .clear_content').animate({opacity:'show'},'slow')
			
			//$('#content .clear_content').fadeIn(600)
		  }else{
			  set_fixes();
		  }
   });
	mmm.goto(screen-1);
	
	//alert(screen);
}




$(document).ready(function(){
setScreen();
$("#content h1 a").live('mouseover',function(){
//alert('');

$(this).find("img").stop(true,false);
$(this).css({backgroundImage:"url(/images/main_tt_clicker.png)"});
$(this).find("img").css({opacity:0,display:'block'});
$(this).find("img").animate({opacity:1},function(){
$(this).css({backgroundImage:"url(/images/main_tt_clicker_active.png)"});
$(this).find("img").css({opacity:0,display:'none'});
});
//alert();
})
$("#content h1 a").live('mouseout',function(){

	$(this).find("img").stop(true,false);
	$(this).find("img").animate({opacity:0,display:'none'});                                           
});
//alert('');

});
$(document).ready(function(){
//var itself=this;

//var pos=0;

//mmm.goto(3);
$("#alliluya_menu .diagnostic .clicker").click(function(){
	setScreen(0);
	return false;});
$("#alliluya_menu .fast .clicker").click(function(){setScreen(1);;return false;});
$("#alliluya_menu .stacionar .clicker").click(function(){setScreen(2);return false;});
$("#alliluya_menu .consult .clicker").click(function(){
	setScreen(3);
	return false;});
//mmm.goto(2);

$("#alliluya_menu .clicker").hover(
function(){
//alert('');
$(this).parents(".group").find(".loader").stop(false,true);
$(this).parents(".group").find(".loader").fadeIn();
$(this).parents(".group").find(" a.clicker").css({color:'red'});
},
function(){
$(this).parents(".group").find(".loader").stop(false,true);
$(this).parents(".group").find(".loader").fadeOut();
$(this).parents(".group").find(" a.clicker").css({color:'#8e0000'});
})
$("#alliluya_menu .podpis a").hover(
function(){
//alert('');
$(this).parents(".podpis").addClass('hover');

},
function(){
$(this).parents(".podpis").removeClass('hover');

});

$("#content .super_diagnostics .menu .luches:not(.active)").live('click',function(){
$("#content .super_diagnostics:visible").css({zIndex:1}).hide();    
$("#content .super_diagnostics_luches").css({zIndex:5}).fadeIn('fast');    return false;
});
$("#content .super_diagnostics .menu .ultro:not(.active)").live('click',function(){
	
$("#content .super_diagnostics:visible").css({zIndex:1}).hide();    
   $("#content .super_diagnostics_ultro").css({zIndex:5}).fadeIn('fast');
//alert(11);
 return false;
});
$("#content .super_diagnostics .menu .functional:not(.active)").live('click',function(){
$("#content .super_diagnostics:visible").css({zIndex:1}).hide();    
$("#content .super_diagnostics_functional").css({zIndex:5}).fadeIn('fast');    return false;
});
$("#content .super_diagnostics .menu .labolator:not(.active)").live('click',function(){
$("#content .super_diagnostics:visible").css({zIndex:1}).hide();   
$("#content .super_diagnostics_labolator").css({zIndex:5}).fadeIn('fast');    return false;
});
});


/***************************************************************************/
/*
function getElementsByClassName(searchClass, node, tag){
	var classElements = new Array();
	if (node == null)
	{
		node = document;
	}
	if (tag == null)
	{
		tag = '*';
	}
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)" + searchClass + "(\\s|$)");
	for (var i = 0, j = 0; i < elsLen; i++)
	{
		if (pattern.test(els[i].className))
		{
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

*/
