function Init() {



	LightboxInit('#Content');

	EventsInit();

	

	$('#FormularzKontaktowy TEXTAREA').each(function(){

	var obj = $(this).parent().prev();

	obj.css('vertical-align', 'top');

	obj.css('padding-top', '5px');	

	});

	

/*

	$('#Flash').each(function(){

		InsertFlash('fla/flash.swf', 454, 361, 'Flash');

	});

*/

	

	$('#Map').each(function(){

		MapLoad('Map');

	});

	

	$('#HomeCol1').each(function(){

		var hc1 = parseInt($('#HomeCol1').height());

		var hc2 = parseInt($('#HomeCol2').height());

		var hc3 = parseInt($('#HomeCol3').height());

		

		var maxVal = Math.max(hc1, Math.max(hc2, hc3));

		$('#HomeCol1').height(maxVal);

		$('#HomeCol2').height(maxVal);

		$('#HomeCol3').height(maxVal);

	});

	

	$('#RCol1').each(function(){

		if ($('#RCol2').height() > $(this).height()) $(this).height($('#RCol2').height());

	});

}



function NewAlert(txt, btns) {

	var aBox = $('#AlertBox');

	if (!btns) btns = Array('Ok');

	aBox.html('<div id="Alert"><p>' + txt + '</p></div>');

	if (btns.length > 0) {

		$('#Alert').append('<div id="AlertBtns"></div>');

		var aBtns = $('#AlertBtns');

		for (i = 0; i < btns.length; i++) {

			aBtns.append('<div class="alertBtn" name="' + i + '">' + btns[i] + '</div>');

		}

	}

	$('#AlertBox').css('display', 'block');

	$('#AlertBox').css('left', '-4000px');

	var alertHeight		= $('#Alert').height();

	var screenSize			= getScreenSize();

	var scrollPosition	= getScrollXY();

	var alertY = (parseInt(screenSize[1] / 2) - parseInt(alertHeight / 2)) + parseInt(scrollPosition[1]);

	$('#Alert').css('margin-top', alertY + 'px');

	$('#AlertBox').css('left', '0px');

}



function EventsInit() {

	$('A[href="#"]').click(function(){

		return false;

	});

	

	$('#Menu A[href="#"]').hover(function(){
		var id = $(this).attr('class').substr(2);
		var tPos = 53;
		var tWidth = parseInt($(this).css('width'));
		obj = $('.subMenu[name="' + id + '"]');
		//obj.css('width', tWidth + 'px');
		//obj.css('left', tPos + 'px');
		//obj.children('A').css('background-image', 'url("")');
		//obj.children('A').css('width', tWidth + 'px');
		//obj.children('A').css('height', 'auto');
		obj.css('display', 'block');
	});

	

	$('.subMenu').hover(function(){
		
	}, function(){
		$(this).css('display', 'none');
	});
	
	$('#Menu .bt2, #Menu .bt6, #Menu .bt7, #Menu .bt5').hover(function(){
		$('.subMenu').css('display', 'none');
	}, function(){
		
	});
	

	$('.back').click(function(){

		history.go(-1);

		return false;

	});

	

	$('.rH1Butt').click(function(){

		var obj = $(this).parent().next();

		if (parseInt(obj.attr('name')) == 1) {

			obj.attr('name', 2);

			obj.animate({height: 'hide', opacity: 'hide'}, "fast", null, function(){obj.attr('name', 0)});

		} else if (parseInt(obj.attr('name')) == 0) {

			obj.attr('name', 2);

			$('.rColSub[name="1"]').each(function(){

				$(this).prev().find('A:eq(0)').click();

			});

			obj.animate({height: 'show', opacity: 'show'}, "fast", null, function(){obj.attr('name', 1)});

		}



	});

	

	$('.mieszkaniaRow').hover(function(){

		if ($(this).css('cursor') != 'auto') $(this).find('div').css('background-color', '#f5f5f5');

	}, function(){

		if ($(this).css('cursor') != 'auto') $(this).find('div').css('background-color', '#ffffff');

	});

	

	$('.mieszkaniaRow').click(function(){

		if($(this).attr('name')!=undefined)
		{
			dlh('index.php?pid=3&idM=' + $(this).attr('name'));
		}

	});

}



if (window.addEventListener) {

	window.addEventListener("load", Init, false);

}else if (window.attachEvent) {

	window.attachEvent("onload", Init);

}
