function getWinWidth()
{
  if (document.body && document.body.clientWidth)
    return document.body.clientWidth;
  else
  {
    return window.innerWidth;
  }
}

function getWinHeight()
{
	var myHeight = 0;

	if (typeof(window.innerHeight) == 'number') {
		//Non-IE
		myHeight = window.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight) {
		//IE 6+ in 'standards compliant mode'
		myHeight = document.documentElement.clientHeight;
	}
	else if (document.body && document.body.clientHeight) {
		//IE 4 compatible
		myHeight = document.body.clientHeight;
	}

	return myHeight;

}

function set_vybava_rozmery()
{
	var x=getWinWidth();
	var y=getWinHeight();
	var o=document.getElementById('eq_main');
	if (o) {
		if (x) {
			o.style.width = (x - 184) + "px";
		}
		if (y) {
			o.style.height = (y - 280) + "px";
		}
	}
}

function set_vybavaserie_rozmery()
{
	var x=getWinWidth();
	var y=getWinHeight();
	var o=document.getElementById('eq_main');
	if (o) {
		if (x) {
			o.style.width = (x - 184) + "px";
		}
		if (y) {
			o.style.height = (y - 210) + "px";
		}
	}
}

function set_barvy_rozmery()
{
	var x=getWinWidth();
	var y=getWinHeight();
	var o=document.getElementById('eq_main');
	if (o) {
		if (x) {
			o.style.width = (x - 184) + "px";
		}
		if (y) {
			o.style.height = (y - 250) + "px";
		}
	}
}

function set_motoriazace_rozmery()
{
	var x=getWinWidth();
	var y=getWinHeight();
	var o=document.getElementById('eq_main');
	if (o) {
		if (x) {
			o.style.width = (x - 184) + "px";
		}
		if (y) {
			o.style.height = (y - 290) + "px";
		}
	}
}

function tisice(polozka)
{
	polozka = Math.round(polozka);
	polozka = "" + polozka;
	var vysledek = "";
	for (i = 0; i < polozka.length - 3; i = i+3) {
		cast = polozka.substr(polozka.length - 3 - i, 3);
		vysledek = cast + " " + vysledek;
	}
	cast = polozka.substr(0,polozka.length - i);
	vysledek = cast + " " + vysledek;
	vysledek = vysledek.substr(0, vysledek.length - 1);
	return vysledek;
}


var car_price = 0;
var n1 = false;

function price_display(sleva)
{
	var x;


 	if (x = document.getElementById("js_cena_bez_dph_wrap"))
		x.style.visibility = n1 ? "visible" : "hidden";

	if (x = document.getElementById("js_prev_cena_dph"))
		x.innerHTML = tisice(car_price - (sleva * dph_sazba)) + " Kč";

 	if (x = document.getElementById("js_prev_cena_bez_dph"))
		x.innerHTML = tisice(Math.round(car_price / dph_sazba) - sleva) + " Kč";

 	if (x = document.getElementById("js_prev_cena_bez_dph_wrap"))
		x.style.visibility = n1 ? "visible" : "hidden";
}

function price_eq_set(price, add, n1_mode, sleva)
{
	if (add)
		car_price += Number(price);
	else
		car_price -= Number(price);

	n1 = n1_mode;

	price_display(sleva);

}

function price_orig_set(price, add, sleva)
{
	if (add)
		car_price += Number(price);
	else
		car_price -= Number(price);


	price_display(sleva);

}



jQuery(function($) {
	//zoom nahledu


	$('a.headZoomable').fancybox({
		type: 'image',
		titleShow: false,
		overlayShow: false,
		overlayOpacity: 0,
		hideOnContentClick: true,
		hideOnOverlayClick: true,
		transitionIn: 'none',
		transitionOut: 'none',
		autoScale: false,
		padding: 10,
		margin: 5,
		changeSpeed: 0,
		onStart: function() {
			$('#fancybox-wrap').css({top: 160, left: 270});
			$('#load_message').show().css({
				visibility: 'visible',
				top: ($(window).height() - $('#load_message').height()) / 2,
				left: ($(window).width() - $('#load_message').width()) / 2
			});
		},
		onComplete: function () {
			$('#load_message').hide();
			$('#fancybox-wrap').css({top: 160, left: 270});
		}

	});

});


