function $(obj) {
	return document.getElementById(obj);
}

function rollIn(aID) {
	aID.getElementsByTagName('img')[0].style.visibility = 'visible';
}
function rollOut(aID) {
	aID.getElementsByTagName('img')[0].style.visibility = 'hidden';
}

function openPicture(imagePath,imageWidth,imageHeight,alt,posLeft,posTop) {
	newWindow = window.open('','newWindow','width='+imageWidth+',height='+imageHeight+',left='+posLeft+',top='+posTop);
	newWindow.resizeTo(imageWidth+10,imageHeight+40);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body style="background-color:White;margin:0;" onclick="self.close()">');
	newWindow.document.write('<img src="'+imagePath+'" style="width:'+imageWidth+'px;height:'+imageHeight+'px" alt="'+alt+'">');
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}

var newWindow;
function openGallery(imgLink) {
	newWindow = window.open(imgLink.href,'newWindow','width=800,height=640,scrollbars,resizable'
			+',left='+((imgLink.ownerDocument.documentElement.clientWidth-800)*0.5)
			+',top='+((imgLink.ownerDocument.documentElement.clientHeight-640)*0.5));
	newWindow.focus();
	window.onfocus = function(){newWindow.close();};
	return false;
}


function DHTMLSelect(id) {
	var obj = new Object();

	obj.oSelect = null;
	obj.oInputName = null;
	obj.oInputId = null;
	obj.oOptions = null;

	obj.DHTMLSelect = function(id) {
		obj.oSelect = $(id);
		obj.oInputName = obj.oSelect.getElementsByTagName('input')[0];
		obj.oInputId = obj.oSelect.getElementsByTagName('input')[1];
		obj.oOptions = obj.oSelect.getElementsByTagName('div')[0];

		obj.oSelect.onmouseover = function(e) {obj.Show();};
		obj.oSelect.onmouseout = function(e) {obj.Hide();};
		obj.oInputName.readonly = true;

		var OptionsRealH = obj.oOptions.childNodes[0].clientHeight;
		if(OptionsRealH < obj.oOptions.clientHeight)
		{
			obj.oOptions.style.height = obj.oOptions.childNodes[0].clientHeight+1 + 'px';
		}
	};

	obj.Show = function() {
		obj.oOptions.style.visibility = 'visible';
	};

	obj.Hide = function() {
		obj.oOptions.style.visibility = 'hidden';
	};

	this.Change = function(id,name) {
		obj.oInputId.value = id;
		obj.oInputName.value = name;
		obj.Hide();
	};

	obj.DHTMLSelect(id);
}

function ChangeType(obj){
	if(obj.outerHTML != null) {
		obj.outerHTML='<input id="password" class="Txt" name="haslo" type="password" tabindex="102" />';
		$('password').focus();
	}
	else {
		obj.type = 'password';
		obj.value = '';
		obj.onclick = null;
		obj.onfocus = null;
		obj.focus();
	}
}

function setHttps(f) {
	if(f.loginSSL.checked) {
		f.action = f.action.replace('http://','https://');
	}
	return true;
}

function NiesmiertelnikEdytor(niesmId,blachaId,kolorId) {
	newWindow = window.open(pageUrl + '?q[s]=niesmiertelnik&id='+niesmId+'&blacha='+blachaId+'&kolor='+kolorId,'newWindow','width=600,height=330,left=100,top=100');
	newWindow.focus();
}
function NiesmiertelnikZapisz(niesmId,blachaId,wartosc) {
	oldTxt = $('com'+niesmId);
	if (blachaId==1) {
		oldTxt.value = wartosc;
	}
	else {
		oldTxt.value += "\r\n\r\n" + wartosc;
	}
}
