function toggleDiv(id){
	var div = $("#"+id);
	if(div.css('display')=='none'){
		div.show('slow');
	}else{
	div.hide('slow');
	}
}

function toggleButton(id, way){
	if(way=='1'){
		document.getElementById(id+'Button').className = 'hennesy-xo-btn-selected';
		document.getElementById(id+'Left').className = 'h-xo-selected-left';
		document.getElementById(id+'Midd').className = 'h-xo-selected-midd';
		document.getElementById(id+'Right').className = 'h-xo-selected-right';	
	}else{
		document.getElementById(id+'Button').className = 'hennesy-xo-btn-normal';
		document.getElementById(id+'Left').className = 'h-xo-normal-left';
		document.getElementById(id+'Midd').className = 'h-xo-normal-midd';
		document.getElementById(id+'Right').className = 'h-xo-normal-right';			
	}
}

function x2(what){
	if(what=='dobavi'){
		toggleButton('dobavi', 1);
		toggleButton('komentari', 0);
		$('#komentari').hide('fast');
		$('#dobavi').show('slow');
	}
	if(what=='komentari'){
		toggleButton('dobavi', 0);
		toggleButton('komentari', 1);
		$('#dobavi').hide('fast');
		$('#komentari').show('slow');
		window.location = window.location+'#dobavi';		
	}
}

function dobaviKomentar(section){
	var forma = document.getElementById('dobavi_form');
	var title = document.getElementById('comment_title').value;
	var content = document.getElementById('comment_content').value;
	forma.action = '/comments/dobavi/section/'+section;
	forma.method='post';
	
	if(title=='' || content==''){
		alert('Моля, въведете заглавие и коментар.');
	}else{
		forma.submit();		
	}
}
var last_flash = null;
var last_title = '';
function headerFlash(id, title){	
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
	if(last_flash != null) {
		document.getElementById('header-flash-content-'+last_flash).style.display = 'none';
		document.getElementById('header-flash-link-'+last_flash).innerHTML = '<a class="in-table-up-link" style="background:url(\'i/header-circle-'+last_flash+'.png\') left center no-repeat;">'+last_title+'</a>';
		if (jQuery.browser.msie && ie6) {
		$('#header-flash-link-'+last_flash).find("*").each(function(){
			var bgIMG = jQuery(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				var iebg = bgIMG.split('url("')[1].split('")')[0];
				jQuery(this).css('background-image', 'none');
				jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
			}
		});
		}
	}
	document.getElementById('header-flash-content-'+id).style.display = '';
	document.getElementById('header-flash-link-'+id).innerHTML = '<a class="in-table-up-current">'+title+'</a>';
	if (last_flash != id) {
		last_flash = id;
		last_title = title;
	}
	if (jQuery.browser.msie && ie6) {
		$('#header-flash-link-'+id).find("*").each(function(){
			var bgIMG = jQuery(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				var iebg = bgIMG.split('url("')[1].split('")')[0];
				jQuery(this).css('background-image', 'none');
				jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
			}
		});
		}
}

var old_category_link = null;
var old_category_link_title = null;
function indexNewsCategory(category, title){
	if(old_category_link != null){
		var oldcategory_link = document.getElementById('index-news-category-'+old_category_link);
		oldcategory_link.innerHTML = '<div class="in-table-big-up-btn2"><div class="in-table-big-up-btn2-left"></div><div class="in-table-big-up-btn2-center">'+old_category_link_title+'</div><div class="in-table-big-up-btn2-right"></div></div>';
	document.getElementById('index-news-list-'+old_category_link).style.display = 'none';
	}
	var category_link = document.getElementById('index-news-category-'+category);
	category_link.innerHTML = '<div class="in-table-big-orbtn" ><div class="h-xo-selected-left" style="height:43px;">&nbsp;</div><div class="h-xo-selected-midd" style="height:43px;background:url(i/hennessy-xo-selected-bg.gif) repeat center center;"><div style="margin-top: 10px;">'+title+'</div></div><div class="h-xo-selected-right" style="height:43px;">&nbsp;</div></div>';
	document.getElementById('index-news-list-'+category).style.display = 'block';
	old_category_link = category;
	old_category_link_title = title;
}

function formatItem(row){
	return '<strong>' +row[0] + "</strong><br><i style='color: #777777;'>" + row[1] + "</i>";	
}

