
/*
    $(function(){
            $('#tabs').tabs({
    select: function(event, ui) {
        var url = $.data(ui.tab, 'load.tabs');
        if (url.indexOf('ajax') + 1){
            alert(url);
            $(ui.panel).load(url);
        }
        
        if( url ) {
            location.href = url;
            return false;
        }
        return true;
    }, remote: true });
            $('#dialog_link, ul#icons li').hover(
                function() { $(this).addClass('ui-state-hover'); },
                function() { $(this).removeClass('ui-state-hover'); }
                );
    });
*/


function reloadPage(){
      window.location.replace(window.location.href);
}

function site_login(){
      var i=0;
      if (!$('#login').val()){
        i++;
        $('#login').css("background-color", 'red');

      }

      if (!$('#passwd').val()){
        $('#passwd').css("background-color", 'red');
        i++;
      }

      if (!i){
        $('#formlogin').hide('slow');
        $.post("/ajax.php?mod=user",
        { login: $('#login').val(), passwd:$('#passwd').val()},
        function(data){
          var text ='';
          if (data.result){
            text='Пожалуста , подождите...<br><br><span id="domain_iframe" style="border:0px;"></span>';
            $('#message').html(text).css({'left':'50%',
              'margin-left':'-130px',
              'text-align':'center'}).show();
              for (var i in data.domain){
                    
                $("#domain_iframe").append('<iframe src="http://'+data.domain[i]+'/ajax.php?sid='+data.sid+'" style="width:0px;height:0px;border:0px"></iframe><br>');
                          //  alert(data.domain[i]);
              }
              setTimeout("reloadPage()", 6000);
                //   window.location.replace(window.location.href);
          }else{
            text = 'Неверное сочетание логина и пароля <br><a href="#" onclick="$(\'#message\').hide();$(\'#formlogin\').show();" style="color:#FFF">Попробывать еще раз</a>';
          }
                    
                    

        }, 'json'
            );
      }
      return false;
    }

    $(document).ready(function () {
      $('.txt').click(
      function(){
        $(this).css("background-color", 'white') ;
      }
        );
 });
 
 
if(typeof(avto)=="undefined"){
  avto=function(){};
}

avto.form= function(){}


avto.form.list_model=function(brand_id){
  $.get('/ajax.php', {'mod':'car','cmd':'listmodel', 'id':brand_id}, function(data){ $('#model').html(data)});
}

function addPhoto(){
$("#photoarea").append('<br><input type="file" name="photo[]" value="">');
}

function viewPhoto(id){
     $('ul.navigate li.active').removeClass('active');
     $('#li_'+id).addClass('active');
     $('.transparent-frame img').hide();
    $('#img_'+id).show();

}



$(document).ready(function(){


/*
	$('#regform').dialog({ 
		autoOpen: false,modal: true,width: 260,	height: 240,
        buttons:{
            'Регистрация': function(){
              $.post('/ajax.php?mod=userreg',$("#user_form_reg").serialize(), 
                  function(data){ 
                    if (data){
                        alert(data )
                    }else{
                        $(this).dialog('close')
                    }
                    });
                },
            'Отменить': function(){ $(this).dialog('close')}
            }
		 });

 

 $('#authform').dialog({ 
        autoOpen: false, modal: true,   width: 260,  height: 150,
        buttons:{
            'Войти': function(){
              $.post('/ajax.php?mod=user',$("#user_form_auth").serialize(), 
                function(data){ 
                    if (data.result == 0){
                        alert(data.msg )
                    }else{
                        $(this).dialog('close');
                        location.reload();
                    }
               },'json');
             },
             'Отменить': function(){ $(this).dialog('close')}
  
    }
});
*/




$('#link_login').click(function(){
      $('#authform').show();
      return false; })

$('#login_btn').click( function(){
      $.post('/ajax.php?mod=user',$("#user_form_auth").serialize(), 
      function(data){ 
            if (data.result == 0){ alert(data.msg ) }
            else{     location.reload() }
      },'json');
      });

});


function openSub(){
$('#qsubdialog').dialog('open');
	if($('#qsub_type').val()=='icq'){
		$('sub_icq').val($('#qsub_sub').val());
	}else if($('#qsub_type').val()=='icq'){
        $('email').val($('#qsub_sub').val());
    }

}

function quickSub(){
   
$.post('/ajax.php?mod=quicksub',{'type':$('#qsub_type').val(),'sub':$(
'#qsub_sub').val()}, 
    function(data){ alert(data )});
}


