function show_block(div)
{
	div.style.display = "";
}
function hide_block(div)
{
	div.style.display = "none";
}
function showProperties(obj, objName) 
{
  var result = "The properties for the " + objName + " object:" + "\n";
  
  for (var i in obj) {result += i + " = " + obj[i] + "\n";}
  
  return result;
}

function createRequestObject(){
  var xmlhttp;
  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      xmlhttp = false;
    }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}
var http = createRequestObject();

function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function trtover(q) {q.style.backgroundColor='#F4F5F7';}
function trtout(q) {q.style.backgroundColor = '#FFFFFF';}


function show_error()
{
	var width = getClientWidth();
	var div = document.getElementById('error');
	div.style.display = "";
	//div.style.left = (width/2) - (div.clientWidth/2)+"px";
	div.style.left = "30%";
	
 	document.body.color = "#000000"; 
 	document.getElementById('error_fon').style.display = ""; 
}


function get_proxy_subtypes(type)
{
    document.getElementById('count').innerHTML="<input type='text' name='count' value='Выберите подтип прокси' disabled='1' class='input'/>";
    if (type!=0)
    {
        http.open('get', 'for_scripts.php?type=get_proxy_subtypes&proxy_type='+type);
        http.onreadystatechange = get_proxy_subtypes_result;
        http.send(null);
    }
    else
    {
        document.getElementById('subtype').innerHTML="<input type='text' name='proxy_subtype' value='Выберите тип прокси' disabled='1' class='input'/>";
    }
}
function get_proxy_subtypes_result()
{
    if(http.readyState == 4)
    {
        var response = http.responseText;
    	document.getElementById('loader').style.display = "none";
        var i=0;
    	var subtype = new Array();
    	var subtype_array = new Array();
    	subtype = response.split("|");
    	document.getElementById('subtype').innerHTML="";
    	document.getElementById('subtype').innerHTML+="<select name='proxy_subtype' id='subtype_id' onChange='get_proxy_count(this.value)' class='input'>";
    	var select = document.getElementById("subtype_id");
        select.options[select.options.length] = new Option("Выберите значение", "0");
    	for (i=0;i<subtype.length;i++)
    	{
    		subtype_array = subtype[i].split("*");
    		select.options[select.options.length] = new Option(subtype_array[1], subtype_array[0]);
    	}
    	document.getElementById('subtype').innerHTML+="</select>";
    }
    else
    {
    	document.getElementById('loader').style.display = "";
    }
}
function get_proxy_count(subtype)
{
    if (subtype!=0)
    {
        http.open('get', 'for_scripts.php?type=get_proxy_count&proxy_subtype='+subtype);
        http.onreadystatechange = get_proxy_count_result;
        http.send(null);
    }
    else
    {
        document.getElementById('count').innerHTML="<input type='text' name='count' value='Выберите подтип прокси' disabled='1' class='input'/>";
    }
}
function get_proxy_count_result()
{
    if(http.readyState == 4)
    {
        var response = http.responseText;
    	document.getElementById('loader').style.display = "none";
        var i=0;
    	var count_array = new Array();
    	count_array = response.split("|");
    	document.getElementById('count').innerHTML="";
    	document.getElementById('count').innerHTML+="<select name='count' id='count_id' onChange='enable_buy_button()' class='input'>";
    	var select = document.getElementById("count_id");
    	for (i=0;i<count_array.length;i++)
    	{
    		select.options[select.options.length] = new Option(count_array[i], count_array[i]);
    	}
    	document.getElementById('count').innerHTML+="</select>";
    }
    else
    {
    	document.getElementById('loader').style.display = "";
    }
}
function enable_buy_button()
{
    document.getElementById('submit').disabled = 0;
}
function iveread(plati_id)
{
    if (document.getElementById('plati_id').innerHTML == "")
    {
        document.getElementById('check').checked = 1;
        document.getElementById('plati_id').innerHTML = "<a href='http://www.oplata.info/asp/pay_wm.asp?id_d="+plati_id+"' target='_blank'><img src='http://www.digiseller.ru/outside/images/pay_get.gif' width='180' height='55' border='0'></a>";
    }
    else
    {
        document.getElementById('check').checked = 0;
        document.getElementById('plati_id').innerHTML = "";
    }
}
