/* SKRYPTY Z POPRZEDNIEJ WERSJI STRONY */

function sendMail(whom, ob) {
   ob.href = "mail" + "to" + ":" + whom + unescape("%40") + "4system.com";
}

function sendMail2(whom, subject, ob) {
    try{
        if (document.location!=null){
            document.location.href = "mail" + "to" + ":" + whom + unescape("%40") + "4system.com?subject="+subject;
        }
    }catch(e){
//            document.location.href = "mail" + "to" + ":" + whom + unescape("%40") + "4system.com?subject="+subject;
    }
}

function openNewWindow(adresURL,exWidth,exHeight,exTop,exLeft){
	var wind = window.open(adresURL,"example_window","width="+exWidth+", height="+exHeight+", top="+exTop+", left="+exLeft+", toolbar=no, menubar=no, location=no, personalbar=no, status=no, resizable=no, scrollbars=no, copyhistory=no");
}

// NOWE SKRYPTY, jQuery

function mail(whom, subject) {
	if (document.location != null){
		document.location.href = "mail" + "to" + ":" + whom + "?subject=" + subject;
	}
}

$(document).ready(function(){
		
		if ($.browser.msie && parseInt($.browser.version) < 7) {
			DD_belatedPNG.fix('#wrapper, #white_back, #main_menu, #content, #left, #right, .top_sep, #our_clients, #footer, .top_element, .news li, .min_icn, .main_icn, .ill_icn');
			
			$("#container #wrapper .menu .top_element").hover(function(){
				$(this).find("ul.sub").addClass("ie6_menu_hover");
			}, function(){
				$(this).find("ul.sub").removeClass("ie6_menu_hover");
			});
			
		}
		
		// TODO: poprawić CSS
		// leży nawet w IE8
		if ($.browser.msie){
			$('#client_city').attr('size', $('#client_city').attr('size') - 1);
			$('#client_email').attr('size', $('#client_email').attr('size') - 1);
		};

		$("a[href$='.jpg'],a[href$='.gif'],a[href$='.png']").lightBox({
			txtImage: 'Zdjęcie',
			txtOf: 'z'
		});
		
		$("a[href$='.pdf']").fancybox({'width' : 1000, 'height': 900, 'overlayShow': true, 'hideOnContentClick': false}); 

		if ($(".main_content").length > 0)
			$("#content, #left").addClass("full_text");

		$(window).load(function() {
				$("img.illustration_left").each(function(){
					var new_content = $('<div class="img_left"></div>');
					new_content.insertBefore($(this));
					new_content.html($(this));
					new_content.append('<span style="width: ' + new_content.width() + 'px ">' + $(this).attr('alt') + '</span>');
				});
				
				// wyrównanie obrazka do prawej z podpisem
				// podpis pobrany z atrybutu "alt" obrazka
				$("img.illustration_right").each(function(){
					var new_content = $('<div class="img_right"></div>');
					new_content.insertBefore($(this));
					new_content.html($(this));
					new_content.parent("p")
					.css("float", "right");
					new_content.append('<span style="width: ' + new_content.width() + 'px ">' + $(this).attr('alt') + '</span>');
				});
				
				$(".frame").each(function(){
					var user_content = $(this).html();
					var frame = '<div class="top-left"><div class="top-right"><div class="bottom-left"><div class="bottom-right"><div class="top"></div><div class="left"><div class="right"><div class="inner">' + user_content + '</div></div></div><div class="bottom"></div></div></div></div></div>';
					$(this).html(frame);
					
					if ($(this).width() > 236)
						$(this).width(236);
				});
				
				$(".frame").each(function(){
					var min_width = 0;
					$(this).find('img').each(function(){
						if ($(this).width() > min_width);
							min_width = $(this).width();
					});
					
					if (min_width > 200)
						$(this).width(min_width + 36);
					else
						$(this).width(236);
				});
				
				if ($("#left").height() > $("#right").height())
				{
					$("#right").height($("#left").height())
					
					if ($(".main_content").length > 0)
					{
						$("#content").css("background-color", '#FFFFFF');
						$("#left")
						.css("background", 'none')
						.css("padding-bottom", '0px');
						
					}
				}
				else
				{
					$("#left").height($("#right").height());
				}
		});
		
		
});
