/*Javascript pro zobrazení náhledu*/

function validate(formular)
{
     if ((document.getElementById("text").value==""))
      {
       alert("Musíte vyplnit potřebná pole.");
       document.getElementById("text").focus();
       return false;
      }
     return true;
}

function validate_cislo(formular)
{
     if ((document.getElementById("text").value.length==0) || isNaN(parseInt(document.getElementById("text").value)) )
     {
       alert('Vyplňte prosím číselnou hodnotu do pole pro počet otázek.');
       focus();
       return false;
     }
     return true;
}

//myField accepts an object reference, myValue accepts the text strint to add
function insertAtCursor(myField, myValue)
{
	//IE support
	if (document.selection)
	{
		myField.focus();

		//in effect we are creating a text range with zero
		//length at the cursor location and replacing it
		//with myValue
		sel = document.selection.createRange();
		sel.text = myValue;
	}

	//Mozilla/Firefox/Netscape 7+ support
	else if (myField.selectionStart || myField.selectionStart == '0')
	{
		//Here we get the start and end points of the
		//selection. then we create substrings up to the
		//start of the selection and from the end point
		//of the selection to the end of the field value.
		//then we concatenate the first substring, myValue,
		//and the second substring to get the new value.
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		myField.value = myField.value.substring(0, startPos)+ myValue+ myField.value.substring(endPos, myField.value.length);
	}
	else
	{
		myField.value += myValue;
	}
}

function showID1HideID2(id1,id2,prepinac)
{
  document.getElementById( id1 ).style.display = '';
  document.getElementById( id2 ).style.display = 'none';
  document.getElementById( prepinac ).checked = false;
}

function colapse( id )
{
    if( document.getElementById( id ).style.display == 'none' )
    {
        document.getElementById( id ).style.display = '';
    }
    else if( document.getElementById( id ).style.display == '' )
    {
        document.getElementById( id ).style.display = 'none';
    }
}

function validateEmail()
{
  if (window.RegExp)
  {
		re = new RegExp("^[_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$");
		if (!re.test(document.getElementById("liame").value))
    {
		  alert('Špatný formát položky EMAIL!');
		  return false;
	  }
	}
  return true;
}

