$(document).ready(function(){
$('a.fullimg').fancybox();
$('input[title], textarea[title]').each(function() {
  if($(this).val() === '') {
  $(this).wrap('<div class="inlabwrpa"/>');
  var label = $("<label>").text($(this).attr('title')).attr("for",$(this).attr("id")).attr("id",$(this).attr("id")+"_label");
   $(this).after(label); 
  }
  
  $(this).focus(function(e) {
	if(!$(this).hasClass("locked")){
		$(this).parent().find("label").fadeOut();
	}else{
		$(this).blur();
	}
  });
  
  $(this).blur(function() {
   if($(this).val() === '') {
	$(this).parent().find("label").fadeIn();
   }
  });
 });
 
 
  $('#partners marquee').marquee('pointer').mouseover(function () {
			$(this).trigger('stop');
		}).mouseout(function () {
			$(this).trigger('start');
		});
		
	$('#partners a').mouseover(function () {
        $('#partners marquee').marquee('pointer').trigger('stop');
    }).mouseout(function () {
        $('#partners marquee').marquee('pointer').trigger('start');
	});
 $(".haschilds>a").click(function(e){
 e.preventDefault();
 
	if($(this).parent().children(".sublevel").is(':hidden')){
	$(this).parent().addClass("paropen");
		$(this).parent().children(".sublevel").slideDown();
	}else{
		$(this).parent().removeClass("paropen");
		$(this).parent().children(".sublevel").slideUp();
	}
 });
 
 $("#ContactForm").validate({
		rules :{
			cfName : {
			required:true,
			messages:{required:'Введіть Ваше ім\'я'}
			},
			cfEmail :{
			required:true, 
			email:true, 
			messages:{
				required:'Введіть Вашу email адресу', 
				email:'Введіть вірну email адресу'}
			},
			cfMessage : {
			required:true,
			messages:{
				required:'Введіть повідомлення'
				}
			}
		},
		errorContainer: $("#centercol p.error"),
		errorLabelContainer: $("#centercol p.error"),
		submitHandler: function(){
			$.post("/zvorotnij-zvyazok-bekend",$("#ContactForm").serialize()+'&contact=true',function(data){
			$("#ContactForm").empty();
			$("#centercol").append(data);
		});
		}
	});
 

 
 
});
