﻿// Chevron -----------------------------------------------------------------
function MyChevronBase(owner,show)
{ 
  if (show)
  {
    document.getElementById(owner+'Hide').style.display = 'none'; 
    document.getElementById(owner+'Show').style.display = 'block';
  }
  else
  {
    document.getElementById(owner+'Hide').style.display = 'block'; 
    document.getElementById(owner+'Show').style.display = 'none';
  }
}

// Chevron - pouziva technologie PC -----------------------------------------------------------------
function MyChevron(owner,show)
{ 

  if (show)
  {
    document.getElementById(owner+'Hide').style.display = 'none'; 
    document.getElementById(owner+'Show').style.display = '';
    document.getElementById(owner).style.display = '';
  }
  else
  {
    document.getElementById(owner+'Hide').style.display = ''; 
    document.getElementById(owner+'Show').style.display = 'none';
    document.getElementById(owner).style.display = 'none';
  }
}
 
function MyChevronDiv(owner,show)
{ 
  if (show)
  {
    document.getElementById(owner+'Hide').style.display = 'none'; 
    document.getElementById(owner+'Show').style.display = '';
  }
  else
  {
    document.getElementById(owner+'Hide').style.display = ''; 
    document.getElementById(owner+'Show').style.display = 'none';
  }
}



function MyNavigate(pNavigate) {
   window.location.replace(pNavigate);  
}

// sirka okna
function winW() {
   if (window.innerWidth)
      /* NN4 a kompatibilní prohlížeče */
      return window.innerWidth;
   else if
   (document.documentElement &&
   document.documentElement.clientWidth)
      /* MSIE6 v std. režimu - Opera a Mozilla
      již uspěly s window.innerHeight */
      return document.documentElement.clientWidth;
   else if
   (document.body && document.body.clientWidth)
      /* starší MSIE + MSIE6 v quirk režimu */
      return document.body.clientWidth;
   else
      return null;
}

// vyska okna
function winH() {
   if (window.innerHeight)
      /* NN4 a kompatibilní prohlížeče */
      return window.innerHeight;
   else if
   (document.documentElement &&
   document.documentElement.clientHeight)
      /* MSIE6 v std. režimu - Opera a Mozilla
      již uspěly s window.innerHeight */
      return document.documentElement.clientHeight;
   else if
   (document.body && document.body.clientHeight)
      /* starší MSIE + MSIE6 v quirk režimu */
      return document.body.clientHeight;
   else
      return null;
}

function GetFromInput(pID)
{
   return document.getElementById(document.getElementById(pID).id).value;
}

/*

pPasswordInput - input hesla
pLabel - kam se bude vypisovat hlaseni
pT1 - Zadejte heslo
pT2 - Zadejte více znaků
pT3 - slabe
pT4 - stredni
pT5 - silne

vraci cislo, ktere chybou i vyznamem odpovida pT1 .. pT5


*/

function passwordChanged(pPasswordInput, pLabel, pT1, pT2, pT3, pT4, pT5 ) {
	var strength = document.getElementById(pLabel);
	var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
	var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
	var enoughRegex = new RegExp("(?=.{6,}).*", "g");

	var pwd = document.getElementById(pPasswordInput);

	if (pwd.value.length==0) 
	{
		strength.innerHTML = pT1;
		return 1;
	} 
	else 
	if (false == enoughRegex.test(pwd.value)) 
	{
		strength.innerHTML = pT2;
		return 2;
	} 
	else 
	if (strongRegex.test(pwd.value)) 
	{
		strength.innerHTML = pT5;
		return 5;
	} 
	else 
	if (mediumRegex.test(pwd.value)) 
	{
		strength.innerHTML = pT4;
		return 4;
	} 
	else 
	{ 
		strength.innerHTML = pT3;
		return 3;
	}
	
	
	return 0;
	
}






