	$(function(){
		
		if(site==''){
			$('#popUp').css('display','block');
		}
		var hei = $(document).height();
		$('#popUp').css('height',hei+'px');
		$('#popUp').click(function(){
			$(this).fadeOut();
		});
		
		
				// wejscie strony
				$("#tresc").fadeTo(0, 0.1);
				setTimeout(function(){
					$("#tresc").fadeTo(250,1);
				}, 250);
				
				
				// po kliknięciu ściemnia obraz
				$("area, a").bind('click', function(event){
					var href = $(this).attr('href');
					
					if(href != "" && href != "#" && !$(this).hasClass('noEffect') && !$(this).hasClass('img_zoom_elements') && !$('#fancybox-close'))
					{
						event.preventDefault();
						
						$("#tresc").fadeTo(250,0);
						
						setTimeout(function(){
							document.location = href;
						}, 500);
					}
				});
				
				// oryginalny obrazek
				var orginal = $("#map").attr('src');
				var orginalr = $("#mapr").attr('src');
				
				// najechanie myszką nad link
				$('area, a').hover(
					function () {
						// zapamietaj adres
						var href=$(this).attr('href');
						
						// przeszukaj mapke obrazka w poszukiwaniu takiego pola
						$('#imagemap area').each(function(){
							// znaleziono? podstaw za src wartosc atrybutu ref
							if($(this).attr('href') == href)
								$("#map").attr('src', $(this).attr('ref'));
						})
					},
					// przyworc oryginalny obrazek
					function(){
						$("#map").attr('src', orginal);
					}
				);
				// najechanie myszką nad link
				$('area, a').hover(
					function () {
						// zapamietaj adres
						var href=$(this).attr('href');

						// przeszukaj mapke obrazka w poszukiwaniu takiego pola
						$('#imagemapr area').each(function(){
							// znaleziono? podstaw za src wartosc atrybutu ref
							if($(this).attr('href') == href)
								$("#mapr").attr('src', $(this).attr('ref'));
								var orginalr = $("#mapr").attr('src');
						})
					},
					// przyworc oryginalny obrazek
					function(){
						$("#mapr").attr('src', orginalr);
					}
				);
				
				/*********************************************/
				$('#imagemapr area').each(function(){
					if(String(window.location).indexOf($(this).attr('href')) > 0)
					   $("#mapr").attr('src', $(this).attr('ref'));
					   orginalr = $("#mapr").attr('src');
					});
				/*********************************************/
				
				// zaznacz wybrany region
				$('#imagemap area').each(function(){
					if(String(window.location).indexOf($(this).attr('href')) > 0)
					   $("#map").attr('src', $(this).attr('ref'));
					   orginal = $("#map").attr('src');
					});
					
				// zaznacz wybrane menu
				var selected = false;
				$('#menu_dol > ul > li > a').each(function(){
					if(String(window.location).indexOf($(this).attr('href')) > 0)
					{
					   $(this).parent('li').addClass('selected');
					   selected = true;
					   
					}
					
				});
				if(!selected){
					if((site!='oferta')&&($('#menu_dol > ul').attr('id')!='connect_ul'))
						$('#menu_dol > ul > li > a').first().parent('li').addClass('selected');
						
				}
				
				
				// zaznacz wybrane menu
				var selected = false;
				$('#podmenu > li > a').each(function(){
					if(String(window.location).indexOf($(this).attr('href')) > 0)
					{
						$(this).parent('li').addClass('selected');
						selected = true;
						
					}

				});
				if(!selected){
						$('#podmenu > li > a').first().parent('li').addClass('selected');
				}
				
			
				
					
					
				
					
				var wid = 0;
				var hei = 0;
				var anim = false;
				var element = '';
				
				
				$('#menu_dol > #oferta_ul > li > a').hover(function() {
					var id=$(this).first().parent('li').attr('id');
					//alert(id);
					
//					Cufon.replace(this, {fontFamily: 'Myriad Pro', hover:true});
					element= $('img[name=' + id + ']');
					
					element.css({'z-index' : '8'});
					
					var id = element.attr('name');
					
					wid = parseInt(element.attr('wid'));
					var wid2 = wid+10;
					
					if(!$.browser.msie)
					{
						element.stop().animate({
							width: wid2+"px",
							height:"110px",
							top: "-5px",
							left: "-5px"
						}, 400 );
					}else
					{
						element.css('width', wid2+"px");
						element.css('height', "110px");
						element.css('top', "-5px");
						element.css('left', "-5px");
					}

				},function(){
				var id=$(this).first().parent('li').attr('id');
			
				element.css({'z-index' : '0'});
					
					if(($(this).parent().attr('flaga')!='no_hover')&&((!$.browser.msie))){
						Cufon.replace('#'+id+' a', {fontFamily: 'Myriad Pro',color: '#ffffff',hover: false});
					}
					
					if(!$.browser.msie)
					{
						element.stop().animate({
							width: wid+"px",
							height: "100px",
							top: "0px",
							left: "0px"
						}, 400);
					}
					else
					{
						element.css('width', wid+"px");
						element.css('height', "100px");
						element.css('top', "0px");
						element.css('left', "0px");
					}
						

					
				});
				
				$('#podmenu li a').click(function(){
					$('#podmenu li').removeClass('selected');
					$(this).parent().addClass('selected');
				});
				
				//==================podświetlanie ikonek na stronie gółwnej simon->simon blu planet =======================
				var name= '';
				$('#loga a').hover(function() {
					name = $(this).find('img').attr('name');
					if(name!='')
						$(this).find('img').attr('src', 'img/'+name+'.png');
				
				},function(){
					if(name!='')
						$(this).find('img').attr('src', 'img/'+name+'_c.png');
				});
				
					
				// powiększające się kontakty w ofercie produktowej
				var wid = 0;
				var hei = 0;
				var anim = false;
				$('#oferta_zdjecia img').hover(function() {
  					
					if(($(this).attr('alt')!='ip44')&&($(this).attr('alt')!='nowa_seria')){
						$(this).css({'z-index' : '8'});
	
						var id = $(this).attr('name');
						$('#'+id+'').addClass('selected');
	
						Cufon.replace('#'+id+'', {fontFamily: 'Myriad Pro',hover: true});
						wid = parseInt($(this).attr('wid'));
						var wid2 = wid+10;
	
						$(this).stop().animate({
							width: wid2+"px",
							height:"110px",
							top: "-5px",
							left: "-5px"
						}, 400 );
					}
					
				},function(){
				
				if(($(this).attr('alt')!='ip44')&&($(this).attr('alt')!='nowa_seria')){
					var id = $(this).attr('name');
					$(this).css({'z-index' : '0'});
						$(this).stop().animate({
							width: wid+"px",
							height: "100px",
							top: "0px",
							left: "0px"
						}, 400);
	
						$('#'+id+'').removeClass('selected');
						Cufon.replace('#'+id+'', {fontFamily: 'Myriad Pro',hover: true});
					}
				});
				
				$('.kategoria_element  a').click(function (e){
					//alert( e.pageY+'tutja');
					$('#produkty_opis div').css('display','none');
					$('.kategoria_element ').css('border-right','1px solid #b3b4b5');
					$(this).parent('div').parent('div').css('border-right','0px');
					var id = $(this).attr('value');
					var y;
					if(e.pageY){
						y = e.pageY;
						y=y/10;
						parseInt(y);
						y=y*10;
						y= y-235;
					}else{
						y= $(this).position().top;
						y=y/10;
						parseInt(y);
						y=y*10;
						y= y-200;
					}
					var pos = $(this).position().top - 50;
					$('html, body').animate({scrollTop:pos}, 800);
					$('#'+id+'').css('display','block');
					$('#'+id+'').css('top',y);
					var element_height = $('#'+id+'').height();
					var right_height = element_height+y;
					$('#produkty_opis').css('height',right_height);
					
				});
				
				
				
				//================================Slider do connecta =============================
				
				$(".scrollable").scrollable({circular: true}).autoscroll({ autoplay: true ,	interval: 3000});
				$("#etykietka").css("opacity", 0.7);
				
				//=============================== ZAKŁADKI  W OPISIE CONNECT =============================
				//$(".zewnetrzny_zakladki").scrollable({circular: true}).autoscroll({ autoplay: false ,interval: 3000});
				
				
				$('.accordion h3').next().hide();
				$('.accordion h3').click(function(event) {
					var down = true;
					if($(this).next().css('display') == "block")
						down = false;
					$('.accordion h3').next().slideUp(250);
	
					if(down)
						$(this).next().slideDown(250);
					return false;
				});
				//$("#materialy"+id).click();
				
				//===========================DYMIKI Z ZAJAWKĄ W CONNECT================================
				$('#next').hover(function(){
					$('#dymek_next').css('display','table');

				},function(){
					$('#dymek_next').css('display','none');
				});
				
				$('#prev').hover(function(){
					$('#dymek_prev').css('display','table');

				},function(){
					$('#dymek_prev').css('display','none');
				});
				
				
				/////////////////////////////////////////////////////////////////////////////////////////////
				///// Tylko dwie pozycje w checkboxach dla instalatora
				////////////////////////////////////////////////////////////////////////////////////////////
				var ile = 0;
				var arr = new Array();
				$('input[type="checkbox"]').click(function(event){
					
					if($(this).attr('clicked') == 1){
						$(this).attr('clicked', 0);
						ile--;
					}else{
						if( ile >=2){
							event.preventDefault();
						}else{
							$(this).attr('clicked', 1);
							ile++;
						}
					}
					
				});
				
			
					//alert(ile+'div');
					/*var temp=$('#instalator_form').find('.checkbox').attr('id');
					alert(temp);*/
				
				
});

var windowHeight = -1;
var windowWidth = -1;
$(document).ready(function(){
			
				$('#menu_dol a').addClass('ghotic720');
				if ( $.browser.msie ){
					$('#oferta_ul a').removeClass('ghotic720');
					$('#oferta_produktowa a').removeClass('ghotic720');
				}
				Cufon.replace('.ghotic720', {fontFamily: 'Myriad Pro',hover: true});
		
			
			setInterval(function(){
				var dstHeight = $("#mainContent").outerHeight();
				var dstWidth = $("#mainContent").outerWidth();
				if(dstHeight != windowHeight || dstWidth != windowWidth)
				{
					windowHeight = dstHeight;
					windowWidth = dstWidth;
					$('#background_image').height(dstHeight);
					$('#background_image img').height(dstWidth * 828 / 1800);
					$('#background_image').fadeIn();
				}
			}, 1000);
			
			// przekierowanie dla starej przegladarki
			var is_ie6 = (window.external && typeof window.XMLHttpRequest == "undefined");
			if(is_ie6) document.location = "ie6warn.php";
			
			// wyrownanie
			
			var height1 =  $('#menu_dol').height();
			var height2 =  $('#tresc_rama').height();
			if(height1 > height2)
				$('#tresc_rama').height(height1+50);

			
			// selecty
			if(typeof($("body select").msDropDown) != "undefined")
				$("body select").msDropDown();
});


// walidator
function validate(element,kind){
$('.error-message').hide();
ok=true;
$(element).ready(	function()	{
		//alert(element);
		element = '#'+element;
		if($(element).val()=='undefined' || $(element).val()=='' || $(element).val()==null)
		{
			var width = $(element).width();
			if($(element).parent().parent().parent().parent().parent().attr('id')=='form')
				width = width+380;
			else
				width = width-20;
				
			$(element).parent().append('<div class="error-message" style="left: ' + (width) + 'px;">Wymagane</div>');
			ok = false;
			var pos = $(element).position().top + 40;
			$('html, body').animate({scrollTop:pos}, 800);
		}
		else
		{
			var width = $(element).width();
			if($(element).parent().parent().parent().parent().parent().attr('id')=='form')
				width = width+380;
			else
				width = width-20;
				
			switch(kind)
			{
				case 's':
				{
						pattern = /^[a-zA-ZążśźęćńółĄŻŚŹĘĆŃÓŁ,-,.,0-9\s^\/\/$]{2,}$/;
						seq = $(element).val();
						if(pattern.test(seq)==false)
						{
							
							//var width = $(element).width();
							$(element).parent().append('<div class="error-message" style="left: ' + (width) + 'px;">Niedozwolone znaki</div>');
							ok = false;
							var pos = $(element).position().top - 60;
							$('html, body').animate({scrollTop:pos}, 800);

						}
						break;
				}

				case 'n':
				{
						pattern = /^[\d\s-+]+$/;
						seq = $(element).val();
						if(pattern.test(seq)==false)
						{
							//var width = $(element).width();
							$(element).parent().append('<div class="error-message" style="left: ' + (width) + 'px;">Niedozwolone znaki</div>');
							ok = false;
							var pos = $(element).position().top - 50;
							$('html, body').animate({scrollTop:pos}, 800);
						}
						break;
				}

				case 'e':
				{
						pattern = /^[0-9a-z_.-]+@+[0-9a-z.-]+\.[a-z]{2,3}$/i;
						seq = $(element).val();
						if(pattern.test(seq)==false)
						{
							//var width = $(element).width();
							$(element).parent().append('<div class="error-message" style="left: ' + (width) + 'px;">Niepoprawny email</div>');
							ok = false;
							var pos = $(element).position().top - 50;
							$('html, body').animate({scrollTop:pos}, 800);
						}
						break;
				}

				case 't':
				{
						pattern = /^[0-9a-z_.-]+@+[0-9a-z.-]+\.[a-z]{2,3}$/i;
						seq = $(element).val();
						if(pattern.test(seq)==false)
						{
							//var width = $(element).width();
							$(element).parent().append('<div class="error-message" style="left: ' + (width) + 'px;">Niedozwolone znaki</div>');
							ok = false;
							var pos = $(element).position().top - 50;
							$('html, body').animate({scrollTop:pos}, 800);
						}
						break;
				}
				
				case 'c':
				{
					
						if($(element).attr('clicked')!=1)
						{
							//var width = $(element).width();
							$(element).parent().append('<div class="error-message" style="left: ' + (width) + 'px;margin-top:-100px;">Musisz zaakceptować</div>');
							ok = false;
							var pos = $(element).position().top - 50;
							$('html, body').animate({scrollTop:pos}, 800);
						}
						break;
				}
				case 'st':
				{
						pattern = /^[a-zA-ZążśźęćńółĄŻŚŹĘĆŃÓŁ!@#$%?,.^&*()_0-9\s]{2,}$/;
						seq = $(element).val();
						if(pattern.test(seq)==false)
						{
							//alert(element);
							//var width = $(element).width();
							$(element).parent().append('<div class="error-message" style="left: ' + (width) + 'px;">Niedozwolone znaki</div>');
							ok = false;
							var pos = $(element).position().top - 50;
							$('html, body').animate({scrollTop:pos}, 800);

						}
						break;
				}
				
			}
		}
		return ok;
	});
return ok;
};
