function aTarget(el, name)
{
    el.setAttribute('target', '_blank');
}

function $ (e) {
	if (typeof(e) != 'string') return e;
	if (document.getElementById) e = document.getElementById(e);
	else if (document.all) e = document.all[e];
	else e = null;
	return e;
}

function dPlay (nr, all, str) {
	
	var i;
	for (i=1; i<=all; i++) {
		if (nr == i) {
			$(str + i).style.display = 'block';
		}
		
		else {
			$(str + i).style.display = 'none';				
		}
	}
}

function showStill (txt) {
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);
	var lightboxLeft = arrayPageScroll[0];
	Element.setTop('still', lightboxTop);
	Element.setLeft('still', (arrayPageSize[0] - 420)/2);
	$('stillcontent').innerHTML = txt;
	$('overlay2').style.display = 'block';
	Element.setWidth('overlay2', arrayPageSize[0]);
	Element.setHeight('overlay2', arrayPageSize[1]);
	Element.setOpacity('overlay2', 0.5);
	$('still').style.display = 'block';
	arrayPageSize = getPageSize();
	Element.setHeight('overlay2', arrayPageSize[1]);
}

function showStillFrom (element) {
	showStill ($(element).innerHTML);
}

function unshowStill () {
	var arrayPageSize = getPageSize();
	$('still').style.display = 'none';
	$('overlay2').style.display = 'none';
	Element.setHeight('ccenter', 100);
}

function getNewHttpObject() {
    var objType = false;
    try {
        objType = new ActiveXObject('Msxml2.XMLHTTP');
    } catch(e) {
        try {
            objType = new ActiveXObject('Microsoft.XMLHTTP');
        } catch(e) {
            objType = new XMLHttpRequest();
        }
    }
    return objType;
}

//Function used to update page content with new xhtml fragments by using a javascript object, the dom, and http.
function getAXAH(url,elementContainer){
	document.getElementById(elementContainer).innerHTML = '<img src="gfx/loading2.gif" alt="ładowanie" />';
	var theHttpRequest = getNewHttpObject();
	theHttpRequest.onreadystatechange = function() {processAXAH(elementContainer);};
	theHttpRequest.open("GET", url);
	theHttpRequest.send(false);

		function processAXAH(elementContainer){
		   if (theHttpRequest.readyState == 4) {
			   if (theHttpRequest.status == 200) {
				   document.getElementById(elementContainer).innerHTML = theHttpRequest.responseText;
			   } else {
				   document.getElementById(elementContainer).innerHTML="<p><span class='redtxt'>Error!<\/span> HTTP request return the following status message:&nbsp;" + theHttpRequest.statusText +"<\/p>";
			   }
		   }
		}
}

function showRecaptcha(element) {
  Recaptcha.create("6LfV6QcAAAAAAFehwJrIoRCRCWWpwF274MZDWqUu", element, {
	theme: "blackglass", 
	callback: Recaptcha.focus_response_field});
}
