function mosDHTML(){ 
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")<-1
	this.ie5=(this.ver.indexOf("MSIE 5")<-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")<-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")<-1
	this.ns6=(this.dom && parseInt(this.ver) <= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5);

	this.activeTab = '';
	this.onTabStyle = 'active';
	this.offTabStyle = 'inactive';

	this.setElemStyle = function(elem,style) {
		document.getElementById(elem).className = style;
	}
	
	this.showElem = function(id) {
		if (elem = document.getElementById(id)) {
			elem.style.visibility = 'visible';
			elem.style.display = 'block';
		}
	}
	this.hideElem = function(id) {
		if (elem = document.getElementById(id)) {
			elem.style.visibility = 'hidden';
			elem.style.display = 'none';
		}
	}
	this.cycleTab = function(name) {
//alert(this.activeTab);
//alert(name);
		if (this.activeTab) {
			this.setElemStyle( this.activeTab, this.offTabStyle );
			page = this.activeTab.replace( 'tab', 'page' );
			this.hideElem(page);
		}else
		{
      		this.hideElem("page1");
		  	this.hideElem("page2");
			this.hideElem("page3");
			this.hideElem("page4");
    	}

		if(this.activeTab != name)
		{
			this.setElemStyle( name, this.onTabStyle );
			this.activeTab = name;
			page = this.activeTab.replace( 'tab', 'page' );
			this.showElem(page);
		}else
		{
			this.setElemStyle( this.activeTab, this.offTabStyle );
			this.activeTab = "tab0";
			this.showElem("page0");
		}
	}
	this.scycleTab = function(name) {
		if (this.activeTab) {
			this.setElemStyle( this.activeTab, this.offTabStyle );
			page = this.activeTab.replace( 'stab', 'spage' );
			this.hideElem(page);
		}
		this.setElemStyle( name, this.onTabStyle );
		this.activeTab = name;
		page = this.activeTab.replace( 'stab', 'spage' );
		this.showElem(page);
	}
	return this;
}

function cardView(ipagestr,ilinkstr,type){ 
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")<-1
	this.ie5=(this.ver.indexOf("MSIE 5")<-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")<-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")<-1
	this.ns6=(this.dom && parseInt(this.ver) <= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5);

	this.activeTab = '';
	this.onTabStyle = 'menulink2';
	this.offTabStyle = 'menulink2';
	
	this.pagestr=ipagestr;
	this.linkstr=ilinkstr;

	this.setElemStyle = function(elem,style) {
		document.getElementById(elem).className = style;
	}
	this.showElem = function(id) {
		if (elem = document.getElementById(id)) {
			elem.style.visibility = 'visible';
			elem.style.display = 'block';
		}
	}
	this.hideElem = function(id) {
		if (elem = document.getElementById(id)) {
			elem.style.visibility = 'hidden';
			elem.style.display = 'none';
		}
	}
	this.cycleTab = function(name) {

		if (this.activeTab) {
			if(type)this.setElemStyle( this.activeTab, this.offTabStyle );
			page = this.activeTab.replace( this.linkstr, this.pagestr );
			this.hideElem(page);
		}
		if(type){this.setElemStyle( name, this.onTabStyle );
		}
		this.activeTab = name;
		page = this.activeTab.replace( this.linkstr, this.pagestr );
		this.showElem(page);
	}
this.switchTab = function(name) {
		this.setElemStyle( name, this.onTabStyle );
		elem = document.getElementById(name);
		if(elem.style.visibility=='hidden')
		{
			elem.style.visibility = 'visible';
			elem.style.display = 'block';
		}else
		{
			elem.style.visibility = 'hidden';
			elem.style.display = 'none';
		}
	}
	return this;
}
var dhtml = new mosDHTML();


function validateForm(form)
{
   var i,field,theCheck,theCheck2,pom2,name,errors='';
   for (i=0; i<(form.elements.length-1); i+=1)
   {
      field = form.elements[i];
      if (field.title)
      {
         theCheck=field.title.substr(field.title.length-1,1);
         theCheck2=field.title.substr(3,1);
         if (theCheck=='*')
         {
            name=field.title.substr(0,field.title.length-1);
            if (theCheck2=='-') {name= name.substr(4,name.length);}
            if (!(field.value) || (field.value=="@"))
            { //IF EMPTY FIELD
               
               errors += name + ' chybí\n';
               field.className += " inValid";
            }
            else
              {
              field.className += " isValid";
              }
            if (theCheck2=='-')
            {
              pom1 = field.title.substr(0,3);
              theExt = pom1.toUpperCase();
              pom2 = field.value.substr(field.value.length-3,3);
              testExt = pom2.toUpperCase();
              if (testExt!=theExt)
              {
               errors += name + ' nemá příponu ' + theExt + '\n';
               field.className += " inValid";
              }
              else
                {
                field.className += " isValid";
                }
            }
            
         }
         else if ((field.value) && (theCheck!='*') && (theCheck2=='-'))
            {
            name=field.title.substr(4,field.title.length);
            pom1 = field.title.substr(0,3);
              theExt = pom1.toUpperCase();
              pom2 = field.value.substr(field.value.length-3,3);
              testExt = pom2.toUpperCase();
              if (testExt!=theExt)
              {
               errors += name + ' nemá příponu ' + theExt + '\n';
               field.className += " inValid";
              }
              else
              {
              field.className += " isValid";
              }
            }
            
      }
   }
   if (errors)
      alert('Objevily se následující chyby:\n\n'+errors);

   return (errors == '');
}
function addRow() 
{
	document.formNew.count.value = parseInt(document.formNew.count.value) + 1;
	var i = parseInt(document.formNew.count.value);

	form = document.getElementById('others');
	if(i<=9)
	{
		data = '<span id="lin'+i+'">'+i+'. <input type="text" size="20" class="inputText" name="name[]" title="'+i+'. Název*" value="" /> <input type="text" class="inputText" name="link[]" size="30" value="" title="'+i+'. Odkaz*" /> <input type="text" class="inputText" name="order[]" size="10" value="" title="Pořadí" /><br /></span>';
		form.innerHTML += data;	
	}
	if(i>1)
		document.getElementById('-Butt').disabled = false;
		
	if(i==9)
		document.getElementById('+Butt').disabled = true;
}
function delRow() 
{
	var i = parseInt(document.formNew.count.value);
	document.formNew.count.value = parseInt(document.formNew.count.value) - 1;

	form = document.getElementById('lin'+i);
      var parent = form.parentNode;
      parent.removeChild(form);

	if(i==2)
		document.getElementById('-Butt').disabled = true;
	
	if(i<9)
		document.getElementById('+Butt').disabled = false;
}
function addRowFile() 
{
	document.formNew.count.value = parseInt(document.formNew.count.value) + 1;
	var i = parseInt(document.formNew.count.value);

	form = document.getElementById('others');
	if(i<=9)
	{
		data = '<span id="lin'+i+'">'+i+'. <input type="text" size="20" class="inputText" name="name[]" title="'+i+'. Název*" value="" /> <input type="file" class="inputFile" id="ButtFile" name="file[]" title="'+i+'. Soubor*" value="" class="button"><br /></span>';
		form.innerHTML += data;	
	}
	if(i>1)
		document.getElementById('-Butt').disabled = false;
		
	if(i==9)
		document.getElementById('+Butt').disabled = true;
}
function delRowFile() 
{
	var i = parseInt(document.formNew.count.value);
	document.formNew.count.value = parseInt(document.formNew.count.value) - 1;

	form = document.getElementById('lin'+i);
      var parent = form.parentNode;
      parent.removeChild(form);

	if(i==2)
		document.getElementById('-Butt').disabled = true;
	
	if(i<9)
		document.getElementById('+Butt').disabled = false;
}
function deleteItem(path)
{
   if (confirm("Opravdu chcete soubor vymazat?"))
   {
	  window.location.href=path;
   }
   else
   {
   		return
   }
}
function PrintDocument()
{
    window.document.execCommand('print');
}
