// test na povinne parametry formulare
function checkMe(tf,text,pars)
{
	pole=pars.split(',');
	for(i=0;i<pole.length;i+=2)
	{
		if(eval('typeof  tf.'+pole[i])!='undefined'){
			if(eval('tf.'+pole[i]+'.value')=='')
			{
				alert(pole[(i+1)]+' '+text);
				eval('tf.'+pole[i]+'.focus()');
				return false;
			}
		}
	}
	return true;
}

// nove okno
function previewWindow(url, title)
{
	window.open(url, title, "toolbar=no,status=no,scrollbars=yes,resizable=yes,width=800,height=600");
}

function newwindow(url,title){
	window.open(url, title, "toolbar=yes,status=yes,scrollbars=yes,resizable=yes");
}


// vraci hodnotu z popup okna zpet do formulara
function backToForm(elName, newId, newName){

//	if (window.showModalDialog) {
//		dialogArguments.document.all(dialogArguments.elementFk).value = newId;
//		dialogArguments.document.all(dialogArguments.elementName).innerHTML = newName;
//	} else { //Netscape
		var opnr=window.opener;
		opnr.document.getElementById(elName+'_fk').value=newId;
		opnr.document.getElementById(elName+'_name').innerHTML=newName;	
//	}
	window.setTimeout('window.close()',10);
}

// smaza hodnoty z formulare u tematu 
function deleteFormInput(name){
	document.getElementById(name+'_fk').value='';
	document.getElementById(name+'_name').innerHTML='';
}

// Otevre okno pro vyber souboru (reuse)
function chooseFile(inpId){
//	if (window.showModalDialog) {
//		window.elementFk = inpId+'_fk';
//		window.elementName = inpId+'_name';
//		showModalDialog ("../fileman/files.asp?inpID="+inpId, window, "dialogheight=600px;dialogwidth=800px;status=no;toolbar=no;menubar=no;location=no;resizable=yes;scroll:yes")
//	} else {
		window.open("../fileman/files.asp?inpID="+inpId, 'zipWindow', 'width=800,height=600,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes,')
//	}
}

function changeimage(imgName,newImgName){
	eval("document." + imgName + ".src = '/data/prodejni-mista/n_"+newImgName+".gif'");	
}


function previewFoto(filePath,id){
	pole=get_element(id);
	pole.src=filePath;
}
function previewClear(filePath,id){
	pole=get_element(id)
	pole.src=filePath;
}
function get_element(name) {
	if (document.all) {
		return document.all[name];
	} else {
		return document.getElementById(name);
	}
}

function hidefields(s, f){
	hod=s.options[s.selectedIndex].value.substring(0,1);
	if (hod=='1'){showDiv('1');hideDiv('2');hideDiv('3');}
	if (hod=='2'){showDiv('1');showDiv('2');hideDiv('3');}
	if (hod=='3'){showDiv('1');showDiv('2');showDiv('3');}
	if (hod=='4'){showDiv('1');hideDiv('2');showDiv('3');}
	if (hod=='5'){hideDiv('1');hideDiv('2');showDiv('3');}
}

function  hideDiv(id){get_element('div_'+id).style.display='none';}
function  showDiv(id){get_element('div_'+id).style.display='';}

function SmajlClick(ItemName, a) {
  InsertTag(document.getElementById(ItemName), '<smajlik' + a + '>');
}
function replyClick(ItemName, a) {
  InsertTag(document.getElementById(ItemName), '' + a + ': ');
}
function FileClick(ItemName, filName) {
  InsertTagFile(window.opener.document.getElementById(ItemName), '<fotka' + filName + '>');
  //alert('cop.. copak' + window.opener.document.getElementById(ItemName).value);
  window.setTimeout('window.close()',10);
}


function InsertTag(oElement, ThisTagName) {
  if (document.selection) { 
	  if ( typeof(oElement) == 'object' ) {
	 	  oElement.focus();
	 	  if ( typeof(document.selection.createRange()) == 'object' ) {
	 			var seltext = document.selection.createRange();
	  		seltext.text = ThisTagName + seltext.text ;
	  		document.selection.clear;
	  	}
	  }
  }else{	  
	oldValue = oElement.value;
	if (oElement.selectionStart == oElement.selectionEnd) {
		selStart = oldValue.substring(0,oElement.selectionStart);
		selEnd = oldValue.substring(oElement.selectionStart, oElement.textLength);
		oElement.value = selStart + ThisTagName + selEnd;
	} else {
		oElement.value = oElement.value +  ThisTagName ;
	}
	
  }		
}

function nastavObsah(blogerId){
		for(i=1;i<=4;i++) document.getElementById('bloger_'+i).className="";
		document.getElementById('bloger_'+blogerId).className="active";
          document.getElementById('blogClanek').innerHTML = document.getElementById('blog_' + blogerId).innerHTML;
}

function nastavObsahNew(blogerId){
		for(i=5;i<=6;i++) document.getElementById('bloger_'+i).className="";
		document.getElementById('bloger_'+blogerId).className="active";
          document.getElementById('blogClanek').innerHTML = document.getElementById('blog_' + blogerId).innerHTML;
}

function openiframe() {
  var adresa;
  document.getElementById('popup').style.display='';
  adresa = document.getElementById('nodesignUrl').value+"";   
  document.getElementById('ramec').src='/reguser.asp?doit=doLogin&nodesign=no&menuparent='+adresa;

}

function closeiframe() {
  document.getElementById('popup').style.display='none';
  document.getElementById('ramec').src='';    
}

function zobrazit_form(){
    if (document.getElementById('regFormHide').style.display=='none'){
        document.getElementById('regFormHide').style.display='';
    }else{
        document.getElementById('regFormHide').style.display='none';
    }
}

function checkForm(tf,text)
    {
        if (!tf.souhlas.checked){alert(''+text);return false;}
    }
    
function NastavHodnoty(img, url, name){
  var txtUrl = window.opener.document.getElementById('txtUrl');
  txtUrl.value=img;

  var txtLnkUrl = window.opener.document.getElementById('txtLnkUrl');
  txtLnkUrl.value=url;
  
  var txtAlt = window.opener.document.getElementById('txtAlt');
  txtAlt.value=name;
  window.opener.UpdatePreview();
  //alert(window.opener.txtVSpace);
  //window.opener.txtVSpace.value='10';
  window.close();
}
