//
// Skrypty używane na każdej podstronie
//


Array.prototype.inArray = function(v) {
	for (var i = this.length - 1; i >= 0; i--) {
		if(this[i] === v) {
			return true;
		}
	}
	return false;
}

function hasClass(e, c) {
	return new RegExp("(^|\\s)" + c + "(\\s|$)").test(e.className) ? true : false;
}

// dodawanie do ulubionych (wywolywane na stronie glownej z flasha)
function ulubiona() {
	var url = document.location
	var title = document.title

	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,""); 
	} else if (window.external) {
        window.external.AddFavorite( url, title); 
    } else if(window.opera && window.print) {
        var mbm = document.createElement('a');
        mbm.setAttribute('rel','sidebar');
        mbm.setAttribute('href',url);
        mbm.setAttribute('title',title);
        mbm.click();
    } else if (document.all) {
    	window.external.AddFavorite(url, title);
    }
}

$(document).ready(function() {
	// otwieranie linkow z atrybutem rev="_blank" w nowym oknie
	$("a[@rev=_blank]").each(function(i) {
		$(this).click(function() {
			window.open(this.href);
		});
	});
		
	// dodawanie do ulubionych
	$("a.dodajDoUlubionych").click(function() {
		if (window.external) {
			window.external.AddFavorite(window.location.href, document.title);
		}
		return true;
	});
	
	var searchField = $("div#pageContent div.h2 form input.text").addClass("default_value");
	searchField.focus(function() {
		if (hasClass(this, "default_value")) {
			this.value = "";
			$(this).removeClass("default_value");
		} 
	});
});

