function foto(id, width, winheight, description){
	fotowin = window.open("", "foto", "width =" +width +",height =" + winheight +",location=no,menubar=no,directories=no,toolbar=no,scrollbars=no,resizable=no,status=no");
	fotowin.document.write("<html><head><title>foto</title></head><body leftmargin=\"0\" topmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\" marginwidth=\"0\"><img src=\"/mma_bin.php?src=mid&amp;id=" + id + "\" onclick=\"window.close();\" /><br clear=\"all\"><div style=\"color: #333333; font-size:60%; margin-left :10px; margin-right :10px; margin-top :5px; font-family: Arial;  align=\"justify\">"+ description +"</div></boby></html>");
	fotowin.document.close();
	document.body.onfocus = closeFotoWin;
}

function foto_list(i, a){
	fotowin = window.open("", "foto", "width =" + a[i][1] +",height =" + a[i][2] +",location=no,menubar=no,directories=no,toolbar=no,scrollbars=no,resizable=no,status=no");
	fotowin.document.write("<html><head><title>foto</title><script type=\"text/javascript\">var i="+i+"; var a="+stringizeArray(a)+"</script></head><body leftmargin=\"0\" topmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\" marginwidth=\"0\"><div style=\"text-align:center\"><span style=\"cursor:pointer;margin:3px;color:blue;\" onclick=\"if (i<=0) {i=a.length-1} else {i--};window.resizeTo(a[i][1],a[i][2]); document.getElementById('desc').innerHTML=a[i][4]; document.getElementById('img').src='/mma_bin.php?src=mid&amp;id='+a[i][0]+''\">nazaj</span> | <span style=\"cursor:pointer;margin:3px;color:blue;\" onclick=\"if (i>=a.length-1) {i=0} else {i++}; window.resizeTo(a[i][1],a[i][2]); document.getElementById('desc').innerHTML=a[i][4]; document.getElementById('img').src='/mma_bin.php?src=mid&amp;id='+a[i][0]+''\">naprej</span></div><img id=\"img\" src=\"/mma_bin.php?src=mid&amp;id=" + a[i][0] + "\"/><br clear=\"all\"><div id=\"desc\" style=\"color: #333333; font-size:60%; margin-left :10px; margin-right :10px; margin-top :5px; font-family: Arial;\"  align=\"justify\">"+ a[i][4] +"</div></body></html>");
	fotowin.document.close();
	document.body.onfocus = closeFotoWin;
}

function checkFilePass(passMd5, fileId, form){
	var formName = document.getElementById(form);
	var errReport = document.getElementById("err_"+fileId);
	newPassMd5 = hex_md5(formName.pass.value);
	if(newPassMd5 == passMd5){
		window.location = "/mma_bin.php?id="+fileId;
		displayNone('light_'+fileId);
		displayNone('fade');
	}else{
		errReport.innerHTML = 'Napačno geslo!';
		formName.pass.value = "";
		formName.pass.focus();
	}
	
}

function fieldFocus(formName){
	
	var form = document.getElementById(formName);
	form.pass.focus();
}

function displayBlock(el){
	if(navigator.appName == "Microsoft Internet Explorer"){
		if(el != 'fade'){
			document.getElementById(el).style.display="block";
		}
	}else{
		document.getElementById(el).style.display="block";
	}
	
}

function displayNone(el){
	document.getElementById(el).style.display="none";
}

// create a string from an array to be used inside escaped javascript code
function stringizeArray(a) {
	var len = a.length;
	var s = "[";
	for (var i = 0; i < len; i++) {
		s += "[";
		var len2 = a[i].length;
		for (var j = 0; j < len2; j++) {
			if (j == 3 || j == 4) {
				s += "'";
			}
			s += a[i][j];
			if (j == 3 || j == 4) {
				s += "'";
			}
			if (j < (len2 - 1)) {
				s += ",";
			}
		}
		s += "]";
		if (i < (len - 1)) {
			s += ",";
		}
	}
	s += "]";
	return s;
}

function closeFotoWin() {
	if(fotowin != null && !(fotowin.closed)) {
		fotowin.close();
	}
}

//mail decode
function mDec(ensl, enlsShow, addToHref, firstPartHrefOnly) {
	if ((enlsShow == undefined || enlsShow == "") && (firstPartHrefOnly == undefined || firstPartHrefOnly == "")) {
		enlsShow = ensl;
	}
	
	if (addToHref == undefined) {
		addToHref = "";
	}

	s="";
	for(i=0; i<enlsShow.length; i++) {
		n=enlsShow.charCodeAt(i);
		if (n >= 35 && n <= 126) {
			s+=String.fromCharCode((n-3));
		} else {
			s+=enlsShow.charAt(i);
		}
	}
	nslvShow = s;
	
	a="pdlowr="+ensl; 
	nslv = "";
	for(i=0; i<a.length; i++) {
		n=a.charCodeAt(i)-3;
		nslv+=String.fromCharCode(n);
	}
	if (firstPartHrefOnly == true) {
		document.write("<a class=\"email\" href=\"" + nslv + addToHref + "\">");		
	} else {
		document.write("<a class=\"email\" href=\"" + nslv + addToHref + "\">"+nslvShow+"</a>");		
	}
}

function printWindow() {
	window.open("?vie=print", "print", "width=620,height=550,location=no,menubar=no,directories=no,toolbar=no,scrollbars=yes, resizable=no,status=no");
}


function show(element) {
	if (document.getElementById) {
		// W3C standard
		var style2 = document.getElementById(element).style;
		style2.display = "block";
	} else if (document.all) {
		// old MSIE versions
		var style2 = document.all[element].style;
		style2.display = "block";
	} else if (document.layers) {
	// Netscape 4
		var style2 = document.layers[element].style;
		style2.display = "block";
	}
}


function hide(element) {
	if (document.getElementById) {
		// W3C standard
		var style2 = document.getElementById(element).style;
		style2.display = "none";
	} else if (document.all) {
		// old MSIE versions
		var style2 = document.all[element].style;
		style2.display = "none";
	} else if (document.layers) {
	// Netscape 4
		var style2 = document.layers[element].style;
		style2.display = "none";
	}
}

function showHideAll(id_select, type) {

	var cCommonDivName = "section";
	
	var arrDivs = document.getElementsByTagName(type);

	for(i = 0 ; i < arrDivs.length ; i++) {
		if (arrDivs[ i ].id.match(cCommonDivName)) {
			if(arrDivs[ i ].id == id_select){
				show(arrDivs[ i ].id);
			}else{
				hide(arrDivs[ i ].id);    
			}
		}
	}
}

function showAll(type) {
	var cCommonDivName = "section";
	
	var arrDivs = document.getElementsByTagName(type);

	for(i = 0 ; i < arrDivs.length ; i++) {
		if (arrDivs[ i ].id.match(cCommonDivName)) {
			show(arrDivs[ i ].id);
		}
	}
}

function switchOver(num) {
	document['image'+num].src = eval("image" + num + "over.src");
}

function switchOff(num)	{
	//if (num != menuHoldHiglighted) {
		document['image'+num].src = eval("image" + num + "off.src");
	//}
}

function getBrowserWidth() {
	if (window.innerWidth) {
		return window.innerWidth;
	} else if (document.documentElement && document.documentElement.clientWidth != 0) {
		return document.documentElement.clientWidth;
	} else if (document.body) {
		return document.body.clientWidth;
	}
	
	return 0;
}

function reorderModuleColumnsByRes() {
	var w = getBrowserWidth();
	var placeholder = document.getElementById("placeholder");
	var contentEntry = document.getElementById("content_entry");
	var rid = 3;
	var colWidth = 236;
	var rightColWidth = 163;
	if (w <= (240 + 3 * colWidth + rightColWidth)) {
		rid = 0; // one column
		placeholder.style.width = colWidth + 'px';
		contentEntry.style.width = 2 * colWidth + rightColWidth + 'px';
	} else if ((w > (240 + 3 * colWidth + rightColWidth)) && (w <= (240 + 4 * colWidth + rightColWidth))) {
		rid = 1; // two columns
		placeholder.style.width = 2 * colWidth + 'px';
		contentEntry.style.width = 3 * colWidth + rightColWidth + 'px';
	} else if ((w > (240 + 4 * colWidth + rightColWidth)) && (w <= (240 + 5 * colWidth + rightColWidth))) {
		rid = 2; // three columns
		placeholder.style.width = 3 * colWidth + 'px';
		contentEntry.style.width = 4 * colWidth + rightColWidth + 'px';
	} else {
		rid = 3; // four columns
		placeholder.style.width = 4 * colWidth + 'px';
		contentEntry.style.width = 5 * colWidth + rightColWidth + 'px';
	}
	reorderModuleColumns(rid);
}

function reorderModuleColumns(rid) {
	var placeholder = document.getElementById("placeholder");
	var a =
	[
		[
			['sporocila-za-bodoce-studente','sporocila-za-studente','sporocila-za-javnost','sporocila-za-zaposlene','sporocila-za-poslovne-partnerje','sporocila-za-alumne']
		],
		[
			['sporocila-za-zaposlene','sporocila-za-bodoce-studente','sporocila-za-javnost'],
			['sporocila-za-studente','sporocila-za-poslovne-partnerje','sporocila-za-alumne']
		],
		[
			['sporocila-za-bodoce-studente','sporocila-za-studente'],
			['sporocila-za-javnost','sporocila-za-zaposlene'],
			['sporocila-za-poslovne-partnerje','sporocila-za-alumne']
		],
		[
			['sporocila-za-javnost sporocila-za-bodoce-studente','sporocila-za-bodoce-studente'],
			['sporocila-za-studente','sporocila-za-zaposlene'],
			['sporocila-za-poslovne-partnerje'],
			['sporocila-za-alumne']
		]		
	];
	var i = 0;
	ourHTML = '';
	while(i<a[rid].length){
		ourHTML += '<div id="col'+(i+1)+'">';
		var j=0;
		while(j<a[rid][i].length){
			var el = document.getElementById(a[rid][i][j]);
			var elcontent = el.innerHTML;
			el.parentNode.removeChild(el);
			//el.removeNode(true); /* IE */
			//el.removeChild(el.childNodes[0]); /* FF */
			if(el.style.display == "none"){
				ourHTML += '<div class="module" id="'+a[rid][i][j]+'" style="display:none;">';
			}else{
				ourHTML += '<div class="module" id="'+a[rid][i][j]+'">';
			}
			ourHTML += elcontent;
			ourHTML += '</div>';
			j++;
		}
		ourHTML += '</div>';
		i++;
	}
	placeholder.innerHTML = ourHTML;
}
