
//spremenljivke
var isDOM      = 1;
var capable    = 1;
var isServer   = true;
var currentAtomId = 0;
var isExpanded   = false;

var imgOpened    = new Image(9,9);
imgOpened.src    = 'statika/images/minus.gif';
var imgOpenedNote    = new Image(9,9);
imgOpenedNote.src	 = 'statika/images/Kvadratek_MinusRumeni.gif';
var imgClosed    = new Image(9,9);
imgClosed.src    = 'statika/images/plus.gif';
var imgClosedNote    = new Image(9,9);
imgClosedNote.src    = 'statika/images/Kvadratek_PlusRumeni.gif';
var polje1;
var polje2;
var mywindow2;
var backgroundColor = "#d4d0c8";
var vOblikovanju = false;
var cursorPos;
var win;
var curpos;
var izvorna;

var e; 
var ta; 
var frm;
var kliklink=false;
var FotoPlay = null; //ali predvajamo ali ne
var Fototime = null; //za preklic klica
var FotoZacetek = 0;
var FotoCurrent = 0; //id trenutno prikazane slike

var vmesnicas = 4500; //milisekund med menjavo slike
var FotoNew = 0;
var elFocused =null;
var okno = null;
var zapstIzpit = Array();
var cakaj;
var glavat=0;
var glaval=0;
var menuitem=null;
var lastkaz = null;
var toolboxiNovic = Array();
var sprEC = new Array();
var meniBozadja ='';	
var toolbar=null;

window.dhx_globalImgPath="statika/Images/";
var imgmeniArr= new Array();



//spremenljivke
/*****************************************************************************/


/*****************************************************************************
Copyright (C) 2006  Nick Baicoianu

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*****************************************************************************/
//constructor for the main Epoch class (ENGLISH VERSION)
function Epoch(name,mode,targetelement,multiselect)
{
	this.state = 0;
	this.name = name;
	this.curDate = new Date();
	//alert(this.curDate);
	this.mode = mode;
	this.selectMultiple = (multiselect == true); //'false' is not true or not set at all
	
	//the various calendar variables
	//this.selectedDate = this.curDate;
	this.selectedDates = new Array();
	
	this.calendar;
	this.calHeading;
	this.calCells;
	this.rows;
	this.cols;
	this.cells = new Array();
	
	//The controls
	this.monthSelect;
	this.yearSelect;
	
	//preberemo vnaprej definiran datum v inputu, ga locimo na dan, mesec in leto, ter dodamo v array selectedDates: 
	var inputDatum = jQuery(targetelement).val();
	var inputDatumSplit = inputDatum.split (".");
    var day, month, year;
    day = parseInt(inputDatumSplit[0],10);
    month = parseInt(inputDatumSplit[1],10);
    year = parseInt(inputDatumSplit[2]);

    // Preverimo ali so podatki veljavni in po potrebi priredimo trenuten datum.
    var today;
    today = new Date();
    if (isNaN(day))
        day = today.getDate();
    if (isNaN(month))
        month = today.getMonth()+1;
    if (isNaN(year))
        year = today.getFullYear();
        
    var meseciTmp = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
    var nasDatum = new Date (meseciTmp[month-1] + ' ' + day + ' ' + year);
    this.selectedDates[0] = nasDatum;
    
	
	//standard initializations
	this.mousein = false;
	this.calConfig();
	this.setDays();
    
	this.displayYear = this.displayYearInitial;
	this.displayMonth = this.displayMonthInitial;
	
	this.createCalendar(); //create the calendar DOM element and its children, and their related objects
	
	if(this.mode == 'popup' && targetelement && targetelement.type == 'text') //if the target element has been set to be an input text box
	{
		this.tgt = targetelement;
		this.calendar.style.position = 'absolute';
		this.topOffset = this.tgt.offsetHeight; // the vertical distance (in pixels) to display the calendar from the Top of its input element
		this.leftOffset = 0; 					// the horizontal distance (in pixels) to display the calendar from the Left of its input element
		this.calendar.style.top = this.getTop(targetelement) + this.topOffset + 'px';
		this.calendar.style.left = this.getLeft(targetelement) + this.leftOffset + 'px';
		document.body.appendChild(this.calendar);
		this.tgt.calendar = this;
		this.tgt.onfocus = function () {this.calendar.show();}; //the calendar will popup when the input element is focused
		this.tgt.onblur = function () {if(!this.calendar.mousein){this.calendar.hide();}}; //the calendar will popup when the input element is focused
	}
	else
	{
		this.container = targetelement;
		this.container.appendChild(this.calendar);
	}
	
	this.state = 2; //0: initializing, 1: redrawing, 2: finished!
	this.visible ? this.show() : this.hide();
}
//-----------------------------------------------------------------------------
Epoch.prototype.calConfig = function () //PRIVATE: initialize calendar variables
{
	//this.mode = 'flat'; //can be 'flat' or 'popup'
	//ce se ne prikazujeta trenutno leto in mesec se preberejo iz inputa
	var leto1 = this.curDate.getFullYear();
	var leto2 = this.selectedDates[0].getFullYear();
	if (leto2!=leto1) {
	    this.displayYearInitial = leto2; //the initial year to display on load
    } else {
        this.displayYearInitial = leto1;
    }
	var mesec1 = this.curDate.getMonth();
	var mesec2 = this.selectedDates[0].getMonth();
	if (mesec2!=mesec1) {
	    this.displayMonthInitial = mesec2; //the initial month to display on load (0-11)
	} else {
	    this.displayMonthInitial = mesec1;
	}
	this.rangeYearLower = 2005;
	this.rangeYearUpper = 2037;
	this.minDate = new Date(2005,0,1);
	this.maxDate = new Date(2037,0,1);
	this.startDay = 1; // the day the week will 'start' on: 0(Sun) to 6(Sat)
	this.showWeeks = false; //whether the week numbers will be shown
	this.selCurMonthOnly = false; //allow user to only select dates in the currently displayed month
	this.clearSelectedOnChange = true; //whether to clear all selected dates when changing months
	
	//flat mode-only settings:
	//this.selectMultiple = true; //whether the user can select multiple dates (flat mode only)

	switch(this.mode) //set the variables based on the calendar mode
	{
		case 'popup': //popup options
			this.visible = false;
			break;
		case 'flat':
			this.visible = true;
			
			break;
	}
	this.setLang();
};
//-----------------------------------------------------------------------------
Epoch.prototype.setLang = function()  //all language settings for Epoch are made here.  Check Date.dateFormat() for the Date object's language settings
{
	this.daylist = new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat','Sun','Sun','Mon','Tue','Wed','Thu','Fri','Sat'); /*<lang:en>*/
	this.months_sh = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
	this.monthup_title = 'Next month';
	this.monthdn_title = 'Previous month';
	this.clearbtn_caption = 'Clear';
	this.clearbtn_title = 'Clear all selected dates';
	this.maxrange_caption = 'This is maximum range';
};
//-----------------------------------------------------------------------------
Epoch.prototype.getTop = function (element) //PRIVATE: returns the absolute Top value of element, in pixels
{
    var oNode = element;
    var iTop = 0;
    
    while(oNode.tagName != 'BODY') {
        iTop += oNode.offsetTop;
        oNode = oNode.offsetParent;
    }
    
    return iTop;
};
//-----------------------------------------------------------------------------
Epoch.prototype.getLeft = function (element) //PRIVATE: returns the absolute Left value of element, in pixels
{
    var oNode = element;
    var iLeft = 0;
    
    while(oNode.tagName != 'BODY') {
        iLeft += oNode.offsetLeft;
        oNode = oNode.offsetParent;        
    }
    
    return iLeft;
};
//-----------------------------------------------------------------------------
Epoch.prototype.show = function () //PUBLIC: displays the calendar
{
	this.calendar.style.display = 'block';
	this.calendar.style.zindex = '0';
	this.visible = true;
	//getById(selectPolje).style.visibility='hidden';
};
//-----------------------------------------------------------------------------
Epoch.prototype.hide = function () //PUBLIC: Hides the calendar
{
	this.calendar.style.display = 'none';
	this.visible = false;
	//getById(selectPolje).style.visibility='visible';
};
//-----------------------------------------------------------------------------
Epoch.prototype.toggle = function () //PUBLIC: Toggles (shows/hides) the calendar depending on its current state
{
	if(this.visible) {
		this.hide();
	}
	else {
		this.show();
	}
};
//-----------------------------------------------------------------------------
Epoch.prototype.setDays = function ()  //PRIVATE: initializes the standard Gregorian Calendar parameters
{
	this.daynames = new Array();
	var j=0;
	for(var i=this.startDay; i< this.startDay + 7;i++) {
		this.daynames[j++] = this.daylist[i];
	}
		
	this.monthDayCount = new Array(31,((this.curDate.getFullYear() - 2000) % 4 ? 28 : 29),31,30,31,30,31,31,30,31,30,31);
};
//-----------------------------------------------------------------------------
Epoch.prototype.setClass = function (element,className) //PRIVATE: sets the CSS class of the element, W3C & IE
{
	element.setAttribute('class',className);
	element.setAttribute('className',className); //<iehack>
};
//-----------------------------------------------------------------------------
Epoch.prototype.createCalendar = function ()  //PRIVATE: creates the full DOM implementation of the calendar
{
	var tbody, tr, td;
	this.calendar = document.createElement('table');
	
	this.calendar.setAttribute('id',this.name+'_calendar');
	this.setClass(this.calendar,'calendar');
	//to prevent IE from selecting text when clicking on the calendar
	this.calendar.onselectstart = function() {return false;};
	this.calendar.ondrag = function() {return false;};
	tbody = document.createElement('tbody');
	
	//create the Main Calendar Heading
	tr = document.createElement('tr');
	td = document.createElement('td');
	td.appendChild(this.createMainHeading());
	tr.appendChild(td);
	tbody.appendChild(tr);
	
	//create the calendar Day Heading
	tr = document.createElement('tr');
	td = document.createElement('td');
	td.appendChild(this.createDayHeading());
	tr.appendChild(td);
	tbody.appendChild(tr);

	//create the calendar Day Cells
	tr = document.createElement('tr');
	td = document.createElement('td');
	td.setAttribute('id',this.name+'_cell_td');
	this.calCellContainer = td;	//used as a handle for manipulating the calendar cells as a whole
	td.appendChild(this.createCalCells());
	tr.appendChild(td);
	tbody.appendChild(tr);
	
	//create the calendar footer
	tr = document.createElement('tr');
	td = document.createElement('td');
	td.appendChild(this.createFooter());
	tr.appendChild(td);
	tbody.appendChild(tr);
	
	//add the tbody element to the main calendar table
	this.calendar.appendChild(tbody);

	//and add the onmouseover events to the calendar table
	this.calendar.owner = this;
	this.calendar.onmouseover = function() {this.owner.mousein = true;};
	this.calendar.onmouseout = function() {this.owner.mousein = false;};
};
//-----------------------------------------------------------------------------
Epoch.prototype.createMainHeading = function () //PRIVATE: Creates the primary calendar heading, with months & years
{
	//create the containing <div> element
	var container = document.createElement('div');
	container.setAttribute('id',this.name+'_mainheading');
	this.setClass(container,'mainheading');
	//create the child elements and other variables
	this.monthSelect = document.createElement('select');
	this.yearSelect = document.createElement('select');
	var monthDn = document.createElement('input'), monthUp = document.createElement('input');
	var opt, i;
	//fill the month select box
	for(i=0;i<12;i++)
	{
		opt = document.createElement('option');
		opt.setAttribute('value',i);
		if(this.state == 0 && this.displayMonth == i) {
			opt.setAttribute('selected','selected');
		}
		opt.appendChild(document.createTextNode(this.months_sh[i]));
		this.monthSelect.appendChild(opt);
	}
	//and fill the year select box
	for(i=this.rangeYearLower;i<=this.rangeYearUpper;i++)
	{
		opt = document.createElement('option');
		opt.setAttribute('value',i);
		if(this.state == 0 && this.displayYear == i) {
			opt.setAttribute('selected','selected');
		}
		opt.appendChild(document.createTextNode(i));
		this.yearSelect.appendChild(opt);		
	}
	//add the appropriate children for the month buttons
	monthUp.setAttribute('type','button');
	monthUp.setAttribute('value','>');
	monthUp.setAttribute('title',this.monthup_title);
	monthDn.setAttribute('type','button');
	monthDn.setAttribute('value','<');
	monthDn.setAttribute('title',this.monthdn_title);
	this.monthSelect.owner = this.yearSelect.owner = monthUp.owner = monthDn.owner = this;  //hack to allow us to access this calendar in the events (<fix>??)
	
	//assign the event handlers for the controls
	monthUp.onmouseup = function () {this.owner.nextMonth();};
	monthDn.onmouseup = function () {this.owner.prevMonth();};
	this.monthSelect.onchange = function() {
		this.owner.displayMonth = this.value;
		this.owner.displayYear = this.owner.yearSelect.value; 
		this.owner.goToMonth(this.owner.displayYear,this.owner.displayMonth);
	};
	this.yearSelect.onchange = function() {
		this.owner.displayMonth = this.owner.monthSelect.value;
		this.owner.displayYear = this.value; 
		this.owner.goToMonth(this.owner.displayYear,this.owner.displayMonth);
	};
	
	//and finally add the elements to the containing div
	container.appendChild(monthDn);
	container.appendChild(this.monthSelect);
	container.appendChild(this.yearSelect);
	container.appendChild(monthUp);
	return container;
};
//-----------------------------------------------------------------------------
Epoch.prototype.createFooter = function () //PRIVATE: creates the footer of the calendar - goes under the calendar cells
{
	var container = document.createElement('div');
	
	var clearSelected = document.createElement('input');
	clearSelected.setAttribute('type','button');
	clearSelected.setAttribute('value',this.clearbtn_caption);
	clearSelected.setAttribute('title',this.clearbtn_title);
	clearSelected.owner = this;
	clearSelected.onclick = function() { this.owner.resetSelections(false);};
	container.appendChild(clearSelected);
	return container;
};
//-----------------------------------------------------------------------------
Epoch.prototype.resetSelections = function (returnToDefaultMonth)  //PRIVATE: reset the calendar's selection variables to defaults
{
	this.selectedDates = new Array();
	this.rows = new Array(false,false,false,false,false,false,false);
	this.cols = new Array(false,false,false,false,false,false,false);
	if(this.tgt)  //if there is a target element, clear it too
	{
		this.tgt.value = '';
		if(this.mode == 'popup') {//hide the calendar if in popup mode
			this.hide();
		}
	}
		
	if(returnToDefaultMonth == true) {
		this.goToMonth(this.displayYearInitial,this.displayMonthInitial);
	}
	else {
		this.reDraw();
	}
};
//-----------------------------------------------------------------------------
Epoch.prototype.createDayHeading = function ()  //PRIVATE: creates the heading containing the day names
{
	//create the table element
	this.calHeading = document.createElement('table');
	this.calHeading.setAttribute('id',this.name+'_caldayheading');
	this.setClass(this.calHeading,'caldayheading');
	var tbody,tr,td;
	tbody = document.createElement('tbody');
	tr = document.createElement('tr');
	this.cols = new Array(false,false,false,false,false,false,false);
	
	//if we're showing the week headings, create an empty <td> for filler
	if(this.showWeeks)
	{
		td = document.createElement('td');
		td.setAttribute('class','wkhead');
		td.setAttribute('className','wkhead'); //<iehack>
		tr.appendChild(td);
	}
	//populate the day titles
	for(var dow=0;dow<7;dow++)
	{
		td = document.createElement('td');
		td.appendChild(document.createTextNode(this.daynames[dow]));
		if(this.selectMultiple) { //if selectMultiple is true, assign the cell a CalHeading Object to handle all events
			td.headObj = new CalHeading(this,td,(dow + this.startDay < 7 ? dow + this.startDay : dow + this.startDay - 7));
		}
		tr.appendChild(td);
	}
	tbody.appendChild(tr);
	this.calHeading.appendChild(tbody);
	return this.calHeading;	
};
//-----------------------------------------------------------------------------
Epoch.prototype.createCalCells = function ()  //PRIVATE: creates the table containing the calendar day cells
{
	this.rows = new Array(false,false,false,false,false,false);
	this.cells = new Array();
	var row = -1, totalCells = (this.showWeeks ? 48 : 42);
	var beginDate = new Date(this.displayYear,this.displayMonth,1);
	var endDate = new Date(this.displayYear,this.displayMonth,this.monthDayCount[this.displayMonth]);
	var sdt = new Date(beginDate);
	sdt.setDate(sdt.getDate() + (this.startDay - beginDate.getDay()) - (this.startDay - beginDate.getDay() > 0 ? 7 : 0) );
	//create the table element
	this.calCells = document.createElement('table');
	this.calCells.setAttribute('id',this.name+'_calcells');
	this.setClass(this.calCells,'calcells');
	var tbody,tr,td;
	tbody = document.createElement('tbody');
	for(var i=0;i<totalCells;i++)
	{
		if(this.showWeeks) //if we are showing the week headings
		{
			if(i % 8 == 0)
			{
				row++;
				tr = document.createElement('tr');
				td = document.createElement('td');
				if(this.selectMultiple) { //if selectMultiple is enabled, create the associated weekObj objects
					td.weekObj = new WeekHeading(this,td,sdt.getWeek(),row)
				}
				else //otherwise just set the class of the td for consistent look
				{
					td.setAttribute('class','wkhead');
					td.setAttribute('className','wkhead'); //<iehack>
				}
				td.appendChild(document.createTextNode(sdt.getWeek()));			
				tr.appendChild(td);
				i++;
			}
		}
		else if(i % 7 == 0) //otherwise, new row every 7 cells
		{
			row++;
			tr = document.createElement('tr');
		}
		//create the day cells
		td = document.createElement('td');
		td.appendChild(document.createTextNode(sdt.getDate()));// +' ' +sdt.getUeDay()));
		var cell = new CalCell(this,td,sdt,row);
		this.cells.push(cell);
		td.cellObj = cell;
		sdt.setDate(sdt.getDate() + 1); //increment the date
		tr.appendChild(td);
		tbody.appendChild(tr);
	}
	this.calCells.appendChild(tbody);
	this.reDraw();
	return this.calCells;
};
//-----------------------------------------------------------------------------
Epoch.prototype.reDraw = function () //PRIVATE: reapplies all the CSS classes for the calendar cells, usually called after chaning their state
{
	this.state = 1;
	var i,j;
	for(i=0;i<this.cells.length;i++) {
		this.cells[i].selected = false;
	}
	for(i=0;i<this.cells.length;i++)
	{
		for(j=0;j<this.selectedDates.length;j++) { //if the cell's date is in the selectedDates array, set its selected property to true
			if(this.cells[i].date.getUeDay() == this.selectedDates[j].getUeDay() ) {
				this.cells[i].selected = true;
			}
		}

		this.cells[i].setClass();
	}
	//alert(this.selectedDates);
	this.state = 2;
};
//-----------------------------------------------------------------------------
Epoch.prototype.deleteCells = function () //PRIVATE: removes the calendar cells from the DOM (does not delete the cell objects associated with them
{
	this.calCellContainer.removeChild(this.calCellContainer.firstChild); //get a handle on the cell table (optional - for less indirection)
	this.cells = new Array(); //reset the cells array
};
//-----------------------------------------------------------------------------
Epoch.prototype.goToMonth = function (year,month) //PUBLIC: sets the calendar to display the requested month/year
{
	this.monthSelect.value = this.displayMonth = month;
	this.yearSelect.value = this.displayYear = year;
	this.deleteCells();
	this.calCellContainer.appendChild(this.createCalCells());
};
//-----------------------------------------------------------------------------
Epoch.prototype.nextMonth = function () //PUBLIC: go to the next month.  if the month is december, go to january of the next year
{
	
	//increment the month/year values, provided they're within the min/max ranges
	if(this.monthSelect.value < 11) {
		this.monthSelect.value++;
	}
	else
	{
		if(this.yearSelect.value < this.rangeYearUpper)
		{
			this.monthSelect.value = 0;
			this.yearSelect.value++;
		}
		else {
			alert(this.maxrange_caption);
		}
	}
	//assign the currently displaying month/year values
	this.displayMonth = this.monthSelect.value;
	this.displayYear = this.yearSelect.value;
	
	//and refresh the calendar for the new month/year
	this.deleteCells();
	this.calCellContainer.appendChild(this.createCalCells());
};
//-----------------------------------------------------------------------------
Epoch.prototype.prevMonth = function () //PUBLIC: go to the previous month.  if the month is january, go to december of the previous year
{
	//increment the month/year values, provided they're within the min/max ranges
	if(this.monthSelect.value > 0)
		this.monthSelect.value--;
	else
	{
		if(this.yearSelect.value > this.rangeYearLower)
		{
			this.monthSelect.value = 11;
			this.yearSelect.value--;
		}
		else {
			alert(this.maxrange_caption);
		}
	}
	
	//assign the currently displaying month/year values
	this.displayMonth = this.monthSelect.value;
	this.displayYear = this.yearSelect.value;
	
	//and refresh the calendar for the new month/year
	this.deleteCells();
	this.calCellContainer.appendChild(this.createCalCells());
};
//-----------------------------------------------------------------------------
Epoch.prototype.addZero = function (vNumber) //PRIVATE: pads a 2 digit number with a leading zero
{
	return ((vNumber < 10) ? '0' : '') + vNumber;
};
//-----------------------------------------------------------------------------
Epoch.prototype.addDates = function (dates,redraw)  //PUBLIC: adds the array "dates" to the calendars selectedDates array (no duplicate dates) and redraws the calendar
{
	var j,in_sd;
	for(var i=0;i<dates.length;i++)
	{	
		in_sd = false;
		for(j=0;j<this.selectedDates.length;j++)
		{
			if(dates[i].getUeDay() == this.selectedDates[j].getUeDay())
			{
				in_sd = true;
				break;
			}
		}
		if(!in_sd) { //if the date isn't already in the array, add it!
			this.selectedDates.push(dates[i]);
		}
	}
	if(redraw != false) {//redraw  the calendar if "redraw" is false or undefined
		this.reDraw();
	}
};
//-----------------------------------------------------------------------------
Epoch.prototype.removeDates = function (dates,redraw)  //PUBLIC: adds the dates to the calendars selectedDates array and redraws the calendar
{
	var j;
	for(var i=0;i<dates.length;i++)
	{
		for(j=0;j<this.selectedDates.length;j++)
		{
			if(dates[i].getUeDay() == this.selectedDates[j].getUeDay()) { //search for the dates in the selectedDates array, removing them if the dates match
				this.selectedDates.splice(j,1);
			}
		}
	}
	if(redraw != false) { //redraw  the calendar if "redraw" is false or undefined
		this.reDraw();
	}
};
//-----------------------------------------------------------------------------
Epoch.prototype.outputDate = function (vDate, vFormat) //PUBLIC: outputs a date in the appropriate format (DEPRECATED)
{
	var vDay			= this.addZero(vDate.getDate()); 
	var vMonth			= this.addZero(vDate.getMonth() + 1); 
	var vYearLong		= this.addZero(vDate.getFullYear()); 
	var vYearShort		= this.addZero(vDate.getFullYear().toString().substring(3,4)); 
	var vYear			= (vFormat.indexOf('yyyy') > -1 ? vYearLong : vYearShort);
	var vHour			= this.addZero(vDate.getHours()); 
	var vMinute			= this.addZero(vDate.getMinutes()); 
	var vSecond			= this.addZero(vDate.getSeconds()); 
	return vFormat.replace(/dd/g, vDay).replace(/mm/g, vMonth).replace(/y{1,4}/g, vYear).replace(/hh/g, vHour).replace(/nn/g, vMinute).replace(/ss/g, vSecond);
};
//-----------------------------------------------------------------------------
Epoch.prototype.updatePos = function (target) //PUBLIC: moves the calendar's position to target's location (popup mode only)
{
	this.calendar.style.top = this.getTop(target) + this.topOffset + 'px'
	this.calendar.style.left = this.getLeft(target) + this.leftOffset + 'px'
}
//-----------------------------------------------------------------------------

/*****************************************************************************/
function CalHeading(owner,tableCell,dow)
{
	this.owner = owner;
	this.tableCell = tableCell;
	this.dayOfWeek = dow;
	
	//the event handlers
	this.tableCell.onclick = this.onclick;
}
//-----------------------------------------------------------------------------
CalHeading.prototype.onclick = function ()
{
	//reduce indirection:
	var owner = this.headObj.owner;
	var sdates = owner.selectedDates;
	var cells = owner.cells;
	
	owner.cols[this.headObj.dayOfWeek] = !owner.cols[this.headObj.dayOfWeek];
	for(var i=0;i<cells.length;i++) //cycle through all the cells in the calendar, selecting all cells with the same dayOfWeek as this heading
	{
		if(cells[i].dayOfWeek == this.headObj.dayOfWeek && (!owner.selCurMonthOnly || cells[i].date.getMonth() == owner.displayMonth && cells[i].date.getFullYear() == owner.displayYear)) //if the cell's DoW matches, with other conditions
		{
			if(owner.cols[this.headObj.dayOfWeek]) 		//if selecting, add the cell's date to the selectedDates array
			{
				if(owner.selectedDates.arrayIndex(cells[i].date) == -1) { //if the date isn't already in the array
					sdates.push(cells[i].date);
				}
			}
			else										//otherwise, remove it
			{
				for(var j=0;j<sdates.length;j++) 
				{
					if(cells[i].dayOfWeek == sdates[j].getDay())
					{
						sdates.splice(j,1);	//remove dates that are within the displaying month/year that have the same day of week as the day cell
						break;
					}
				}
			}
			cells[i].selected = owner.cols[this.headObj.dayOfWeek];
		}
	}
	owner.reDraw();
};
/*****************************************************************************/
function WeekHeading(owner,tableCell,week,row)
{
	this.owner = owner;
	this.tableCell = tableCell;
	this.week = week;
	this.tableRow = row;
	this.tableCell.setAttribute('class','wkhead');
	this.tableCell.setAttribute('className','wkhead'); //<iehack>
	//the event handlers
	this.tableCell.onclick = this.onclick;
}
//-----------------------------------------------------------------------------
WeekHeading.prototype.onclick = function ()
{
	//reduce indirection:
	var owner = this.weekObj.owner;
	var cells = owner.cells;
	var sdates = owner.selectedDates;
	var i,j;
	owner.rows[this.weekObj.tableRow] = !owner.rows[this.weekObj.tableRow];
	for(i=0;i<cells.length;i++)
	{
		if(cells[i].tableRow == this.weekObj.tableRow)
		{
			if(owner.rows[this.weekObj.tableRow] && (!owner.selCurMonthOnly || cells[i].date.getMonth() == owner.displayMonth && cells[i].date.getFullYear() == owner.displayYear)) //match all cells in the current row, with option to restrict to current month only
			{
				if(owner.selectedDates.arrayIndex(cells[i].date) == -1) {//if the date isn't already in the array
					sdates.push(cells[i].date);
				}
			}
			else										//otherwise, remove it
			{
				for(j=0;j<sdates.length;j++)
				{
					if(sdates[j].getTime() == cells[i].date.getTime())  //this.weekObj.tableRow && sdates[j].getMonth() == owner.displayMonth && sdates[j].getFullYear() == owner.displayYear)
					{
						sdates.splice(j,1);	//remove dates that are within the displaying month/year that have the same day of week as the day cell
						break;
					}
				}
			}
		}
	}
	owner.reDraw();
};
/*****************************************************************************/
//-----------------------------------------------------------------------------
function CalCell(owner,tableCell,dateObj,row)
{
	this.owner = owner;		//used primarily for event handling
	this.tableCell = tableCell; 			//the link to this cell object's table cell in the DOM
	this.cellClass;			//the CSS class of the cell
	this.selected = false;	//whether the cell is selected (and is therefore stored in the owner's selectedDates array)
	this.date = new Date(dateObj);
	this.dayOfWeek = this.date.getDay();
	this.week = this.date.getWeek();
	this.tableRow = row;
	
	//assign the event handlers for the table cell element
	this.tableCell.onclick = this.onclick;
	this.tableCell.onmouseover = this.onmouseover;
	this.tableCell.onmouseout = this.onmouseout;
	
	//and set the CSS class of the table cell
	this.setClass();
}
//-----------------------------------------------------------------------------
CalCell.prototype.onmouseover = function () //replicate CSS :hover effect for non-supporting browsers <iehack>
{
	this.setAttribute('class',this.cellClass + ' hover');
	this.setAttribute('className',this.cellClass + ' hover');
};
//-----------------------------------------------------------------------------
CalCell.prototype.onmouseout = function () //replicate CSS :hover effect for non-supporting browsers <iehack>
{
	this.cellObj.setClass();
};
//-----------------------------------------------------------------------------
CalCell.prototype.onclick = function () 
{
	//reduce indirection:
	var cell = this.cellObj;
	var owner = cell.owner;
	if(!owner.selCurMonthOnly || cell.date.getMonth() == owner.displayMonth && cell.date.getFullYear() == owner.displayYear)
	{
		if(owner.selectMultiple == true)  //if we can select multiple cells simultaneously, add the currently selected cell's date to the selectedDates array
		{
			if(!cell.selected) //if this cell has been selected
			{
				if(owner.selectedDates.arrayIndex(cell.date) == -1) {
					owner.selectedDates.push(cell.date);
				}
			}
			else		
			{
				var tmp = owner.selectedDates; // to reduce indirection
				//if the cell has been deselected, remove it from the owner calendar's selectedDates array
				for(var i=0;i<tmp.length;i++)
				{
					if(tmp[i].getUeDay() == cell.date.getUeDay()) {
						tmp.splice(i,1);
					}
				}
			}
		}
		else //if we can only select one cell at a time
		{
			owner.selectedDates = new Array(cell.date);
			if(owner.tgt) //if there is a target element to place the value in, do so
			{
				owner.tgt.value = owner.selectedDates[0].dateFormat();
				if(owner.mode == 'popup') {
					owner.hide();
				}
			}
		}
		owner.reDraw(); //redraw the calendar cell styles to reflect the changes
	}
};
//-----------------------------------------------------------------------------
CalCell.prototype.setClass = function ()  //private: sets the CSS class of the cell based on the specified criteria
{
	if(this.selected) {
		this.cellClass = 'cell_selected';
	}
	else if(this.owner.displayMonth != this.date.getMonth() ) {
		this.cellClass = 'notmnth';	
	}
	else if(this.date.getDay() > 0 && this.date.getDay() < 6) {
		this.cellClass = 'wkday';
	}
	else {
		this.cellClass = 'wkend';
	}
	
	if(this.date.getFullYear() == this.owner.curDate.getFullYear() && this.date.getMonth() == this.owner.curDate.getMonth() && this.date.getDate() == this.owner.curDate.getDate()) {
		this.cellClass = this.cellClass + ' curdate';
	}

	this.tableCell.setAttribute('class',this.cellClass);
	this.tableCell.setAttribute('className',this.cellClass); //<iehack>
};
/*****************************************************************************/
Date.prototype.getDayOfYear = function () //returns the day of the year for this date
{
	return parseInt((this.getTime() - new Date(this.getFullYear(),0,1).getTime())/86400000 + 1);
};
//-----------------------------------------------------------------------------
Date.prototype.getWeek = function () //returns the day of the year for this date
{
	return parseInt((this.getTime() - new Date(this.getFullYear(),0,1).getTime())/604800000 + 1);
};
/*function getISOWeek()
{
	var newYear = new Date(this.getFullYear(),0,1);
	var modDay = newYear.getDay();
	if (modDay == 0) modDay=6; else modDay--;
	
	var daynum = ((Date.UTC(this.getFullYear(),this.getMonth(),this.getDate(),0,0,0) - Date.UTC(this.getFullYear()),0,1,0,0,0)) /1000/60/60/24) + 1;
	
	if (modDay < 4 ) {
	    var weeknum = Math.floor((daynum+modDay-1)/7)+1;
	}
	else {
	    var weeknum = Math.floor((daynum+modDay-1)/7);
	    if (weeknum == 0) {
	        year--;
	        var prevNewYear = new Date(this.getFullYear(),0,1);
	        var prevmodDay = prevNewYear.getDay();
	        if (prevmodDay == 0) prevmodDay = 6; else prevmodDay--;
	        if (prevmodDay < 4) weeknum = 53; else weeknum = 52;
	    }
	}
	
	return + weeknum;
}*/
//-----------------------------------------------------------------------------
Date.prototype.getUeDay = function () //returns the number of DAYS since the UNIX Epoch - good for comparing the date portion
{
	return parseInt(Math.floor((this.getTime() - this.getTimezoneOffset() * 60000)/86400000)); //must take into account the local timezone
};
//-----------------------------------------------------------------------------
Date.prototype.dateFormat = function(format)
{
	if(!format) { // the default date format to use - can be customized to the current locale
		format = 'd.m.Y';
	}
	LZ = function(x) {return(x < 0 || x > 9 ? '' : '0') + x};
	var MONTH_NAMES = new Array('Januar','Februar','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
	var DAY_NAMES = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
	format = format + "";
	var result="";
	var i_format=0;
	var c="";
	var token="";
	var y=this.getFullYear().toString();
	var M=this.getMonth()+1;
	var d=this.getDate();
	var E=this.getDay();
	var H=this.getHours();
	var m=this.getMinutes();
	var s=this.getSeconds();
	var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
	// Convert real this parts into formatted versions
	var value = new Object();
	//if (y.length < 4) {y=''+(y-0+1900);}
	value['Y'] = y.toString();
	value['y'] = y.substring(2);
	value['n'] = M;
	value['m'] = LZ(M);
	value['F'] = MONTH_NAMES[M-1];
	value['M'] = MONTH_NAMES[M+11];
	value['j'] = d;
	value['d'] = LZ(d);
	value['D'] = DAY_NAMES[E+7];
	value['l'] = DAY_NAMES[E];
	value['G'] = H;
	value['H'] = LZ(H);
	if (H==0) {value['g']=12;}
	else if (H>12){value['g']=H-12;}
	else {value['g']=H;}
	value['h']=LZ(value['g']);
	if (H > 11) {value['a']='pm'; value['A'] = 'PM';}
	else { value['a']='am'; value['A'] = 'AM';}
	value['i']=LZ(m);
	value['s']=LZ(s);
	//construct the result string
	while (i_format < format.length) {
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		if (value[token] != null) { result=result + value[token]; }
		else { result=result + token; }
		}
	return result;
};
/*****************************************************************************/
Array.prototype.arrayIndex = function(searchVal,startIndex) //similar to array.indexOf() - created to fix IE deficiencies
{
	startIndex = (startIndex != null ? startIndex : 0); //default startIndex to 0, if not set
	for(var i=startIndex;i<this.length;i++)
	{
		if(searchVal == this[i]) {
			return i;
		}
	}
	return -1;
};




// These scripts were originally found on cooltype.com.
// Modified 01/01/1999 by Tobias Ratschiller for linuxapps.com

// Modified 7th June 2000 by Brian Birtles for Mozilla 5.0
// compatibility for phpMyAdmin

// Rewritten and put in a libray 2nd May 2001 by Loďc Chapeaux

// Test passed with:
// - Mozilla 0.8.1, 0.9.0, 0.9.1, 0.9.2 for Windows (js enabled
//    & disabled)
// - IE5, 5.01, 5.5 for Windows
// - Netscape 4.75 for Windows

// Test failed (crappy DOM implementations) with:
// - Opera 5.02 for windows: 'getElementsByTagName' is unsupported
// - Opera 5.10 to 5.12 for windows, Opera 5+ for Linux: 'style.display' can't
//   be changed
// - Konqueror 2+: 'style.display' can't be changed 



/**
 * Do reloads the frame if the window has been resized under Netscape4+
 *
 * @access  private
 */
function reDo() {
  if (innerWidth != origWidth || innerHeight != origHeight)
    location.reload(true);
} // end of the 'reDo()' function

/**
 * Positioned element resize bug under NS4+
 */

/**
 * Gets the id of the first collapsible room
 *
 * @param  string  the name of the first collapsible room
 *
 * @return  integer  the index number corresponding to this room
 *
 * @access  public
 */
function nsGetIndex(el) {
  var ind       = null;
  var theLayers = document.layers;
  var layersCnt = theLayers.length;
  for (var i = 0; i < layersCnt; i++) {
    if (theLayers[i].id == el) {
      ind = i;
      break;
    }
  }
  return ind;
} // end of the 'nsGetIndex()' function


/**
 * Positions layers under NS4+
 *
 * @access  public
 */
function nsArrangeList() {
  if (firstInd != null) {
    var theLayers = document.layers;
    var layersCnt = theLayers.length;
    var nextY     = theLayers[firstInd].pageY + theLayers[firstInd].document.height;
    for (var i = firstInd + 1; i < layersCnt; i++) {
      if (theLayers[i].visibility != 'hide') {
        theLayers[i].pageY = nextY;
        nextY              += theLayers[i].document.height;
      }
    }
  }
} // end of the 'nsArrangeList()' function


/**
 * Expand databases at startup
 *
 * @access  public
 */
function nsShowAll() {
  var theLayers = document.layers;
  var layersCnt = theLayers.length;
  for (i = firstInd; i < layersCnt; i++) {
    theLayers[i].visibility = 'show';
  }
} // end of the 'nsShowAll()' function


/**
 * Collapses databases at startup
 *
 * @access  public
 */
function initIt()
{
  if (!capable || !isServer)
    return;

  if (isDOM) {

    var tempColl    = document.getElementsByTagName('DIV');
    var tempCollCnt = tempColl.length;
    for (var i = 0; i < tempCollCnt; i++) {
		if (tempColl[i].className == 'zamik') {
			tempColl[i].style.display = 'none';	
		}
    }
  } // end of the DOM case
} // end of the 'initIt()' function


/**
 * Collapses/expands a database when the user require this to be done
 *
 * @param  string  the  name of the room to act on
 * @param  boolean whether to expand or to collapse the database content
 *
 * @access  public
 */
function expandBase(el, unexpand)
{
	 if (!capable)
    return;

	
  if (isDOM) {
    var whichEl = document.getElementById(el + 'Parent');
    var whichCh = document.getElementById(el + 'Child');
    var whichIm = document.getElementById(el + 'Img');
    
    if (whichEl==null) return;
    
    var ime;
    var prvi = true;
    var kaj = "none";
    if (whichCh) kaj = whichCh.style.display;
    if (kaj=='none') {kaj='block';} else {kaj='none';}

	initIt();
    
    while (whichEl!=null) {

		if (whichCh) whichCh.style.display  = kaj;
		if (whichIm && whichCh) {
			if (kaj!='none') 
			{
				if ((whichIm.src != null)&&(whichIm.src.indexOf('Rumeni')!=-1))
					whichIm.src = imgOpenedNote.src;
				else whichIm.src = imgOpened.src;
			}
			else {
				if ((whichIm.src != null)&&(whichIm.src.indexOf('Rumeni')!=-1))
					whichIm.src = imgClosedNote.src;
				else whichIm.src = imgClosed.src;
			}
		}
			
/*		if (whichEl.style.display == 'none' && whichIm) {
		whichEl.style.display  = 'block';
		whichIm.src            = imgOpened.src;
		}
		else if (unexpand && prvi) {
		whichEl.style.display  = 'none';
		whichIm.src            = imgClosed.src;
		}
*/	    //alert(whichEl.id);
		whichCh = whichEl.parentNode;
		//alert(whichCh.id);
		whichEl = null;
		if (whichCh!=null) {
			ime = whichCh.id;
			whichIm = document.getElementById(ime.replace("Child","Img"));
			whichEl = document.getElementById(ime.replace("Child","Parent"));
			prvi = false;
			kaj = 'block';
		}
	}    
  } // end of the DOM case
} // end of the 'expandBase()' function

function SetValue(val) {
	var o;
    var tempColl = document.getElementsByName('ans');
    var tempCollCnt = tempColl.length;
    for (var i = 0; i < tempCollCnt; i++) {
		o = tempColl[i];
		if (o.type=="checkbox") {
			ar = val.split(",");
			for (var j = 0; j < ar.length; j++) {
				if (o.value==ar[j]) o.checked = true;
			}
		}
		if (o.type=="radio") if (o.value==val) o.checked = true;
		if (o.type=="text") o.value = val;
		if (o.type=="textarea") o.innerText = val;
	}
	return(true);
}

function slika_odstani_sirino(e) {
	//alert(e.id);
	var obj = e.id;
	//alert(obj);
	var j;
	var o = document.getElementById(obj);
	for(i=0;i<=o.document.images.length-1;i++) {
		var pic = o.document.images[i];
		if(pic.attributes['odstrani'] && pic.attributes['odstrani'].value == 'da')
		{
			pic.removeAttribute("width");
			pic.removeAttribute("style");
			pic.removeAttribute("odstrani");
		}
	}
}

function slika_odstani_sirinoFCK() {
    alert('dela'); /*
	//alert(e.id);
	var obj = e.id;
	//alert(obj);
	var j;
	var o = document.getElementById(obj);
	for(i=0;i<=o.document.images.length-1;i++) {
		var pic = o.document.images[i];
		if(pic.attributes['odstrani'] && pic.attributes['odstrani'].value == 'da')
		{
			pic.removeAttribute("width");
			pic.removeAttribute("style");
			pic.removeAttribute("odstrani");
		}
	}
	*/
}

function slika_obdelaj() {
	var j;

for(i=0;i<=document.images.length-1;i++) {
	if(document.images[i].id == "raw" && (document.forms("frm1") != null || document.forms("frmspr") != null))
	{
		var pic = document.images[i];
		var izvor = pic.src;
		//alert(izvor);
		var sid = frm.spletaj_id.value;
		j = izvor.lastIndexOf('statika');
		k = izvor.lastIndexOf('novice');
		l = izvor.lastIndexOf('/');
		if (j >= 0) {
			izvor = izvor.substr(j);
		} 
		else if (k > 0) {
			izvor = izvor;
			//izvor = 'show.aspx?xid=WBT:X:DOWNLOAD&file=/'+sid+izvor;
		}
		else if(l > 0) {
			izvor = izvor.substr(l);
			//izvor = 'objekti/'+sid+izvor;
			izvor = 'nogzip.aspx?xid=WBT:X:DOWNLOAD&file=/'+sid+izvor;
		}
		//alert(izvor);
		pic.removeAttribute("id");
		pic.removeAttribute("width");
		pic.removeAttribute("height");
		pic.removeAttribute("ondragend");
		pic.removeAttribute("onmouseout");
		pic.src = izvor;
	}
}

var obj;
var link;
for(i=0;i<=document.links.length-1;i++)
{
	obj = document.links[i];
	if (obj!=null) {
		link = obj.href;
		j = link.lastIndexOf('objekti');
		if (j>0) obj.href = link.substr(j);
	}
}
}
//*********************************************
//             DELO Z SLIKAMI
//*********************************************
/*  
za odstrel
function restart() {
    insertAtCursor(polje2,"["+SRCslike+"]");
    mywindow.close();
}

function restart2() {
    insertAtCursor(polje2,SRCslike);
}
*/
// odpremo okno
function newWindow2() {
	if(polje2 == null) 
	{
		alert(_b2lj);
	}
}
function newWindow() {
	if(polje2 == null) 
	{
		alert(_b2lk);
	} 
	else
	{
		mywindow =open('show.aspx?obj=WBTobjekt&d=T_slike','myname','location=no, menubar=no, width=600,height=400,scrollbars=yes,status=yes,resizable=yes');
		mywindow.location.href = 'show.aspx?obj=WBTobjekt&d=T_slike';
		if (mywindow.opener == null) mywindow.opener = self;
	}
}

function insertAtCursor(polje, vrednost) {
//IE support
	if (document.selection) {
		polje.focus();
		sel = document.selection.createRange();
		sel.text = vrednost;
	}
	//MOZILLA/NETSCAPE support
	else if (polje.selectionStart || polje.selectionStart == '0') {
		var startPos = polje.selectionStart;
		var endPos = polje.selectionEnd;
polje.value = polje.value.substring(0, startPos)+ vrednost + polje.value.substring(endPos, polje.value.length);
	} else {
		polje.value += vrednost;
	}
}

/* menda za odstrel
function Vstavi(srcSlike) {
	opener.SRCslike = srcSlike;
	//opener.field = fld;
    opener.restart();
    self.close;
}
function Vstavi2(srcSlike) {
	opener.SRCslike = srcSlike;
	//opener.field = fld;
    opener.restart2();
    self.close;
}
*/
//*********************************************
//             KONEC DELO Z SLIKAMI
//*********************************************

//*********************************************
//                 EDITOR
//*********************************************
//var idEdit = '';

function dw(niz)
{
// frma.debug.value += niz + '\n\r';
}

function urediP(ar,start,stop) {

	var ods = -1;
	var inTD = 0;
	var TDstart = -1;

	var s = "";
	for(i=start;i<=stop;i++) s+=ar[i];
	//dw("not:"+s);

	for(i=start;i<=stop;i++) {
		s = ar[i];
		if (s.substring(0,3)=="<TD") {
			if (inTD==0) TDstart = i;		
			inTD += 1;
		}
		if (s.substring(0,4)=="</TD") {
			inTD -= 1;
			if ((inTD==0) && (TDstart>=0)) {
				urediP(ar,TDstart+1,i-1);
				TDstart = -1;
			}
		}
		if (inTD==0) {
			if (s.substring(0,2)=="<P") {
				if (ods>=0) ar[i-1] += "</P>";
				ods = i;
			}
			if ((i==start) && (s.substring(0,2)!="<P")) {
				ar[i] = "<P>"+ar[i];
				ods = i;
			}
			if (s.substring(0,3)=="</P") ods = -1;
		}
	}
	if (ods>=0) ar[stop] += "</P>";

	s = "";
	for(i=start;i<=stop;i++) s+=ar[i];
	//dw("ven:"+s);	
}




function BreakToArray(h) {
	var n,i,s,ar;
	
	ar = new Array();
	n = 0;

	regExWS = /\S/;
	regEx = /<[^>]*>/ig;
	i = h.search(regEx);
	while (i>=0) {
		if (i>0) {
			s = h.substring(0,i);
			if (s.match(regExWS))		// vzamemo samo tiste, ki imajo kaksen nonWhithe character
				ar[n++] = s;
			h = h.substring(i);
		} else {
			arm = h.match(regEx);
			ar[n++] = arm[0];
			h = h.substring(arm[0].length);
		}
		i = h.search(regEx);
	}
	ar[n++] = h;
	return ar;
}


function oblikuj(slog,tag) {
//frm.debug.value ="";
// preden karkoli naredimo podelamo slike
	//dw("START "+ new Date());
	slika_obdelaj();
	var regEx,ar;
	//var e = document.getElementById(id_editorja);
	//if(e==null) dw('Nimam idja editorja!');
	//dw(vOblikovanju);	
	if (vOblikovanju) return(false);
	if (e.innerHTML=="") return(false);
	//dw('before underlinie');
	//dw(e.innerHTML);
	vOblikovanju = true;
	setTimeout("vOblikovanju = false;",500);

	document.forms[0](e.id).document.execCommand("underline");
	var h = e.innerHTML;
	//dw('after underlinie');
	//dw(h);
	if (h.search(/<U>/)<0) {
		try {
			cursorPos.collapse();
			cursorPos.pasteHTML("<U></U>");
		} catch (err){
		}
		h = e.innerHTML;
	}
	if (h.search(/<U>/)<0) return;
	
	var i,n;
	//dw("Pred arrayem "+ new Date());
	ar = new Array();
	n = 0;

	regExWS = /\S/;
	regEx = /<[^>]*>/ig;
	i = h.search(regEx);
	var s;
	while (i>=0) {
		if (i>0) {
			s = h.substring(0,i);
			if (s.match(regExWS))		// vzamemo samo tiste, ki imajo kaksen nonWhithe character
				ar[n++] = s;
			h = h.substring(i);
		} else {
			arm = h.match(regEx);
			ar[n++] = arm[0];
			h = h.substring(arm[0].length);
		}
		i = h.search(regEx);
	}
	ar[n++] = h;
//dw("Konec array "+ new Date());
	// for(i=0;i<ar.length;i++) dw(ar[i]);
//dw("Start for: "+ new Date());	
	var ods=-1,span=-1,spannivo=0,curposset=false,j,ss,i2,i3,tablestart=-1,rowstart=-1;
	for(i=0;i<ar.length;i++) {
	
		s = ar[i];
		if (s.substring(0,5)=="<FONT") ar[i]="";
		if (s.substring(0,6)=="</FONT") ar[i]="";
		if (s.substring(0,2)=="<P") ods = i;
		if (s.substring(0,3)=="</P") ods = -1;
		if (s.substring(0,5)=="<SPAN") {
			if (s.search('class='+slog)>0) {
				span = i;  // imamo zacetni tag, če ga bomo kaj rabili 
				spannivo = 1;
				//dw("EVO");
			} else {
				if (spannivo>0) spannivo++;	// gre za en drug span class, pomembno zaradi gnezdenja	
			}
		}
		if (s.substring(0,6)=="</SPAN") spannivo--;
		if (s.substring(0,6)=="<TABLE") tablestart = i;
		if (s.substring(0,7)=="</TABLE") tablestart = -1;
		if (s.substring(0,3)=="<TR") rowstart = i;
		if (s.substring(0,4)=="</TR") rowstart = -1;

		if (s.substring(0,2)=="<U") {
			ar[i] = "";
			if ((tag=="P") && (ods>=0)) {
				ar[ods] = '<P class='+slog+'>';
			} else if (tag=="SPAN") {
				if (spannivo>0) {  // potem izklopimo obliko
					ar[span] = "";
					for(j=i+1;j<ar.length;j++) {
						if (ar[j].substring(0,6)=="</SPAN") {
							spannivo--;
							if (spannivo==0) ar[j] = "";
							if (spannivo<=0) break;
						}
					
					}
				} else {
					i2 = i;
					for(j=i+1;j<ar.length;j++) {
						if (ar[j].substring(0,3)=="</U") {
							i2 = j;
							break;
						}
					}
					if (i<i2-1) {
						ar[i] = "<SPAN class="+slog+">";
						ar[j] = "</SPAN>";
					}
				}
			} else if ((tag=="PIC") && (ods>=0)) {
				for(j=ods+1;j<ar.length;j++) {
					if (ar[j].substring(0,4)=="<IMG") {
/*						s = ar[j];
						i2 = s.search("align");
						if (i2>=0) {
							ar[j] = s.substring(0,i2);
							s = s.substring(i2);
							i2 = s.search(" ");
							if (i2>s.search("/")) i2 = s.search("/");
							ar[j] += s.substring(i2);
						}*/
						ar[j] = "<IMG align="+slog+" "+ar[j].substring(4);
						//dw(ar[j]);
						break;
					}
				}
			} else if ((tag=="BOX") && (ods>=0)) {
				//dw(ar[ods]);
                ar[ods] += "[opomba tip="+slog+"]"+_b2ll+" [/opomba]";
				//dw("---------");
				//dw(ar[ods]);
			} else if (tag=="TAB") {
				if (slog=="new") {
					if (tablestart>=0) {
						i2 = 1;
						for(j=tablestart+1;j<ar.length;j++) {
							if (ar[j].substring(0,6)=="<TABLE") break;
							if (ar[j].substring(0,7)=="</TABLE") break;
							if (ar[j].substring(0,3)=="<TR") {
								if (i2==1) {
									ar[j] = "<TR class=tabH1>";
								} else if (i2%2==0) {
									ar[j] = "<TR class=tabTR1>";
								} else {
									ar[j] = "<TR class=tabTR2>";
								}
								i2++;
							}
						}					
					} else {
						ar[i] = "<table border=1><tr><td>";
						//dw(ar[i]);
						for(j=i+1;j<ar.length;j++) {
							if (ar[j].substring(0,3)=="</U") {
								ar[j] = "&nbsp;</td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td></tr></table>"
								//dw(ar[j]);
								break;
							}
						}
					}
				} else if ((slog=="rowadd") && (tablestart>=0) && (rowstart>=0)) {
					s = "";
					i2 = -1;
					for(j=rowstart;true;j++) {
						if (ar[j].substring(0,3)=="<TD") s += "<TD>&nbsp;</TD>";
						if (ar[j].substring(0,7)=="</TABLE)") break;
						if ((j>rowstart) && (ar[j].substring(0,3)=="<TR")) break;
						i2 = j;
						if (ar[j].substring(0,4)=="</TR") break;
					}
					if (i2>=0) ar[i2] += "<TR>"+s+"</TR>";
				} else if ((slog=="rowsub") && (tablestart>=0) && (rowstart>=0)) {
					for(j=rowstart;true;j++) {
						if (ar[j].substring(0,7)=="</TABLE)") break;
						if ((j>rowstart) && (ar[j].substring(0,3)=="<TR")) break;
						if (ar[j].substring(0,4)=="</TR") {
							ar[j] = "";
							break;
						}
						ar[j] = "";
					}
				} else if ((slog=="coladd") && (tablestart>=0) && (rowstart>=0)) {
					i2 = 0;
					for(j=rowstart;j<i;j++)
						if (ar[j].substring(0,3)=="<TD") i2++;
					i3 = 0;
					for(j=tablestart+1;true;j++) {
						if (ar[j].substring(0,3)=="<TR") i3=0;
						if (ar[j].substring(0,3)=="<TD") i3++;
						if (ar[j].substring(0,7)=="</TABLE") break;
						if (ar[j].substring(0,6)=="<TABLE") break;
						if ((ar[j].substring(0,4)=="</TD") && (i3==i2)) ar[j] += "<TD>&nbsp;</TD>";
					}				
				} else if ((slog=="colsub") && (tablestart>=0) && (rowstart>=0)) {
					i2 = 0;
					for(j=rowstart;j<i;j++)
						if (ar[j].substring(0,3)=="<TD") i2++;
					i3 = 0;
					for(j=tablestart+1;true;j++) {
						if (ar[j].substring(0,3)=="<TR") i3=0;
						if (ar[j].substring(0,3)=="<TD") i3++;
						if (ar[j].substring(0,7)=="</TABLE") break;
						if (ar[j].substring(0,6)=="<TABLE") break;
						if (i2==i3) ar[j] = "";
					}				
				}
			}
			if (!curposset) ar[i] = "##CURSOR_HERE##"+ar[i];
			curposset = true;
			
		}
		if (s.substring(0,3)=="</U") ar[i] = "";
	//
	}
	//dw("Konec for: "+ new Date());
	//dw("Start uredip : "+ new Date());
	//nato pa preverimo še P je. Začne se z P, in dodamo manjkajoče	
	urediP(ar,0,ar.length-1);	
	//dw("End uredip : "+ new Date());
	s = "";
	for(i=0;i<ar.length;i++) s+=ar[i];
	e.innerHTML = s;
	//dw(s.length);
	//dw("--------");

	rng = document.selection.createRange();
	if(rng.findText("##CURSOR_HERE##")) {
		rng.text="";
		rng.select();
	}

}


function clearOblika() {
if(cursorPos.htmlText=="") {alert(_b2lm);return; }
document.forms[0](e.id).document.execCommand("underline");
	var h = e.innerHTML;

	if (h.search(/<U>/)<0) {
		try {
			cursorPos.collapse();
			cursorPos.pasteHTML("<U></U>");
		} catch (err){
		}
		h = e.innerHTML;
	}

	var noviH = h;
	var str,regExWS,regEx,i,n;
	n = 0;
	//regEx = /<[^>]*>.*<U>.*<\/U>.*<[^>]*>/ig;
	regEx = /<P>.*<U>.*<\/U>.*<\/P>/ig;
	i = h.search(regEx);
	while (i>=0) {
		arm = h.match(regEx);
		str = arm[0];
		var strstari = str;
		var strnovi = str;
		
		var j= str.indexOf("<");

		while(j>=0) {

			k = str.indexOf(">");

			var tag=str.substring(0,k);

			if(tag.substring(0,2) == "<P") {
				strnovi=strnovi.replace(tag,"<P");
			}
			
			if(tag.indexOf("<SPAN")>=0) {
				var s_span = tag.indexOf("<SPAN");
				var cel_span = tag.substring(s_span);
				strnovi=strnovi.replace(cel_span+">" ,"");
			}
			if(tag.indexOf("</SPAN")>=0) {
				strnovi=strnovi.replace("</SPAN>","");
			}
			if(tag.indexOf("<FONT")>=0) {
				var s_span = tag.indexOf("<FONT");
				var cel_span = tag.substring(s_span);
				strnovi=strnovi.replace(cel_span+">" ,"");
			}
			if(tag.indexOf("</FONT")>=0) {
				strnovi=strnovi.replace("</FONT>","");
			}
			if(tag.indexOf("<B")>=0) {
				var s_span = tag.indexOf("<B");
				var cel_span = tag.substring(s_span);
				strnovi=strnovi.replace(cel_span+">" ,"");
			}
			if(tag.indexOf("</B")>=0) {
				strnovi=strnovi.replace("</B>","");
			}
			if(tag.indexOf("<STRONG")>=0) {
				strnovi=strnovi.replace("<STRONG>","");
			}
			if(tag.indexOf("</STRONG")>=0) {
				strnovi=strnovi.replace("</STRONG>","");
			}			
			if(tag.indexOf("<I")>=0) {
				var istart = tag.indexOf("<I");
				var nov1 = tag.substring(istart)
				if(nov1.substring(0,4) != "<IMG") {
					var s_span = tag.indexOf("<I");
					var cel_span = tag.substring(s_span);
					strnovi=strnovi.replace(cel_span+">" ,"");
					dw("strnovi " + strnovi);
				}
			}
			if(tag.indexOf("</I")>=0) {
				strnovi=strnovi.replace("</I>","");
			}
			if(tag.indexOf("<EM")>=0) {
				strnovi=strnovi.replace("<EM>","");
			}
			if(tag.indexOf("</EM")>=0) {
				strnovi=strnovi.replace("</EM>","");
			}
			str = str.substring(k+1);
			j=str.indexOf("<");

		}
		noviH = noviH.replace(strstari,strnovi);	
		h = h.substring(arm[0].length);
		i = h.search(regEx);
	}
	noviH = noviH.replace(/<U>/g,"");
	noviH = noviH.replace(/<\/U>/g,"");
	e.innerHTML = noviH;	
}

//*********************************************
//             KONEC EDITOR
//*********************************************
//*********************************************
//             ZACETEK OPOMBE
//*********************************************

function saveCursorPos(){
	if (vOblikovanju) return(false);
	try {
		cursorPos=document.selection.createRange().duplicate();
	} catch(err) {alert(err);}
}

function link(target)
{
	range = document.selection.createRange();
	oznaceni = range.htmlText;
	//dw('--- link ----');
	//dw(oznaceni);

	if(oznaceni)
	{
		url = prompt(_b2lh,' ');
		title = prompt(_b2li,' ');
		if(url)
		{
			if(target)
			{
				cursorPos.pasteHTML("<a class=povezavaAtomfa target=\"" + target + "\" href=\""+url+"\" title=\""+title+"\">"+oznaceni+"</a>");
				//dw("<a class=povezavaAtomfa target=\"" + target + "\" href=\""+url+"\">"+oznaceni+"</a>");
			}
			else
			{
				cursorPos.pasteHTML("<a class=povezavaAtoma href=\""+url+"\" title=\""+title+"\">"+oznaceni+"</a>");
				//dw("<a class=povezavaAtoma href=\""+url+"\">"+oznaceni+"</a>");
			}
		}
	}
}

//*********************************************
//             KONEC OPOMBE
//*********************************************

function ShowAr(ar,pos,img,ia,ip) {
	
	for(i=0;i<ar.length;i++) {
		ar[i].style.display='none';
		img[i].src = ip[i];	
	}
	if(id_boxa!=pos) {
		ar[pos].style.display='inline';
		img[pos].src = ia[pos];
		id_boxa= pos;
	} else {
		id_boxa = -1;
	}	
}

function ChangeImageBtn(img,izbira) {
	var i = "";
	i = img.src;
	if (izbira) {
		i = i.substr(0,i.length-4)+"_izbira.gif";
	} else {
		i = i.replace("_izbira","");
	}
	img.src = i;
}

function ChangeImageBtn0(img, izbira) {
	var i = "";
	var imgsrc = "";
	if(img.src.lastIndexOf("/plus") > 0 ) {
	    imgsrc = img.src.substr(0,img.src.lastIndexOf("/") + 1);
	    
	    if(izbira) imgsrc += "plus_izbira.gif";
	    else imgsrc += "plus.gif";
	
	    if (img.src != imgsrc) img.src = imgsrc;
	}
}

//function ChangeImageBtn(img) {
//	var i = "";
//	i = img.src;
//	if (izbira) {
//		i = i.substr(0,i.length-4)+"_izbira.gif";
//	} else {
//		i = i.replace("_izbira","");
//	}
//	img.src = i;
//}

function ChangeStyle(obj,stil) {
	obj.className = stil;
}
		
	
/*
function flash_drop() {
	if(window.event.dataTransfer.getData("text") != null) {
		window.event.returnValue = false;
		saveCursorPos();
		cursorPos.pasteHTML("<SPAN class='flashmovie' id=" + window.event.dataTransfer.getData("text")+ " style='WIDTH:100px; HEIGHT:100px;'>Flash movie</SPAN>");
	}
}*/

function object_dragstart(id) {
	window.event.dataTransfer.setData("Text", id);
}

/**/
function object_drop()
{
	podatki = window.event.dataTransfer.getData("Text");
	if(podatki != null) {
	tip = podatki.substr(0,1);
	window.event.returnValue = false;
		if(document.forms["frm"] != null)
		{
			saveCursorPos();
			switch(tip)
			{
				case 'f': cursorPos.pasteHTML("<SPAN class='flashmovie' id=" + podatki + ">Flash movie</SPAN>"); break
			}
		}
		if(document.forms["frmspr"] != null)
		{
			switch(tip)
			{
				case 'i': 
					prilepi = '['+podatki.substr(1)+']';
					if(polje2!=null)
					{
						polje2.value += prilepi;
					}
				break
			}
		}
	}
	//slika();
}

//***** Prenos pojma iz slovarja v editor ****
function prenospojma(slovar_id,pojem_slo,enoalidrugo) {
	win = window.parent;
	win.opener.focus();
	win.opener.document.getElementById('edit').focus();
	curpos = win.opener.document.selection.createRange().duplicate();
	var pojem = curpos.text;
	pojem = pojem.replace(/^\s*|\s*$/g,"");
	var endspace="";
	if(pojem != curpos.text)
		endspace = " ";
	if(enoalidrugo)
		curpos.pasteHTML("<span class='slovar' id=dic" + slovar_id + ">" + pojem + "</span>" + endspace);
	else
	{
		curpos.pasteHTML(pojem + endspace + "<span class='slovar_razlaga' id=dic" + slovar_id + ">+</span>");
	}
}

/* Enter proži submit forme */
function entsub(event,ourform)
{
	if (event && event.keyCode == 13)
		ourform.submit();
	else
		return true;
}
/* Enter prestavi fokus na podano polje (element) */
function entGo2El(event,el) {
    if (event && event.keyCode == 13) {
        getById(el).focus();
        return false;
    }
    else return true;
}

/* Enter proži funkcijo*/
function entfunc(event, func) {
    if (event && event.keyCode == 13) {
        func();
        return false;
    }
    else return true;
}
// funkcija se klice na editorju ob kliku na gumb shrani
function before_save()
{
	slika_obdelaj();
	//var e = document.getElementById(id_editorja);
	//if(e==null) dw('Nimam idja editorja!');
	//var ta = document.getElementById(id_ta);
	//if(ta==null) dw('Nimam idja hidden polja!');

	ta.value=e.innerHTML;
	var sas = document.getElementById('submitandsave');
	var i= sas.value;

	if(frm.atom_id.value==0) {
		frm.submitandsave.value=1;
		frm.target='';
	}
	else if(i!=2){
		frm.submitandsave.value=0;
		frm.target='wndsave';
		var wsave = document.getElementsByName('wndsave');
		wsave[0].style.display = 'inline';

	}else {frm.target='';}	
	frm.submit();
}
// funkcija se klice na editorju ob kliku na gumb shrani!
function before_saveandclose()
{
	slika_obdelaj();
	//var e = document.getElementById(id_editorja);
	if(e==null) dw(_b2lf);	
	//var ta = document.getElementById(id_ta);
	if(ta==null) dw(_b2lg);
	frm.submitandsave.value=1;
	ta.value=e.innerHTML;
	frm.target='';
	frm.submit();
}
function showHide(elementID)
{if (capable) {expandBase(elementID, true); return false;}}


function iskanje(ev)
{	
	var fo =document.getElementById('fiskanje'); 
	var io =document.getElementById('iniz'); 
	fo.niz.value=io.value; 
	if(fo.niz.value.length >0) { 
		return entsub(ev,fo); 
	}
	
}

function submitiskanje() {

	var fo = document.getElementById('fiskanje'); 
	var io = document.getElementById('iniz'); 
	fo.niz.value=io.value; 
	if(fo.niz.value.length >0) { 
		return fo.submit(); 
	}
}

function toolbarshow(element_id,show) {
	var o = document.getElementById(element_id);
	if(o){
		if(show==1)	 {o.style.visibility='visible';}
		if(show==0)	o.style.visibility='hidden';
	}
}
function initeditor(id_e,id_ta,id_frm)
{
	dw("initeditor");
	frm = document.forms[id_frm];
	if(frm==null) { dw("Init frm spodletel"); alert("Init frm error");}
	ta = document.getElementById(id_ta);
	if(ta==null) { dw("Init ta spodletel"); alert("Init ta error");}
	e = document.getElementById(id_e);
	if(e==null) { dw("Init e spodletel"); alert("Init e error");}
	void(0);
}



function onLoadVprasanje()
{
	var o1 = document.getElementById("stodgovorov");
	var ve = document.getElementById("vprasanje");
	var vta = document.getElementById("vprasanje_ta");
	if(vta!="") ve.innerHTML = vta.value;
	var i= o1.value;

	for(j=1;j<=i;j++)
	{
		var odg = document.getElementById("odg"+j);
		
		var ta = document.getElementById("odg_ta"+j);
		odg.innerHTML = ta.value;
	}
}

function showDIV(id,w) {
	dw("showDIV");
	if(!id) return;
	var div1 = document.getElementById(id);
		dw("showDIV4");

	if(w == 1)
	{
		if(toolbar!=null) document.getElementById(toolbar).style.display= 'none';
		div1.style.display= 'block';
		toolbar=id;
	}	
	if(w == 0)
		div1.style.display= 'none';
}
function show(id) {
	if(!id) return;
	var div1 = document.getElementById(id);

	if(div1.style.display == 'none')
		div1.style.display = 'block';
	else
		div1.style.display = 'none';
}	
function showInline(id) {
	if(!id) return;
	var div1 = getById(id);

	if(div1.style.display == 'none' || div1.style.display == '')
		div1.style.display = 'inline';
	else
		div1.style.display = 'none';
}

function show3(id) {
	if(!id) return;
	var o = getById(id);
	if(o) o.style.display = '';
}	

function oznaciVse(field) {
if(field.length) {
	for (i = 0; i < field.length; i++) {
	    var tdo = field[i].parentNode;
	    var tro = tdo.parentNode;
	    if(tro.style.display != 'none') field[i].checked = true ;
	}
} else {
	    field.checked = true;
}
}

function odznaciVse(field) {
if(field.length) {
	for (i = 0; i < field.length; i++)
		field[i].checked = false ;
} else
	field.checked = false;
}

function entsub_chat(event,ourform)
{
	if (event && event.keyCode == 13) {
		ourform.submit();
		setTimeout('document.chatfrm.reset()',500);
	}
	else
		return true;
}

/* MOTIVACIJSKA VPRAŠANJA */
function ShowAnswer(tip,vprasanje_id) {
	var odgovorPravilen = 0;
	document.getElementById('Pravilen').style.display = 'none';
	document.getElementById('Nepravilen').style.display = 'none';
	var ajax_odg = "";
	var pravilnih=0;
	if(tip == 'vec' || tip == 'en') {
		var oznacenih =0;		
		for (var i = 0; i<document.mot.elements.length; i++) {
		
			if ((document.mot.elements[i].name.indexOf('odg_'+vprasanje_id) > -1)) {
				var odg = document.mot.elements[i];
				
				var obr = document.getElementById('obrazlozitev'+odg.value); //div z obrazložitvijo
				if(obr) obr.style.display = 'none'; //skrijemo
				if(odg.checked) {
					ajax_odg += '&odg_'+vprasanje_id+'=' + odg.value;					
					var predpreverjanjem = pravilnih;
					for(k=0;k<aoP.length;k++)  {
						if(aoP[k]== odg.value) pravilnih++;
					}
					//odgovor je označen vendar ni pravilen, prikažemo obrazložitev
					if(predpreverjanjem == pravilnih && obr) obr.style.display = '';
				oznacenih++;
				} else {
				    // če odgovor ni označen pa je med pravilnimi, , prikažemo obrazložitev
				   	for(k=0;k<aoP.length;k++)  {
						if(aoP[k] == odg.value && obr) obr.style.display = '';
					} 
				}
			}
		}
		if(pravilnih == aoPLen && oznacenih == pravilnih) {
			var odgp = getById('Pravilen');
			odgp.style.display = 'block';
			odgovorPravilen = 1;	
		}
		else {
			document.getElementById('Nepravilen').style.display = 'block';
			odgovorPravilen = 0;
		}	
	}
	
	if(tip=='tekst') {
        var obr = getById('obrazlozitev' + vprasanje_id); //div z obrazložitvijo
        if(obr) obr.style.display = 'none'; //skrijemo
		for (var i = 0; i<document.mot.elements.length; i++) {
			if ((document.mot.elements[i].name.indexOf('odg_'+vprasanje_id) > -1)) {
				var odg = document.mot.elements[i];
				
				for(k=0;k<aoP.length;k++)  {
					var odg_value='';
					if(aoP[k]!= null)  {
						odg_arr = BreakToArray(aoP[k]);
						for(k1=0;k1<odg_arr.length;k1++) {
							if(odg_arr[k1].length != 0 && odg_arr[k1].indexOf('<')<0) {
								odg_value += odg_arr[k1];
							}
						}
					}
					var odgovor_value = odg.value;
					odgovor_value = odgovor_value.replace(/^\s*|\s*$/g,""); // javascript trim
					odg_value = odg_value.replace(/^\s*|\s*$/g,""); // javascript trim
					//ajax_odg += '&odg_'+vprasanje_id+'=' + odg_value;
					//ajax_odg += '&odg_'+vprasanje_id+'=' + odgovor_value;
					if(odg_value.toLowerCase() == odgovor_value.toLowerCase() && odgovor_value != "") 
					{
					    ajax_odg = '&odg_'+vprasanje_id+'=' + odgovor_value;
					    pravilnih++;
					}
					else
					{
					    ajax_odg = '&odg_'+vprasanje_id+'=' + odgovor_value;
					}
					    
				}		
				if(pravilnih>0) {
					getById('Pravilen').style.display = 'block';
					odgovorPravilen = 1;
				}
				else {
					getById('Nepravilen').style.display = 'block';
					odgovorPravilen = 0;
					if(obr) obr.style.display = ''; //prikažemo obrazložitev
				}
			}
		}
	}
	if(tip == 'tekstarea') {
	var odg = '';
			for (var i = 0; i<document.mot.elements.length; i++) {
				if ((document.mot.elements[i].name.indexOf('odg_'+vprasanje_id) > -1)) {
					odg = document.mot.elements[i];
				}
			}
		//ajax_odg += '&odg_'+vprasanje_id+'=' + odg.value;		
		ajax_odg += '&odg_'+vprasanje_id+'=' + odgovor_value;
	}
	
	// shranjevanje odgovora
	
	var at_id = 0; 
	if(document.mot.elements['at_id'])
		at_id = document.mot.elements['at_id'].value;

	if(document.mot.elements['atom_id'])
		at_id = document.mot.elements['atom_id'].value;	

	//alert(at_id);
	if(at_id <=0) alert(_b2ln);
	ShraniOdgovor(vprasanje_id,odgovorPravilen,ajax_odg,at_id);

	return;
}
/* END MOTTIVACIJSKA VPRAŠANJA*/
/* START ZAPIRANJE in ODPIRANJE MENIJA*/
function menu2(w,s) {
  var s = "show.aspx?xid=WBT:X:ECShrani&"+w+"="+s;
  var uec = getById('userEC');
  if(uec) uec.src=s;
  return true;
} 

function menu(w,s) {
  setTimeout('menu2(\''+w+'\',\''+s+'\')',500);
  return true;
} ;

function CloseAllOpenOne(ar, arN, pos,barva1) {
	if(kliklink) return false;

	for(i=0;i<ar.length;i++) {
		var aro = document.getElementById(ar[i]);
		var arNo = document.getElementById(arN[i]);
		if(aro) {aro.style.display='none';}
		if(arNo) {arNo.style.backgroundColor = '#ffffff';}
	}
	
	meniBozadja = '#ffffff';
	//alert(meniBozadja);
	if(pos==null || pos == -1) return;
	
	var aro = document.getElementById(ar[pos]);
	var arNo = document.getElementById(arN[pos]);
	
	//alert('odprt: ' + odprtiMeni + ' pos: ' + pos);
	
	if(pos==odprtiMeni) {
		if(aro) aro.style.display='none';
		if(arNo) arNo.style.backgroundColor = '#ffffff';
		odprtiMeni = -1;
	} else {
		//alert(pos);
		if(aro) aro.style.display='block';
		if(arNo) arNo.style.backgroundColor = barva1;
		meniBozadja = barva1;
		odprtiMeni = pos;
	}
}

function ChangeBack(obj,color) {
	meniBozadja = obj.style.backgroundColor;
	obj.style.backgroundColor = color;
}
function RestoreBack(obj) {
	 obj.style.backgroundColor = meniBozadja;
}

function show1(id) {
	if(!id) return;

	var div1 = document.getElementById(id);
	var img1 = document.getElementById(id+'.img');
	if(div1==null || img1== null) return;
	if(div1.style.display == 'none') {
		img1.src = imgmeniArr[1];
		div1.style.display = 'block';
		menu(id,1);
	} else {
		div1.style.display = 'none';
		img1.src = imgmeniArr[0];
		menu(id,0);
	}
}
/* END ZAPIRANJE in ODPIRANJE MENIJA*/
function odpriokno(link,imeokna,parametri)
{
	window.open(link, imeokna, parametri); 
}
function odprioknoNorm(link,imeokna)
{
	if(imeokna)
	   window.open(link, imeokna);
	else
	   window.open(link);
}


function natisni(url)
{
	window.open('show.aspx?xid=WBT:X:Natisni&amp;url='+url,'tiskanje');
}

function PM_send(field) {
	var fuid='';
	for (i = 0; i < field.length; i++) {
		if(field[i].checked == true) fuid += field[i].value + ',';
	}
	//alert(fuid);
	if(fuid.length > 0) 
		fuid = fuid.substring(0,fuid.length-1);
	document.location.href = "show.aspx?xid=WBT:X:ZasebnoSporociloVecim&skupina_id=&fuid="+fuid;
}

function getById(id) {
        if (document.getElementById)
                return document.getElementById(id);
        return document.all[id];
}

function alternate_show_meni(ar, par) {
	if(kliklink) return false;
	//alert(par);						
	for(var o in ar) {				// vse razen najvisjih (nimajo nadrejenga) skrijemo
		var obj = getById(o);	
		if (obj) {
			if ((ar[o]!=par) && ar[o]) obj.style.display='none';
		}
	}

	alternate_show_tr(ar,par);	// otroke prikazemo ali skrijemo
		
	stars = ar[par];	// starsi so prikazani vedno
	while (stars) {
		var obj = getById(stars);
		if (obj) obj.style.display='';
		stars = ar[stars];
	}
	
	stars = ar[par];	// bratje in sestre so tudi prikazani
	for(var o in ar) {
		if (ar[o]==ar[par]) {
			var obj = getById(o);
			if (obj) obj.style.display='';
		}
	}
		
}


function alternate_show_tr(ar,par) {
    alternate_show_tr_force(ar,par,'x');
}

function toggleBlock(id) {
	var obj = getById(id);
	if (obj) {
		show = obj.style.display;
		if (show=="none") obj.style.display = "";
		else obj.style.display = "none";
	
	}
	var h = "?hash="+(Math.random()*1000); 
	var o = jQuery('#'+id+' iframe');
	if(o) {
	    var osrc = o.attr("src");
	    if(osrc.indexOf('?') > -1) osrc = osrc.substr(0, osrc.indexOf('?'));
	    else osrc = o.attr("src");
	    o.attr("src",osrc+h);
	}
	return(false);
}

function alternate_show(id1,id2) {
	var obj1 = getById(id1);
	var obj2 = getById(id2);

	if (obj1 && obj2) {
		show = obj1.style.display;
		obj1.style.display = obj2.style.display;
		obj2.style.display = show;
	}
}


function hideall(ar)
{
  for(var o in ar) {
	var obj = getById(o);
	if (obj) {
		obj.style.display='none';
	}
  }	
}

function showall(ar)
{
  for(var o in ar) {
  
	var obj = getById(o);
	if (obj) {
		obj.style.display='block';
	}
  }	
}

function showallinline(ar)
{
  for(var o in ar) {
  
	var obj = getById(o);
	if (obj) {
		obj.style.display='inline';
	}
  }	
}

function PocistiWord()
{

	var whtm = e.innerHTML;
	whtm = whtm.replace(/<o:p>\s*<\/o:p>/g, "") ;
	whtm = whtm.replace(/<o:p>.*?<\/o:p>/g, "&nbsp;") ;
	
	// Remove mso-xxx styles.
	whtm = whtm.replace( /\s*mso-[^:]+:[^;"]+;?/gi, "" ) ;

	// Remove margin styles.
	whtm = whtm.replace( /\s*MARGIN: 0cm 0cm 0pt\s*;/gi, "" ) ;
	whtm = whtm.replace( /\s*MARGIN: 0cm 0cm 0pt\s*"/gi, "\"" ) ;

	whtm = whtm.replace( /\s*TEXT-INDENT: 0cm\s*;/gi, "" ) ;
	whtm = whtm.replace( /\s*TEXT-INDENT: 0cm\s*"/gi, "\"" ) ;

	whtm = whtm.replace( /\s*TEXT-ALIGN: [^\s;]+;?"/gi, "\"" ) ;

	whtm = whtm.replace( /\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi, "\"" ) ;

	whtm = whtm.replace( /\s*FONT-VARIANT: [^\s;]+;?"/gi, "\"" ) ;

	whtm = whtm.replace( /\s*tab-stops:[^;"]*;?/gi, "" ) ;
	whtm = whtm.replace( /\s*tab-stops:[^"]*/gi, "" ) ;

	// Remove FONT face attributes.

	whtm = whtm.replace( /\s*face="[^"]*"/gi, "" ) ;
	whtm = whtm.replace( /\s*face=[^ >]*/gi, "" ) ;

	whtm = whtm.replace( /\s*size=[^ >]*/gi, "" ) ;
	whtm = whtm.replace( /\s*FONT-FAMILY:[^;"]*;?/gi, "" ) ;


	// Remove Class attributes
	whtm = whtm.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;

	// Remove styles.

	whtm = whtm.replace( /<(\w[^>]*) style="([^\"]*)"([^>]*)/gi, "<$1$3" ) ;
	
	whtm = whtm.replace( /<(\w[^>]*) size="([^\"]*)"([^>]*)/gi, "<$1$3" ) ;
	whtm = whtm.replace( /<(\w[^>]*) color="([^\"]*)"([^>]*)/gi, "<$1$3" ) ;

	// Remove empty styles.
	whtm =  whtm.replace( /\s*style="\s*"/gi, '' ) ;
	
	whtm = whtm.replace( /<SPAN\s*[^>]*>\s*&nbsp;\s*<\/SPAN>/gi, '&nbsp;' ) ;
	
	whtm = whtm.replace( /<SPAN\s*[^>]*><\/SPAN>/gi, '' ) ;
	
	// Remove Lang attributes
	whtm = whtm.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
	
	whtm = whtm.replace( /<SPAN\s*>(.*?)<\/SPAN>/gi, '$1' ) ;
	
	whtm = whtm.replace( /<FONT\s*>(.*?)<\/FONT>/gi, '$1' ) ;

	// Remove XML elements and declarations
	whtm = whtm.replace(/<\\?\?xml[^>]*>/gi, '') ;
	
	// Remove Tags with XML namespace declarations: <o:p></o:p>
	whtm = whtm.replace(/<\/?\w+:[^>]*>/gi, "") ;
	
	whtm = whtm.replace( /<H\d>\s*<\/H\d>/gi, '' ) ;

	whtm = whtm.replace( /<H1([^>]*)>/gi, '<span class="naslov">' ) ;
	whtm = whtm.replace( /<H2([^>]*)>/gi, '<p>' );
	whtm = whtm.replace( /<H3([^>]*)>/gi, '<p>' );
	whtm = whtm.replace( /<H4([^>]*)>/gi, '<p>' )
	whtm = whtm.replace( /<H5([^>]*)>/gi, '<p>' )
	whtm = whtm.replace( /<H6([^>]*)>/gi, '<p>' )
	whtm = whtm.replace( /<H7([^>]*)>/gi, '<p>' )

	whtm = whtm.replace( /<\/H1>/gi, '</span>' ) ;
	whtm = whtm.replace( /<\/H2>/gi, '</p>' ) ;
	whtm = whtm.replace( /<\/H3>/gi, '</p>' ) ;
	whtm = whtm.replace( /<\/H4>/gi, '</p>' ) ;
	whtm = whtm.replace( /<\/H5>/gi, '</p>' ) ;
	whtm = whtm.replace( /<\/H6>/gi, '</p>' ) ;
	whtm = whtm.replace( /<\/H7>/gi, '</p>' ) ;
	
	
	whtm = whtm.replace( /<(U|I|STRIKE)>&nbsp;<\/\1>/g, '&nbsp;' ) ;

	// Remove empty tags (three times, just to be sure).
	whtm = whtm.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;
	whtm = whtm.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;
	whtm = whtm.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;

	e.innerHTML=whtm;
	//return false;
}

function ajax_test(s) {
var url = 'show.aspx';  
var data = 'xid=WBT:X:AJAX&par=0&q='+s;


var func = function() 
{
    if (processReqChange(req)) {
		var res = req.responseText.substring(0,3);
		var id = req.responseText.substring(3);
		if (res=='OK-') {
			var d = getById("el"+id+"Parent");
			if (d) {
			    currentAtomId = id;
				if (lastkaz) lastkaz.className = "kaz2";
				d.className = "kaz3";
				lastkaz = d;
				expandBase("el"+id,true);
				d.scrollIntoView(false);
			}
			var gr = getById("napgraf");
			if (gr) {
				var ar;
				var gurl = gr.src;
				ar = gurl.split("&");
				gurl = ar[0]+"&"+(new Date()).getTime();
				gr.src = gurl;
			}
		}
		// alert(req.responseText);
	}
}
var req = loadXMLDoc( 'POST', url + "?" + data, "", func);
}

function shraniEC(w,s) {
	var url='show.aspx?xid=WBT:X:ECShrani&' + w + '=' + s;

	var func = function() {
		 if(processReqChange(req)) {
		   var res = req.responseText.substring(0,3);
		   if(res == 'GIF') {
			if(s == 0)
				alert(_b2ld);
			else
				alert(_b2le);
		   }
		 }
	}
	var req = loadXMLDoc('GET',url,null,func);
}

function GETurl(url,message) {
	var func = function() {
		if(processReqChange(req)) {
			var res = req.responseText.substring(0,3);
			alert(message);
		}
	}
	var req = loadXMLDoc('GET',url,null,func);
}


function show2(id,polid) {
    if(menuitem) {menuitem.style.display = 'none';}
	if(!id) return;
	clearTimeout(cakaj);

	var div1 = getById(id);
	menuitem=div1;
	div1.style.display = 'block';
	//div1.style.top=glavat; 
	//div1.style.left=glaval;
}

function hide2(id) {
	if(!id) return;
	var div1 = getById(id);
	if(div1)
		div1.style.display = 'none';
}

function skrij(id,cas) {
	cakaj = setTimeout('hide2("'+id+'")',cas);
}

/* funkcija nastavi fokus najprej na okno ki se odpira, potem pa še na element(polje) */
function fokusokna(okno) {
    okno.focus();    
    if($('username')) $('username').focus();
    if($('naziv')) $('naziv').focus();
}

/*FOTOGALERIJA*/
//show
function FotoShow() {
	if(FotoPlay && FotoPlay == 1) {	
		if(FotoNew != 0)
			FotoCurrent = FotoNew;
		FotoGet(FotoCurrent);
		
		Fototime = setTimeout('FotoShow()',vmesnicas);
	}
}


// gre na strežnik po novo sliko 
function FotoGet(FotoCurrent) {
	var url='show.aspx?xid=WBT:X:FotoGShowNext&o=' +  FotoCurrent;
	
	var func1 = function() {
		 if(processReqChange(req)) {
		   var res = req.responseText;
		  // alert(res);
		   if(res != null && res != "")
		   {
				var ret = new Array();
				ret = res.split(";");
				//alert(ret[0] + " - " + ret[1]);
				var slika = getById('obj'+FotoCurrent);
				if(slika) {
					slika.id = 'obj' + ret[0];
					slika.src = 'nogzip.aspx?xid=WBT:X:Download&amp;file='+ret[1];
					var FGopis = getById('opis');
					FGopis.innerHTML = ret[2];
					//alert(ret[2]);
					//alert('id: ' + slika.id + '  - ' + slika.src);
					FotoNew = ret[0];	
				}
				
		   } else {
				FotoStop();
		   }
		 }
	}
	var req = loadXMLDoc('GET',url,null,func1);
}

// ustavimo predvajanje
function FotoStop() {
	clearTimeout(Fototime);
	FotoPlay = 0;
}

//začnemo predvajanje
function FotoStart() {
	FotoPlay = 1;
	FotoShow();
}

// naslednja slika
function FotoNaprej() {
	FotoStop();
	//alert('pred: ' + FotoNew);
	if(FotoNew != 0)
		FotoCurrent = FotoNew;
		
	FotoGet(FotoCurrent);
}
/*END FOTOGALERIJA*/

function dohideshow(tf) {
	if(tf) {
		showallinline(zapstIzpit);
	} else {
		hideall(zapstIzpit);
	}
}

function katDodajNovo(id0,id1) {
  var el0 = getById(id0);
  var el1 = getById(id1);

  if(el0.value == -1) {
    el0.style.display = 'none';
    el1.style.display = '';
  }
}

function AttributiBeforeSubmit() {
  var el1 = getById('kat1');
  if(el1.value != -1) getById('kat1input').value = el1.value;

  var el2 = getById('kat2');
  if(el2.value != -1) getById('kat2input').value = el2.value;

  var el3 = getById('kat3');
  if(el3.value != -1) getById('kat3input').value = el3.value;

  var el4 = getById('tipenote');
  if(el4.value != -1) getById('tipenoteinput').value = el4.value;
  
  var el5 = getById('nahajalisc');
  if(el5.value != -1) getById('nahajaliscinput').value = el5.value;  
}

function prikazi(id) {
povezavaizberi('','');
  for(var i=1; i<=5;i++) {
    hide2('pov'+i);
    
    if(id == i) show3('pov'+i);
    if(id == 1) {
		show3('pov11');
		show3('pov12');
		show3('pov13');
		show3('pov10');
    } else {
        hide2('pov11');
		hide2('pov12');
		hide2('pov13');            
		hide2('pov10');
    }
  }
}

function povezavaizberi(tip,vrednost) {
	var p = getById('povezava');
	var v = getById('vrednost');
	p.value=tip;
	v.value=vrednost;
	if(tip == 'spletaj_id' && vrednost == 0)
	{
	   	hide2('pov10');
	   	hide2('pov13');
        hide2('pov11');
        hide2('pov12');
	}
}

function spletajselect(va) {
	var o = getById('atom_id');
	if(o) {
	if(va <= 0) 
		o.disabled=true;
	else {
		o.disabled=false; 
		//todo: filanje atoma;
		
	}
	}
}

function onpovezavasubmit(skupina_id, urnik_id, spletaj_id) {
	//alert(skupina_id + ' - ' + urnik_id + ' - ' + spletaj_id);
	//TODO: preverjanje parametrov funkcije
	var p = getById('povezava');
	var v = getById('vrednost');
	//alert('p: ' + p.value + ' v: ' + v.value);
		if((v.value > 0) || (v.value == -1) || (p.value == null) || (p.value == '')) {
		    var fo = getById('frmpovezave');
		    if(fo) fo.submit();
		    //alert('forma sumbit');
		    return;
	    }
	//alert('redirect');
	switch(p.value) 
	{
		case 'spletaj_id': window.location="?xid=WBT:X:VnosSpletaja&spletaj_id=0&frompovezave=1&urnik_id="+urnik_id+"&skupina_id="+skupina_id;
			break;
		case 'forum_id': window.location="?xid=WBT:X:VnosForuma&forum_id=0&frompovezave=1&urnik_id="+urnik_id+"&skupina_id="+skupina_id;
			break;
		case 'novica_id': window.location="?xid=W:X:NovicaUredi&nid=&frompovezave=1&urnik_id="+urnik_id+"&skupina_id="+skupina_id;
			break;
		case 'test_id': window.location="?xid=WBT:X:UrejanjeIzpitov&test_id=0&spletaj_id=&frompovezave=1&urnik_id="+urnik_id+"&skupina_id="+skupina_id;
			break;
		case 'test_idk': window.location="?xid=WBT:X:PregledVprasanjL&test_id=0&spletaji=" + getById('spletaji').value + "&mode=2";
			break;			
	}	
}

/* script za analizo kje je user kliknil */

var url4senddata = '';
var maxUserY = 0;

function alertSize() {
var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode' 
    myHeight = document.documentElement.clientHeight;
  } else if( document.body &&( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight ;
  }
  
  myVisina = myHeight;
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }

    if (myHeight+scrOfY>maxUserY) maxUserY = myHeight+scrOfY;

//url4senddata = 'show.aspx?xid=WBT:AJAX:blank&WS='+maxUserY+'&DS='+document.body.scrollHeight+'&MY='+myHeight+'&referer='+window.location;
}

setInterval ('alertSize();', 100 );


/* script za analizo kje je user kliknil */

var myVisina = 0;

function shraniSamoHTML() {
		frm.submit();
}

/* prikaže vse tiste idje v arraju ki vsebujejo vrednost iz polja field_id*/
function iskanje_arr(arr) {
	var niz = '';
	var re = new RegExp($('isk_skupina').value, "gi");
	//var re = document.getElementById('isk_skupina').value; 
	for(var i=1;i<arr.length;i++) {
		niz = arr[i];
		var j = niz.search(re);
		var o = getById('sk'+i);
		if(j != -1) o.style.display='';
		else o.style.display='none';
	}
}

/* prikaže vse tiste idje v arraju, ki ustrezajo vrednosti*/
function filter_arr(elarr, vrednost, predpona) {
	var niz = '';
	//alert(elarr.length);
	for(var i=1;i<elarr.length;i++) {
		niz = elarr[i];
		var o = getById(predpona+i);
		if(vrednost == '' || niz == vrednost) o.style.display='';
		else o.style.display='none';
	}
}

/*generične funkcije za preverjanje obracev*/

var f = null;
function B2ChkForm(forma) {
	var error = '';
	var f1 = getById(forma);
	
	for( var x = 0; x < f1.childNodes.length; x++ ) {
		error += f1.childNodes[x];
	}
return false;
}

function B2ChkEmail(field,msg)
{
	var x = getById(field);
	var m = getById(msg);
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(x.value)) {
		x.className = "err";
		if (m) m.style.display='';
		return(false);
	}
	if (m) m.style.display='none';
	x.className = '';
	return(true);
}

function B2ChkReq(field,msg)
{
	var x = getById(field);
	var m = getById(msg);
	if (x.value=="") {
		x.className = "err";
		if (m) m.style.display='';
		return(false);
	}
	if (m) m.style.display='none';
	x.className = '';
	return(true);
}


function B2ChkNumber(field,msg)
{
	var x = getById(field);
	var m = getById(msg);
	var filter  = /^([0-9\.\-])/;
	if (!filter.test(x.value)) {
		x.className = "err";
		if (m) m.style.display='';
		return(false);
	}
	if (m) m.style.display='none';
	x.className = '';
	return(true);
}


/*end generične funkcije */

/* Funkcije za validacijo obrazcev*/

function B2CheckForm(forma) {
	var f0 = true;
	var obrazec = null;
	obrazec = document.getElementsByName(forma);
	if(!obrazec) return false;
	
	// PREVERJAMO OBVEZNA POLJA
	var r = document.getElementsByName('B2ReqFields');
	var req;
	if(r && r[0]) {
		req = r[0].value;
		var reqs = req.split(",");
		for (var j = 0; j < reqs.length; j++) {
			//alert(reqs[j]);
			if(f0) f0 = B2CheckRequiredField(reqs[j], reqs[j] + '_msg');
			else B2CheckRequiredField(reqs[j], reqs[j] + '_msg');
		}
	}
	
	// PREVERJAMO MAILE
	var e = document.getElementsByName('B2EmlFields');
	var eml;
	if (e && e[0]) {
		eml = e[0].value;	
		var emls = eml.split(",");
		for (var j = 0; j < emls.length; j++) {
			if(f) f = B2CheckEmailField(emls[j], emls[j] + '_msg');
			else B2CheckEmailField(emls[j], emls[j] + '_msg');
		}
	}
	
	//PREVERJAMO ŠTEVILA
	var n = document.getElementsByName('B2NumFields');
	var num;
	if (n && n[0]) {
		num = n[0].value;
		var nums = num.split(",");
		for (var j = 0; j < nums.length; j++) {
			if(f) f = B2CheckNumberField(nums[j], nums[j] + '_msg');
			else B2CheckNumberField(nums[j], nums[j] + '_msg');
		}
	}
	return f;
}

function B2CheckRequiredField(fieldname) {

	var fld = document.getElementsByName(fieldname);
	var m = getById(fieldname + '_msg');
	var n = 0;
	if(!fld || !fld[0] || fld[0].value == '') n = 1;
	
	if(n == 0 ) {
		if (m) m.style.display='none';
		fld[0].className = '';
		return(true);
	}
	fld[0].className = 'err';
	if (m) m.style.display='';
	return(false);
}


function B2CheckNumberField(fieldname) {

	var fld = document.getElementsByName(fieldname);
	var m = getById(fieldname + '_msg');
	var n = 0;
	
	if(!fld || !fld[0] || fld[0].value == '') n = 1;
	if(n == 0) {
		var filter  = /^\d+(\,\d*)?$/;
		if(filter.test(fld[0].value)) {
			if (m) m.style.display = 'none';
			fld[0].className = '';
			return(true);
		}
	}
	fld[0].className = 'err';
	if (m) m.style.display='';
	return(false);
}

function B2CheckEmailField(fieldname) {

	var fld = document.getElementsByName(fieldname);
	var m = getById(fieldname + '_msg');
	var n = 0;
	
	if(!fld || !fld[0] || fld[0].value == '') n = 1;
	if(n == 0) {
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		
		if(filter.test(fld[0].value)) {
			if (m) m.style.display = 'none';
			fld[0].className = '';
			return(true);
		}
	}
	fld[0].className = 'err';
	if (m) m.style.display='';
	return(false);
}
// lepo ime za uporabo na vsebini
function B2ElementShow(id) {
	return show3(id);
}
// lepo ime za uporabo na vsebini
function B2ElementHide(id) {
	return hide2(id);
}
function B2ElementSetValue(id, v) {
	var o = getById(id);
	if(o) {
		o.value = v;
		return;
	}
	return;
}
/* END Funkcije za validacijo obrazcev*/

/* scrool za LUKK*/
function actualstyle(el, cssproperty) {
	if (el.currentStyle) return el.currentStyle[cssproperty]
	else if (window.getComputedStyle) { 
		var elstyle = window.getComputedStyle(el, "")
		return elstyle.getPropertyValue(cssproperty)
	}
}
function glideroutine(obj){
	if (parseInt(actualstyle(obj, "left")) > -250)
		obj.style.left = parseInt(actualstyle(obj, "left")) - 2;
	else
		obj.style.left = 250;
}
/* END scrool za LUKK*/

function alternate_show_tr_force(ar,par,show) {
  for(var o in ar) {
    if (ar[o]==par) {
      var obj = getById(o);
      if (obj) {
        if (show=='x') {
          if (obj.style.display=='none') show = '';
          else show = 'none';
        }
        obj.style.display = show;
        alternate_show_tr_force(ar,o,'none');
      }
    }
  }
  var par_obj = getById(par);
  if(par_obj && par_obj.firstChild && par_obj.firstChild.firstChild && par_obj.firstChild.firstChild.firstChild)
    if(par_obj.firstChild.firstChild.firstChild.tagName == "IMG")
        ChangeImageBtn0(par_obj.firstChild.firstChild.firstChild, show=='');
}

function doFilter(vrednost) {
 var vinloc = '';
  vinloc = window.location.href;
  var k = vinloc.indexOf('skupina_id');
  if(k!= -1) vinloc = vinloc.substr(0,k-1);
  vinloc = vinloc.replace(/&pagenumber=\b[0-9]/gi,"");
  if(vrednost <=0) window.location = vinloc;

  else window.location = vinloc + '&skupina_id='+vrednost;
return;
}

function doFilterStatus(vrednost) {
 var vinloc = '';
  vinloc = window.location.href;
  var k = vinloc.indexOf('status');
  if(k!= -1) vinloc = vinloc.substr(0,k-1);
  vinloc = vinloc.replace(/&pagenumber=\b[0-9]/gi,"");
  if(vrednost <=0) window.location = vinloc;

  else window.location = vinloc + '&status='+vrednost;
return;
}

function insertswf(swWidth, swHeight, swFile)
{
	document.write(createswfhtml(swWidth, swHeight, swFile));
}

function createswfhtml(swWidth, swHeight, swFile)
{
    var str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
	str += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"';
	str += ' id="F'+swFile+'" width="'+swWidth+'" height="'+swHeight+'">\n';
	str += ' <param name="src" value="'+swFile+'">\n';
	str += ' <param name="loop" value="0">\n';
	str += ' <param name="autoplay" value="0">\n';
	str += ' <param name="menu" value="false">\n';
	str += ' <param name="wmode" value="transparent">\n';
	str += ' <embed src="'+swFile+'"';
	str += ' width="'+swWidth+'" height="'+swHeight+' " wmode="transparent" loop="0" autoplay="0" ';
	str += ' type="application/x-shockwave-flash" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"  menu="false">\n';
	str += '</embed></object>';
    return str;
}

var combos = new Array();


function ZapisiRezultatIskanja(rezultat) {
   var fres = getById('field_rezultati');
   fres.innerHTML = rezultat;
   getById('pbarisci').style.display='none';
   return true;
}

/* Funkcija s katero sprožimo iskanje */
function isciajax() {
   getById('pbarisci').style.display='';
   var url = 'show.aspx?xid=WBT:X:Ajax';
   var args = ajax.serialize($('iskanje1'));
   ajax.post(url, ZapisiRezultatIskanja, args);
   return true;
}
function doSubmitEditor(go2Tree, frmId, taName, where) {
   if(kliklink)
   {     
       var frmE = getById(frmId);   
       // zapišemo xhtml iz editorja v textarea
       FCK2Ta(taName);
       switch (where) {
            case 'atom': SaveAtom(frmE, go2Tree); break;
            case 'news': SaveNovica('submitandsave', go2Tree); break;
            case 'question': SaveQuestion('submitandsave', go2Tree); break;
            case 'exam' : SaveExam('submitandsave', go2Tree); break;
       }
       frmE.submit();
   }
   kliklink = false;
}

/*specifične funkcije za shranjevanje*/
function SaveExam(sasId, sasValue) {
    var sas = getById(sasId);
    sas.value = sasValue;
    FCK2Ta('koncni_ta');
}

function SaveQuestion(sasId, sasValue) {
    var sas = getById(sasId);
    sas.value = sasValue;

	var o1 = getById("stodgovorov");
	var i= o1.value;
	for(j=1;j<=i;j++) FCK2Ta("odg_ta"+j);   
}

function SaveNovica(sasId,sasValue) {
    var sas = getById(sasId);
    sas.value = sasValue;
    FCK2Ta('tekst_ta'); 
}


function SaveAtom(frm, go2Tree) {
   //moram preverit če to sploh še rabimo
   //slika_obdelaj();
   getById('shrani').value='true';
   var sas = getById('submitandsave');

   if(getById('atom_id').value==0 || go2Tree == 1) {
		sas.value=1;
		frm.target='';
    }
    else if(sas.value!=2) {
	    sas.value=0;
	    frm.target='wndsave';
	    var wsave = document.getElementsByName('wndsave');
	    wsave[0].style.display = 'inline';

   } else { frm.target=''; }
}

/*End specifične funkcije za shranjevanje*/


function replaceTags(id) {
    var el1 = $(id);
    var rand = Math.floor(Math.random()*1000);
    var txt = '<input type=\"text\" name=\"'+el1.attributes["b2name"].value+'\" value=\"'+el1.innerHTML+'\" title=\"'+_b2lc+'\" onfocus=\"var cal'+rand+' = new Epoch(\'epoch_popup\',\'popup\',this);cal'+rand+'.toggle();\" />';
    el1.innerHTML = txt;
}


function createEditorc(id) {
    var el1 = $(id);
    var visina = el1.clientHeight*(1.2);
    var vsebinca = el1.innerHTML;
    var txt = '<div id=\"xToolbar\"></div><textarea id=\"editor\" />';
    el1.innerHTML = txt;
    $('editor').value = vsebinca;
    var oFCKeditor = new FCKeditor( 'editor' );
    oFCKeditor.Config['CustomConfigurationsPath'] = '../../ext/B2/B2fckconfig.js?hash=' + Math.random();
    oFCKeditor.Height = visina;
    oFCKeditor.Width = '100%';
    oFCKeditor.ToolbarSet = 'AtomEditor' ;
    oFCKeditor.ReplaceTextarea() ;
}



var _usr_id=null;
var _link_id=null;
var myEffects = null;

function ShowUserData(usr_id, link_id) {
    _usr_id = usr_id;
    _link_id = link_id;
	if(!usr_id) return;
	if(!$('usrData'+ usr_id)) GetUserData(usr_id, link_id);
	else AnimateUserData(usr_id, link_id);
}


var AnimateUserData = function(usr_id, link_id) {
	if(myEffects) {
		myEffects.stop();
		myEffects = null;
	}
	if(!$('usrData'+ usr_id)) return;

	var topLink = $(link_id).getTop()+40;
	//var sizeBox = $('usrData'+ usr_id).getSize().size.x;
	$('usrData'+ usr_id).setStyle('top',topLink + 'px');
	$('usrData'+ usr_id).setStyle('left','40px');
    $('usrData'+ usr_id).setStyle('display','');
	$('usrData'+ usr_id).setStyle('filter','alpha(opacity=0)');
	$('usrData'+ usr_id).setStyle('-moz-opacity','0.0');
        
	myEffects = new Fx.Styles('usrData'+ usr_id, {duration: 1000,transition: Fx.Transitions.linear});
	myEffects.start({'opacity': [0, 1]});
	
}

function GetUserData(usr_id, link_id) {

	var newDiv = new Element('div', {'class': 'usrDataDiv','id': 'usrData' + usr_id});
	newDiv.injectBefore(link_id);	
	B2Ajax.WSservice.set_defaultSucceededCallback(SucceededCallback);
    B2Ajax.WSservice.GetUserDataProfileBox(usr_id);
}

function HideUserData(usr_id) {
	if(myEffects) {
		myEffects.stop();
		myEffects = null;
	}
	if(!usr_id) return;

	$('usrData'+ usr_id).setStyle('filter','alpha(opacity=0)');
	$('usrData'+ usr_id).setStyle('-moz-opacity','0.0');
    $('usrData'+ usr_id).setStyle('display','none');
}

function FCK2Ta(editorId) {
$(editorId).value = FCKeditorAPI.GetInstance(editorId).GetXHTML();
}



var zdxC=null;

function doitonclick(vrednost) {
  if(vrednost > 0) {
    var qs = 'show.aspx?xid=WBT:X:Ajax' + CreateQueryString('spletaj_id,act=7,p,what=cbx_atom_ucilnica_povezave'); 
    if(!zdxC || zdxC == null) zdxC = new dhtmlXCombo("atom_id1","frmpovezave",200);
    zdxC.loadXML(qs);
    zdxC.show(true);

  }
}

function beforeSubmit() {
    if(zdxC) {
      var vred_AtomId = zdxC.getSelectedValue();
      if(vred_AtomId != null && vred_AtomId > 0) povezavaizberi('atom_id',vred_AtomId);
    }
}

/* funkcija za polnjenje comboboxa */
var comboObjectId=null;
var comboFormId=null;
var comboWidth=null;
function NafilajComboboxSkupine(tipi, idobjekta, idforme, sirinaCombota, delayInt) {
    comboObjectId = idobjekta;
    comboFormId = idforme;
    comboWidth = sirinaCombota;
    if(delayInt && delayInt > 0) B2Ajax.WSservice.delay(delayInt);
    B2Ajax.WSservice.set_defaultSucceededCallback(SucceededCallback);
    B2Ajax.WSservice.ComboBoxSkupine(tipi);
}

var id_spletaja=null;
var id_tip = null;
function PosodobiSteviloVprasanjVLiniji(Checked, vprasanje_id, spletaj_id, test_id, tip)
{
    id_spletaja = spletaj_id;
    id_tip = tip
    B2Ajax.WSservice.set_defaultSucceededCallback(SucceededCallback);    
    B2Ajax.WSservice.SteviloVprasanjLinijaKrka(Checked, vprasanje_id, spletaj_id, test_id, tip);
}

function UpdateVprasanjeNaliniji(spletaj_id, test_id, stevilo)
{
    B2Ajax.WSservice.UpdateStVprasanjNaLiniji(spletaj_id, test_id, stevilo);
}

function GetVersion()
{
    B2Ajax.WSservice.set_defaultSucceededCallback(SucceededCallback);    
    B2Ajax.WSservice.GetCurrentVersion();
}

//function SpletajiPodrocjeGet(podrocje_id)
//{
//	var rez = $('tabcontent');
//	rez.innerHTML = 'Nalagam...<br/><img id="pbarisci" src="statika/images/pbar.gif" width="119px"/>';
//    B2Ajax.WSservice.set_defaultSucceededCallback(SucceededCallback);    
//    B2Ajax.WSservice.DrevoSpletajevIzPodrocja(podrocje_id);
//}

// Funkcija, z uporabo AJAX metod, zamenja vsebino elementa z novo, katero nam vrne strežnik.
// Parametri:
//  URL (string): Url naslov ali samo parametri (npr 'xid=WBT:X:ShowUserData?show_detailes=true&show_picture=false&blabla').
//  blockID (string): ID atribut html predmeta kateremu hočemo zamenjati vsebino. Predmet mora podpirati 'innerHTML' atribut.
function AJAXReplaceBlockContent(URL, blockID) {
  ShowWaiting();
  //var ni = document.getElementById(blockID);
  //ni.innerHTML = '<div id="Nalagam' + '@' + blockID + '" style="background-color: Red; width: 100%; height: 100%; position: relative; top: 0px; left: 0px; font-weight: bold; display: block;">' + _b2lac + '</div>';
  // Nastavimo povratne klice.
  B2Ajax.WSservice.set_defaultSucceededCallback(SucceededCallback);
  // Kličemo funkcijo na strežniku.
  B2Ajax.WSservice.ReplaceBlockContent(URL, blockID);
  HideWaiting();
}

/*Funkcija s katero obdelamo vrnjene vrednosti iz server metod*/
function SucceededCallback(result, userContext, methodName)
{ 
    switch(methodName)
    {
        case ("Send3xMail"):
        {
            if (result.strRet.length > 0)
                alert(result.strRet);
            break;
        }
        case ("ReplaceBlockContent"):
        {
          if (result.objectID.length > 0) {
            // Prepišemo vsebino v telo predmeta določenega s result.objectID.
            document.getElementById(result.objectID).innerHTML = result.strRet;
          }
          break;
        }       
        case ("ComboBoxSkupine"):
        {
            if(!zdxC || zdxC == null){
                zdxC = new dhtmlXCombo(comboObjectId, comboFormId, comboWidth);             
                zdxC.addOption(result.arrRet);
                zdxC.show(true);
            }
            break;
        }
        case ("GetUserDataProfileBox"):
        {
            $('usrData'+ _usr_id).innerHTML = result.strRet;
            AnimateUserData(_usr_id, _link_id);
            break;
        }
        case ("SteviloVprasanjLinijaKrka"):
        {
           //ce je checkbox obvezno polje tip = 1
           if(id_tip == 1)
           {
                $("obvlinija"+id_spletaja).value = result.intRet;
                break;
           }
           else if(id_tip == 9)
           { 
                $("linija"+ id_spletaja).value = result.intRet;
                break;
           }
        }      
        case ("UpdateStVprasanjNaLiniji"):
        {
            $("linija" + id_spetaja).value = result.intRet;
            break;
        } 
        case ("GetSubGroups"):
        {
            //$('usrData'+ _usr_id).innerHTML = result.strRet;
            //AnimateUserData(_usr_id, _link_id);
            DoAddInside(result.arrRet, result.strRet, activePos);               
            break;
        }
        case ("GetCurrentVersion"):
        {
   	    alert(_b2la + result.arrRet[0] + _b2lb + result.arrRet[1]);
            break;
        }
//        case ("DrevoSpletajevIzPodrocja"):
//        {
//            //alert(result.sbRet);
//	        $('tabcontent').innerHTML = result.xmlDoc;
//            break;
//        }       
        case ("SlikaVisinaGet"):
        {
            //alert(result.sbRet);
            pictureHeight = result.intRet;
            alert(pictureHeight);
            break;
        }
        default:
        {
            alert(_b2lo);
        }
    }       
}

/* Skupine uporabnika */
var activeDiv,activeSid, activePos;
var groups = new Array();

function GetUserSubGroups(sid,o,iskalnik,pos) {
activePos = pos;
if(sid == -1 && iskalnik != null && iskalnik != '') sid = iskalnik;
  if (!groups['skup' + sid + '_' + pos] ) {
    var tab,row,newrow,n;
    if(iskalnik != null && iskalnik != '') {
        activeDiv = $('skupineOut');
        $('skupineOut').getElements('div[class^=vrstica]').setStyles({display:'none'});
        activeSid = iskalnik;
        sid = -1;
    } else {
        activeDiv = o.parentNode.parentNode.parentNode.parentNode.parentNode;
        activeSid = sid;
    }

    B2Ajax.WSservice.set_defaultSucceededCallback(SucceededCallback); 
    B2Ajax.WSservice.GetSubGroups(sid, "1,4", iskalnik);
  } 
  
  else
  {
    var ar = new Array();
    if(sid == -1 && iskalnik != null && iskalnik != '') sid = iskalnik;
    ar = groups['skup'+sid+'_'+pos];
    if (ar.length==0) return;
    var obj = $(ar[0]);
    var _show = "";
    if (obj) _show = obj.style.display;
    if (_show == "") _show = "none";
    else _show = "";
    if(sid == iskalnik) _show = "";
    ShowHideArray(ar,_show);
  }
}

function ShowBackGroups() {
    var ar = new Array();
    ar = $('skupineOut').getElements('div[name=js]'); //.each(function(item){item.remove()});
    for(o in ar) {   
var obj = $(ar[o]);
       if (obj) obj.remove();
    }
    $('skupineOut').getElements('div[class^=vrstica]').setStyles({display:''});
    groups=new Array();
}

function ShowHideArray(ar,_show) {
    if (ar.length==0) return;
    for(o in ar) {
       var obj = $(ar[o]);
       if (obj) obj.style.display = _show;
    }
}

function DoAddInside(ret,B2Error) {
    if(!ret && B2Error && B2Error!="") { alert(B2Error); return;}
  var _div = activeDiv;
  var templateDiv = $('templateDiv');

  var ar = ret;
  var s,n,i;
  var childs = new Array();

  if (ar.length>0) {
  
    for(i=0;i<(ar.length);i++) {
    var _ar = ar[i];
      var newdiv = templateDiv.cloneNode(true);
      _div.appendChild(newdiv);

      s = newdiv.innerHTML;
      s = s.replace(/_skupina_id_/g,_ar[0]);
      s = s.replace(/_skupina_naziv_/g,_ar[1]);
      s = s.replace(/_skupina_stats_/g,_ar[2]);
      s = s.replace(/_pos_/g,_ar[5]);
      newdiv.innerHTML = s;

      newdiv.className = 'vrstica' + ((i % 2)+1);
      if(typeof(activeSid)=='string') 
        newdiv.attributes["name"].value = "js";
      newdiv.id = 'skup' + _ar[0] + '_' + _ar[5];
      childs[childs.length] = newdiv.id;
      newdiv.firstChild.firstChild.firstChild.firstChild.style.paddingLeft = (parseInt(_ar[3])+1)*9+"px";
      if (_ar[4]==0) {
        var ss = newdiv.firstChild.firstChild.firstChild.firstChild.firstChild;
        ss.firstChild.src = "statika/images/Prazenkvadratek.gif";
        if(jQuery.browser.msie) {
            ss.onclick="";
            ss.style.cssText="";
        } else {
            ss.attributes["style"].value="";
            ss.attributes["onclick"].value="";
	    }
      }
      newdiv.style.display = "";
    }
  }
  groups['skup'+activeSid+'_'+activePos] = childs;
}

/* END skupine uporabnika*/

//***** Prenos pojma iz slovarja v editor ****
function prenospojmaFCK(slovar_id,pojem_slo,enoalidrugo) {
    wio = window.parent.opener;
    if(wio) {
        var pojem, pojem_orig;
        var _FCK = wio.FCKeditorAPI.GetInstance("vsebina");
        var userSelection;
        
        if (window.getSelection) userSelection = _FCK.EditorWindow.getSelection();
        else if (document.selection) userSelection = _FCK.EditorDocument.selection.createRange();
        
        if(userSelection) {
            pojem_orig = userSelection;
            if (userSelection.text) pojem_orig = userSelection.text;

            if(typeof(pojem_orig) == "object") pojem_orig = String(pojem_orig);
            pojem = pojem_orig.replace(/^\s*|\s*$/g,"");
            if(pojem=="[object]") pojem= "";
        }
        
        var endspace="";
        if(pojem != pojem_orig) endspace = " ";
        	 
        if(enoalidrugo) {
            wio.FCK.InsertHtml("<span class='slovar' id=dic" + slovar_id + ">" + pojem + "</span>"+ endspace) ;
        } else {
            wio.FCK.InsertHtml(pojem + endspace + "<span class='slovar_razlaga' id=dic" + slovar_id + ">+</span>"+ endspace) ;
        }
    }
}

function Poslji(akc, vrednost)
{
	//vrednost = 0 --> shranjevanje, 1 --> potrdi, 2 --> zavrni, 3 --> user odda 
	var potrdi; 	
	
	$('akcija').value = akc;
	$('vpis').value = vrednost;
	
	if(vrednost == 3) potrdi = confirm(_b2lt);	
	else if(vrednost == 1) potrdi = confirm(_b2lp);		
	else if(vrednost == 2) potrdi = confirm(_b2lq); 	
	
	if(potrdi || vrednost == 0)
		$('frmdipl').submit();
}

function AutoSave(uporabnik_id, delovni_naziv, soavtor1, soavtor2, mentor, somentor_naziv, somentor_podjetje, problem, metoda, kazalo, viri, opomba, status, diploma_vloga_id, miliSekunde)
{
    //1 sekunda = 1000 milisekund, 
    //1 minuta = 1000000 milisekund    
 
    window.clearTimeout(interval);
    var interval;   
    
    alert(diploma_vloga_id);
    if(diploma_vloga_id <=0)
    {
        interval = window.setTimeout(function() { DiplomaVlogaInsert(uporabnik_id, delovni_naziv, soavtor1, soavtor2, mentor,somentor_naziv, somentor_podjetje, problem, metoda, kazalo, viri, opomba, status); }, miliSekunde);         
    }
    else
    {
        interval = window.setTimeout(function() { DiplomaVlogaUpdate(uporabnik_id, delovni_naziv, soavtor1, soavtor2, mentor,somentor_naziv, somentor_podjetje, problem, metoda, kazalo, viri, status, opomba, diploma_vloga_id); }, miliSekunde);        
    }
}

function DiplomaVlogaInsert(uporabnik_id, delovni_naziv, soavtor1, soavtor2, mentor, somentor_naziv, somentor_podjetje, problem, metoda, kazalo, viri, opomba, status)
{
    //klic metoda za save
    B2Ajax.WSservice.DiplomaStudentInsert(uporabnik_id, delovni_naziv, soavtor1, soavtor2, mentor, somentor_naziv, somentor_podjetje, problem, metoda, kazalo, viri, opomba, status);
}

function DiplomaVlogaUpdate(uporabnik_id, delovni_naziv, soavtor1, soavtor2, mentor, somentor_naziv, somentor_podjetje, problem, metoda, kazalo, viri, status, opomba, diploma_vloga_id)
{
    B2Ajax.WSservice.DiplomaStudentUpdate(uporabnik_id, delovni_naziv, soavtor1, soavtor2, mentor, somentor_naziv, somentor_podjetje, problem, metoda, kazalo, viri, status, opomba, diploma_vloga_id);
}

function radioCheck()
{          
    var soavtor1 = $('frmdipl').soavtor1Radio.value;
    var soavtor2 = $('frmdipl').soavtor2Radio.value;
    if($('inpSamost').checked)
    {        
        $('soavtor1').readOnly = true; 
        $('soavtor2').readOnly = true;    
        $('soavtor1').value = ''; 
        $('soavtor2').value = '';         
    }
    else if($('inpTim').checked)
    {
        $('soavtor1').readOnly = false; 
        $('soavtor2').readOnly = false; 
        $('soavtor1').value = soavtor1; 
        $('soavtor2').value = soavtor2;         
    }
}

function gumbShraniPrikazi()
{
    if($('strinjanjePravilnik').checked)
         $('shraniGumb').style.visibility = "visible";
    else
         $('shraniGumb').style.visibility = "hidden";
}

function PreveriOznacitevSkupin(field) {
var _vseOk = false;
if(field && field.length) {
	for (i = 0; i < field.length; i++) {
	    if(field[i].checked) { 
		_vseOk = true
		if(_vseOk) break;
	    }
	}
} else if(field && field.checked)  _vseOk = true;

if(!_vseOk) {alert(_b2lr);}
else $('frmspr').submit();
}

function FooterScript() {
    imgmeniArr[0] = 'statika/images/odpri_meni.gif';
    imgmeniArr[1] = 'statika/images/zapri_meni.gif';

    for(var a in sprEC) {
    var o = document.getElementById(a);
    var slika = document.getElementById(a + '.img');

    if(a=='ec.novica.quickedit') {
      if(sprEC[a]=='0') {
          hideall(toolboxiNovic);
      } else {
          showall(toolboxiNovic);
      }
      continue;
    }

      if(o!=null) {
         if(sprEC[a]=='1') {
           o.style.display = 'block';
           if(slika) slika.src = imgmeniArr[1];
         } else {
           o.style.display = 'none';
           if(slika) slika.src = imgmeniArr[0];
         }
      }
    }
}

function doFullPageDiv(text) {
//	var newDiv = new Element('div', {'class': 'fullPageDiv'});
//	newDiv.injectAfter('userEC');	
	
}

//funkcija, ki preveri da so v datumskih poljih samo stevilke
function PreveriVnos(e)
{
    var tipkaZnak = (e.which) ? e.which : event.keyCode
    if (tipkaZnak > 31 && (tipkaZnak < 45 || tipkaZnak > 57))
        return false;    
    return true;        
}


/* Auto Save */
var mnAutoSaveMilliSeconds=0;
var mnAutoSaveMilliSecondsExp=0;
var mnAutoSaveInterval=30000;

  function AutoSaveInit(nMilliSeconds)
  {
     try
     {
       var nMinutes=0;
         
       AutoSaveClearTimeOuts();

       nMinutes = ((nMilliSeconds / 1000) / 60); 
       mnAutoSaveMilliSeconds = nMilliSeconds; 
       mnAutoSaveMilliSecondsExp=0;

       oTimeOut = window.setTimeout("AutoSaveSubmit()",nMilliSeconds);
       oInterval = window.setInterval("AutoSaveCountDown()",mnAutoSaveInterval);
       $("divAutoSave").innerHTML = "<b>"+ _b2lv + AutoSaveRoundNumber(nMinutes,2) + _b2lz +"</b>";	
      }
      catch (exception) 
      { 
        if (exception.description == null) { alert("AutoSaveInit Error: " + exception.message); }  
        else {  alert("AutoSaveInit Error: " + exception.description); }
      }
  }

  function AutoSaveCountDown()
  {

    var nMinutesLeft=0;
    var nMilliSecondsLeft=0;

    mnAutoSaveMilliSecondsExp =  mnAutoSaveMilliSecondsExp + mnAutoSaveInterval;

    if ( mnAutoSaveMilliSeconds > mnAutoSaveMilliSecondsExp)
    {
      nMilliSecondsLeft = mnAutoSaveMilliSeconds - mnAutoSaveMilliSecondsExp;
      nMinutes= AutoSaveRoundNumber(((nMilliSecondsLeft / 1000) / 60), 2); 
      $("divAutoSave").innerHTML = "<b>"+ _b2lv + nMinutes + _b2lz +"</b>";
    }

  }

  function AutoSaveBeforeSubmit()
  {
     $("divAutoSave").innerHTML = '<b>'+_b2lu+'</b>';
     return true;
  }


  function AutoSaveClearTimeOuts()
  {
    try
    {
      window.clearInterval(oInterval);
      window.clearTimeout(oTimeOut);
    }
    catch (exception) { }
  }

  function AutoSaveSubmit()
  {
    try
    {
      AutoSaveClearTimeOuts();
      AutoSaveBeforeSubmit();
      Poslji('vnesi', 0 );
     }
    catch (exception) {}
  }

   function AutoSaveRoundNumber(number,X)
  {
	  
    var number2;
    var TmpNum;

     X=(!X ? 1:X);
	
     number2 = Math.round(number*Math.pow(10,X))/Math.pow(10,X);
     TmpNum = "" + number2;
     var TmpArray = TmpNum.split(".");
     if (TmpArray.length <2) { number2 = number2 + ".0"; }
     number2 +='';
     if(number2.indexOf(".") != -1)  number2 = number2.replace(".",",");
     return number2;
  }
  
function B2LoadCss( url )
{ 

	document.write( '<link href="' + url + '?hash=' + Math.random() +'" type="text/css" rel="stylesheet" />' ) ;
}
/* end auto save*/


/* 

GESLOMETER
************************************************************
Created: 20060120
Author:  Steve Moitozo <god at zilla dot us>
Description: This is a quick and dirty password quality meter 
		 written in JavaScript so that the password does 
		 not pass over the network
Revision Author: Dick Ervasti (dick dot ervasti at quty dot com)
Revision Description: Exchanged text based prompts for a graphic thermometer

Password Strength Factors and Weightings

password length:
level 0 (3 point): less than 4 characters
level 1 (6 points): between 5 and 7 characters
level 2 (12 points): between 8 and 15 characters
level 3 (18 points): 16 or more characters

letters:
level 0 (0 points): no letters
level 1 (5 points): all letters are lower case
level 2 (7 points): letters are mixed case

numbers:
level 0 (0 points): no numbers exist
level 1 (5 points): one number exists
level 1 (7 points): 3 or more numbers exists

special characters:
level 0 (0 points): no special characters
level 1 (5 points): one special character exists
level 2 (10 points): more than one special character exists

combinatons:
level 0 (1 points): letters and numbers exist
level 1 (1 points): mixed case letters
level 1 (2 points): letters, numbers and special characters 
					exist
level 1 (2 points): mixed case letters, numbers and special 
					characters exist


NOTE: Because I suck at regex the code below is incomplete and 
	  does not accurately assess the strength of passwords 
	  according to the above factors and weightings
	  
NOTE: Instead of putting out all the logging information,
	  the score, and the verdict it would be nicer to stretch
	  a graphic as a method of presenting a visual strength
	  guage.

************************************************************ */
function testPassword(passwd)
{
var description = new Array();
description[0] = "<table border=0 cellpadding=0 cellspacing=0><tr><td class=bold width=100>Mo&#269; gesla:</td><td><table cellpadding=0 cellspacing=2><tr><td height=15 width=30 bgcolor=#ff0000></td><td height=15 width=120 bgcolor=#dddddd></td></tr></table></td><td class=bold>Zelo &#353;ibko</td></tr></table>";
description[1] = "<table border=0 cellpadding=0 cellspacing=0><tr><td class=bold width=100>Mo&#269; gesla:</td><td><table cellpadding=0 cellspacing=2><tr><td height=15 width=60 bgcolor=#bb0000></td><td height=15 width=90 bgcolor=#dddddd></td></tr></table></td><td class=bold>&#352;ibko</td></tr></table>";
description[2] = "<table border=0 cellpadding=0 cellspacing=0><tr><td class=bold width=100>Mo&#269; gesla:</td><td><table cellpadding=0 cellspacing=2><tr><td height=15 width=90 bgcolor=#ff9900></td><td height=15 width=60 bgcolor=#dddddd></td></tr></table></td><td class=bold>Srednje</td></tr></table>";
description[3] = "<table border=0 cellpadding=0 cellspacing=0><tr><td class=bold width=100>Mo&#269; gesla:</td><td><table cellpadding=0 cellspacing=2><tr><td height=15 width=120 bgcolor=#00bb00></td><td height=15 width=30 bgcolor=#dddddd></td></tr></table></td><td class=bold>Mo&#269;no</td></tr></table>";
description[4] = "<table border=0 cellpadding=0 cellspacing=0><tr><td class=bold width=100>Mo&#269; gesla:</td><td><table cellpadding=0 cellspacing=2><tr><td height=15 width=150 bgcolor=#00ee00></td></tr></table></td><td class=bold>Najmo&#269;nej&#353;e</td></tr></table>";
description[5] = "<table border=0 cellpadding=0 cellspacing=0><tr><td class=bold width=100>Mo&#269; gesla:</td><td><table cellpadding=0 cellspacing=2><tr><td height=15 width=150 bgcolor=#dddddd></td></tr></table></td><td class=bold>Pri&#269;nite s tipkanjem</td></tr></table>";

		var intScore   = 0
		var strVerdict = 0
		
		// PASSWORD LENGTH
		if (passwd.length==0 || !passwd.length)                         // length 0
		{
			intScore = -1
		}
		else if (passwd.length>0 && passwd.length<5) // length between 1 and 4
		{
			intScore = (intScore+3)
		}
		else if (passwd.length>4 && passwd.length<8) // length between 5 and 7
		{
			intScore = (intScore+6)
		}
		else if (passwd.length>7 && passwd.length<12)// length between 8 and 15
		{
			intScore = (intScore+12)
		}
		else if (passwd.length>11)                    // length 16 or more
		{
			intScore = (intScore+18)
		}
		
		
		// LETTERS (Not exactly implemented as dictacted above because of my limited understanding of Regex)
		if (passwd.match(/[a-z]/))                              // [verified] at least one lower case letter
		{
			intScore = (intScore+1)
		}
		
		if (passwd.match(/[A-Z]/))                              // [verified] at least one upper case letter
		{
			intScore = (intScore+5)
		}
		
		// NUMBERS
		if (passwd.match(/\d+/))                                 // [verified] at least one number
		{
			intScore = (intScore+5)
		}
		
		if (passwd.match(/(.*[0-9].*[0-9].*[0-9])/))             // [verified] at least three numbers
		{
			intScore = (intScore+5)
		}
		
		
		// SPECIAL CHAR
		if (passwd.match(/.[!,@,#,$,%,^,&,*,?,_,~]/))            // [verified] at least one special character
		{
			intScore = (intScore+5)
		}
		
																 // [verified] at least two special characters
		if (passwd.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/))
		{
			intScore = (intScore+5)
		}
	
		
		// COMBOS
		if (passwd.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/))        // [verified] both upper and lower case
		{
			intScore = (intScore+2)
		}

		if (passwd.match(/(\d.*\D)|(\D.*\d)/))                    // [FAILED] both letters and numbers, almost works because an additional character is required
		{
			intScore = (intScore+2)
		}
 
																  // [verified] letters, numbers, and special characters
		if (passwd.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/))
		{
			intScore = (intScore+2)
		}
	
	
		if(intScore == -1)
		{
		   strVerdict = description[5];
		}
		else if(intScore > -1 && intScore < 16)
		{
		   strVerdict = description[0];
		}
		else if (intScore > 15 && intScore < 25)
		{
		   strVerdict = description[1];
		}
		else if (intScore > 24 && intScore < 35)
		{
		   strVerdict = description[2];
		}
		else if (intScore > 34 && intScore < 45)
		{
		   strVerdict = description[3];
		}
		else
		{
		   strVerdict = description[4];
		}
	
	document.getElementById("Words").innerHTML= (strVerdict);
	
}
function atomTreeVsi(){
    if (jQuery(".izberiVse").is(":checked")){
       jQuery("input.atomTreeCheck").attr("checked", "checked");
       jQuery(".izberiVse").attr("checked", "checked");
       jQuery(".atomtree span a").css("color", "blue");
    } else {
       jQuery("input.atomTreeCheck").removeAttr("checked");
       jQuery(".izberiVse").removeAttr("checked");
       jQuery(".atomtree span a").css("color", "black");
    }
}

function selectSublist(check){
    var p = jQuery(check).parent().parent().parent().parent(); //parent li
    jQuery(p).attr('id', 'targetLi'); //dinamicno dodamo id samo za potrebe funkcije
    if(jQuery(check).is(":checked")) {
      jQuery("#targetLi ul input.atomTreeCheck").attr("checked", "checked");   //ce ni atributa checked ga dodamo
      jQuery("#targetLi span a").css("color", "blue");
    } else {
      jQuery("#targetLi ul input.atomTreeCheck").removeAttr("checked");   //ce je checked ga izbrisemo
      jQuery("#targetLi span a").css("color", "black");
    }
    jQuery(p).removeAttr("id"); //odstranimo id na koncu funkcije
}

function atomSelectAll(param1, param2){
    if (jQuery("." + param1).is(":checked")){
       jQuery("#" + param2 + " input.atomTreeCheck").attr("checked", "checked");
       jQuery("." + param1).attr("checked", "checked");
       jQuery("#" + param2 + " span a").css("color", "blue");
    } else {
       jQuery("#" + param2 + " input.atomTreeCheck").removeAttr("checked");
       jQuery("." + param1).removeAttr("checked");
       jQuery("#" + param2 + " span a").css("color", "black");
    }
}

function kopirajAtom(id) {
    var inp = jQuery('#copyAtom');
    inp.val('');
    jQuery('#' + id + ' .atomTreeCheck:checkbox:checked').each(function () {
        inp.val(inp.val() + jQuery(this).val() + ',');
    });
    jQuery('#' + id + ' .atomTreeCheck:checkbox:checked').length
    if (inp.val() == '')
        return 0;
    else
        return 1;
}
function kopirajVseAtome(id) {
    var inp = jQuery('#copyAtom');
    inp.val('');
    jQuery('#' + id + ' .atomTreeCheck:checkbox').each(function () {
        inp.val(inp.val() + jQuery(this).val() + ',');
    });
    if (inp.val() == '')
        return 0;
    else
        return 1;
}
function odstraniAtom(id) {
    var inp = jQuery('#deleteAtom');
    inp.val('');
    jQuery('#' + id + ' .atomTreeCheck:checkbox:checked').each(function () {
        inp.val(inp.val() + jQuery(this).val() + ',');
    });
    jQuery('#lblDelete').html(_b2lw.replace('##st##',jQuery('#atomList2 .atomTreeCheck:checkbox:checked').length));
}

function validateDate(fld1, fld2, formId) {
    var datumArr = new Array();
    var pravilen = true;
    datumArr[0] = jQuery("#"+fld1).val();
    datumArr[1] = jQuery("#"+fld2).val();
    for (i=0; i<2; i++) {
        var datumSplit = datumArr[i].split (".");
        var day, month, year;
        day = parseInt(datumSplit[0], 10);
        month = parseInt(datumSplit[1], 10);
        year = parseInt(datumSplit[2], 10);
        var nasDatum = month + '/' + day + '/' + year;
        var RegExPattern = /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;
        if ((nasDatum.match(RegExPattern)) && (nasDatum!='')) {
            //alert(datum je pravilen!);
        } else {
            alert(_b2lab.replace('##datum##', datumArr[i]));
            pravilen = false;
        } 
    }
    if (pravilen == true)
        document.getElementById(formId).submit();
}

function checkBrowser()
{
    var browser=navigator.appName;        
    if (browser=="Netscape")
    {
        alert('Za zagon programa eCTray morate uporabiti Microsoft Internet Explorer');
        return false;
    }
    return true;
}
var loadingTimer;
var loadingFrame=1;

function posCenter(iWidth,iHeight){
	var iLeft = (jQuery(window).width() - iWidth) / 2 + jQuery(window).scrollLeft();
	var iTop = (jQuery(window).height() - iHeight) / 2 + jQuery(window).scrollTop();
	iLeft=(iLeft < 0)?0:iLeft;
	iTop=(iTop < 0)?0:iTop;
		return {left:iLeft,top:iTop};
}
	
function ShowWaiting() {
    AnimateBg(300,40);
    jQuery('#B2waitingInner').css(posCenter(100,100));
    jQuery('#B2waiting').height(jQuery(document).height());
    jQuery('#B2waiting').show();
}

function HideWaiting() {
    jQuery('#B2waiting').hide();
}

function AnimateBg(fullBgHeight, pieceBgHeight) {
   clearInterval(loadingTimer);
   loadingTimer = setInterval(AnimateLoading, 66); 
}

function AnimateLoading(animateEl) {
        var ss = '0px '+(loadingFrame * -40)+'px';
        //
		jQuery('#B2waitingInnerDiv').css('background-position', ss);
		loadingFrame = (loadingFrame + 1) % 12;

}
/*
	$.fn.fancybox.showLoading = function() {
		clearInterval(loadingTimer);

		var pos = $.fn.fancybox.getViewport();

		$("#fancy_loading").css({'left': ((pos[0] - 40) / 2 + pos[2]), 'top': ((pos[1] - 40) / 2 + pos[3])}).show();
		$("#fancy_loading").bind('click', $.fn.fancybox.close);
		
		loadingTimer = setInterval($.fn.fancybox.animateLoading, 66);
	};

	$.fn.fancybox.animateLoading = function(el, o) {
		if (!$("#fancy_loading").is(':visible')){
			clearInterval(loadingTimer);
			return;
		}

		$("#fancy_loading > div").css('top', (loadingFrame * -40) + 'px');

		loadingFrame = (loadingFrame + 1) % 12;
	};
*/

var iframeids;

function resizeCaller() {
  if (document.getElementById)
     resizeIframe(iframeids)
}

function resizeIframe(frameid){
 var currentfr=document.getElementById(frameid);
 var innHeight = 0;
 var innWidth = 0;
 if (currentfr) {
  if (!window.opera) {
   currentfr.style.display="block";
   if (currentfr.contentDocument) {
     innHeight = currentfr.contentDocument.body.offsetHeight;
     innWidth = currentfr.contentDocument.body.clientWidth;
     currentfr.contentDocument.getElementsByTagName("body")[0].addEventListener ("click", parent.changeSize, false);
     currentfr.style.width = innWidth + "px";
     currentfr.style.height = innHeight+10+"px";
   } 
   else if (currentfr.Document) {
     innHeight = currentfr.Document.body.scrollHeight;
     innWidth = currentfr.Document.body.scrollWidth;
     currentfr.Document.getElementsByTagName("body")[0].attachEvent ("onclick",parent.changeSize);
     currentfr.style.width = innWidth + "px";
     currentfr.style.height = innHeight+10+"px";
   }

   if (currentfr.addEventListener) {
     currentfr.addEventListener("load", readjustIframe, false);
   }
   else if (currentfr.attachEvent){
     currentfr.detachEvent("onload", readjustIframe);
     currentfr.attachEvent("onload", readjustIframe);
   }
  }
 }
}

function changeSize() {
  var innerFrame=document.getElementById("hotpotatoe_frame");
  var innerFrameHeight=0;
  var extraHeight=0;
  if (innerFrame.contentDocument) {
    innerFrameHeight = innerFrame.contentDocument.getElementsByTagName("body")[0].clientHeight;
    extraHeight = 10;
  }
  else if (innerFrame.Document) {
    innerFrameHeight=innerFrame.Document.getElementsByTagName("body")[0].clientHeight;
  }
  document.getElementById("hotpotatoe_frame").style.height=innerFrameHeight+extraHeight+"px";
}

function readjustIframe(loadevt) {
  var crossevt=(window.event)? event : loadevt;
  var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement;
  if (iframeroot) 
    resizeIframe(iframeroot.id)
}

function loadintoIframe(iframeid, url){
  if (document.getElementById)
    document.getElementById(iframeid).src=url
}
function changeTab(id,podrocje_id) {
	if(id > -1) {
		var tab = tabs[id];

		for(var i=0; i< tabs.length;i++) {
			getById(tabs[i]).className = '';
		}
		getById(tab).className = 'selected';
	}
	if(podrocje_id > 0)
		AJAXReplaceBlockContent('?xid=WBT:X:ReplaceContentDiv&podrocje_id=' + podrocje_id + '&akc=2','tabcontent');
}


function getDomainName() {
    var gDNh=window.location.href;
    var gDNp=window.location.protocol;

    gDNh=gDNh.replace(gDNp+'//','');
    //alert(gDNh);
    var gDNkosi=gDNh.split('/');
    var gDNh10=gDNp+'//';
    //alert(gDNkosi.length);
    for(li=0;li<gDNkosi.length;li++) {
     if(gDNkosi[li].indexOf('?')==-1) {
	    //alert(gDNkosi[li]);
       gDNh10+=gDNkosi[li]+'/';
     }
    }
    //alert(gDNh10);
    return(gDNh10);
}


function getBasePath(url) {
    if(url.indexOf('wbtweb')==-1) return '/statika/fck/';
    else return '/wbtweb/statika/fck/';
}

function Enter(e, tip, vprasanje_id)
{ 
    var key = e.keyCode || e.which;
    if (key == 13)
    {           
        ShowAnswer(tip, vprasanje_id);        
        return false;
    }
}
//prikazovanje orodne vrstice na atomshowu
function navigacijaShow(el, imgId) {
    var src = jQuery("#" + imgId).attr('src');
    var srcMod = src.substr(src.length - 6, src.length);
    var navadniArr = new Array();
        navadniArr[0] = 'statika/images/Ikona_Napredek.gif';
        navadniArr[1] = 'statika/images/Ikona_Zapiski.gif';
        navadniArr[2] = 'statika/images/Ikona_Vprasanje.gif';
        navadniArr[3] = 'statika/images/Ikona_Delavna_mapa.gif';
    //nastavi zacetno stanje    
    var slikeArr = jQuery(".navimg");
    for (i = 0; i < slikeArr.length; i++) {
        jQuery(slikeArr[i]).attr("src", navadniArr[i]);
    }
    //nastavi izbrano
    if (srcMod == '_1.gif') {
        src = src.substr(0, src.length - 6) + ".gif";
    } else {
        src = src.substr(0, src.length - 4) + "_1.gif";
    }
    jQuery("#" + imgId).attr('src', src);
    //prikazi boxe
    var elem = jQuery('#' + el);
    jQuery('.navigacijaPolje').not(elem).css('display', 'none');
    var value = jQuery(elem).css('display');
    if (value == 'block')
        jQuery(elem).css('display', 'none');
    else if (value == 'none')
        jQuery(elem).css('display', 'block');
}

//funkcija spremeni sliko iz plus.gif v minus.gif in obratno
function spremeniSliko(slikaId) {
    if ($(slikaId)) {
        var slika = $(slikaId);
        var index = slika.src.lastIndexOf('/') + 1;
        var dolzina = slika.src.length;
        var preveriSliko = slika.src.substring(index, dolzina);
        if (preveriSliko == "plus.gif") {
            slika.src = "statika/images/minus.gif";
        }
        else {
            slika.src = "statika/images/plus.gif";
        }
    }
}
//najde slike formul (visina 22px ali manj) v atomih in jim nastavi align
jQuery(document).ready(function() {
    if (jQuery(".atomshow img").length > 0) {
        jQuery(".atomshow img").each(
            function(intIndex) {
                if (jQuery(this).attr("height") <= 22 || jQuery(this).height() <= 22)
                    jQuery(this).css("vertical-align", "middle");
            }
        );
    }
});

