var rem_addr = '';
var MSIE = false;
if(navigator.userAgent.indexOf('MSIE')>=0 && navigator.userAgent.indexOf('Opera')<0)MSIE=true;
var arVersion = navigator.appVersion.split("MSIE");
var version = parseFloat(arVersion[1]);
var debug = false;
var helpers = {
	FormularzKontaktowy:function(){
		if (parseInt(Wyszukajauto.getCookie('_kon'))>5) {
			Wyszukajauto.addFrontError(Wyszukajauto.errs['zaduzo']);
			return false;
		}
		var tlo = Wyszukajauto.tlo('#000000',Wyszukajauto.RemTlo);
		var height = 475;
		switch(Wyszukajauto.getCookie('_actStyl')){
			case '1':
			height = 475;
			break;
			case '2':
			height = 500;
			break;
			case '3':
			height = 515;
			break;
		}
		helpers.srodek(tlo,'/index/kontakt',height);
	},
/*	srodek: function(tlo,url,height){
		try{
			if ($('#gr').length == 0) {
				var srodek = document.createElement('div');
				srodek.id = "gr";
				var ll =  Math.round(($('body').outerWidth()-459)/2)+"px";
				$(srodek).css({position: 'absolute',left: ll,width:'459px',height:'119px',background:'url(/img/komunikat_del.png) center center no-repeat',zIndex: 100});
				$('body').append(srodek);
			}else{
				$('#gr').show().fadeTo(1,1);
				var srodek = $('#gr');
			}
			var lz = Math.round(($(tlo).outerWidth()-459)/2)+'px';
			var err =  '<div style="padding: 20px; position: absolute; top: 10px; left: 70px; background: url(/img/loading.gif) center center no-repeat; height:'+parseInt(height-30)+'px; width: 270px;" id="tar"></div>';
			$(srodek).css({position:'absolute',zIndex:'100',left:lz,width:'459px',height:height+'px',color: '#000000'}).append(err);
			//$('#tar').load(url);
			var jqxhr = $.get(url,function(data){
					$('#tar').css({width: 'auto',height: 'auto',background: 'transparent'}).html(data);
					Cufon.replace('.kulfon');
				}).error(function(){
					window.location.href='/';
					return;
				});
			if (height > 119) {
				$(srodek).css('background','url(/img/komunikat2.png) top center repeat-y');
				var srodek2 = document.createElement('div');
				$(srodek2).css({position: "absolute",zIndex: 220,width: '459px',height: '15px',left: "0px",bottom: "-5px",background: 'url(/img/komunikat_ok2.png) bottom center no-repeat'});
				$(srodek).append(srodek2);
				var srodek3 = document.createElement('div');
				$(srodek3).css({position: "absolute",zIndex: 223,width: '459px',height: '30px',left: "0px",top:"-5px",background: 'url(/img/komunikat_ok.png) top center no-repeat'});
				$(srodek).append(srodek3);
				var srodek4 = document.createElement('div');
				$(srodek4).css({position:"absolute",zIndex:224,width:'54px',height:'80px',left: "15px",top: "35px",background: 'url(/img/komunikat4.png) center center no-repeat'});
				$(srodek).append(srodek4);
			}else{
				$(srodek).css('background','url(/img/komunikat_ok.png) top center repeat-y');
			}
			if (!IE6) {
				if (MSIE) {
					var winHeight = document.documentElement.clientHeight;
				}else{
					var winHeight = window.innerHeight;
				}
				if (height+80<winHeight) {
					$(srodek).css('position','fixed');
					$(srodek).css('top',Math.max(0,Math.round((winHeight-height)/2)-50)+"px");
				}else{
					$(srodek).css('top',Math.max(0,Math.round((winHeight-height)/2)+$(document).scrollTop()-50)+"px");
				}
			}else{
				var coordinates = $('body').scrollTop();
				$(srodek).css('top',Math.round((document.documentElement.clientHeight-height)/2)-50+coordinates+'px');
			}
		}catch(e){
			//alert(e.toString());
			return false;
		}
	},*/
	srodek: function(tlo,url,height,width,handler){
		if (height == undefined) {
			var height = 300;
		}
		if (width == undefined) {
			var width = 459;
		}
		if ($('#gr').length == 0) {
			var srodek = document.createElement('div');
			srodek.id = "gr";
			$('body').append(srodek);
		}else{
			$('#gr').show().fadeTo(1,1).css('background','none');
			var srodek = $('#gr');
		}
		$('body').append(srodek);
		var lz = Math.round(($(tlo).outerWidth()-width)/2)+'px';
		var inheight = parseInt(height-8-26);
		var inwidth = parseInt(width-2*14);
		var err =  '<div class="topcapt" style="width: '+width+'px;"><div class="klt"></div><div class="capt" style="width:'+inwidth+'px;"><div class="capnap"></div></div><div class="krt"></div></div>';
		err +=  '<div class="cy" style="width: '+width+'px; height: '+inheight+'px"><div class="ly" style="height: '+inheight+'px"></div><div style="padding: 5px; position: absolute; top: 2px; left: 70px;" id="tar"></div><div class="ry" style="height: '+inheight+'px"></div></div>';
		err += '<div class="bot" style="width: '+width+'px; top:'+parseInt(height-8)+'px"><div class="kbl"></div><div class="by" style="width: '+inwidth+'px;"></div><div class="kbr"></div></div>';
		$(srodek).css({position:'absolute',zIndex:'300',left:lz,width:width+'px',height:height+'px',color: '#000000'}).append(err);
		if (handler != undefined) {
			$('#tar').load(url,handler);
		}else{
			$('#tar').load(url);
		}
		var srodek4 = document.createElement('div');
		$(srodek4).css({position:"absolute",zIndex:324,width:'54px',height:'80px',left: "15px",top: "35px"/*,background: 'url(/img/znak.png) center center no-repeat'*/});
		$(srodek).append(srodek4);
		if (!IE6) {
			if (MSIE) {
				var max = document.documentElement.clientHeight;
			}else{
				var max = window.innerHeight;
			}
			if (max-100<height) {
				$(srodek).css('top',$(document).scrollTop()+5+"px");
			}else{
				$(srodek).css('top',Math.max(0,Math.round((max-height)/2)-50)+"px");
				$(srodek).css('position','fixed');
			}
		}else{
			var coordinates = $(document).scrollTop();
			$(srodek).css('top',Math.round((document.documentElement.clientHeight-height)/2)-50+coordinates+'px');
		}
	}
}
