// <![CDATA[
$(document).ready(function(){
	var font_size=12;
	var line_height=16;

	$("#suche_feld").focusin(function(){$(this).attr("value", "");});
	$("#font_small").click(function(){change_fontsize('minus')});
	$("#font_normal").click(function(){change_fontsize('reset')});
	$("#font_large").click(function(){change_fontsize('plus')});
	$("#font_print").click(function(){var text_to_print=$("#body .left").html(); printContent(text_to_print);});

	// print
	function printContent(content){
		newwin=window.open('','printwin','left=100,top=100,width=400,height=400');
		newwin.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n');
		newwin.document.write('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru" lang="ru">\n');
		newwin.document.write('<head>\n');
		newwin.document.write('\t<meta http-equiv="content-type" content="text/html; charset=windows-1251" />\n');
		newwin.document.write('\t<title>íÒÕÆÕÞÊÝÌØÈ ßÞÈÐ ÖÍÏÍÄÞ ìÍÁÍßÕÀÕÏßÉÞ</title>\n');
		newwin.document.write('\t<link rel="stylesheet" href="/css/base.reset.css" type="text/css" charset="utf-8" />\n');
		newwin.document.write('\t<link rel="stylesheet" href="/css/base.font.css"  type="text/css" charset="utf-8" />\n');
		newwin.document.write('\t<link rel="stylesheet" href="/css/site.font.css"  type="text/css" charset="utf-8" />\n');
		newwin.document.write('\t<link rel="stylesheet" href="/css/base.print.css" type="text/css" charset="utf-8" />\n');

		newwin.document.write('\t<script language="javascript">\n');
		newwin.document.write('\t\tfunction chkstate(){\n');
		newwin.document.write('\t\t\tif(document.readyState=="complete"){window.close()}\n');
		newwin.document.write('\t\t\telse{setTimeout("chkstate()",2000)}\n');
		newwin.document.write('\t\t}\n');
		newwin.document.write('\t\tfunction print_win(){window.print(); chkstate();}\n');
		newwin.document.write('<\/script>\n');

		newwin.document.write('</head>\n');
		newwin.document.write('<body onload="print_win()">\n');
		newwin.document.write('\t<div id="print_logo"><img alt="" src="/i/logo_print.jpg" width="299" height="118" /></div>\n');
		newwin.document.write('\t<div id="print_body">\n');
		newwin.document.write(content);
		newwin.document.write('\n');
		newwin.document.write('\t\t<div class="clear"></div>\n');
		newwin.document.write('\t</div>\n');
		newwin.document.write('</body>\n');
		newwin.document.write('</html>\n');
		newwin.document.close();
	}

	// forme hovers
	$("#suche_knopf").hover(
		function(){$(this).css('color', '#fff')},
		function(){$(this).css('color', '#000')}
	);

	$("#internal_search input").hover(
		function(){
			if ($(this).attr('type')=='submit'){
				$(this).css('cursor', 'pointer');
				$(this).css('background', '#cacaca');
				$(this).css('color', '#000000');
			}
		},
		function(){
			$(this).css('background', '#fff');
			$(this).css('color', '#333');
		}
	);

	// fotoalbum overrides
	var galerie=$("#body .left div.galerie").html();
	if (galerie!=null){
		$('#body .left div.galerie img').each(function(index){
			if ($(this).attr('height')>183){
				var width=$(this).attr('width');
				var height=$(this).attr('height');
				var koeffizient=height/183;
				var new_width=Math.round(width/koeffizient);
				$(this).css('height', '183px');
				$(this).css('width', new_width+'px');
			}

		});
/*
		var image_height=$("#body .left div.galerie .linie div p.image img").attr('height');
		var image_width=$("#body .left div.galerie .linie div p.image img").attr('width');
		if (image_height>=183){
			image_height=Math.round((image_width*100)/image_height);
			// alert(image_height);
		}
		// alert(image_height+' x '+image_width);
		*/
	}

	// style overrides
	var styled_div=$("#body .left div");
	if (styled_div){
		var styled_div_style=$("#body .left div").attr('style');
		if (styled_div_style){
			$(styled_div).css('margin-top', '18px');
			$(styled_div).css('width', '100%');
			$(styled_div).css('line-height', '18px');
			$(styled_div).css('text-align', 'left');
			$("#body .left div p, #body .left div ol, #body .left div ul, #body .left div table").css('padding-right', '20px');
			$("#body .left div p, #body .left div ol, #body .left div ul, #body .left div table").css('padding-bottom', '18px');
			$("#body .left div p, #body .left div ol, #body .left div ul, #body .left div table").css('text-align', 'left');
		}
	}

	// schriftart groesse
	function change_fontsize(action){
		if ((action=='minus')&&(font_size>10)){font_size=font_size-1; line_height=line_height-2;}
		else if ((action=='plus')&&(font_size<16)){font_size=font_size+1; line_height=line_height+2;}
		else if (action=='reset'){font_size=12; line_height=16;}
		$("#body .left .content").css('font-size', font_size+'px');
		$("#body .left .content, #body .left .content p").css('line-height', line_height+'px');
	}


	// banner carouselle
	jQuery('#banner .inhalte .carouselle').jcarousel({
		scroll: 1,
		auto: 5,
		wrap: "circular",
		initCallback: mycarousel_initCallback
	});

	/* schriftart-icons hover */
	$("#body .left .date .right a").hover(
		function(){
			var obj=$(this).children("img");
			var src=$(obj).attr("src");
			if (src.match("_off")){
				var src_new=src.replace("_off","_on");
				$(obj).attr("src", src_new);
			} // end if
		},
		function(){
			var obj=$(this).children("img");
			var src=$(obj).attr("src");
			if (src.match("_on")){
				var src_new=src.replace("_on","_off");
				$(obj).attr("src", src_new);
			} // end if
		}
	); // end icons hover

	// colorbox
	$("a").click(function(event){
		$tag_attr=$(this).parent().attr('class');
		if ($tag_attr=='image'){$(this).colorbox();}
	});


  $('#body .content ul').each(function(i, e)
  {
    if($(e).attr('type'))
    {
      $(e).find('> li').css('list-style-type', $(e).attr('type'));
    }
  });

  var pp_number = function(number, form1, form2, form3)
  {
    if(number % 10 >=5 || number % 10 == 0 ||
       number > 10 && number < 21)
    {
        return form3;
    }
    else if(number % 10 >= 2)
    {
        return form2;
    }
    else if(number % 10 == 1)
    {
        return form1;
    }
  };
  setInterval(function(e)
  {
    var hours = parseInt($('#time_str').find('span:first').text() ,10);
    var minutes = parseInt($('#time_str').find('span:last').text() ,10);
    minutes = (minutes + 1) % 60;
    if(!minutes) hours = (hours + 1) % 24;
    var hours_form = pp_number(hours, '÷àñ', '÷àñà', '÷àñîâ');
    var minutes_form = pp_number(minutes, 'ìèíóòà', 'ìèíóòû', 'ìèíóò');
    if(minutes.toString().length == 1) minutes = '0' + minutes.toString();
    if(hours.toString().length == 1) hours = '0' + hours.toString();
    var time = '<span>' + hours + '</span> ' + hours_form + ' <span>' + minutes + '</span> ' + minutes_form;
    $('#time_str').html(time);
  }, 60000);
}); // end document.ready();

function mycarousel_initCallback(carousel){
	carousel.buttonNext.bind('click', function(){carousel.startAuto(0);});
	carousel.buttonPrev.bind('click', function(){carousel.startAuto(0);});

	carousel.clip.hover(
		function(){carousel.stopAuto(); },
		function(){carousel.startAuto();}
	);
};

function headcarousel_initCallback(carousel) {
	jQuery('.jcarousel-control a').bind('click', function() {
        	carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
	        return false;
	});

	jQuery('.jcarousel-scroll select').bind('change', function() {
        	carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
	        return false;
	});

	jQuery('#mycarousel-next').bind('click', function() {
	        carousel.next();
        	return false;
	});

	jQuery('#mycarousel-prev').bind('click', function() {
		carousel.prev();
		return false;
	});
};




$(function() {
$('.icon_for_media img').tooltip({
track: true,
delay: 0,
showURL: false,
fade: 200
});
});
// ]]>
