mkPopup=function(mypage,myname,w,h,scroll){
 var winl=(screen.width-w)/2;
 var wint=(screen.height-h)/2;
 var settings='height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no';
 win=window.open(mypage,myname,settings);
}
resBody=function(o){
	return true;
	var w=o.width;
	var h=o.height;
	if (w>0&&h>0) {
		var resWidth = w + 0;
		var resHeight = h + 40;
		var ua = navigator.userAgent.toLowerCase();
		var isOp=(ua.indexOf("opera")!=-1?true:false);
		var isIe=(ua.indexOf("msie")!=-1&&!isOp?true:false);
		if (isIe) {
			resWidth = w + 35;
			resHeight = h + 65;
		}
	
		if (window.screen.width < resWidth)resWidth=window.screen.width-20;
		if (window.screen.height < resHeight)resHeight=window.screen.height-20;
		
		window.resizeTo(resWidth, resHeight);
		
		var wx=(screen.width-w)/2, wy=(screen.height-h)/2;
 		window.moveTo(wx,wy);
		//self.focus();
	}
}
function preloadImg(src) {
	new Image().src=src;
}

function gourl(u)
{
	document.location.replace(u);
	return false;
}

function chmimg(imgid) {
	if (imgs[imgid]) {
		$('prod_mimg').src = imgs[imgid].D;
		$('prod_mimg').parentNode.href=imgs[imgid].D;
		new Image().src=imgs[imgid].D;
	}
}

/** email validation stuff. Based on: SmartWebby.com (http://www.smartwebby.com/dhtml/) */
isEmail=function(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
		return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return false
	}

	if (str.indexOf(at,(lat+1))!=-1){
		return false
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false
	}

	if (str.indexOf(dot,(lat+2))==-1){
		return false
	}
	
	if (str.indexOf(" ")!=-1){
		return false
	}

	return true					
}

function checkHeight(d) {
	if (!d) return false;
	var divHeight=0;
	//d=$(arguments[0]);
	if(d.offsetHeight)
		divHeight=d.offsetHeight;
	else if(d.style.pixelHeight)
		divHeight=d.style.pixelHeight;
	return divHeight;
}
function max(a,b) {return (a>b)?a:b}
function bim(){try{window.event.returnValue=false}catch(e){};return false}

function addToFavorite()
{
	try {
		window.external.AddFavorite(document.location, document.title);
	} catch(e) {
		alert('Jeżeli chcesz dodać tę stronę do ulubionych, naciśnij OK a następnie CTRL+D');
	}
}

tabs = {
	panels: ['details', 'comments', 'add_comment'],
	switchmode: true,
	clkfunction: '',
	return_value: false,
	ch: function(obj)
	{
		if ($('#tabs_'+obj).hasClass('a') && (!tabs.switchmode || $('#tab_'+obj)[0].style.display=='block'))
		{
			return false;
		}
		
		//Zamknięcie pozostałych zakładek
		$.each(tabs.panels, function(i,p){
			if ($('#tabs_'+p) && $('#tab_'+p))
			{
				$('#tabs_'+p).removeClass('a');
				if (tabs.switchmode) {
					$('#tab_'+p).hide();
				}
			}
		});
		$.each(tabs.panels, function(i,p){
			if (p==obj)
			{
				$('#tabs_'+p).addClass('a');
				if (tabs.switchmode) {
					$('#tab_'+p).show();
				}
			}
		})
		
		if (tabs.clkfunction!='') {
			tabs.clkfunction(obj);
		}
		
		return tabs.return_value;
	}
}

// Creates a marker at the given point with the given number label
gMaps = {
	accom_tpl: function(t,i,tx,tp,ds,im,s) {
		var h = '<div class="gmap-wnd"><div><img src="'+im+'"/><h2>'+t+'</h2><p>'+tx+' <a href="'+SERVOFFSET+'/Accommodation/'+t+','+i+'">more&nbsp;&raquo;</a></p></div><p><strong>ACCOMMODATION:</strong> '+tp+' / <strong>District:</strong> '+ds+'</p></div>';
		return h;
	},
	rest_tpl: function(t,i,tx,tp,ds,im) {
		var h = '<div class="gmap-wnd"><div><img src="'+im+'"/><h2>'+t+'</h2><p>'+tx+' <a href="'+SERVOFFSET+'/Restaurants/'+t+','+i+'">more&nbsp;&raquo;</a></p></div><p><strong>RESTAURANT:</strong> '+tp+' / <strong>District:</strong> '+ds+'</p></div>';
		return h;
	},
	nlife_tpl: function(t,i,tx,tp,ds,im) {
		var h = '<div class="gmap-wnd"><div><img src="'+im+'"/><h2>'+t+'</h2><p>'+tx+' <a href="'+SERVOFFSET+'/Nightlife/'+t+','+i+'">more&nbsp;&raquo;</a></p></div><p><strong>NIGHTLIFE:</strong> '+tp+' / <strong>District:</strong> '+ds+'</p></div>';
		return h;
	},
	shop_tpl: function(t,i,tx,tp,ds,im) {
		var h = '<div class="gmap-wnd"><div><img src="'+im+'"/><h2>'+t+'</h2><p>'+tx+' <a href="'+SERVOFFSET+'/Shopping/'+t+','+i+'">more&nbsp;&raquo;</a></p></div><p><strong>SHOPPING:</strong> '+tp+' / <strong>District:</strong> '+ds+'</p></div>';
		return h;
	},
	thingstodo_tpl: function(t,i,tx,tp,ds,im) {
		var h = '<div class="gmap-wnd"><div><img src="'+im+'"/><h2>'+t+'</h2><p>'+tx+' <a href="'+SERVOFFSET+'/Things to do/'+t+','+i+'">more&nbsp;&raquo;</a></p></div><p><strong>THINGS TO DO:</strong> '+tp+' / <strong>District:</strong> '+ds+'</p></div>';
		return h;
	},
	tourattr_tpl: function(t,i,tx,tp,ds,im) {
		var h = '<div class="gmap-wnd"><div><img src="'+im+'"/><h2>'+t+'</h2><p>'+tx+' <a href="'+SERVOFFSET+'/Tourist attractions/'+t+','+i+'">more&nbsp;&raquo;</a></p></div><p><strong>TOURIST ATTRACTIONS:</strong> '+tp+' / <strong>District:</strong> '+ds+'</p></div>';
		return h;
	},
	taxi_tpl: function(t,tx,tp) {
		var h = '<div class="gmap-wnd"><div>'+(t!=''?('<h2>'+t+'</h2>'):'')+'<p>'+tx+'</p></div><p><strong>TAXI point:</strong> '+tp+'</p></div>';
		return h;
	},
	buses_tpl: function(t,tx,tp,f) {
		var h = '<div class="gmap-wnd"><div>'+(t!=''?('<h2>'+t+'</h2>'):'')+'<p>'+tx+'</p></div>'+(f=='T'?'<p>Additional info: <strong>Night stop.</strong></p>':'')+'</div>';
		return h;
	},
	trams_tpl: function(t,tx,tp,f) {
		var h = '<div class="gmap-wnd"><div>'+(t!=''?('<h2>'+t+'</h2>'):'')+'<p>'+tx+'</p></div>'+(f=='T'?'<p>Additional info: <strong>Night stop.</strong></p>':'')+'</div>';
		return h;
	}
}
function gMapCreateMarkerWnd(point, c, index) {
	var markerParams = {};
	if (typeof index != 'undefined') {
		// Create a base icon for all of our markers that specifies the
		// shadow, icon dimensions, etc.
		var baseIcon = new GIcon(G_DEFAULT_ICON);
		baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
		baseIcon.iconSize = new GSize(20, 34);
		baseIcon.shadowSize = new GSize(37, 34);
		baseIcon.iconAnchor = new GPoint(9, 34);
		baseIcon.infoWindowAnchor = new GPoint(9, 2);
		var index = 1;
		// Create a lettered icon for this point using our icon class
		var letter = String.fromCharCode("A".charCodeAt(0) + index - 1);
		var letteredIcon = new GIcon(baseIcon);
		letteredIcon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";
	   markerParams.icon = letteredIcon;
	}
	var marker = new GMarker(point, markerParams);
   GEvent.addListener(marker, "click", function() {
      marker.openInfoWindowHtml(c);
   });
   return marker;
}
function gMapCreateMarker(point) {
   var marker = new GMarker(point);
   return marker;
} 
function checkFltrAny(o) {
	if (this.checked) {
		$.each($('input[type=checkbox][value'+(-1==this.value?'!':'')+'=-1]', $(this).parents().parents()[0]), function(e,i){i.checked=false});
	}
}

function fsubmitg(f) {
	var n,m={};
	$.each($('input', $('#'+f)), function(e,i){
		if (i.type=='checkbox'&&i.checked){
			n=i.name.substring(0,i.name.length-2)
			if (typeof m[n] == 'undefined')m[n]=[];
			m[n].push(i.value);
			$.each(m, function(e,i){
				if ($('#f'+f+' input[name='+e+']'))
					$('#f'+f+' input[name='+e+']')[0].value=i.join(',');
			})
		}
	})
	$('#f'+f).submit();
}

sgtabs = {
	run: function(p) {
		tabs.panels=p;
		tabs.switchmode=false;
		tabs.clkfunction=function(_t){
			var _f=$('#find-all-about-cracow .cont .tglass');
			_f.height($('#find-all-about-cracow .cont').height()).show();
			$('#find-all-about-cracow .cont .mimg img')[0].onload=function(){
				$('#find-all-about-cracow .cont .tglass').hide();
				this.onload=null;
			};
			$('#find-all-about-cracow .cont .mimg img')[0].src='http://img'+(Math.round(Math.random()*10)%4+1)+'.'+location.host+'/x,'+panels_cfg[_t].i[0]+',eee,cjb.jpg';
			$('#find-all-about-cracow .cont .mimg a')[0].href=panels_cfg[_t].n.replace(/\ /g, '-');
			$('#find-all-about-cracow .cont #mimg_glass p').html(panels_cfg[_t].c);
			$('#find-all-about-cracow .cont .imgs ul li').remove();
			$.each(panels_cfg[_t].i, function(i,e){
				$('#find-all-about-cracow .cont .imgs ul').append('<li'+(i==0?' class="a"':'')+'><img src="http://img'+(Math.round(Math.random()*10)%4+1)+'.'+location.host+'/x,'+e+',bfa,ji.jpg" width="150" height="98" alt="" onclick="$(\'li\', this.parentNode.parentNode).removeClass(\'a\');$(this.parentNode).addClass(\'a\');$(\'#find-all-about-cracow div.mimg img\')[0].src=\'http://img'+(Math.round(Math.random()*10)%4+1)+'.'+location.host+'/x,'+e+',eee,cjb.jpg\'"/></li>');
			});
			$('#find-all-about-cracow .cont form')[0].action=SERVOFFSET+'/'+panels_cfg[_t].n.replace(/\ /g, '-');
			$('#find-all-about-cracow .cont form input[type=submit]')[0].value='Find '+panels_cfg[_t].n.toLowerCase();
			$('#find-all-about-cracow .cont form div *').remove();
			var _ident = panels_cfg[_t].n.toLowerCase().replace(/\ /g, '-');
			$('#find-all-about-cracow .cont form div').append('<input type="checkbox" id="find-'+_ident+'-all" name="type[]" value="-1"/> <label for="find-'+_ident+'-all">All</label>');
			$.each(panels_cfg[_t].t, function(i,e){
				$('#find-all-about-cracow .cont form div').append('<input type="checkbox" id="find-'+_ident+'-'+i+'" name="type[]" value="'+i+'"/> <label for="find-'+_ident+'-'+i+'">'+e+'</label>');
			})
			_f.height($('#find-all-about-cracow .cont').height());
		};
		tabs.return_value=false;
		jQuery('div.mimg').hover(function(){jQuery('#mimg_glass').removeClass('hide')},function(){jQuery('#mimg_glass').addClass('hide')});
	}
}