// ver 1.0


function popUp(link,width,height) {
	prozor = window.open(link, "pictures", 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+width+',height='+height);
	prozor.focus();
}



// MULTIPLE SELECTION 

function moveOver(ponudjeni,odabrani,vrednost){
	
	var boxLength = odabrani.length;
	var selectedItem = ponudjeni.selectedIndex;
	var selectedText = ponudjeni.options[selectedItem].text;
	var selectedValue = ponudjeni.options[selectedItem].value;
	var i;
	var isNew = true;

	if (boxLength != 0) {
		for (i = 0; i < boxLength; i++) {
			thisitem = odabrani.options[i].text;

			if (thisitem == selectedText) {
				isNew = false;
				break;
 	    			}
		  }
	} 
	
	if (isNew) {
		newoption = new Option(selectedText, selectedValue, false, false);
		odabrani.options[boxLength] = newoption;
	}
	
	ponudjeni.selectedIndex=-1;
	saveMe(odabrani,vrednost)
}



function removeMe(odabrani,vrednost) {
	var boxLength = odabrani.length;
	arrSelected = new Array();
	var count = 0;

	for (i = 0; i < boxLength; i++) {
		if (odabrani.options[i].selected) {
			arrSelected[count] = odabrani.options[i].value;
		}
		count++;
	}

	var x;
	
	for (i = 0; i < boxLength; i++) {
		
		for (x = 0; x < arrSelected.length; x++) {
			if (odabrani.options[i].value == arrSelected[x]) {
				odabrani.options[i] = null;
   		}
		}
		
		boxLength = odabrani.length;
	}

	saveMe(odabrani,vrednost)
}




function saveMe(odabrani,vrednost) {
	var strValues = "";
	var boxLength = odabrani.length;
	var count = 0;
	if (boxLength != 0) {
		for (i = 0; i < boxLength; i++) {
			
			if (count == 0) {
				strValues = odabrani.options[i].value;
			} else {
				strValues = strValues + " ; " + odabrani.options[i].value;
			}
			
			count++;
   }
	}

	if (strValues.length == 0) {
		vrednost.value = strValues;
		alert("You have not made any selections");

	} else {
		//alert("Here are the values you've selected:\r\n" + strValues);
		vrednost.value = strValues;
	}
}

// MULTIPLE SELECTION 



	function cssLayer(objID, action) {
		
		var thisLayer = document.getElementById(objID);
		
		if(!thisLayer)
			return;
				
		if( thisLayer.style.display == 'block' ) {
			thisLayer.style.display = 'none';
	
		} else {
			thisLayer.style.display = 'block';
		}
	}
