﻿var DialogWindow=null;

function GetLookUpWindow(lookupurl, controlId, textId, dataSourceId)
{
	var url = lookupurl+'?control='+controlId+'&textId='+textId+'&dataSourceId='+dataSourceId;

	DialogWindow = window.open(url, 'LookUpWindow', 
            "dependent=yes, menubar=no, location=no, scrollbars=yes, resizable=yes, width=760, height=580, toolbar=no, top=100,left=300" );
    DialogWindow.focus();
}

function TransferValue(value, name, controlId, textId)
{
	document.getElementById(controlId).value=value;
	document.getElementById(textId).value=name;

	DialogWindow.close();
}


function getElementsByClassName(class_name)
{
  var all_obj,ret_obj=new Array(),j=0,teststr;

  if(document.all)all_obj=document.all;
  else if(document.getElementsByTagName && !document.all)
    all_obj=document.getElementsByTagName("*");

  for(i=0;i<all_obj.length;i++)
  {
    if(all_obj[i].className.indexOf(class_name)!=-1)
    {
      teststr=","+all_obj[i].className.split(" ").join(",")+",";
      if(teststr.indexOf(","+class_name+",")!=-1)
      {
        ret_obj[j]=all_obj[i];
        j++;
      }
    }
  }
  return ret_obj;
}

function AddAttachment()
{
	var area=document.getElementById("attachments");
	var index = Number(area.childNodes.length);
	
	var nd=document.createElement("div");
	nd.setAttribute("class", "control");
	nd.setAttribute("className", "control");
	nd.id="div"+index;
	
	var inpt=document.createElement("input");
	inpt.setAttribute("type","file");
	inpt.setAttribute("size","40");
	inpt.id="file"+index;
	inpt.name="file"+index;
	inpt.setAttribute("runat", "server");

	nd.appendChild(inpt);
	
	nd.appendChild(document.createTextNode(" "));
	
	var lnk=document.createElement("a");
	lnk.setAttribute("href","#");
	lnk.onclick=function(){RemoveAttachment("div" + index);};

	lnk.appendChild(document.createTextNode("Odstranit"));
	nd.appendChild(lnk);	
	area.appendChild(nd)
}

function RemoveAttachment(id)
{
	var area=document.getElementById("attachments");
	area.removeChild(document.getElementById(id));
	area.appendChild(document.createElement("span"))
	
}

