
$(document).ready(function(){	
			if($(".date").length>0){
				$(".date").datepicker({
					showAnim: 'drop',
					dateFormat: 'dd-mm-yy',
					changeMonth: true,
					changeYear: true,
					yearRange: '1870:2020'
				});
			}
		});
		

jQuery(function($){
	
	$(".clients_field img").live("mouseenter",function(){
		var txt=$(this).attr("alt");
		var posx=$(this).offset().left;
		var posy=$(this).offset().top;
		
		$(this).after("<div class='client_hint' style='top: "+posy+"px; left: "+posx+"px;'>"+txt+"</div>");
		
	})
	
	$(".clients_field img").live("mouseleave",function(){
		$(this).next(".client_hint").remove();
	})
	
	$("input").live('focus',function(){
		if($(this).val()==$(this).attr("alt")){
			$(this).val("");	
		}
	})
	$("input").live('blur',function(){
		if($(this).val()==''){
			txt=$(this).attr("alt");
			$(this).val(txt);	
		}
	})
	$(".error").live("change",function(){
		$(this).removeClass("error");
	})
	
	
})
//TRIM строки
function trim(string){
	return string.replace(/(^\s+)|(\s+$)/g, "");
}

function make_error(str,el,tp){
	var d = new Date();
	var curid=d.getTime();
	if(tp==0)var cls="warning";
	if(tp==1)var cls="success";
	$(el).append("<div class='"+cls+"' id='warn_"+curid+"'>"+str+"</div>");
	$("#warn_"+curid).slideDown('fast').delay(2000).slideUp('fast',function(){$(this).remove();});
}

//ЗНАЧЁК ЗАГРУЗКИ
function startbotload(){
	if(!($(".globloader").lenght)){
		$("body").append("<div class='globloader'><span></span></div>");	
		$(".globloader").fadeIn(300);
	}
}
function stopbotload(callback){
	if($(".globloader").length){
		$(".globloader").fadeOut(300,function(){
			$(this).remove();	
			if(typeof callback == 'function'){
				callback.call(this);
			  }

		});
	}
}



function formsub(el){
		return AIM.submit(el, {'onStart' : startCallback, 'onComplete' : completeCallback})	;
	}
	
function startCallback(){
	$('.info_left').append("<div id='logloading'></div>");
	$("#logloading").fadeIn('fast');
}
function completeCallback(response){
	$("#logloading").remove();
	if(response!=0){
		$(".userav").attr("src","http://test.napoker.com/upload/temp/"+response);
		$("#userpic").val(response);	
	}
}
