function expandLine() {
	line_aa=document.getElementById('line_a');
	pic_aa=document.getElementById('pic_a');
	line_bb=document.getElementById('line_b');
	pic_bb=document.getElementById('pic_b');

	if (line_aa.style.display == "none") {
		line_aa.style.display = "";pic_aa.src="img/nic.gif";
		line_bb.style.display = "";pic_bb.src="img/nic.gif";
	} else {
		line_aa.style.display = "none";pic_aa.src="img/tree/folder.gif";
		line_bb.style.display = "none";pic_bb.src="img/tree/folder.gif";
	}
}
function openNewWindow(URLtoOpen, windowName, windowFeatures) {
	newWindow=window.open(URLtoOpen, windowName, windowFeatures);
}

function expandSemiLine(suf) {
	line_aa=document.getElementById('line'+suf);
	pic_aa=document.getElementById('pic'+suf);

	if (line_aa.style.display == "none") {
		line_aa.style.display = "";pic_aa.src="img/nic.gif";
	} else {
		line_aa.style.display = "none";pic_aa.src="img/tree/folder.gif";
	}
}

function expandSemiLinex(suf) {
	line_aa=document.getElementById('line'+suf);
	pic_aa=document.getElementById('pic'+suf);

	if (line_aa.style.display == "none") {
		line_aa.style.display = "";pic_aa.src="img/tree/xfolder-open.gif";
	} else {
		line_aa.style.display = "none";pic_aa.src="img/tree/xfolder.gif";
	}
}


//===============================================================================================
// Function opens popup to edit html field
//===============================================================================================
	function popupHtmlEditWindow(url, width, height, field, formName) {
		var top=(screen.height-height)/2;
		var left=(screen.width-width)/2;
		var Win = window.open(url + "?fieldName=" + field + "&formName=" + formName + "&txt=false","",'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',menubar=0, resizable=0, scrollbars=1, status=0,titlebar=0,toolbar=0');
		Win.creator=self;
	}

	function popupHtmlEditClassWindow(url, width, height, field, formName, className) {
		var top=(screen.height-height)/2;
		var left=(screen.width-width)/2;
		var Win = window.open(url + "?fieldName=" + field + "&formName=" + formName + "&className=" + className + "&txt=false","",'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',menubar=0, resizable=0, scrollbars=1, status=0,titlebar=0,toolbar=0');
		Win.creator=self;
	}
//===============================================================================================
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=1, scrollbars=1, status=0,titlebar=0,toolbar=0');
		popupWin.creator=self;
		return false;
}
function openStrongPopup(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;
}
//===============================================================================================
//===============================================================================================
function setAll(str_sel){	
  sel=getObjectRef(str_sel);
  var i;
  for(i=0;i<sel.length;i++){
  	sel.options[i].selected=true;
  	
  }
}
//===============================================================================================
function unSetAll(str_sel){	
  sel=getObjectRef(str_sel);
  var i;
  for(i=0;i<sel.length;i++) sel.options[i].selected=false;
}
//===============================================================================================    

//===============================================================================================
function getStyleRef(id){
	return ((isNS4) ? getObjectRef(id) : getObjectRef(id).style);
}



function validateSend(num) {
	var theone = 0;
	var pole = "odp"+num;

	var length = document.testForm.elements[pole].length;
	if (num == 2) length = length - 1; // There is one hint radio that we cannot take into account (pkrawczyk)
	
	for (i=1; i<length; i++) {
		if (document.testForm.elements[pole][i].checked == true) {
			theone=1;
		}
	}

	if (theone > 0) { 
		document.testForm.submit() 
	} else {
		alert("Proszę zaznaczyć odpowiedź.");	
	}
}

function validateSixSend() {
    var num = 6;
	var theone = 0;
	var pole = "odp"+num;
    var three = 0;
	var four = 0;
	
	if (document.testForm.elements[pole+"a"][1].checked == true) theone=1;
	if (document.testForm.elements[pole+"b"][1].checked == true) theone=1;
	if (document.testForm.elements[pole+"c"][1].checked == true) { theone=1; three=1; }
	if (document.testForm.elements[pole+"d"][1].checked == true) { theone=1; four=1; }

	if (theone == 0) { 
		alert("Proszę zaznaczyć odpowiedź.");	
	} else if (three + four == 2) {
	    alert("Proszę wybrać odpowiedzi niewykluczające się");
	} else {
		document.testForm.submit();
	}
}
