function show_div(Xwidth,Yheight,divid) { 
// First, determine how much the visitor has scrolled

	var scrolledX, scrolledY; 
	if( self.pageYOffset ) 
	{ 
		scrolledX = self.pageXOffset; 
		scrolledY = self.pageYOffset; 
	} 
	else  if( document.documentElement && document.documentElement.scrollTop ) 
	{ 
		scrolledX = document.documentElement.scrollLeft; 
		scrolledY = document.documentElement.scrollTop; 
	} 
	else if( document.body ) 
	{ 
		scrolledX = document.body.scrollLeft; 
		scrolledY = document.body.scrollTop; 
	}

// Next, determine the coordinates of the center of browser's window

	var centerX, centerY; 
	if( self.innerHeight )
	{ 
		centerX = self.innerWidth; 
		centerY = self.innerHeight; 
	} 
	else if( document.documentElement && document.documentElement.clientHeight ) 
	{ 
		centerX = document.documentElement.clientWidth; 
		centerY = document.documentElement.clientHeight; 
	} 
	else if( document.body ) 
	{ 
		centerX = document.body.clientWidth; 
		centerY = document.body.clientHeight; 
	}

// Xwidth is the width of the div, Yheight is the height of the 
// div passed as arguments to the function: 

	var leftOffset = scrolledX + (centerX - Xwidth) / 2; 
	var topOffset = scrolledY + (centerY - Yheight) / 2; 
// The initial width and height of the div can be set in the 
// style sheet with display:none; divid is passed as an argument to // the function 
	var o=document.getElementById(divid); 
	var r=o.style; 
	r.position='absolute'; 
	r.top = topOffset + 'px'; 
	r.left = leftOffset + 'px'; 
} 


	$(document).ready(function()						   
	{
		
		
		$("a[rel^='group']").colorbox();
		
		 $("#div_send").click(function(){
									   
									   
			var mail=document.getElementById("user_mail").value;	
			var name=document.getElementById("user_name").value;
			var phone=document.getElementById("user_phone").value;
			var type=document.getElementById("user_type").value;
			var text=document.getElementById("textdata").value;
			var city=document.getElementById("user_city").value;
			var country=document.getElementById("user_country").value;

			
			
			
			document.getElementById("error_messages").innerHTML="";
          
            if(name=="")
			{
				document.getElementById("error_messages").innerHTML="• Ошибка! Введите ваше имя.";
				return false;
			} 
			
			if(city=="")
			{
				document.getElementById("error_messages").innerHTML="• Ошибка! Введите название города и области.";	
				return false;
			} 

			if(phone=="")
			{
				document.getElementById("error_messages").innerHTML="• Ошибка! Введите ваш контактный телефон.";	
				return false;
			} 

			
			
			
			
			if(mail.length==0) 
			{
				document.getElementById("error_messages").innerHTML="• Ошибка! Введите ваш электронный адрес.";
				return false;
			}
			if (!(mail.indexOf("@")==mail.lastIndexOf("@")&&mail.lastIndexOf(".")>mail.indexOf("@")+1&&mail.indexOf("@")>0&&mail.length>mail.lastIndexOf(".")+2))
			{
				document.getElementById("error_messages").innerHTML="• Ошибка! неверный адрес электронной почты.";
				return false;
			}
		
			   //alert("user_country="+country+"&user_mail="+mail+"&user_name="+name+"&user_phone="+phone+"&user_city="+city+"&user_type="+type+"&user_text="+text+"&encode=абвг");
			$.ajax({

				method: "post",url: "http://arlekin.ua/ajax/add_user.php",

				data: "user_country="+country+"&user_mail="+mail+"&user_name="+name+"&user_phone="+phone+"&user_city="+city+"&user_type="+type+"&user_text="+text+"&encode=абвг",
				success: function(text)
				{ 
				//	alert(text);
alert("Спасибо, запрос прайс-листа продукции был отправлен, наши менеджеры свяжутся с вами ближайшее время.");
					document.getElementById('float_div').style.display='none';  
					
				}
			});
          }); 
		 
		 
		 $("#show_div").click(function(){
			
		   show_div(600,500,'float_div');
			document.getElementById('float_div').style.display='';       
          });  
		 
		  $("#hide_div").click(function(){
		
		   
			document.getElementById('float_div').style.display='none';       
          });
		 
		 $(window).scroll(function () 
		{
			document.getElementById('float_div').style.display='none';     
  		});

		$(window).resize(function() 
		{
			if (document.getElementById('float_div').style.display=='')   			  
			show_div(600,500,'float_div');   
  
		});
		
		
		
	});
