		$(document).ready(
			function(){
				/* Vertical tabs */
				$('.main-news-item, .main-news-item-active').hover(
					function(){
						im = $(this).attr('img');
						if( im == '' ) {
							im = 'http://static.zakon.kz/img/nophoto.jpg';
						}
						p = $(this).parents('div').get(0);
						$(p).children('.illustration').html("<img src='"+im+"' alt=''>");
						//$(p).children('.main-news-item-active').removeClass('main-news-item-active').addClass('main-news-item');
						//$(this).removeClass('main-news-item').addClass('main-news-item-active');
						
					}
				);
				
				/* Horizontal tabs */
				$('.tabs li').hover(
					function(){
						$(this).addClass('hover');
					},
					function(){
						$(this).removeClass('hover');
					}
				);
				
				$('.tabs li').click(
					function(){
						p = $(this).parent().get(0);
						$(p).children('.active').removeClass('active');
						$(this).addClass('active');
						//n = $(this).children().get(0).attr('href');
						n = $(this).children().get(0).getAttribute('name');
						$('.tab_content').hide();
						$(n).show();
						return false;
					}
				);

				/* Input fields with "alt" text */
				$('input:text, input:password').each(
					function(){
						$(this).focus(
							function(){
								if($(this).attr('value') == $(this).attr('alt')) {
									$(this).attr('value', '');
								}
							}
						);
						
						$(this).blur(
							function(){
								if($(this).attr('value') == '') {
									alt = $(this).attr('alt');
									$(this).attr('value', alt);
								}
							}
						);
					}
				);		
				$('.addcomment-button').click(function(){
					//$('#editor_block').toggle(); 
					//$('.addcomment-button').toggle();
					/*
					p = location.href.split('#');

					if( p[1] != 'open_editor' ) {
						location.href = location.href + '#open-editor';
					} else {
					*/
						scroll(0, 10000);
					//}
				});
				/*
				switch(true) {
					case $.browser.version.substr(0, 1) >= 9 && $.browser.version.substr(2, 2) > 50:
					case $.browser.safari:
					case $.browser.mozilla && $.browser.version.substr(0, 1) == 1 && $.browser.version.substr(2, 1) < 9:
						fix_margin = true;
					break;

					default:
						fix_margin = false;
					break;
				}

				if( fix_margin ) {
					$('#inner_center_row').css('margin-right', '25px');
				}
				*/
				$('.kurs_tab, .kurs_tab_active').click(function(){
					tab = $(this).attr('tab');
					$('.kurs_tab_content').hide();
					$(tab).show();
					$('.kurs_tab_active').removeClass('kurs_tab_active').addClass('kurs_tab');
					$(this).removeClass('kurs_tab').addClass('kurs_tab_active');
				});
			}
		);

function loadInfo(u, e, c) {
	$('#'+e).load(u);
	if(c != '') {
		$('#'+c).show('fast');
	}
}

function mRate( rate, story ) {
///engine/ajax/rating.php?news_id=29074&skin=Default&go_rate=2&rndval=1245819381685
	$.ajax({
		type: "GET",
		url: "/engine/ajax/rating.php?news_id=" + story + "&skin=Default&go_rate=" + rate + "&rndval=" + (Math.random()),
		success: function(msg) {
			//$('.current-rating').css('width', rate*9+'px');			
			//$('#rating-voten').html(parseInt($('#rating-voten').html())+1);
			$('#rating').html(msg);
		}
	});
}

function fnCC(cid) {
	$.cookie('pogoda_city_id', cid, { expires:new Date("January 12, 2025") });
	re = new RegExp('do=pogoda', 'gi');
	if(re.test(location.href)){
			location.href = "/?do=pogoda";
			return;
	}
	loadInfo('/getcinimainfo.php?go=pogoda_sity_id&city_id='+cid, 'pogoda_sity', '');
	$('#panelcity').hide('fast');
	return false;
}

function hide(e) {
	$('#'+e).hide(); 
	return false;
}

function show(e, s) {
	h = $('#'+e).height();
	o = $(s).offset();
	mh = o.top - h;
	if($('body').height() < mh) { mh = $('body').height() - h };
	$('#'+e).css('top', (o.top + h/2));
	$('#'+e).show();
	return false;
}

function get_selection() {
   if (document.getSelection){
	selection = document.getSelection();
	selection = selection.replace(/\r\n\r\n/gi, "_doublecaret_");
	selection = selection.replace(/\r\n/gi, " ");
       while (selection.indexOf("  ") !=-1) selection = selection.replace(/  /gi, ""); 
	selection = selection.replace(/_doublecaret_/gi, "\r\n\r\n");
  } else
      selection = document.selection.createRange().text;
  return selection;
}