<!--
var wsw = (window.screen.width);
var wsh = (window.screen.height);

var wwsw = rozmeryKlient('w');
var wwsh = rozmeryKlient('h');

/* ====================================================================== */

if ((navigator.userAgent.match(/iPad/i))) {
	//alert('iPad');
	document.write("<link type=\"text\/css\" rel=\"stylesheet\" media=\"all\" href=\"css\/ipad.css\" \/>");
	//document.write("<meta name=\"viewport\" content=width=1024px, minimum-scale=1.0, maximum-scale=1.0 \/>");
}
else if (navigator.userAgent.match(/iPhone/i)) {
	//alert('iPhone');
	document.write("<link type=\"text\/css\" rel=\"stylesheet\" media=\"all\" href=\"css\/iphone.css\" \/>");
	//document.write("<meta name=\"viewport\" content=width=768px, minimum-scale=1.0, maximum-scale=1.0 \/>");
}

/* ====================================================================== */

	function ReceiveServerData(arg, context) {

		var cb = arg.toString();
		var myArr = cb.split('|');

		if (myArr[0] == 'chyba') {

			// prozatim nic

		} else if (myArr[0] == 'clkHODed') { // hodnoceni clanku - uz hlasoval(a)

			gEBI('clkHodMsg').innerHTML = 'U&#x17e; jsi hlasoval(a)';
			gEBI('clkHodMsg').style.display = '';

		} else if (myArr[0] == 'clkHOD') { // hodnoceni clanku - uprava zobrazeni

			gEBI('hYesPocet').innerHTML = myArr[1] + 'x';
			gEBI('hNoPocet').innerHTML = myArr[2] + 'x';
			gEBI('clkHodMsg').style.display = '';


		} else if (myArr[0] == 'voted') { // palcovani na HP - uz hlasoval(a)

			gEBI('palceMsg').innerHTML = 'Znovu hlasovat nelze';
			gEBI('palceMsg').style.top = '100px';
			gEBI('palceMsg').style.display = '';

		} else if (myArr[0] == 'vote') { // palcovani na HP - uprava zobrazeni

			gEBI('percAno').innerHTML = myArr[1] + '%';
			gEBI('graphAno').style.height = myArr[2] + 'px';
			gEBI('percNe').innerHTML = myArr[3] + '%';
			gEBI('graphNe').style.height = myArr[4] + 'px';
			gEBI('palceMsg').style.display = '';

		}
	}

/* ====================================================================== */
/* LoginForm */
/* =========*/

function popUpLoginForm() {
	$('div#lfClose').hide(); $('div#lfOpen').show(); $('div#LoginForm').animate({ top: '-37px' }, 1);
}

function hideLF() {
	$('div#LoginForm').animate({ top: '-37px' }, 500, 'easein'); $('div#lfClose').hide(); $('div#lfOpen').show();
}

function showLF() {
	$('div#LoginForm').animate({ top: '0px' }, 500, 'backin'); $('div#lfClose').show(); $('div#lfOpen').hide();
}

/* ====================================================================== */

function validateLength(sender, args) {
	var tb = gEBI(srchtb);
	if (tb.value.length < 3) {
		//show an error message
		args.IsValid = false;
	} else {
		args.IsValid = true;
	}
}

/* ====================================================================== */

function ensureChecked(source, args) {
	var cb = document.getElementById(cbREG);
	if ( cb.checked == true ) {
		args.IsValid = true;
	} else {
		args.IsValid = false;
	}
}

/* ====================================================================== */

function chngTemplejt(bgr, logo, titl) {
	var b = gEBI('bodyID');
	b.className = bgr + ' ' + logo + ' ' + titl;
}

function skinThisPage(skin) {
	var b = gEBI('bodyID');
	b.className = skin;
}

function skinTitle(skin) {
	var b = gEBI('bodyIn');
	b.className = skin;
}

/* ====================================================================== */

function ShowHideKSinfo(el, cil) {
	var ksi = gEBI(cil);
	if (ksi.style.display == 'none') {
		ksi.style.display = '';
		el.className = 'subSekceInfoMinus';
	} else {
		ksi.style.display = 'none'
		el.className = 'subSekceInfoPlus';
	}
}

/* ====================================================================== */

function ZobrazitDatum(datum, divadlo, rUrl, sekce) {
	var dat = gEBI(datum).value;
	var arr = dat.split(".");
	var d = arr[0].toString(); if (d.length == 1) { d = '0' + d; }
	var m = arr[1].toString(); if (m.length == 1) { m = '0' + m; }
	var y = arr[2].toString();
	var dlo = gEBI(divadlo);
	var sel = dlo.options[dlo.selectedIndex];

	if (sel.value == "0") {
		location = rUrl + '/'+ sekce + '/' + y + m + d;
	} else {
		location = rUrl + '/'  + y + m + d + '/' + sel.value + '.htm';
	}
}

/* ====================================================================== */

function ZobrazitKino(datum, kino, film, rUrl, sekce) {
	var dat = gEBI(datum).value;
	var arr = dat.split(".");
	var d = arr[0].toString(); if (d.length == 1) { d = '0' + d; }
	var m = arr[1].toString(); if (m.length == 1) { m = '0' + m; }
	var y = arr[2].toString();
	var kEL = gEBI(kino);
	var kSel = kEL.options[kEL.selectedIndex];
	var fEL = gEBI(film);
	var fSel = fEL.options[fEL.selectedIndex];
	
	if (kSel.value == "0" && fSel.value == "0") {	// nevybrane ani kino ani film
		location = rUrl + '/'+ sekce + '/' + y + m + d;
	} else if (kSel.value == "0" && fSel.value !== "0") {	// nevybrane kino, vybrany film
		location = rUrl + '/'+ sekce + '/' + y + m + d + '/' + fSel.value + '.htm';
	} else if (kSel.value !== "0" && fSel.value !== "0") {	// vybrane kino i film
		location = rUrl + '/' + y + m + d + '/' + kSel.value + '/' + fSel.value + '.htm';
	} else { // vybrane jen kino
		location = rUrl + '/'  + y + m + d + '/' + kSel.value + '.htm';
	}
}

/* ====================================================================== */

function CreateLink( domena, name, text ) {
zavinac = "@"

    if( CreateLink.arguments.length == 2 ) {
		document.write('<a href="mailto:'+ name + zavinac + domena +'">'+ name + zavinac + domena +'<\/a>');
	} else {
		document.write('<a href="mailto:'+ name + zavinac + domena +'">'+ text +'<\/a>');
	}
}	// CreateLink()

/* ====================================================================== */

function gEBI(eID) {
	var obj = document.getElementById(eID);
	return obj;
}	// gEBI()

/* ====================================================================== */

function detectBrowser() {
	return navigator.appName;
}

/* ====================================================================== */

function rozmeryKlient(typRozmeru) {
	var kW = 0;
	var kH = 0;

	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		kW = window.innerWidth;
		kH = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		kW = document.documentElement.clientWidth;
		kH = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		kW = document.body.clientWidth;
		kH = document.body.clientHeight;
	}

	if (typRozmeru == 'h') {
		return kH;
	} else if (typRozmeru == 'w') {
		return kW;
	}
}

/* ====================================================================== */

function ShowFestival(kotva) {
	location = 'http://www.houser.cz/festivalovy-special/8525-kam-na-festival-aneb-prehledny-festivalovy-pruvodce.htm#' + kotva;
}

/* ====================================================================== */

//color -> worst
var initColor = new Array(208,16);
//color -> best
var endColor = new Array(16,208);
//
var composante3 = 16;
//messages
var infoSecure = "heslo je: "
var secureMsg = new Array("", infoSecure+"velmi slabé", infoSecure+"slabé",infoSecure+"pĝijatelné",infoSecure+"silné",infoSecure+"velmi silné");
//maximum value
var coefColor = 13;
var valSecure = 0;

function Password_check(obj) {
  valSecure = 0;
  //one lower case letter
  if (obj.value.match(/[a-z]/)) {
    valSecure++;
  }                         

  //one upper case letter
  if (obj.value.match(/[A-Z]/)) {
    valSecure++;
  }  

  //one number
  if (obj.value.match(/\d+/)) {
    valSecure++;
  }

  //both upper and lower case
  if (obj.value.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) {
    valSecure+=3;
  }

  //both letters and numbers, almost works because an additional character is required
  if (obj.value.match(/(\d.*\D)|(\D.*\d)/)) {
    valSecure+=3;
  }

  /*
  //three numbers
  if (obj.value.match(/(.*[0-9].*[0-9].*[0-9])/)) {
    valSecure++;
  }

  //one special character
  if (obj.value.match(/.[!,@,#,$,%,^,&,*,?,_,~]/)) {
    valSecure++;
  }

  //letters, numbers, and special characters
  if (obj.value.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/)) {
    valSecure++;
  }
  */

  if (obj.value.length ==0) {
    valSecure = 0;
  } else if (obj.value.length <= 4) {
    valSecure=1;
  } else if (obj.value.length <= 7) {
    valSecure=2;
  } else {
    valSecure += 4;
  }

  getBar(valSecure);
}

function getBar(refColor) {

  var rgbColor = new Array();
  rgbColor = getColor(refColor);

  document.getElementById("passwd_lv").style.backgroundColor = "rgb("+ rgbColor[0] +"," + rgbColor[1] + "," + composante3 + ")";
  document.getElementById("passwd_lv").style.width = Math.round(100*refColor/coefColor) + "%";
  document.getElementById("passwd_lv_txt").innerHTML = secureMsg[Math.ceil(refColor/coefColor*(secureMsg.length-1))];
  document.getElementById("passwd_lv_txt").style.color = "rgb("+ rgbColor[0] +"," + rgbColor[1] + "," + composante3 + ")";
}

function getColor(coef) {

  var diffr = 0;
  var diffg = 0;
  var tabResult = new Array(0,0);
  var coefV1 = 1;
  var coefV2 = 1;

  if (endColor[0]>=initColor[0]) {
    diffr = endColor[0] - initColor[0];
    coefV1 = 1;
  } else {
    diffr = initColor[0] - endColor[0];
    coefV1 = -1;
  }

  if (endColor[1]>=initColor[1]) {
    diffg = endColor[1] - initColor[1];
    coefV2 = 1;
  } else {
    diffg = initColor[1] - endColor[1];
    coefV2 = -1;
  }

  var diffTotal = diffr + diffg;
  var v1 = diffTotal*coef/coefColor;
  
  if (initColor[0]>endColor[0]) {

    if (v1<=diffr) {
      tabResult[0] = Math.round(initColor[0]);
      tabResult[1] = Math.round(initColor[1]-(v1*coefV1));
    } else {
      tabResult[0] = Math.round(initColor[0]-(v1*coefV2)+(diffr*coefV2));
      tabResult[1] = Math.round(endColor[1]);
    }

  } else {

    if (v1<=diffr) {
      tabResult[0] = Math.round(initColor[0]+(v1*coefV1));
      tabResult[1] = Math.round(initColor[1]);
    } else {
      tabResult[0] = Math.round(endColor[0]);
      tabResult[1] = Math.round(initColor[1]+(v1*coefV2)-(diffr*coefV2));
    }

  }

  return tabResult;
}
