function inputready(obj){if(obj.value==obj.defaultValue) obj.value='';obj.style.color='#333';}
function focusout(obj2){
if(obj2.value==''){obj2.value= obj2.defaultValue; obj2.style.color='#сссссс';}
}

function makeRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
           // http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html; charset=windows-1251');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }

      http_request.onreadystatechange = alertContents;
      http_request.open('GET', url + parameters, true);
//alert(url + parameters);
      http_request.send(null);
document.getElementById('result').innerHTML = '<img src="/newimg/loading.gif" alt="Подождите">';


   }


function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);

            result = http_request.responseText;
            document.getElementById('result').innerHTML = result;     

         } else {
            alert('There was a problem with the request.');
         }
      }
   }




function changeCheck(el)
/*
    функция смены вида и значения чекбокса
	    el - span контейнер дял обычного чекбокса
	    input - чекбокс
	*/
	{
	     var el = el,
	          input = el.getElementsByTagName("input")[0];
	         
	     if(input.checked)
	     {
	         el.style.backgroundPosition="0 0";
			 el.style.color="#333";
	         input.checked=false;
	     }
	     else
	     {
	          el.style.backgroundPosition="44px 0";
			  el.style.color="#fff";
	          input.checked=true;
	     }
	     return true;
	}
	function startChangeCheck(el)
	/*
	    если значение установлено в on, меняем вид чекбокса на включенный
	*/
	{
	    var el = el,
	          input = el.getElementsByTagName("input")[0];
	     if(input.checked)
	     {
	          el.style.backgroundPosition="44px 0";
el.style.color="#fff";			  
	      }
	     return true;
	}
	 
	function startCheck()
	{
	    /*
	         при загрузке страницы заменяем проверяем значение чекбокса в указанном контенере.
	         если чекбоксов несколько, нужно будет несколько раз вызвать функциую с нужными id
	     */
startChangeCheck(document.getElementById("niceCheckbox1"));
startChangeCheck(document.getElementById("niceCheckbox2"));
startChangeCheck(document.getElementById("niceCheckbox3"));
startChangeCheck(document.getElementById("niceCheckbox4"));
startChangeCheck(document.getElementById("niceCheckbox5"));
startChangeCheck(document.getElementById("niceCheckbox6"));


	}

function checkboxone(input)
{
el = input.parentNode;
if(input.checked)
	     {
	         el.style.backgroundPosition="0 0";
			 el.style.color="#333";
	         input.checked=false;
	     }
	     else
	     {
	          el.style.backgroundPosition="44px 0";
			  el.style.color="#fff";
	          input.checked=true;
	     }
}

function checkfield(field)
{
var inpts=cont.getElementsByTagName("input");
  for(var i=0; i<inpts.length; i++)
    if(inpts[i].type=="checkbox" ) inpts[i].checked=false; 
dname= field.value.split('.');
if(dname.length==2){
tld=dname[1];

var checkBoxes = document.getElementsByName(tld);
checkBoxes[0].checked = "checked";
nodeup = checkBoxes.parentNode;
nodeup.style.backgroundPosition="0 0";
checkboxone(checkBoxes);

}


}



function reset()
{
var inpts=cont.getElementsByTagName("input");
  for(var i=0; i<inpts.length; i++)
    if(inpts[i].type=="checkbox" ) inpts[i].checked=false; 
}




/* TABSLIDEOUT */

(function($){
    $.fn.tabSlideOut = function(callerSettings) {
        var settings = $.extend({
            tabHandle: '.handle',
            speed: 300, 
            action: 'click',
            tabLocation: 'left',
            topPos: '200px',
            leftPos: '20px',
            fixedPosition: false,
            positioning: 'absolute',
            pathToTabImage: null,
            imageHeight: null,
            imageWidth: null                       
        }, callerSettings||{});

        settings.tabHandle = $(settings.tabHandle);
        var obj = this;
        if (settings.fixedPosition === true) {
            settings.positioning = 'fixed';
        } else {
            settings.positioning = 'absolute';
        }
        
        //ie6 doesn't do well with the fixed option
        if (document.all && !window.opera && !window.XMLHttpRequest) {
            settings.positioning = 'absolute';
        }
        
        //set initial tabHandle css
        settings.tabHandle.css({ 
            'display': 'block',
            'width' : settings.imageWidth,
            'height': settings.imageHeight,
            'textIndent' : '-99999px',
            'background' : 'url('+settings.pathToTabImage+') no-repeat',
            'outline' : 'none',
            'position' : 'absolute'
        });
        
        obj.css({
            'line-height' : '1',
            'position' : settings.positioning
        });

        
        var properties = {
                    containerWidth: parseInt(obj.outerWidth(), 10) + 'px',
                    containerHeight: parseInt(obj.outerHeight(), 10) + 'px',
                    tabWidth: parseInt(settings.tabHandle.outerWidth(), 10) + 'px',
                    tabHeight: parseInt(settings.tabHandle.outerHeight(), 10) + 'px'
                };

        //set calculated css
        if(settings.tabLocation === 'top' || settings.tabLocation === 'bottom') {
            obj.css({'left' : settings.leftPos});
            settings.tabHandle.css({'right' : 0});
        }
        
        if(settings.tabLocation === 'top') {
            obj.css({'top' : '-' + properties.containerHeight});
            settings.tabHandle.css({'bottom' : '-' + properties.tabHeight});
        }

        if(settings.tabLocation === 'bottom') {
            obj.css({'bottom' : '-' + properties.containerHeight, 'position' : 'fixed'});
            settings.tabHandle.css({'top' : '-' + properties.tabHeight});
            
        }
        
        if(settings.tabLocation === 'left' || settings.tabLocation === 'right') {
            obj.css({
                'height' : properties.containerHeight,
                'top' : settings.topPos
            });
            
            settings.tabHandle.css({'top' : 0});
        }
        
        if(settings.tabLocation === 'left') {
            obj.css({ 'left': '-' + properties.containerWidth});
            settings.tabHandle.css({'right' : '-' + properties.tabWidth});
        }

        if(settings.tabLocation === 'right') {
            obj.css({ 'right': '-' + properties.containerWidth});
            settings.tabHandle.css({'left' : '-' + properties.tabWidth});
            
            $('html').css('overflow-x', 'hidden');
        }

        //functions for animation events
        
        settings.tabHandle.click(function(event){
            event.preventDefault();
        });
        
        var slideIn = function() {
            
            if (settings.tabLocation === 'top') {
                obj.animate({top:'-' + properties.containerHeight}, settings.speed).removeClass('open');
            } else if (settings.tabLocation === 'left') {
                obj.animate({left: '-' + properties.containerWidth}, settings.speed).removeClass('open');
            } else if (settings.tabLocation === 'right') {
                obj.animate({right: '-' + properties.containerWidth}, settings.speed).removeClass('open');
            } else if (settings.tabLocation === 'bottom') {
                obj.animate({bottom: '-' + properties.containerHeight}, settings.speed).removeClass('open');
            }    
            
        };
        
        var slideOut = function() {
            
            if (settings.tabLocation == 'top') {
                obj.animate({top:'-3px'},  settings.speed).addClass('open');
            } else if (settings.tabLocation == 'left') {
                obj.animate({left:'-3px'},  settings.speed).addClass('open');
            } else if (settings.tabLocation == 'right') {
                obj.animate({right:'-3px'},  settings.speed).addClass('open');
            } else if (settings.tabLocation == 'bottom') {
                obj.animate({bottom:'-3px'},  settings.speed).addClass('open');
            }
        };

        var clickScreenToClose = function() {
            obj.click(function(event){
                event.stopPropagation();
            });
            
            $(document).click(function(){
                slideIn();
            });
        };
        
        var clickAction = function(){
            settings.tabHandle.click(function(event){
                if (obj.hasClass('open')) {
                    slideIn();
                } else {
                    slideOut();
                }
            });
            
            clickScreenToClose();
        };
        
        var hoverAction = function(){
            obj.hover(
                function(){
                    slideOut();
                },
                
                function(){
                    slideIn();
                });
                
                settings.tabHandle.click(function(event){
                    if (obj.hasClass('open')) {
                        slideIn();
                    }
                });
                clickScreenToClose();
                
        };
        
        //choose which type of action to bind
        if (settings.action === 'click') {
            clickAction();
        }
        
        if (settings.action === 'hover') {
            hoverAction();
        }
    };
})(jQuery);

function initbox()
{

$('.slide-out-div').tabSlideOut({
tabHandle: '.handle', // класс элемента
pathToTabImage: '/newimg/getbonus.png',          //путь к изображению *required*
imageHeight: '169px', // высота  *required*
imageWidth: '40px', // width of tab image *required*    
tabLocation: 'right', //side of screen where tab lives, top, right, bottom, or left
speed: 300, // speed of animation
action: 'click', // options: 'click' or 'hover', action to trigger animation
topPos: '200px', // position from the top
fixedPosition: false // options: true makes it stick(fixed position) on scroll
});
 }


function shclientbox(){
$('#authblock').toggle();
$('#shadow').toggle(); 
}





function get(obj) {
var getstr = "?";

for (i=0; i<obj.elements.length; i++) 
{
    if (obj.elements[i].tagName == "INPUT") 
 {
		 
		 
            if (obj.elements[i].type == "text") {
               getstr += obj.elements[i].name + "=" + obj.elements[i].value + "&";
            }
            if (obj.elements[i].type == "checkbox") {
               getstr += obj.elements[i].name + "=" + obj.elements[i].checked + "&";
            }
  }   
       
}


      makeRequest('/js/get.php', getstr);
	  
}



function init(){

$('#in').bind('click', shclientbox);
$('#authblock a').bind('click', shclientbox);

}

$(document).ready(function(){
initbox();init();startCheck();


});


