///////////////////////////////////////////
//	CHECK FOR IE
///////////////////////////////////////////
var IE = $.browser.msie;

if(IE==true){
	var agent = navigator.userAgent;
	var pos = agent.lastIndexOf('MSIE');
	var VER = agent.substr(pos+5,1);
}
///////////////////////////////////////////
//	REMOVE SCROLLS -> NEW SCROLLS
///////////////////////////////////////////
function create_scrolls(nr){
	if(nr){
		if($('#scrollholder'+nr).children().filter('.track').length > 0)	$('#scrollholder'+nr).children().filter('.track').remove();
		ScrollLoad ('scrollholder'+nr,'scroll'+nr,false);
	}else{
		if($('.track').length > 0)	$('.track').remove();
		ScrollLoad ("scrollholder1", "scroll1", false);
		ScrollLoad ("scrollholder2", "scroll2", false);
		ScrollLoad ("scrollholder3", "scroll3", false);
		ScrollLoad ("scrollholder4", "scroll4", false);
		if($('#scrollholder5').length){
			ScrollLoad ("scrollholder5", "scroll5", false);
		}
	}
}
///////////////////////////////////////////
//	WRAP WORDS FOR THE CONTENT
///////////////////////////////////////////
var g_txt = new Array();
function word_wrap(){
	var c = 1;
	if($('div.big').length > 0){
		var w = $('div.big>.scrollholder>.scroll>.data').width();
	}else{
		var w = $('div.data').width();
	}
	$('.info').each(function(){
		var letters = Math.floor(w/7);
		var txt = $(this).text();
		if(typeof g_txt[c] == 'undefined'){
			g_txt[c] = txt;
		}
		if(g_txt[c].length > letters*2){
			var i = g_txt[c].substr(0,letters*2);
			var space = i.lastIndexOf(' ');
			var d = i.substr(0,space);
			$(this).html(d).append('...');
		}else{
			var index = g_txt[c].lastIndexOf('...');
			if(index>0){
				g_txt[c] = g_txt[c].substr(0,index);
			}
			$(this).html(g_txt[c]);
		}
		c++;
	});
}
///////////////////////////////////////////
//	SET KNOWLEDGE IMAGE SIZE
///////////////////////////////////////////
function set_sticky(){
	if($('div.big').length > 0){
		var img_w = $('div.big>.scrollholder>.scroll>.data').width();
	}else{
		var img_w = $('div.know>.scrollholder>.scroll>.data').width();
	}
	$('div.know>.scrollholder>.scroll>.data>.k_body>img').each(function(){ 
		$(this).attr({width:img_w});
		return true;
	});
}
///////////////////////////////////////////
//	SET IMAGE WIDTH
///////////////////////////////////////////
/*function img_width(nr){
	if($('div.big').length > 0){
		var d = $('.big>.scrollholder>.scroll>.data').width();
	}else{
		var d = $('.data').width();
	}
	if(d!=0){
		$('img.data_img').each(function(){
			if($(this).attr('title').length == 0){
				var src = $(this).attr('src');
				var split = src.lastIndexOf('x=');
				var new_source = src.substr(0,split+2)+d;
				//console.log(new_source);
				$(this).attr({src:new_source});
			}
		});
	}else{
		setTimeout('img_width()',50);
	}
	/*
	var id = images[nr];
	if($('#'+id).attr('title').length == 0){
		var src = $('#'+id).attr('src');
		var split = src.lastIndexOf('x=');
		var width = $('#'+id).parents().filter('.data').width();
		var new_source = src.substr(0,split+2)+width;
		$('#'+id).attr({src:new_source});
		nr++
		img_width(nr);
	}
	
}*/
function img_width(nr){
	var id = images[nr];
	if(id && $('img#'+id).attr('title').length < 1){
		var src = $('img#'+id).attr('src');
		var split = src.lastIndexOf('x=');
		var width = $('img#'+id).parents().filter('div.data').width();
		if(width > 0){
			var new_source = src.substr(0,split+2)+width;
			$('img#'+id).attr({src:new_source}).unbind('load').load(function(){
				nr++;
				img_width(nr);
			});
		}else{
			nr++;
			img_width(nr);
		}
	} 
}

///////////////////////////////////////////
//	LOAD IMAGES
///////////////////////////////////////////
function load_images(nr){
	if(!nr) nr=0;
	var id = images[nr];
	var title = $('img#'+id).attr('title');
	var width = $('img#'+id).parents().filter('.data').width();
	if(IE){ 
		$('img#'+id).attr({src:'thumb.php'+title+width})./*unbind('load').*/bind('load', {nr:nr}, function(e){
			$(this).attr({title:''});
			var nr = e.data.nr;
			nr++;
			load_images(nr);
		});
	}else {
		$('img#'+id).attr({src:'thumb.php'+title+width}).unbind('load').bind('load', {nr:nr}, function(e){
			$(this).attr({title:''});
			var nr = e.data.nr;
			nr++;
			load_images(nr);
		});
	}
}
///////////////////////////////////////////
//	ROTATE COLUMN HEADLINES
///////////////////////////////////////////
function headline_rotation(type){
	$('div.h_t').removeClass('visibility');
	if(type == 'wide'){
		$('div:not(.big)>.headline').each(function(){
			$(this).children().filter('div.h_t:first').hide();
			$(this).children().filter('div.h_t:last').show();
		});
	}else if(type == 'front'){
		$('div.headline').each(function(){
			$(this).children().filter('div.h_t:last').hide();
			$(this).children().filter('div.h_t:first').show();
		});
	}else if(type == 'menu'){
		$('div.headline').each(function(){
			$(this).children().filter('div.h_t:first').hide();
			$(this).children().filter('div.h_t:last').show();
		});
	}	
}
///////////////////////////////////////////
//	MENU BUTTONS COLOR CHANGER
///////////////////////////////////////////
function switch_menubuttons(color){
	$('div.main_menu>a>img').each(function(){
		var src = $(this).attr('src');
		var dot = src.lastIndexOf('.');
		var img = src.substring(0,dot-1);
		var ext = src.substring(dot);
		var new_src = img+color+ext;
		$(this).attr('src',new_src);
	});
}
///////////////////////////////////////////
//	COLUMN HEADLINE SWITCHER
///////////////////////////////////////////
function switch_headers(type){
	if(VER!=6){
	$('div.headline').each(function(){
		var image = $(this).children().filter('div.h_t:first').children().filter('a').children().filter('img');
		var src = image.attr('src');
		var dot = src.lastIndexOf('.');
		var img = src.substring(0,dot-1);
		var ext = src.substring(dot);
		var new_src = img+type+ext;
		image.attr('src',new_src);
	});
	}
}
///////////////////////////////////////////
//	COLUMN WIDE ANIMATION
///////////////////////////////////////////
function wide_view(type){
	var b_w = $(window).width()-60;
	if(b_w < 1025){
		b_w = 1016;	
		var c_w = (b_w-115);
		var d_w = Math.floor((c_w-75)/4);
		$('.data_spacer').css({width:'1px'});
		$('.small').css({width:'1px'});	
		switch_headers('n');
	}else{
		var c_w = (b_w-115);
		var d_w = Math.floor((c_w-75)/4)-30;
		$('div.data_spacer').css({width:'30px'});
		$('div.small').css({width:'20px'});
		switch_headers('w');
	}
	
	if($('.active_menu').length){
		$('.active_menu').removeClass('active_menu');
		switch_menubuttons('w');
	}
	
	if(VER<7) d_w -=1;
	
	$('div.splitter').show();
	
	if($('div#content').width() != 1){
		$('div#content_data').remove();
		var btn_cnt = 0
		$('.btn').fadeOut('fast',function(){
			btn_cnt++;
			if(btn_cnt==8){

				headline_rotation('front');
				
				$('div#content').children().remove();
				$('div#content').removeClass('big_c');
				$('div#content').animate({width:1},'fast','swing',function(){
					$('div.first_data').css({display:'none'});
					$('div.'+type).addClass('big').animate({width:c_w},'fast','swing',function(){
						
						headline_rotation('wide');
						
						$('div.data').css({width:d_w});
						
						var d_h = d_w/1.7;
						$('div#flash_div').css({width:d_w,height:d_h});
						
						$('.main_btn').fadeIn('fast');
						$('div.scroll').css({width:c_w-25});
						$('div.big>.scrollholder').css({display:''});
						$('div.big>.scrollholder>.scroll').css({display:''});
						$('.visible').css({display:''});
						$('div.data_spacer').css({display:''});
						word_wrap();
						set_sticky();
						img_width(0);
						stop_movie('true');
						setTimeout('create_scrolls()',50);
					});
				});
			}
		});
	}else{
		$('div.scroll').css({display:'none'});
		$('div.first_data').css({display:'none'});
		$('div.data').css({width:d_w});
		
		var d_h = d_w/1.7;
		$('div#flash_div').css({width:d_w,height:d_h});
		
		var btn_cnt=0;
		$('.btn').fadeOut('fast',function(){
			btn_cnt++;
			if(btn_cnt==8){
				
				headline_rotation('front');
				
				$('div.container').animate({width:35},'fast','swing');
				$('div.big').removeClass('big');
				$('div.'+type).addClass('big').animate({width:c_w},'fast','swing',function(){
					
					headline_rotation('wide');
					
					if($('div#main_wrapper').length > 0){
						$('div#main_wrapper').remove();
						$('div.data').show();
						$('div.splitter').show();
					}
					
					if(IE){
						$('.data').css('visibility', 'visible');
					}
					
					$('.main_btn').fadeIn('fast');
					$('div.scroll').css({width:c_w-25});
					$('div.big>.scrollholder').css({display:''});
					$('div.big>.scrollholder>.scroll').css({display:''});
					$('.visible').css({display:''});
					$('div.data_spacer').css({display:''});
					word_wrap();
					set_sticky();
					img_width(0);
					stop_movie('true');
					setTimeout('create_scrolls()',50);
				});
			}
		});
	}		
}

///////////////////////////////////////////
//	DETAIL VIEW OF DATA-BLOCK ANIMATION
///////////////////////////////////////////
function detail_view(type,id){
	
	var b_w = $(window).width()-60;
	if(b_w < 1025){
		b_w = 1016;	
		var c_w = (b_w-115);
		var d_w = Math.floor((c_w-75)/4);
		$('div.data_spacer').css({width:'1px'});
		$('div.small').css({width:'1px'});
	}else{
		var c_w = (b_w-115);
		var d_w = Math.floor((c_w-75)/4)-30;
		$('div.data_spacer').css({width:'30px'});
		$('div.small').css({width:'20px'});
		//console.log('spacer 30');
	}
	
	if($('.active_menu').length){
		$('.active_menu').removeClass('active_menu');
		switch_menubuttons('w');
	}
	
	if($('div#main_wrapper').length > 0){	
		$('div#main_wrapper').remove();
		$('div.data').show();
		$('div.splitter').show();
	}
	
	$('div.scroll').css({display:'none'});
	$('div.first_data').css({display:'none'});
	$('div.data').css({width:d_w});
	if(IE){
		$('div.data').css('visibility', 'hidden');
	}
		
	if($('div.big').length > 0){
			var big = $('div.big > .scrollholder > .scroll');
			var big_w = $('div.big').width();
			big.children().css({display:'none'});
			headline_rotation('wide');
			$.get('details.php',{'type':type,'id':id},function(data){
				big.append(data);
				big.css({display:''});
				stop_movie('true');
				create_scrolls();
			});
	}else{
		if($('div#content').width != 1){
			$('div#content').children().remove();
			$('div#content').animate({width:1},'fast','swing');
		}
		var btn_cnt=0;
		$('.btn').fadeOut('fast',function(){
			btn_cnt++;
			if(btn_cnt==8){
				$('div.container').animate({width:35},'fast','swing');
				$('div.big').removeClass('big');
				$('div.'+type).addClass('big').animate({width:c_w},'fast','swing',function(){
					
					headline_rotation('wide');
					
					$('.main_btn').fadeIn('fast');
					$('div.scroll').css({width:c_w-25});
					$('div.big>.scrollholder').css({display:''});
					$('div.big>.scrollholder>.scroll').css({display:''});
					var big = $('div.big > .scrollholder > .scroll');
					big.children().css({display:'none'});
					$.get('details.php',{'type':type,'id':id},function(data){
						big.append(data);
						big.css({display:''});
						stop_movie('true');
						create_scrolls();
					});
				});
			}
		});
	}
}

///////////////////////////////////////////
//	FRONT VIEW ANIMATION FUNCTION
///////////////////////////////////////////
function front_animate(){
	var b_w = $(window).width()-60;
	
	if(b_w < 1025){
		var b_w = 1016;
		var c_w = (b_w-20)/4;
		if(IE) c_w-=1;
		var s_w = c_w-25;
		var d_w = s_w-10;
	}else{
		var c_w = (b_w-10)/4;
		var s_w = c_w-25;
		var d_w = c_w-35;
		var w_w = b_w;
	}
	$('div.splitter').hide();
	$('div#wrapper').css({width:'100%'});
	$('div.container').animate({width:c_w},'fast','swing',function(){
		$('div.scrollholder').css({width:'100%'});
		set_sticky();
		headline_rotation('front');
		if(IE){
			$('.data').css('visibility', 'visible');
		}
		$('.btn').fadeIn('fast');
		$('div.scroll').css({width:s_w});
		$('div.scroll').css({display:''});
		$('div.first_data').css({display:''});
		$('div.data').css({width:d_w});
		
		var d_h = d_w/1.7;
		$('#flash_div').css({width:d_w,height:d_h});
		
		$('div.data').css({display:''});
		$('div.data').css({height:''});
		if($('div#content_data').length > 0)	$('#content_data').remove();
		
		word_wrap();
		img_width(0);
		switch_headers('n');
		create_scrolls();
	});
}

///////////////////////////////////////////
//	FRONT VIEW ANIMATION
///////////////////////////////////////////
function front_view(){
	
	if($('.active_menu').length){
		$('.active_menu').removeClass('active_menu');
		switch_menubuttons('w');
	}
	
	if($('div#content').width() != 1){
		$('div#content_data').remove();
		var btn_cnt = 0
		$('.btn').fadeOut('fast',function(){
			btn_cnt++;
			if(btn_cnt==8){
				$('div#content').children().css({display:'none'});
				$('div#content').removeClass('big_c');
				$('div#content').animate({width:1},'fast','swing',function(){
					front_animate();
				});
			}
		});
	}
	
	if($('div.big').length > 0){
		
		if($('div#main_wrapper').length > 0){
			$('div#main_wrapper').remove();
			$('div.data').show();
			$('div.splitter').show();
		}
		
		$('div.scroll').css({display:'none'});
		var main_cnt=0;
		$('.main_btn').fadeOut('fast',function(){
			main_cnt++;
			if(main_cnt==4){
				$('div.big').removeClass('big').animate({width:35},'fast','swing',function(){
					front_animate();
				});
			}
		});
	}
}
///////////////////////////////////////////
//	MAIN MENU ANIMATION
///////////////////////////////////////////
function menu_view(type){
	
	$('div#content').html('');
	$('div#content_data').remove();
	$('div.big>.scrollholder>.scroll>.data').css({display:''});
		
	var data = type;
	var b_w = $(window).width();
	if(b_w > 1024){
		b_w-=60;
	}
	var b_h = $(window).height();
	$('div.scroll').css({display:'none'});
	$('.btn').css({'display':'none'});
	
	if($('div#main_wrapper').length > 0){	
		$('div#main_wrapper').remove();
		$('div.data').show();
		$('div.splitter').show();
	}
	
	if($('.active_menu').length){
		$('.active_menu').removeClass('active_menu');
	}
	$('.'+type).addClass('active_menu');

	switch_menubuttons('w');
	/*$('.active_menu').each(function(){*/
	var src = $('.active_menu').attr('src');
	var dot = src.lastIndexOf('.');
	var img = src.substring(0,dot-1);
	var ext = src.substring(dot);
	var new_src = img+'r'+ext;
	$('.active_menu').attr('src',new_src);
	/*});*/
	//console.log($('.active_menu').attr('alt'));
	
	
	
	if($('div.big_c').length > 0){
		$.post('inc.'+data+'.php',function(e){
			html = e;
		});
		$('div#content').animate({width:35}).animate({width:b_w-150},'fast','swing',function(){
			$('.main_btn').fadeIn('fast');
			//$.post('sub/'+data+'.inc.php',function(e){
				//$('div#content').append(e);
				$('div#content').append(html);
				stop_movie('true');
			//});
		});
	}else{
		if($('div.big').length > 0){
			
			headline_rotation('menu');
			
			$('div.big').animate({width:35},'fast','swing',function(){
				$('div#content').animate({width:b_w-150},'fast','swing',function(){
						//alert(1);
						$(this).addClass('big_c');
						$('.main_btn').fadeIn('fast');
						$('div.big').removeClass('big');
						$.post('inc.'+data+'.php',function(e){
							$('div#content').append(e);
							stop_movie('true');
						});
					});
			});
		}else{
			
			headline_rotation('menu');
			
			var c_check=0;
			$('div.container').animate({width:35},'fast','swing',function(){
				c_check +=1;
				if(c_check == 4){
					$('div#content').animate({width:b_w-150},'fast','swing',function(){
						$(this).addClass('big_c');
						$('.main_btn').fadeIn('fast');
						$('div.big').removeClass('big');
						$.post('inc.'+data+'.php',function(e){
							$('div#content').append(e);
							headline_rotation('menu');
							stop_movie('true');
						});
					});
				}
			});
		}
	}
}
///////////////////////////////////////////
//	SET CONTENT WIDTH AND HEIGHT
///////////////////////////////////////////
function set_measurements(){
	var browser_width = $(window).width()-60;
	var browser_height = $(window).height();
	
	if(VER<7) $('div#content').css({margin:0});
	
	if($('div.big_c').length == 0){
		if($('div.big').length == 0){
		 	if(browser_width > 1025){
		 		
		 		//if(IE) browser_width -=10;
		 		var c_w = (browser_width-10)/4;
		 		if(VER<7) c_w -=1;
		 		var s_w = c_w-25;
		 		var d_w = c_w-35;
		 		var d_h = d_w/1.7;
		 		if(VER< 7){
	 		 		$('div#content').css({margin:'0 0 0 20px'});
		 		}else{
		 			$('div#content').css({margin:'0 0 0 30px'});
		 		}
		 		$('div#wrapper').css({width:'100%'});
		 		$('div.container').css({width:c_w});
		 		$('div.scroll').css({width:s_w});
		 		$('div.data').css({width:d_w});
		 		$('div#flash_div').css({width:d_w,height:d_h});
		 		if(VER < 7){
				 	$('.main_menu:first').css({margin:'20px 0 0 25px'});
				 	//$('#logo_img').css({margin:'0 25px 0 0'});
				 	$('#logo_img').css({margin:'0 35px 0 0'});
		 		}else{
				 	$('.main_menu:first').css({margin:'20px 0 0 40px'});
				 	//$('#logo_img').css({margin:'0 30px 0 0'});
				 	$('#logo_img').css({margin:'0 40px 0 0'});
		 		}
	
		 	}else{
		 		var b_w = 1016;
		 		var c_w = (b_w-20)/4;
		 		if(IE) c_w -=1;
		 		if(VER < 7){ c_w -=5; b_w -=21; }
		 		var s_w = c_w-25;
		 		var d_w = s_w-10;
		 		var d_h = d_w/1.7;
		 		$('div#content').css({margin:0});
		 		$('div#wrapper').css({width:b_w});
				$('div.scroll').css({width:s_w});
				$('div.data').css({width:d_w});
				$('div#flash_div').css({width:d_w,height:d_h});
				$('div.container').css({width:c_w});
				
				if(VER < 7){
				 	$('.main_menu:first').css({margin:'20px 0 0 5px'});
		 		}else{
				 	$('.main_menu:first').css({margin:'20px 0 0 10px'});
		 		}
				//$('#logo_img').css({margin:0});
				$('#logo_img').css({margin:'0 10px 0 0'});
		 	}
		 	
		}else{
			if(browser_width > 1025){
				var c_w = browser_width-115;
				var s_w = c_w-25;
				var d_w = Math.floor((s_w-50)/4)-30;
				var d_h = d_w/1.7;
		 		if(VER<7) d_w -=3; 
		 		if(VER< 7){
	 		 		$('div#content').css({margin:'0 0 0 20px'});
		 		}else{
		 			$('div#content').css({margin:'0 0 0 30px'});
		 		}
				$('div.data_spacer').css({width:'30px'});
				$('div.small').css({width:'20px'});
				$('div#wrapper').css({width:'100%'});
				$('div.big').css({width:c_w});
				$('div.big>.scrollholder>.scroll').css({width:s_w});
				$('div.data').css({width:d_w});
				$('div#flash_div').css({width:d_w,height:d_h});
				$('.main_menu:first').css({margin:'20px 0 0 40px'});
				if(VER < 7){
				 	$('.main_menu:first').css({margin:'20px 0 0 25px'});
				 	//$('#logo_img').css({margin:'0 25px 0 0'});
				 	$('#logo_img').css({margin:'0 35px 0 0'});
		 		}else{
				 	$('.main_menu:first').css({margin:'20px 0 0 40px'});
				 	//$('#logo_img').css({margin:'0 30px 0 0'});
				 	$('#logo_img').css({margin:'0 40px 0 0'});
		 		}
		 		switch_headers('w');
			}else{
				var b_w = 1016;
				
				if(VER < 7){ c_w -=5; b_w -=21; }
				
				var c_w = b_w-115;
				var s_w = c_w-25;
				var d_w = Math.floor((s_w-40)/4)-1;
				var d_h = d_w/1.7;
		 		if(VER<7) d_w -=3;
				$('div.data_spacer').css({width:'1px'});
				$('div.small').css({width:'1px'});
		 		$('div#content').css({margin:0});
				$('div#wrapper').css({width:b_w});
				$('div.big').css({width:c_w});
				$('div.big>.scrollholder>.scroll').css({width:s_w});
				$('div.data').css({width:d_w});
		 		$('div#flash_div').css({width:d_w,height:d_h});
				if(VER < 7){
				 	$('.main_menu:first').css({margin:'20px 0 0 5px'});
		 		}else{
				 	$('.main_menu:first').css({margin:'20px 0 0 10px'});
		 		}
				//$('#logo_img').css({margin:0});
				$('#logo_img').css({margin:'0 10 0 0'});
				switch_headers('n');
			}
		}
	}else{
		var b_w = browser_width;
		if(b_w > 1025){
			if(IE) b_w -=21;
		 	if(VER< 7){
	 		 	$('div#content').css({margin:'0 0 0 20px'});
		 	}else{
		 		$('div#content').css({margin:'0 0 0 30px'});
		 	}
			$('div#wrapper').css({width:'100%'});
			$('div.big_c').css({width:b_w-150});
			
		    if(VER < 7){
			 	$('.main_menu:first').css({margin:'20px 0 0 25px'});
			 	//$('#logo_img').css({margin:'0 25px 0 0'});
			 	$('#logo_img').css({margin:'0 35px 0 0'});
	 		}else{
			 	$('.main_menu:first').css({margin:'20px 0 0 40px'});
			 	//$('#logo_img').css({margin:'0 30px 0 0'});
			 	$('#logo_img').css({margin:'0 40px 0 0'});
	 		}
		}else{
			b_w = 1016;
			if(IE) b_w -=21;
		 	$('div#content').css({margin:0});
			$('div#wrapper').css({width:b_w});
			$('div.big_c').css({width:b_w-150});
			
			if(VER < 7){
				$('.main_menu:first').css({margin:'20px 0 0 5px'});
		 	}else{
				$('.main_menu:first').css({margin:'20px 0 0 10px'});
		 	}
			//$('#logo_img').css({margin:0});
			$('#logo_img').css({margin:'0 10px 0 0'});
		}
	}
	
	
	if(browser_height < 600){
		$('div#content').css({height:500});
		$('div.container').css({height:500});
		$('div.scrollholder').css({height:456});
	}else{
		$('div#content').css({height:browser_height-80});
		$('div.container').css({height:browser_height-80});
		$('div.scrollholder').css({height:browser_height-124});
	}
	
	img_width(0);
	set_sticky();
	setTimeout('create_scrolls()',100);
	//create_scrolls();
	
}

function swap_images(){
	$('.data_img').each(function(){
		var title = $(this).attr('title');
		var width = $(this).parents().filter('.data').width();
		$(this).attr({src:'thumb.php'+title+width}).attr({title:''});
	});
}

function load_image(nr){
	var id = images[nr];
	var title = $('img#'+id).attr('title');
	var width = $('img#'+id).parents().filter('.data').width();
	$('img#'+id).attr({src:'thumb.php'+title+width}).load(function(){
		$(this).attr({title:''});
		nr++;
		load_image(nr);
	});
}


///////////////////////////////////////////
//	DOM READY
///////////////////////////////////////////
$(document).ready(function() {
	
	headline_rotation('front');
	set_measurements();
	word_wrap();
	
	$('img.btn').addClass('main_btn');
	
	if(IE==true){
		$('.headline').css({top:15});
	}
	
	setTimeout('load_images(0)',2000);;
	//setTimeout('swap_images()',2000);
	
	$(window).resize(function(){
		set_measurements();
		word_wrap();
	});
	
	//s = setInterval('sticky_size()',50);

	if(VER<7)	$('.bottom').css({margin:'5px 0 0 0'});
	
	$('div.splitter').hide();
	
	//containerite backgroundid
	if(!VER || VER>6){
		$('div.container').hover(function(){
			$(this).css({background:'url(\'img/dark.png\')'});
		},function(){
			$(this).css({background:''});
		});
		$('div.data').hover(function(){
			$(this).children().filter('.image').children().filter('img').fadeTo('fast',0.7);
			$(this).css({color:'#8F8F8F'});
		},function(){
			$(this).children().filter('.image').children().filter('img').fadeTo('fast',1.0);
			$(this).css({color:'#BFBFBF'});
		});
		$('.2').hover(function(){
			$(this).children().filter('.k_body').children().filter('img').fadeTo('fast',0.7);
			$(this).css({color:'#8F8F8F'});
		},function(){
			$(this).children().filter('.k_body').children().filter('img').fadeTo('fast',1.0);
			$(this).css({color:'#BFBFBF'});
		});
	}
	$('.footer_link').mouseover(function(){
		$(this).css('text-decoration','underline');
	}).mouseout(function(){
		$(this).css('text-decoration','none');
	});
	
	$('.footer_link').click(function(){
		var link = $(this).parent('a').attr('href');
		window.open(link);
		return false;
	});
	
	//data bloki click
	$('div.data:not(.noClick)').click(function(){
		$(this).children().filter('.footer').children().filter('.d_more').children().filter('a').trigger('click');
	});
	
	//main menu hover
	$('.main_menu > a > img').hover(function(){
		if($(this).hasClass('active_menu') == false){
			//console.log('on');
			var src = $(this).attr('src');
			var dot = src.lastIndexOf('.');
			var img = src.substring(0,dot-1);
			var ext = src.substring(dot);
			var new_src = img+'r'+ext;
			$(this).attr('src',new_src);
		}
	},function(){
		if($(this).hasClass('active_menu') == false){
			//console.log('off');
			var src = $(this).attr('src');
			var dot = src.lastIndexOf('.');
			var img = src.substring(0,dot-1);
			var ext = src.substring(dot);
			var new_src = img+'w'+ext;
			$(this).attr('src',new_src);
		}
	});
	
});	