//===============================================================================================
// przekierowuje na dana strone
//===============================================================================================
function forward(page){
	document.location.href=page;
	return false;
}
//===============================================================================================
function getObjectRef(id){
	if (isDOM) return document.getElementById(id);
	if (isIE4) return document.all[id];
	if (isNS4) return document.document.layers[id];
}
//===============================================================================================
function getStyleRef(id){
	return (isNS4 ? getObjectRef(id) : getObjectRef(id).style);
}
//===============================================================================================
//===============================================================================================
// przenosi zaznaczone opcje z jednego selecta do drugiego
// jezeli dana opcja juz sie tam znajduje to jej nie przenosi
//===============================================================================================
 function moveFrom(srcSelectName, destSelectName) {		
 	formIndex=0;
	from=document.forms[formIndex].elements[srcSelectName];
	to=document.forms[formIndex].elements[destSelectName];
	
	var fromIndex=from.selectedIndex;
	while(fromIndex>-1){
		toIndex=0;
		
		for (i=0;i<to.length;i++){
			if (to.options[i].value == from.options[fromIndex].value){
				from.options[fromIndex].selected=false;
				fromIndex=from.selectedIndex;
				if (fromIndex==-1) return false;
			}
		}
		// znalezienie pozycji w ktorej 
		// nalezy wstawic nowa opcje
		while(toIndex<to.length) {
			if (from.options[fromIndex].text>to.options[toIndex].text) {
				toIndex++;
			} else {
				break;
			}
		}
		to.options[to.length]=new Option();
		//
		for(var i=to.length-2;i>=toIndex;i--) {
			to.options[i+1].value=to.options[i].value;
			to.options[i+1].text=to.options[i].text;
		}
		to.options[toIndex].value=from.options[fromIndex].value;
		to.options[toIndex].text=from.options[fromIndex].text;
		from.options[fromIndex]=null;
		fromIndex=from.selectedIndex;
	}
}
//===============================================================================================
 function moveBack(srcSelectName, destSelectName) {		
 
 	formIndex=0;		 
	from=document.forms[formIndex].elements[srcSelectName];
	to=document.forms[formIndex].elements[destSelectName];
	
	var fromIndex=from.selectedIndex;
	while(fromIndex>-1){
		var toIndex=0;
		
		while(toIndex<to.length) {
			if (from.options[fromIndex].text>to.options[toIndex].text) {
				toIndex++;
			} else {
				break;
			}
		}
		
		var dont_add=false;
		for (i=0;i<to.length;i++){
			if (to.options[i].value == from.options[fromIndex].value){
				dont_add=true;
			}
		}
		if (!dont_add){
			to.options[to.length]=new Option();
			for(var i=to.length-2;i>=toIndex;i--) {
				to.options[i+1].value=to.options[i].value;
				to.options[i+1].text=to.options[i].text;
			}
			to.options[toIndex].value=from.options[fromIndex].value;
			to.options[toIndex].text=from.options[fromIndex].text;
		}
		from.options[fromIndex]=null;
		fromIndex=from.selectedIndex;
	}
}
//===============================================================================================
function lightUp(obj){
	obj.style.backgroundColor="#E5E7EB";
}
//===============================================================================================
function lightDown(obj){
	obj.style.backgroundColor="";
}
//===============================================================================================
// otwiera okno popup z tekstem bez scrollbara
//===============================================================================================
function openPopup(pagePath, pageWidth, pageHeight){

		var top=(screen.height - pageHeight)/2;
		var left=(screen.width-pageWidth)/2;
        var popupWin = window.open(pagePath,"",'width=' + pageWidth + ',height=' + pageHeight + ',left=' + left + ',top=' + top + ',menubar=0, resizable=0, scrollbars=0, status=0,titlebar=0,toolbar=0');
		popupWin.creator=self;
		return false;
}
//===============================================================================================
function getRealLeft(imgElem) {
	xPos = eval(getObjectRef(imgElem)).offsetLeft
	//*
	tempEl = eval(getObjectRef(imgElem)).offsetParent
	while (tempEl != null) {
		xPos += tempEl.offsetLeft
		tempEl = tempEl.offsetParent
	}
	//*/
	return xPos
}
//===============================================================================================
function getRealTop(imgElem) {

	yPos = eval(getObjectRef(imgElem)).offsetTop

	//*
	tempEl = eval(getObjectRef(imgElem)).offsetParent;
	while (tempEl != null) {
		yPos += tempEl.offsetTop
		tempEl = tempEl.offsetParent
	}
	//*/
	return yPos;
}
//===============================================================================================



