function switchSettings(obj, act, parent) {
	tabs = ['news', 'articles', 'blogs'];
	for (i=0; i<tabs.length; i++) {
		$('#settings_' + tabs[i]).fadeOut('10');
		$('#settings_' + tabs[i]).stop(true, true);
	}

	if (act) {
		oWin = $('#settings_' + obj);
		oParent = $('#'+parent);


		oWin.css('left', oParent.position().left - oWin.width() + oParent.width() + 4);
		oWin.css('top', oParent.position().top - 6);
//		oWin.show('fast');
		oWin.fadeIn('40');
		initSliders(obj);
		oWin.bind("mouseleave",function(){
			switchSettings(obj, false);
		});
	}
}


function initSliders(section) {
	if (section == 'news') {
		jQuery("#latest_news").slider({
			from: 4,
			to: 16,
			step: 1,
			smooth: false,
			round: 0,
			dimension: "",
			skin: "plastic",
			scale: ['4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16']
		});
		jQuery("#discussed_news").slider({
			from: 0,
			to: 10,
			step: 1,
			smooth: false,
			round: 0,
			dimension: "",
			skin: "plastic",
			scale: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
		});
	}
	else if (section == 'articles') {
		jQuery("#exclusive_articles").slider({
			from: 3,
			to: 10,
			step: 1,
			smooth: false,
			round: 0,
			dimension: "",
			skin: "plastic",
			scale: ['3', '4', '5', '6', '7', '8', '9', '10']
		});
		jQuery("#editorial_articles").slider({
			from: 0,
			to: 10,
			step: 1,
			smooth: false,
			round: 0,
			dimension: "",
			skin: "plastic",
			scale: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
		});
		jQuery("#latest_articles").slider({
			from: 0,
			to: 10,
			step: 1,
			smooth: false,
			round: 0,
			dimension: "",
			skin: "plastic",
			scale: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
		});
		jQuery("#special_articles").slider({
			from: 3,
			to: 10,
			step: 1,
			smooth: false,
			round: 0,
			dimension: "",
			skin: "plastic",
			scale: ['3', '4', '5', '6', '7', '8', '9', '10']
		});
		jQuery("#expert_articles").slider({
			from: 0,
			to: 10,
			step: 1,
			smooth: false,
			round: 0,
			dimension: "",
			skin: "plastic",
			scale: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
		});
	}
	else if (section == 'blogs') {
		jQuery("#latest_blogs").slider({
			from: 3,
			to: 10,
			step: 1,
			smooth: false,
			round: 0,
			dimension: "",
			skin: "plastic",
			scale: ['3', '4', '5', '6', '7', '8', '9', '10']
		});
//		jQuery("#super_blogs").slider({
//			from: 0,
//			to: 10,
//			step: 1,
//			smooth: false,
//			round: 0,
//			dimension: "",
//			skin: "plastic",
//			scale: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
//		});
		jQuery("#latest_comments").slider({
			from: 0,
			to: 20,
			step: 1,
			smooth: false,
			round: 0,
			dimension: "",
			skin: "plastic",
			scale: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14','15', '16', '17', '18', '19', '20']
		});
	}
}


function saveSettings(section) {
	if (section == 'news') {
		$.cookie('index_settings_news_latest', $("#latest_news").slider( "value" ), { path: '/', expires: 365 });
		$.cookie('index_settings_news_discussed', $("#discussed_news").slider( "value" ), { path: '/', expires: 365 });
		location.reload();
	}
	else if (section == 'articles') {
		$.cookie('index_settings_articles_exclusive', $("#exclusive_articles").slider( "value" ), { path: '/', expires: 365 });
		$.cookie('index_settings_articles_editorial', $("#editorial_articles").slider( "value" ), { path: '/', expires: 365 });
		$.cookie('index_settings_articles_latest', $("#latest_articles").slider( "value" ), { path: '/', expires: 365 });
		$.cookie('index_settings_articles_special', $("#special_articles").slider( "value" ), { path: '/', expires: 365 });
		$.cookie('index_settings_articles_expert', $("#expert_articles").slider( "value" ), { path: '/', expires: 365 });
		location.reload();
	}
	else if (section == 'blogs') {
		$.cookie('index_settings_blogs_latest', $("#latest_blogs").slider( "value" ), { path: '/', expires: 365 });
		$.cookie('index_settings_blogs_super', $("#super_blogs").slider( "value" ), { path: '/', expires: 365 });
		$.cookie('index_settings_comments_latest', $("#latest_comments").slider( "value" ), { path: '/', expires: 365 });
		location.reload();
	}
}
