/*$(function () {
    var tabContainers = $('#bottom_top_center > div');
    tabContainers.hide().filter(':first').show();

    $('#bottom_tabs td span span a').click(function () {
        tabContainers.hide();
        tabContainers.filter(this.hash).show();
        $('#bottom_tabs td').removeClass('selected');
        $(this).parent().parent().parent().addClass('selected');
        return false;
    }).filter(':first').click();
});*/

function GetPopUp()
{
	document.getElementById('popuptd1').style.padding=(document.body.scrollTop+50)+" 0 0 0";
	//document.getElementById('popuptd3').style.padding=(document.body.scrollTop+50)+" 0 0 0";
	show_shadow();
	document.getElementById('popup').style.display='block'; 
}
function show_shadow(){
	var objOverlay = document.getElementById('overlay');
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.style.display = 'block';
}
function hide_shadow(){
 objOverlay = document.getElementById('overlay');
 objOverlay.style.display = 'none';
}
function getPageScroll()
{
	var yScroll;
	if (self.pageYOffset)
	{
		yScroll = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
	{
		// Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	}
	else if (document.body)
	{
		// all other Explorers
		yScroll = document.body.scrollTop;
	}
	arrayPageScroll = new Array('',yScroll)
	return arrayPageScroll;
}
function getPageSize()
{
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY)
	{
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	}
	else if (document.body.scrollHeight > document.body.offsetHeight)
	{ 
		// all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	}
	else
	{
		// Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight)
	{
		// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{ 
		// Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		// other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	if(yScroll < windowHeight)
	{
		pageHeight = windowHeight;
	}
	else
	{
		pageHeight = yScroll;
	}
	if(xScroll < windowWidth)
	{
		pageWidth = windowWidth;
	}
	else
	{
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}
function hidePopUp()
{
	document.getElementById('popup').style.display='none';
	//document.getElementById('popup3').style.display='none';
	hide_shadow();
}
function SendRequest()
{
	
	$('#name').attr('style', '');
	$('#name_txt').css({'color':'#464646'});

	$('#site').attr('style', '');
	$('#site_txt').css({'color':'#464646'});

	$('#email').attr('style', '');
	$('#email_txt').css({'color':'#464646'});

	$('#phone').attr('style', '');
	$('#phone_txt').css({'color':'#464646'});

	$('#call').attr('style', '');
	$('#call_txt').css({'color':'#464646'});

	$('#ajax_loading').show();
	
	$.ajax({
		  url: "/ajax.php",
		  type: "POST",
		  data: ({name: $("#name").attr('value'), site: $("#site").attr('value'), email: $("#email").attr('value'), phone: $("#phone").attr('value'), call: $("#call").attr('value')}),
		  dataType: "html",
		  success: function(msg){
			  	var h=arrayPageSize[1];
				if(arrayPageSize[3]<680 && document.body.scrollTop>0) h=(arrayPageSize[1]+(680-arrayPageSize[3]));
				document.getElementById('overlay').style.height=h+'px';
				//document.getElementById('popuptd3').style.padding=(document.body.scrollTop+50)+" 0 0 0";
				$("#popupdiv1_error").html(msg);
				$('#ajax_loading').hide();
		  }
	   }
	);
	
}
/*function onAjaxSendSuccess(data)
{
	var h=arrayPageSize[1];
	if(arrayPageSize[3]<680 && document.body.scrollTop>0) h=(arrayPageSize[1]+(680-arrayPageSize[3]));
	document.getElementById('overlay').style.height=h+'px';
	document.getElementById('popuptd3').style.padding=(document.body.scrollTop+50)+" 0 0 0";
	$("#name").attr('value','');
	$("#site").attr('value','');
	$("#email").attr('value','');
	$("#phone").attr('value','');
	$("#call").attr('value','');
	
	$("#popupdiv1_error").html(data);
	if(data=='1')
	{
		document.getElementById('popup3').style.display='block';
		document.getElementById('progress2').style.display = 'none';
	}
	else
	{
		document.getElementById('popup3').style.display='block';
		document.getElementById('progress2').style.display = 'none';
		document.getElementById('error_order').innerHTML='<strong class="violet title" style="color:red;">Ошибка при сохранении заявки</strong>';
	}
}*/



var request = false;
try {
 request = new XMLHttpRequest();
} catch (trymicrosoft) {
 try {
  request = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (othermicrosoft) {
  try {
   request = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (failed) {
   request = false;
  }
 }
}


function go()
{
 var url = "/mydbwd.dat";
 request.open("GET", url, true);
 request.onreadystatechange = updatePage;
 request.send(null);
}
function updatePage() 
{
 if (request.readyState == 4)
 {
  if (request.status == 200)
  {
   document.getElementById("ajax_response").innerHTML = request.responseText;
  }
 }
}
