function ReNewCaptchaById(imageId, captchaKey, captchaHeight)
{
	// Пытаемся получить скрытый объект для input-а
	var captchaObject = document.getElementById(imageId);

	// Элемента нет, добавим его
	if (null != captchaObject && undefined !== captchaObject)
	{
		var antiCache = Math.floor(Math.random()*100000);
		captchaObject.src = "/captcha.php?get_captcha=" + captchaKey + "&height=" + captchaHeight + "&anc=" + antiCache;
	}
}

$(function() {
	$("#login").click(function() {
		$("#popup-login").toggleClass('show hide');
		$("#login-item").toggleClass('active');
		return false;
	});

	$("#accordion").accordion({
	  collapsible: true,
	  active: false,
	  autoHeight: false,
	  icons: false
	});
	if($("select").length){		$("select:not(#selectYear, #selectMonth, #selectDay)").selectbox();	}
	if($("#FlashID").length){
		swfobject.registerObject("FlashID");
	}

	$(".add-news-website").click(function() {
		$("#addNewWebsite").toggleClass('show hide');
		return false;
	});

	$(".remove-from-monitoring").click(function() {
		if(confirm('Remove site monitoring?')){			window.location = '/users/?action=remowe_site&domain='+ $('#selectWebsite').val();		}
		return false;
	});

	$("#SearchWebHost").submit(function() {		$('#search-results').slideUp(200, function(){			$(this).remove();		});
		$.get('/companies/', $(this).serialize(), function(data){			if(data.result != ''){				window.location = data.result;			}else{				$('div.content').prepend('<div id="search-results" style="display:none;"></div>');
				$('#search-results').html(data.error).slideDown(300);			}			//console.log(data);		}, 'json');
		return false;
	});
	
	$('div.hosts-monitored #selectYear').change(function(){
		$('#selectMonth').removeOption(/^[^0]/i); 
		$('#selectDay').removeOption(/^[^0]/i); 
		if($(this).val() != 0){
			$('#selectMonth').addOption(aloved_months[$(this).val()], false);
		}
	});

	$('div.hosts-monitored #selectMonth').change(function(){
		$('#selectDay').removeOption(/^[^0]/i); 
		if($(this).val() != 0) {
			$('#selectDay').addOption(aloved_days[$('#selectYear').val()][$(this).val()], false);
		}
	});
	
	
	
	
});
