$(document).ready(function()
{
 drop_bottom();	
 csshelp();
}
);

function drop_bottom()
{
 var screen_height =((document.compatMode || navigator.isIE) && !navigator.isOpera) ? (document.compatMode == 'CSS1Compat') ? document.documentElement.clientHeight : document.body.clientHeight : (document.parentWindow || document.defaultView).innerHeight;
 var content_height = $("#box").height();
 var bottom_height = $("#bottom").height();
 if (screen_height > content_height + bottom_height)
 {
  var height = screen_height - bottom_height;	
  $("#box").css	
  (
   {
    height: height + "px"
   }
  );
 }
}

function csshelp()
{
 var height = Math.max($("#left").height(),$("#center").height(),$("#right").height());
 $("#left").css(
 { height: height+"px"}
 );
 $("#right").css(
 { height: height+"px"}
 );	
 if ($("#center").height()<height)
 {
  $("#center").css(
  { height: height+"px"}
  );	 	
 }
}

function loadform(alias)
{
 $('#'+alias).ajaxForm(
 { 
  dataType:  'json', 
  success:   processJsonForm
 }
 );	
}

function processJsonForm(data)
{
 $("#inputresult").html(data.text);	
 if(data.done==1) 
 {
  $("#submit_data").attr("disabled","disabled");
  // ставим задержку, чтобы пользователь мог прочитать надпись
  setTimeout(function(){window.location = data.link;}, 3000);
 }
 else
 {
  $("#submit_data").attr("disabled","");	
 }
 $("#ajaxloader").empty();
 csshelp();
}

function loadindicator()
{
 $("#ajaxloader").html("<img src=\"/i/black.gif\" width=\"16\" height=\"16\" alt=\"\" />");
}

function view_results(id)
{
 loadindicator();
 $.getJSON(
 '/view_poll.php',
 {
  id:id,
  submit_login: true
 },
 function(obj)
 {
  if (obj.done == 1)
  {	
   $("#pollbox").html(obj.html);
   $("#viewpoll").empty();
  } 
  else
  {
   $("#inputresult").html(obj.html);	
   $("#ajaxloader").empty();
  } 
 }
 ); 	
}
