
window.addEvent('domready', function () {

	// (1) Nadaj wszystkich linkom <a href=""> onfocus="blur()
	$$('a').each (function (item) {
		item.addEvent('focus', function () {
			item.blur();			
		});
	})

	

	if ($chk(ns_input = $('newsletter_email'))) {
		ns_input.addEvents({
			click: function () {
				if (ns_input.value == '- adres email -')
					ns_input.value = ''
			},
			blur: function () {
				if (ns_input.value == '')
					ns_input.value = '- adres email -'
			}
		})
	}	
	
	
	
	// (4) Stworz efekt milkBox dla wszystkich elementow <a> zawierajacym w srodku <img /> w tresci podstrony
	var body_content = $('content');
	if ($chk(body_content)) {
		var links = body_content.getElements('a');
		if ($chk(links)){
			links.each(function(item) {
				if ($chk(item.getFirst('img'))) {
					
					if (!item.getProperty('rel')) 
						item.setProperty('rel', 'clearbox');
						
						
						
				}
			})
			try {
				CB_Init();	
			} catch (e) {}
			

		}
	}	
	
})



function init_icons_hints () {
	var icons = $$('.icons');
	if ($chk(icons)) {
		
		icons.each(function(it, i) {
			
			var magnify_icon = it.getElements('.icon');
			var icon_name = it.getFirst('.icon_name');
			var big_photos = $$('.big_photos');
			var array_text = new Array ("powiększ", "ściągnij")
			
			magnify_icon.each (function (item, k) {
				
				item.addEvents ({
					'mouseover': function () {
						icon_name.set('text', array_text[k])
						icon_name.fade('show')
						
					},
					'mouseout': function () {
						icon_name.fade('hide')
						icon_name.set('text', array_text[k])
					},
					'click': function () {
						
						var photo = big_photos[i].getElements("a");
						
						photo.each(function(p, j) {
							if (p.getStyle("visibility") == "visible") {
								var case_elem = item.get("class").split(" ");
								
								switch (case_elem[0]) {
									case "download_icon":
										window.open (base_href + p.get("href"), "_blank")										
										break;
									case  "magnify_icon":									
										CB_Open('href=' + base_href + p.get("href"));
										break;
								}	
								 				
							}

						})
					}
				})
			})
		})
		
	}
}

