$(function(){
	
	$('input','.contactsForm').blur(function(){
		if($(this).attr('value') == ''){
			$(this).removeClass('select');
			
			$(this).attr('value', $(this).attr('title'));
		}
	});
	$('input','.contactsForm').focus(function(){
		if($(this).attr('value') == $(this).attr('title')){
			$(this).attr('value','');
			$(this).addClass('select');
		}
	});
	$('textarea','.contactsForm').blur(function(){
		if($(this).attr('value') == ''){
			$(this).removeClass('select');
			$(this).attr('value', $(this).attr('title'));
		}
	});
	$('textarea','.contactsForm').focus(function(){
		if($(this).attr('value') == $(this).attr('title')){
			$(this).attr('value','');
			$(this).addClass('select');
		}
	});
	$('#captcha').mouseup(function(){
		$(this).html('');
		$(this).html('<img src="/bitrix/templates/Main/captcha/captcha.php?r='+Math.random(999)+'" />');
	});
});

function Loading(ob){
	var width = $(ob).width();
	var height = $(ob).height();
	$(ob).css('position','relative');
	if($('.loader', $(ob)).length == 0){
		$(ob).append('<div class="loader" style="z-index:1000;"><div class="load">&nbsp;</div><div class="loadProgres"><img src="/bitrix/templates/Main/images/loading_indicator.gif"> Загрузка...</div></div>');
		$('.loader',ob).css('height',height);
		$('.loader',ob).css('width',width);
		$('.load',ob).css('height',height);
		$('.load',ob).css('width',width);
		$('.loadProgres',ob).css('margin-top',height/2);
		$('.loadProgres',ob).css('width',width);
	}	
}


function ProgressShow(ob, name){
	$(ob).css('position','relative');	
	var width = $(ob).width();
	var height = $(ob).height();
	$(ob).append('<div class="Progress"><div class="ProgressFon">&nbsp;</div><div class="ProgressBar"><img src="/bitrix/templates/Main/images/loading_indicator.gif" alt="" /> '+name+'</div>');
	$('.Progress', $(ob)).css('width',width);
	$('.Progress', $(ob)).css('height',height);
	$('.ProgressFon', $(ob)).css('width',width);
	$('.ProgressFon', $(ob)).css('height',height);
	$('.ProgressBar', $(ob)).css('left',width/2 - $('.ProgressBar', $(ob)).width()/2);
	$('.ProgressBar', $(ob)).css('top',height/2 - $('.ProgressBar', $(ob)).height()/2);
}

function ProgressClose(ob){
	$('.Progress',$(ob)).remove();
	$(ob).css('position','static');
}

function openPopup(url, width, height){
var scroll = "no";
	var top=0, left=0;
	if(width > screen.width-10 || height > screen.height-28) scroll = "yes";
	if(height < screen.height-28) top = Math.floor((screen.height - height)/2-14);
	if(width < screen.width-10) left = Math.floor((screen.width - width)/2-5);
	width = Math.min(width, screen.width-10);
	height = Math.min(height, screen.height-28);
	var wnd = window.open(url,"popup","width="+width+",height="+height+",scrollbars="+scroll+",resizable=yes,left="+left+",top="+top);
	return false;
}

