$(document).ready(function() {
//===ka4vane snimki
 var options = { 
        beforeSubmit: function(){    $("#buttonUpload").attr("disabled","disabled"); // $("#loader").show();   
               },
        success: function(data) {
                   $("#buttonUpload").attr("disabled",""); 
		           res=data.split("|");
		         //  alert(data);
		          if(parseInt(res[1]))
		           {
		           	 $("#img_conntainer").empty();
		             $("#file_id").val(res[1]);
		             $("#img_conntainer").append("<img src=\""+res[3]+"?"+new Date().getTime()+"\" alt=\"\"/>");
                    
                    }
		           alert(res[2]);
		          
		          // $("#loader").hide();
		},
        dataType: 'html',      // 'xml', 'script', or 'json' (expected server response type) 
        //clearForm: true        // clear all form fields after successful submit 
        resetForm: true        // reset the form after successful submit 
        }; 
 
    // bind to the form's submit event 
    $('#uploadForm').submit(function() { 
           $(this).ajaxSubmit(options);
           return false; 
    });
	
	//====
	$(function()
	{
		$('input.calendar').datePicker();
	});
	
	//==========new city imoti
	$("#city").click(function()
	{//alert($("#city option:selected"));
    if($("#city").val()==1)
    {
     $("#div_newcity").attr("style","");
    }
    else
    {
     $("#div_newcity").attr("style","display:none;");
    }
	});
 
//=======================	
	

	
});


//Begin=====Avatar
function sel_avatar(off)
{
$("#activ_gallery").html('<img src="/html/images/load.gif" alt="Зареждане" border="0" />');
$("#TB_window").hide();
$("#TB_window").load("_script_avatars.php",{"offset":off},
function() {	
$("#TB_window").show();
$("#activ_gallery").html("<a href='javascript:;' onclick='javascript:close_avatar();' class='close_gal'>Затвори галерията</a>");					 

});

}
function close_avatar()
{
	$("#TB_window").hide();
	$("#activ_gallery").html("<a href='javascript:;' onclick='javascript:sel_avatar(0);'>Избери аватар от галерията</a>");
}

function profil2_1(str)
{
$('#user_avatar').val(str);
$('#user_avatar_type').val('3');

$('#activ_avatar').after("<img src='/forum/images/avatars/gallery/"+str+"' id='activ_avatar' width='50' height='50'   />");
$('#avatar_div img:first').remove();

}
//END=====Avatar


