
function show_dot(show){
	var show;
		$('#'+show).show();
		
}


function hide_dot(hide){
	var hide;
		$('#'+hide).hide();
}


function preload_img(){

	if (document.images){
	
	pic1= new Image(3,1); 
	pic1.src="/img/top_menu_underline.gif"; 
	
	pic1= new Image(3,1); 
	pic1.src="/img/top_menu_underline_shop.gif"; 

	pic1= new Image(3,1); 
	pic1.src="/img/top_menu_underline_hover.gif"; 

	}

}

function h(what){

$(what).className='news_hover';
}

function unh(what){

$(what).className='news_hover_off';

}

var root = window.addEventListener || window.attachEvent ? window : document.addEventListener ? document : null;
if (root){

  if (root.addEventListener) root.addEventListener("load", preload_img, false);
  else if (root.attachEvent) root.attachEvent("onload", preload_img);

 // if (root.addEventListener) root.addEventListener("mouseover", p, false);
 // else if (root.attachEvent) root.attachEvent("onmouseover", p);


}



$(document).ready(function(){

if($('#UserProfile').length > 0 || $('#UserInfo').length > 0)
{
  $('#UserProfile').FormValidate({
	phpFile:"/homepage/view_new_user_data/",
	ajax:false
});
  
 $('#UserInfo').submit(function(){
								
							 $('#UserProfile').FormValidate({
	phpFile:"/homepage/view_new_user_data/",
	ajax:false
});	
							});
 }

else if($('#ConsultTime').length > 0)
{
	$('#ConsultTime').FormValidate({	phpFile:"/homepage/consult_time/", ajax:false	});
}


else if( $('#validate_form').length > 0 )
{
	var action_and_form_name = $('#validate_form').attr('action');
	$('#' + action_and_form_name).FormValidate({	phpFile:"/homepage/" + action_and_form_name + "/", ajax:false	});

}

else if( $('#notice').length > 0 )
{
	$.jGrowl($('#notice').html(), { 
						 sticky: true,
						 closer: true
	});
					

}

 
  });


function delete_consult(id)
{
var id;
$.ajax({
		   type: "POST",
		   dataType: "html",
		   url: "/backend/delete_consult/" + id,
		   data: "id=" + id,
		   success: function(data){
                $('#consult_time').html(data);
		   }
		});
}

function add_consult_time(consultant_id)
{
var consultant_id;
$.ajax({
		   type: "POST",
		   dataType: "html",
		   url: "/backend/add_consult_time/",
		   data: "consultant[consult_day]=" + $('#consult_day').val() + '&consultant[consultant_id]=' + consultant_id + '&consultant[consult_time_start]=' + $('#consult_time_start').val() + '&consultant[consult_time_end]=' + $('#consult_time_end').val() + '&consultant[consult_minute_end]=' + $('#consult_minute_end').val() + '&consultant[consult_minute_start]=' + $('#consult_minute_start').val(),
		   success: function(data){
                $('#consult_time').html(data);
		   }
		});
}



function showMessage(header, text, unhook, theme)
{
	var text;
	var header;
	var unhook;
	
	if(!theme)
	{
		var theme = 'notice';
	}
	
	if(text.length > 0){
				$.jGrowl(text, { 
						 life: 6000, 
						 header: header,
						 theme: theme,
						 closerTemplate: 'close',
						 beforeOpen: function(e,m,o) {	if (unhook == false) { $('.jGrowl-notification').hide(); };	}
						 });
	}

}

function show_empty_profile()
{

 $.scrollTo('#profile', 900);
showMessage('Личные данные не отправлены.', 'Прежде Вам нужно заполнить и отправить <a href="#profile">форму личных данных в верхней части анкеты</a>.', false);

}
