var lastSelectedIndex;
var DefaultFontSize = 10;

function simulationOnClick(simulatedControlId, callPostBackArg, callPostBackArg2)
{	
  globalResultIsFalsePostback = true;		
       
  var simulatedControl = document.getElementById(simulatedControlId);
  if (simulatedControl.onclick)
  {
    if (!simulatedControl.onclick())
    {
			return;
    }
  }
	__doPostBack(callPostBackArg, callPostBackArg2 ? callPostBackArg2:'');
}

function simulationIfKeyPressed(event, keyStl, simulation, simulatedControlId, callPostBackArg, callPostBackArg2)
{
  if ((event.keyCode == keyStl) || (event.which == keyStl))
  {
    event.returnValue = false;
    event.cancelBubble = true;
	 	if (simulatedControlId)
	  {	
		  simulation(simulatedControlId, callPostBackArg, callPostBackArg2);
	  }     
	}
}

function OnEnter(event, simulatedControlId, callPostBackArg)
{
    if ((event.keyCode == 13) || (event.which == 13))
    {
        event.returnValue = false;
        event.cancelBubble = true;
        if (simulatedControlId)
        {	
            globalResultIsFalsePostback = true;		

            var simulatedControl = document.getElementById(simulatedControlId);
            if (simulatedControl.onclick)
            {
               var res = simulatedControl.onclick();
               //if (res === false) return res;  alebo undefined
            }
            __doPostBack(callPostBackArg, '');
        }     
    }
}


function setTextFromDdl(ddl,tBox) {
	document.getElementById(tBox).value = ddl.options[ddl.selectedIndex].text;
}

//function lvl(i) {var s="";while((i--)>0)s+="  ";return s;}

function ExpandCollapse(obj1, obj2, tOut, i) {
	var x = "";//lvl(i);
  if ( obj1.style.display != "none" ) {
    hideElement(obj1);
	 	document.getElementById(obj2).innerHTML = (tOut ? x+"[+]" : "<img src='RESOURCES/Images/plus.gif' alt=\"[+]\"/>");
	} else {
	  showElement(obj1);
	  document.getElementById(obj2).innerHTML = (tOut ? x+"[-]" : "<img src='RESOURCES/Images/minus.gif' alt=\"[-]\"/>");
	}
}

function setValues(idElements, valueToSet)
{
	var i, elem;
  for (i = 0; i <idElements.length; i++)
  {
    elem = document.getElementById(idElements[i]);
    if (!elem)
    {
      continue;
    }
    if (elem.innerHTML)
    {
      elem.innerHTML = valueToSet;
    }
    if (elem.innerText)
    {
      elem.innerText = valueToSet;
    }
    if (elem.value)
    {
      elem.value = valueToSet;
    }
  }
}

function setChecked(idElements, valueToSet)
{
  var i, elem;
  for (i = 0; i <idElements.length; i++)
  {
    elem = document.getElementById(idElements[i]);
    if (!elem)
    {
      continue;
    }
    elem.checked = valueToSet;
  }
}


function addEvent(obj, evType, fn){
 if (obj.addEventListener){
   obj.addEventListener(evType, fn, true);
   return true;
 } else if (obj.attachEvent){
   var r = obj.attachEvent('on'+evType, fn);
   return r;
 } else {
   return false;
 }
}

function removeOption(idSelectFrom, idSelectTo, idValuesBox, add)
{
  var selectFrom, selectTo, valuesBox;
  valuesBox = document.getElementById(idValuesBox);
  selectFrom = document.getElementById(idSelectFrom);
  selectTo = document.getElementById(idSelectTo);
  var i;
  for(i = 0; i < selectFrom.options.length; i++)
  {
    if (selectFrom.options[i].selected)
    {
      var oOption = document.createElement("OPTION");
      oOption.value =  selectFrom.options[i].value;
      oOption.text  =  selectFrom.options[i].text;
      selectTo.options.add(oOption, searchForIndex(selectTo, selectFrom.options[i].value));
      if (add)
      {
        valuesBox.value = valuesBox.value + ";" + selectFrom.options[i].value + ";";
      }
      else
      {
        valuesBox.value = valuesBox.value.replace(";" + selectFrom.options[i].value + ";", "");
      }
      selectFrom.remove(i);
      i = i - 1;
    }
  }
}


function searchForIndex(select, value)
{
  var max = select.options.length;
  if (select.options[0])
  {
    if (value < select.options[0].value)
    {
      return 0;
    }
  }
  for(var j = 0; j < select.options.length; j++)
  {
    if (value >= select.options[j].value)
    {
      if (select.options[j+1])
      {
         if (value <= select.options[j+1].value)
         {
           return j+1;
         }
      }
      else
      {
        return j+1;  
      }
    }
  }
  return max;
}

function showHideIfChecked(idControl, idShowControl, idHideControl)
{
  var control = document.getElementById(idControl);
  var showControl = document.getElementById(idShowControl);
  var hideControl = document.getElementById(idHideControl);
  if (control)
  {
    if (control.checked)
    {
			if (showControl)
			{
			  showElement(showControl);
      }
      if (hideControl)
      {
        hideElement(hideControl);
      }
    }
    else
    {
			if (showControl)
			{
			  hideElement(showControl);
			}
			if (hideControl)
      {
        showElement(hideControl);
			}
      
      
    }
  }
}

function showHideIfChecked2(idControl, idShowControl, idHideControl)
{
  var control = document.getElementById(idControl);
  var showControl = document.getElementById(idShowControl);
  var hideControl = document.getElementById(idHideControl);
  if (control)
  {
    if (control.checked)
    {
			if (showControl)
			{
			  showOtherElement(showControl);
      }
      if (hideControl)
      {
        hideElement(hideControl);
      }
    }
    else
    {
			if (showControl)
			{
			  hideElement(showControl);
			}
			if (hideControl)
      {
        showOtherElement(hideControl);
			}
      
      
    }
  }
}

function SetValuePostBackAndClose(val, idElement, eventTarget) {
	window.top.opener.document.getElementById(idElement).value = val;
	window.top.opener.__doPostBack(eventTarget,'');
	window.close();
}

function SetValueAndCloseWindow(idElem, val)
{
	for(var i=0;i<idElem.length;i++) {
		window.top.opener.document.getElementById(idElem[i]).value = val[i];
		window.top.opener.document.getElementById(idElem[i]).value = val[i];
  }
  window.close();
}

// parameter openedWindow is not required
function openWindow(url, windowName, sFeatures, specParams, modal, openedWindow)
{
    openedWindow = typeof(openedWindow) != 'undefined' ? openedWindow : null;
    
	if (modal)
	{
		if (window.showModalDialog)
		{
			window.showModalDialog(url, windowName, sFeatures);
		}
		else
		{
			specParams = specParams + ', modal = yes';
		}
	}
	
	if (openedWindow == null)
	{
		openedWindow = window.open(url, windowName, specParams);
		if (openedWindow.focus) openedWindow.focus();
	}
	else
	{	
		if (openedWindow == 1)
		{
			openedWindow = window.open(url, windowName, specParams);
		}
		else
		{
			try
			{
				openedWindow.location = url;
			}
			catch(e)
			{
				openedWindow = window.open(url, windowName, specParams);
			}
		}
		if (openedWindow.focus) openedWindow.focus();
	}
	
	return openedWindow;
}

function MM_preloadImages() 
{ 
	  var d=document; 
	  if(d.images)
	  { 
	    if(!d.MM_p) d.MM_p=new Array();
		  var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
		  for(i=0; i<a.length; i++)
		    if (a[i].indexOf("#")!=0)
		    { 
		      d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];
		    }
		}
}


var timeE; 
var dateE; 
var serverTime;
var startTime;
var DMMY_Array;
var b;
b = true;

function AdjustTimeDate() {
  var now = new Date();
  var actualTime = new Date();
  actualTime.setTime( serverTime.getTime() + now.getTime() - startTime.getTime() );
  if (DMMY_Array[8] == "en") {
    var Hours = actualTime.getHours();
    var ampm = " AM";
    if (Hours == 0) Hours = 12;
    if (Hours > 11)
      ampm = " PM";
    if (Hours > 12)
      Hours -= 12;

    timeE.innerHTML = Hours + ":" + ( actualTime.getMinutes()<10? "0"+actualTime.getMinutes() : actualTime.getMinutes() ) + /*":" + ( actualTime.getSeconds() < 10 ?  "0"+actualTime.getSeconds() : actualTime.getSeconds() ) + */ampm;
  } else {
    timeE.innerHTML = ( actualTime.getHours() < 10 ? "0"+ actualTime.getHours() : actualTime.getHours() ) + ":" + ( actualTime.getMinutes()<10? "0"+actualTime.getMinutes() : actualTime.getMinutes() ) /*+ ":" + ( actualTime.getSeconds() < 10 ?  "0"+actualTime.getSeconds() : actualTime.getSeconds() )*/ ;
  }
  
  if ((b) && (startTime.getDay()!=actualTime.getDay())) {
    dateE.innerHTML =  DMMY_Array[7];
    b = false;
  }
  setTimeout("AdjustTimeDate()",1000*60);
}

function AdjustDateTime( nextMonth , TimeName, DateName) {
  var nmonth = document.getElementById(nextMonth).value;
  timeE = document.getElementById(TimeName);
  dateE = document.getElementById(DateName);
  serverTime = new Date();
  startTime = new Date();
  DMMY_Array = nmonth.split("#"); 
  serverTime.setHours(DMMY_Array[0],DMMY_Array[1],DMMY_Array[2],0);
  serverTime.setFullYear(DMMY_Array[3],DMMY_Array[4]-1,DMMY_Array[5]);
  AdjustTimeDate();
}

function getById(id) {
  return document.getElementById(id);
}

function getElement(name)
{
	//NN4
	if(document.layers)
		return document[name];
	//IE
	if(document.all)
		return document.all[name];
	//NN6
	if(document.getElementById)
		return document.getElementById(name);
		
	return null;
}	


function ChangeImageRegionMap(drop, regionMap)
{
   var val;
   val = drop.options[drop.selectedIndex].value;  
   getElement(regionMap).src = 'RESOURCES/Images/MAPS/mapa'+val+'.gif';
}

function SetImageRegionMap(drop, regionMap)
{
   var val;
   var obj = getElement(drop);
   val = obj.options[obj.selectedIndex].value;  
   getElement(regionMap).src = 'RESOURCES/Images/MAPS/mapa'+val+'.gif';
}


function makeUploadChangeAsyncXMLRequest(url, id1, id2, par1Name, par2Name, par1NamePrefix)
{
    
    
   var req = Sarissa.getDomDocument();
			      
	 req.async = false;
	 
	 var obj1 = window.document.getElementById(id1);
	 var obj2 = window.document.getElementById(id2);
	 	
   var par1Value = par1NamePrefix + obj1.options[obj1.selectedIndex].text;
   
   var par2Value = (obj2 ? (obj2.checked ? 'true' : 'false') : 'true');
   
   if (obj1.options[obj1.selectedIndex].text.length == 0)
   {
    par1Value = '';
   }
      
   req.load(url + '?' + par1Name + '='  + par1Value + "&" + par2Name + '=' + par2Value);
   return req; 
}

function Load_Map(area,oblast,select,div)
{
	if(area != "")
	{
		var id = area.id;

  	SetSelect(area,'',select,'','');

	}
}

function SetSelect(area,oblast,select,div,postback)
{
  if(area != "")
	{
		var id = area.id;		
		var obj= getElement(select);
		var c = obj.options.length;
		for(i=0;i < c; i++)
		{
		  if(obj.options[i].value == id)
		  {
		    obj.options[i].selected = true;	  			     
		  }		
		}
		if(div != "")
		{
		  hideElement(getElement(div));
		}	
		if(postback)
		{
		  __doPostBack(div, '');
		}
	}
}

function HideMapa(map)
{
  var mapcontrol = getElement(map);
  hideElement(mapcontrol);
}


function updateTypAktivityValue(idVybranyTypAktivity,idDropDown) {
  document.getElementById(idVybranyTypAktivity).value = document.getElementById(idDropDown).value;
}

function monitorAktivita(idDropDown, data) {
  var sValue = document.getElementById(idDropDown).value;
  var j = parseInt(sValue);
  if (j < 0)
    j = 0;
  var i;
  if (data[j][0] != null) {
    for(i = 0; i < data[j][0].length; i++) {
      document.getElementById(data[j][3][i]).value='';
      hideElement2(document.getElementById(data[j][0][i]));
      hideElement2(document.getElementById(data[j][8][i]));
      document.getElementById(data[j][9][i]).checked = false;
    }
  }

  if (data[j][1] != null) {
    for(i = 0; i < data[j][1].length; i++) {
      showElement2(document.getElementById(data[j][7][i]));
      document.getElementById(data[j][5][i]).innerHTML = data[j][4][i];
      document.getElementById(data[j][10][i]).innerHTML  = data[j][4][i];
      document.getElementById(data[j][6][i]).checked = true;
      document.getElementById(data[j][2][i]).value='';
      showElement2(document.getElementById(data[j][1][i]));
 
    }
  }
}


function showElementInline(element) {
  element.style.visibility = 'visible';
  element.style.display = 'inline';
}

function hideElement2(element) {
  element.style.visibility = 'hidden';
}

function showElement2(element) {
  element.style.visibility = 'visible';
}
function hideElement(element) {
  element.style.visibility = 'hidden';
  element.style.display = 'none';
}

function showElement(element) {
  element.style.visibility = 'visible';
  element.style.display = 'block';
}
function showOtherElement(element){
  element.style.visibility = 'visible';
  element.style.display = '';
}

function showHideIfCheckedWithMap(idControl, idShowControl, idHideControl, idHideMap, idHideMap2)
{
  var control = getElement(idControl);
  var showControl = getElement(idShowControl);
  var hideControl = getElement(idHideControl);
  
  if (control)
  { 
    if (control.checked)
    {
      hideElement(hideControl);
      showElement(showControl);
    }
    else
    {
      hideElement(showControl);
      showElement(hideControl);
    }
    if(idHideMap != '' && getElement(idHideMap) != null) HideMapa(idHideMap);
    if(idHideMap2 != '' && getElement(idHideMap2) != null) HideMapa(idHideMap2);
  }
}

function SetImageMap(drop, Map)
{
   var val;
   var obj = getElement(drop);
   val = obj.options[obj.selectedIndex].value;  

}


function confirmationStavPublikovania(message, dropId, deleteId, deleteMessage)
{
  var drop = document.getElementById(dropId);
  var text = drop.options[drop.selectedIndex].text;
  if (drop.options[drop.selectedIndex].value == deleteId)
  {
    return window.confirm(deleteMessage);
  }
  else
  {
    return window.confirm(message + ' na ' + text + ' ?');
  }
}

function confirmationJazykovaVerziaPulikovanaExists(buttonId, message)
{
  if (window.confirm(message))
  {
    document.getElementById(buttonId).click();
   
  }
}


function DoPostBackParent(eventTarget, closeAfterSelect)
{
	if (window.top)
		window.top.opener.__doPostBack(eventTarget,''); 
  else
		window.opener.__doPostBack(eventTarget,''); 
  if (closeAfterSelect)
    window.close();
}

function addNewValueToHiddenAndDoPostBack(idHidden, id, button, closeAfterSelect)
{
	if (window.top)
	{
		window.top.opener.document.getElementById(idHidden).value = id;
		window.top.opener.__doPostBack(button,''); 
  }
  else
  {
  	window.opener.document.getElementById(idHidden).value = id;
		window.opener.__doPostBack(button,''); 
  }
  if (closeAfterSelect)
    window.close();
}





function ShowHideElement(idRadioButton, idShowControls, HideControls, ddlTown, TownLiteral, isTownLiteral) {
  var radioB = document.getElementById(idRadioButton);
  var i;
  var showControl;
  
  if ((radioB!=null)&& (radioB.checked)) {
  
    for (i=0; i < idShowControls.length; i++) {
      showControl = document.getElementById(idShowControls[i]);
      if (showControl!=null) {
        showElement(showControl);
      }
    }
    
    var hideControl;
    for(i = 0; i < HideControls.length; i++) {
      hideControl = document.getElementById(HideControls[i]);
      if (hideControl!=null) {
        hideElement(hideControl);
      }
    }
    
    if (ddlTown!='')  {
      showControl = document.getElementById(ddlTown);
      
      if (showControl!=null) {
        if (document.getElementById(isTownLiteral).value == "1") {
          showControl = document.getElementById(TownLiteral);
        }
        showElement(showControl);
      }
    }
  }
}


function tsCancelSelection(args) {
  var i;
  var e;
  for (i = 0; i < args.length; i++) {
    e = getById(args[i]);
    if (e.value)
      e.value = '';
    else if (e.innerHTML) {
      e.innerHTML = '';
      hideElement(e);
    }
  }
}

function showParamSearch(idShowControl, idHideControl)
{
  var showControl = document.getElementById(idShowControl);
  var hideControl = document.getElementById(idHideControl);
  showElement(showControl);
  hideElement(hideControl);
}

function showParamSearchInline(idShowControl, idHideControl)
{
  var showControl = document.getElementById(idShowControl);
  var hideControl = document.getElementById(idHideControl);
  showElementInline(showControl);
  hideElement(hideControl);
}

function setShowHideOnClick(idShow, idHide)
{
  var showControl = document.getElementById(idShow);
  var hideControl = document.getElementById(idHide);
  showElement(showControl);
  hideElement(hideControl);
}

// TODO ... upravit
var uploadArgs = new Array();
var frm;

function CheckFileExistence(idBox, root, messageConfirm, messageAccessDenied , ifrm, existsID)
{
	frm = document.getElementById(ifrm);
	uploadArgs = [document.getElementById(idBox).value,root,messageConfirm,messageAccessDenied];
	frm.src = 'fileexists.ashx?file=' +  encodeURIComponent(root) + "\\" + encodeURIComponent(uploadArgs[0]) + "&eid=" + existsID+"&fncID=0";
}

function CheckFileExistence2(dir, root, messageConfirm, messageAccessDenied, ifrm, existsID ){
	// dir = fileName, root = Directory
	frm = document.getElementById(ifrm);
	uploadArgs = [dir, root, messageConfirm, messageAccessDenied];
	frm.src = 'fileexists.ashx?file=' +  encodeURIComponent(root) + "\\" + encodeURIComponent(dir) + "&eid=" + existsID+"&fncID=2";
}

function Chfe(status) {
	
	frm.src="resources/html/empty.htm";
	if (CheckFileExistence2VV(uploadArgs[0], uploadArgs[1], uploadArgs[2], uploadArgs[3], status))
		ContinueUpload();
}

function Chfe2(status) {
	
	frm.src="resources/html/empty.htm";
	if (CheckFileExistence2VV(uploadArgs[0],uploadArgs[1],uploadArgs[2],uploadArgs[3], status))
		ContinueUpload();
}

function CheckFileExistence2VV(dir, root, messageConfirm, messageAccessDenied, status )
{
	if (status == 1) {
		if (!window.confirm(uploadArgs[2]))
			return false;
	}
	
	if (status == 2)
		if (!window.confirm(uploadArgs[3]))
			return false;
	
	return true;
}

function SetMapLocation(lat, lon, scl)
{
	document.getElementById(latitudeElementId).value = lat;
	document.getElementById(longitudeElementId).value = lon;
	document.getElementById(mierkaElementId).value = scl;
}

function redirectAfterConfirmation(url, message)
{
	if (confirm(message))
	{
		window.location = url;
	}
}





function openWindowIE() {
	var w = null;
	if (this.modal) 
		w = window.showModalDialog(this.sURL, this.vArguments , this.sFeatures);
	else {
		if (this.dependent) {
			w = window.showModelessDialog(this.sURL, this.vArguments, this.sFeatures);
		} else {
			this.windowArguments = this.vArguments;
			w = window.open(this.sURL, this.sName, this.sFeatures, this.bReplace);
		}
	}
	if (w!=null && w.focus)
		w.focus();
	return w;
}

function openWindowOther() {
	var w = null;
	this.windowArguments = this.vArguments;
	//alert("opnening with args: " + this.windowArguments);
	w = window.open(this.sURL, this.sName, this.sFeatures, this.bReplace);
	if (w.focus)
		w.focus();
	return w;
}

function AddFeature(i, value) {
	if (this.wFeatures[this.UA][0][i] != null) {
		if (i < 4) {
			if (value > -1)
				this.sFeatures += this.wFeatures[this.UA][0][i] + this.ValueSeparator + value.toString() + this.SizeUnit + this.FeatureSeparator;
		} else
			this.sFeatures += this.wFeatures[this.UA][0][i] + this.ValueSeparator + value.toString() + this.FeatureSeparator;
	}
}

function prepareFeatures(left, top, width, height, center, menubar, toolbar, location, status, resizable, scroll) {

	if (!this.modal) {
		if (!this.dependent && this.UA == 0)
			this.UA = 2;
	} else {
		this.dependent = true;
	}
	
	if (center) {
		if (this.UA == 0) {
			left = -1;
			top  = -1;
		} else {
			left  = (window.screen.width  - width)  / 2;
			top   = (window.screen.height - height) / 2;
			if (this.UA == 2) {
				if (window.innerHeight) {
					left  = (window.innerWidth  - width)  / 2;
					top   = (window.innerHeight - height) / 2;
				}
			}
		}
	}
	this.ValueSeparator  =  this.wFeatures[this.UA][1];
	this.FeatureSeparator = this.wFeatures[this.UA][2];
	if (null != left)      this.addFeature(0,left);
	if (null != top)       this.addFeature(1,top);
	if (null != width)     this.addFeature(2,width);
	if (null != height)    this.addFeature(3,height);
	if (null != menubar)   this.addFeature(4,this.getBoolValue(menubar));
	if (null != toolbar)   this.addFeature(5,this.getBoolValue(toolbar));
	if (null != location)  this.addFeature(6,this.getBoolValue(location));
	if (null != status)    this.addFeature(7,this.getBoolValue(status));
	if (null != resizable) this.addFeature(8,this.getBoolValue(resizable));
	if (null != scroll)    this.addFeature(9,this.getBoolValue(scroll));
	this.addFeature(10,this.getBoolValue(false));
	this.addFeature(11,this.getBoolValue(this.dependent));
	this.addFeature(12,this.getBoolValue(this.modal));
	if (null != scroll)    this.addFeature(13,this.getBoolValue(center));
	this.sFeatures = this.sFeatures.substring(0,this.sFeatures.length-1);
}

function GetBoolValue(b) {
	if (this.UserAgent == 0)
		return (b?'1':'0');
	else
		return (b?'yes':'no');
}

function popUpManager() {
	
	this.wFeatures =
		[
			[['dialogLeft','dialogTop','dialogWidth','dialogHeight',null,null,null,'status','resizable','scroll',null,null,null,'center'],':',';'], 
			[['left','top','width','height','menubar','toolbar','location','status','resizable','scrollbars','directories','dependent','modal',null],'=',','], 
			[['left','top','width','height','menubar','toolbar','location','status','resizable','scrollbars',null,null,null,null],'=',',']
		];
		
	var agent = window.navigator.userAgent.toLowerCase();
	this.UserAgent = 2;
	
	if (agent.indexOf("opera")  > -1) 
		this.UserAgent = 2;
	else if (agent.indexOf("msie")  > -1) 
		this.UserAgent = 0; 
	else if (agent.indexOf("gecko") > -1) 
		this.UserAgent = 1;
		
	this.UA = this.UserAgent;
	
	this.windowArguments = null;
	this.dialogArguments = null;
	this.parentWindow    = null;
	

					
	var b = false;				
	
	
	if (this.UserAgent == 0) {
		try 
		{
			if (window.dialogArguments)	{
				if (window.dialogArguments!=null) {
					if (window.dialogArguments.length)
						if (window.dialogArguments.length == 2) 
						{
							this.parentWindow    = window.dialogArguments[0];
							this.dialogArguments = window.dialogArguments[1]; 
							b = true;
						}
					}
			}
				
			if (!b && window.opener)    
				if (window.opener != null) 
							if (window.opener.PopUpManager) 
									if (window.opener.PopUpManager.windowArguments != null) 
									{
										this.parentWindow    = window.opener.PopUpManager.windowArguments[0];
										this.dialogArguments = window.opener.PopUpManager.windowArguments[1];
									}
		
		}
		catch (exception) 
		{
		} finally 
		{
		}
	} else {
		try 
		{
			if (window.dialogArguments)	{
				if (window.dialogArguments!=null) {
					if (window.dialogArguments.length)
						if (window.dialogArguments.length == 2) 
						{
							this.parentWindow    = window.dialogArguments[0];
							this.dialogArguments = window.dialogArguments[1]; 
							b = true;
						}
					}
			}
				
			if (!b && window.opener)    
				if (window.opener != null) 
							if (window.opener.PopUpManager) 
									if (window.opener.PopUpManager.windowArguments != null) 
									{
										this.parentWindow    = window.opener.PopUpManager.windowArguments[0];
										this.dialogArguments = window.opener.PopUpManager.windowArguments[1];
									}
		
		}
		catch (exception) 
		{
		} finally 
		{
		}
	}
	
			  
  //alert("this.dialogArguments="+this.dialogArguments+"\n\nthis.windowArguments="+this.windowArguments+"\n\nthis.parentWindow="+this.parentWindow);
		
	if (this.UserAgent == 0)
		this.open = openWindowIE;
	else
		this.open = openWindowOther;
		
	
	this.ValueSeparator =   this.wFeatures[this.UserAgent][1];
	this.FeatureSeparator = this.wFeatures[this.UserAgent][2];
	
	this.SizeUnit = (this.UserAgent < 2 ? 'px' : '');
	
	this.dependent  = null;
	this.sURL       = null;
	this.sName      = null;
	this.vArguments = null;
	this.sFeatures  = null;
	this.bReplace   = null;
	this.modal      = null;
	this.getBoolValue     = GetBoolValue;
	this.addFeature       = AddFeature;
	this.prepare          = prepareFeatures;
}

function openWnd(sURL , sName , vArguments, bReplace, left, top, width, height, center, modal, menubar, toolbar, location, status, resizable, scroll, dependent) {
  if (null == modal)     modal = false;
  if (null == dependent) dependent = false;
  
	PopUpManager.sURL       = sURL;
	PopUpManager.sName      = sName;
	PopUpManager.vArguments = [ window, vArguments ]; // send reference to this window & args
	PopUpManager.sFeatures  = '';
	PopUpManager.bReplace   = bReplace;
	PopUpManager.modal      = modal;
	PopUpManager.dependent  = dependent;
	PopUpManager.prepare(left, top, width, height, center, menubar, toolbar, location, status, resizable, scroll);
	return PopUpManager.open();
}

if (!PopUpManager || PopUpManager==null)
  var PopUpManager = new popUpManager();


var __args;

function __showImage() {
	openWnd(__args[0],__args[1],null,false,0,0,300,300,false,false,false,false,false,true,true,true,false);
}

function setImgPreview(imgId, idA , ddl, values, uwndName) {
	var i = document.getElementById(imgId);
	var a = document.getElementById(idA);
	if (ddl.selectedIndex > 0) {
		i.src = values[ ddl.selectedIndex - 1 ][0];
		__args = [values[ddl.selectedIndex-1][1],uwndName];
		a.onclick = __showImage;
		
		a.href = "javascript: void(0);";
		a.style.visibility="visible";
		a.style.display="inline";
	} else {
		a.style.visibility="hidden";
		a.style.display="none";
	}
}

function setDocumentPreview(idA, ddl, values) {
	var a = document.getElementById(idA);
	if (ddl.selectedIndex > 0) {
		a.href = values[ddl.selectedIndex-1][0];
		a.innerHTML = values[ddl.selectedIndex-1][1];
		a.style.visibility="visible";
		a.style.display="inline";
	} else {
		a.style.visibility="hidden";
		a.style.display="none";
	}
}

function cis(div,link,hText,sText,idHidden) {
	var d = getById(div);
	var l = getById(link);
	var h = getById(idHidden);

	if (d.style.visibility == "hidden") {
		showElement(d);
		h.value = "1";
		l.innerHTML = sText;
	} else {
		hideElement(d);
		h.value = "0";
		l.innerHTML = hText;
	}
}

function sh(elem, ids, show) {
	var e;
	var b = elem.checked;
	for(var i=0;i<ids.length;i++)
	{
		var e = getById(ids[i]);
		if (show) 
			if (b) showElement(e); else hideElement(e);
		else 
			if (b) hideElement(e); else showElement(e);
	}
}

function switchVisibility(rb, ids, vis) {
	if (rb.checked) {
		for(var i=0;i<ids.length;i++)
		{
			if (vis[i])
				showElement(getById(ids[i]));
			else 
				hideElement(getById(ids[i]));
		}
	}
}

function pageWidth() 
{
return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?
       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
} 
function pageHeight() 
{
return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  
		document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
}