$(document).ready(function(){

	$("#tagscloud").each(function(){
		$(this).css('display', 'none');	
		
		var tags = null; 
		var html = $(this).children('h1').html();
		var result = '';
		
		tags = html.split("|");
		
		$(this).children('h1').html(' ');
		
		while(tags.length > 0)
		{
			var index = $.Random(0, (tags.length-1));
			var anchor = tags[index];
			if (anchor == '' || anchor == null)
			{
				continue;
			} 
			tags = $.DeleteFromArray(tags, index);			
			result = result + anchor + ' ';
			if (tags.length == 1)
			{
				break;
			}
		}
		   
		$(this).children('h1').html(result);
		$(this).css('display', 'block');
	});
	
	$('#promotionorder').each(function(){

		var keywords = $(this).find('textarea:first');
		$.SetExampleTextInput(keywords, "Ключевая фраза пример");

	});
	
	$('#comment_form').each(function(){
		
		var products = $('#tcomment');
	    var tr = $(products).children('tr:last');

	    $(tr).prev().css('display','none');
	    $(tr).children('td:last').children('input').attr('value', $.GetTrueDate());
	    
	    $(tr).css('display','none');
	    
	    var button = $('#button');
	    var block = $(button).parent().children('#addcomment');
	    
	    var search = document.location.href.indexOf("#s");
	    if (search != -1) 
		{
	    	search = document.location.href.substr(0, search);
	    	$(button).css('text-align', 'left');
			$(button).html('Для добавления комментария <strong><a href='+search+'>обновите</a></strong> страницу ');
	    	$(block).remove();
	    	return true;
		}
	    
	    $.ShowHideButton(button, block, 'Добавить комментарий', 'Скрыть форму');
	    
	});
	
	$('.tag').each(function(){
		
		$.ShowHint(this, 'div');
		
	});
	
	$('.smpage').each(function(){

		$.ShowHint(this, 'div');
		
	});

});
