var control = new Array(3);
$(document).ready(function(){
	
	swfobject.embedSWF("/flash/banner.swf", "BannerPlace", "990", "300", "9.0.0", "expressInstall.swf", false, {	'menu': 'false', 'wmode': 'transparent' }, false);
	
	
	if($.browser.msie && $.browser.version=='6.0'){
		var lUrl = "/gfx/logos/";
		$.fancybox({
			'height'				: 250,
			'content'			: '<div id="BroswerInfo"><p style="color:#c00;"><strong>UWAGA!!</strong></p><p>Używasz Internet Explorera 6.0 - jest to stara i niebezpieczna wersja.</p><p>By w pełni korzystaż z nowoczesnych serwisów internetowych, a przede wszystkim by bezpiecznie surfować po sieci, zrób upgrade swojej przeglądarki lub zmień Internet Explorera <strong>na jedną z przeglądarek alternatywnych.</strong></p><div class="clear"></div><a href="http://www.google.com/chrome/index.html?hl=pl&brand=CHMG&utm_source=pl" target="_blank"><img src="'+lUrl+'browser_chrome.gif" alt="Pobierz najnowszą przeglądarkę Google Chrome" /><br />Google Chrome</a><a href="http://www.mozilla-europe.org/pl/firefox/" target="_blank"><img src="'+lUrl+'browser_firefox.gif" alt="Pobierz najnowszą przeglądarkę FireFox" /><br />FireFox</a><a href="http://www.microsoft.com/poland/windows/internet-explorer/" target="_blank"><img src="'+lUrl+'browser_ie.gif" alt="Pobierz najnowszą przeglądarkę Internet Explorer" /><br />Internet Explorer</a><a href="http://pl.opera.com/" target="_blank"><img src="'+lUrl+'browser_opera.gif" alt="Pobierz najnowszą przeglądarkę Opera" /><br />Opera</a><a href="http://www.apple.com/pl/safari/" target="_blank"><img src="'+lUrl+'browser_safari.gif" alt="Pobierz najnowszą przeglądarkę Safari" /><br />Safari</a></div>'
		});
	}
	
	$('a.Rep,a.RepGB').each(function(){
		var e = $(this).attr("href").replace("/","").split(".html")[0]+"@"+$(this).attr("rel");
		$(this).attr({"href":"mailto:"+e});
		if($(this).attr('class').indexOf('RepGB')==-1) $(this).text(e);
	});
	$(".lightbox").fancybox({
		'autoScale'			: true,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'image'
	});
	
	$("img.resize").each(function(){
		var tw = $(this).attr("width");
		var th = $(this).attr("height");
		if(!isNaN(tw)&&!isNaN(th)) {
			var ts = $(this).attr("src").split("/");
			$(this).attr({"src":"/galeria/"+ts[ts.length-1]+"?xmax="+tw+"&ymax="+th+"&crop&s"});
		}
	});
	
	//$(".Text").find("p:last").css({"padding-bottom":"0px"});
	
	$("#ContactForm").find(".text,.textarea").each(function(){
		var lab = $("label[for='"+$(this).attr("id")+"']").text();
		$(this).val(lab);
		$(this).blur(function(){ var val = $(this).val(); if(val.length==0) $(this).val(lab); });
		$(this).focus(function(){ var val = $(this).val(); if(val==lab) $(this).val(""); });
	});
	
	$("#SearchWord").each(function(){
		var lab = $("label[for='"+$(this).attr("id")+"']").text();
		$(this).val(lab);
		$(this).blur(function(){ var val = $(this).val(); if(val.length==0) $(this).val(lab); });
		$(this).focus(function(){ var val = $(this).val(); if(val==lab) $(this).val(""); });
	});
	
	$("#ProdMenu a.clk").each(function(){
		var ts = $(this).find("span");
		if($(this).parent().find("ul.show").length) ts.text("[-]");
	});
	$("#ProdMenu a.clk").click(function(){
		var ts = $(this).find("span");
		if(ts.text()=="[+]") ts.text("[-]");
		else ts.text("[+]");
		$(this).parent().find("ul").animate({ height: 'toggle', opacity: 'toggle' }, "fast");
		return false;
	})
	
});

function CheckContactForm() {
	var n = $("#FName").val();
	var f = $("#FFirm").val();
	var e = $("#FEmail").val();
	var p = $("#FPhone").val();
	var t = $("#FText").val();
	
	var dn = $("label[for='FName']").text();
	var fn = $("label[for='FFirm']").text();
	var en = $("label[for='FEmail']").text();
	var pn = $("label[for='FPhone']").text();
	var tn = $("label[for='FText']").text();
	
	if(n==dn) return ShowError("Proszę wpisać swoje imię.");
	if(f==fn) return ShowError("Proszę wpisać nazwę firmy.");
	if(p==pn) return ShowError("Proszę wpisać swój numer telefonu.");
	if(e==en) return ShowError("Proszę wpisać swój email.");
	if(!checkEmail(e)) return ShowError("Proszę POPRAWNIE wpisać swój email.");
	if(t==tn) return ShowError("Proszę wpisać treść zapytania.");
	
	return true;
}

function checkEmail(x){return/^[\w\.-]+@([\w-]+\.)*[a-z]{2,4}$/.test(x)}

function ShowError(txt) {
	$.fancybox({
		'autoScale'			: true,
		'content'			: '<div id="Question"><div class="txt">'+txt+'</div></div>'
	});
	return false;
}

