$(function(){
	/*
	 * preload
	 */

	$("<img />").attr("src", 'i/remen.png');
	$("<img />").attr("src", 'i/bg2.png');
	$("<img />").attr("src", 'i/bg3.png');
	
	/*
	 * accordion
	 */

	if ($('div.accordion').length) {
		$('div.accordion p:gt(0)').hide();
		$('div.accordion h4:eq(0)').addClass('active');
		$('div.accordion h4 a').click(function(){
			var el = $(this).parent();
			if (!el.hasClass('active')) {
				document.body.className = 'main'+($('div.accordion h4').index(el)+1);
				var p = el.next('p');
				$('div.accordion p').not(p).slideUp(300);
				p.slideDown(300);
				el.animate({
					fontSize: '237.5%'
				}, 300, '', function(){
					$(this).addClass('active');
				});
				$('div.accordion h4').not(el).animate({
					fontSize: '100%'
				}, 300, '', function(){
					$(this).removeClass('active');
				});
			}else{
				document.location=this.href;
			}
			return false;
		});
		$('div.container div.wrapper').css({
			height: 400
		});
	}
	
	/*
	 * save
	 */

	$('p.save').click(function(){
		var rm = $('<div class="remen"><div></div></div>').appendTo(document.body);
		rm.click(function(){
			$(this).remove();
		});
		var w = $(document.body).width();
		var h = $(document.body).height();
		var ch = document.documentElement.clientHeight;
		rm.css({
			width: w,
			height: h
		})
		if (w*0.7<h){
			h = w*0.7;
			rm.css({height: h});
		}
		if (h>1198){
			rm.css({height: 1198});
		}
		
		if (!$.browser.msie){
			rm.css({
				position: 'fixed',
				height: (ch<1198)? ch: 1198
			});
		}
		return false;
	});
	
	/*
	 * save resize
	 */

	$(window).resize(function(){
		var rm = $('div.remen'); 
		if (rm.length){
			var w = $(document.body).width();
			var h = $(document.body).height();
			var ch = document.documentElement.clientHeight;
			rm.css({
				width: w,
				height: h
			})
			if (w*0.7<h){
				h = w*0.7;
				rm.css({height: h});
			}
			if (h>1198){
				rm.css({height: 1198});
			}
			if (!$.browser.msie){
				rm.css({
					position: 'fixed',
					height: (ch<1198)? ch: 1198
				});
			}
		}
	});
	
	/*
	 * search
	 *
	
	var sinput = $('div.footer div.search input');
	sinput.attr('value',(sinput.attr('value')=='')?sinput.attr('title'):sinput.attr('value'));
	sinput.focus(function(){
		$(this).attr('value',($(this).attr('value')==$(this).attr('title'))? '': $(this).attr('value'));
	}).blur(function(){
		$(this).attr('value',($(this).attr('value')=='')? $(this).attr('title'): $(this).attr('value'));
	});
	*/
	/*
	 * ie
	 */
	
	if ($.browser.msie){
		$("<img />").attr("src", 'i/remen.ie.png');
		function rs(){
			if (document.documentElement.clientWidth<=1000){
				document.body.style.width='1000px';
			}else{
				document.body.style.width='auto';
			}
		}
		$(window).resize(rs);
		rs();
		
		$('div.mnr div.bg, div.accordion div.bg').each(function(){
			var h = $(this).parent().get(0).offsetHeight;
			$(this).css({height: h});
		});
	}
	
	/* Satelite KASKO
	*/
	$("input[name=f_CAR_SATT]").click(function(){
		if($("input[name=f_CAR_SATT]").attr("checked")=="")
			$(".satnamefld").hide();
		else
			$(".satnamefld").show();
	}); 
});