var rolovat = false;

var theSelection = false;
var clientPC = navigator.userAgent.toLowerCase();
var clientVer = parseInt(navigator.appVersion);
var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));




function rollRight() {      
  if ( rolovat != false ) {
    document.getElementById('show_f').scrollTop = document.getElementById('show_f').scrollTop + 5;
    setTimeout('rollRight("show_f")', 20);
  }
}

function rollLeft() {    
  if ( rolovat != false ) {
    document.getElementById('show_f').scrollTop = document.getElementById('show_f').scrollTop - 5;
    setTimeout('rollLeft("show_f")', 20);
  }
}

function rollStart() {
  rolovat = true;
}

function rollStop() {
  rolovat = false;
}


function display(id){
  //alert(id);
  if(document.getElementById(id).style.display=='none'){
    document.getElementById(id).style.display = 'block';
  }
  else{
    document.getElementById(id).style.display = 'none';
  }
}
function display1(id){
  document.getElementById(id).style.display = 'block';
}
function display2(id){
  document.getElementById(id).style.display = 'none';
}


function buttMenuOver(N, id) {
  document.getElementById(id).src = 'http://www.infoexpress.cz/images/button_on_' + N + '.jpg';
}
function buttMenuOut(N, id) {
  document.getElementById(id).src = 'http://www.infoexpress.cz/images/button_' + N + '.jpg';
}


function potvrzeni_ul(url, dotaz) {
  if( confirm(dotaz) ) {
    location.replace(url);
  }
}
function potvrzeni_l(url, dotaz) {
  if( confirm(dotaz) ) {
    window.location.href = url;
  }
}


function ohodnotit(url) {
  location.replace(url);
}
function relink_re(url) {
  location.replace(url);
}
function relink(url) {
  window.location.href = url;
}


function clanekKomentar(znamka) {
  document.getElementById('clanekHodnoceniKomentar').style.display = 'block';
  document.getElementById('clanekKomentarZ').value = znamka;
}
function galerieKomentar(znamka) {
  document.getElementById('galerieHodnoceniKomentar').style.display = 'block';
  document.getElementById('galerieKomentarZ').value = znamka;
}


function fullSizeFoto(url) {
  window.open(url, 'fullFoto', 'width=800,height=800,menubar=no,resizable=yes,left=50,top=50,scrollbars=yes');
}

function prehledHodnoceni(url) {
  window.open(url, 'prehledHodnoceni', 'width=700,height=400,menubar=no,resizable=yes,left=50,top=50,scrollbars=yes');
}

function vyberKategorie() {
  window.open('vyber_kategorie.php', 'vyberKategorie', 'top=50,left=50,width=400,height=200,menubar=no,resizable=yes,scrollbars=yes');
}


function resizeText(size) {
	text = document.getElementById('textShow');
	text.style.fontSize = size + "px";
}


function linkMouseOver(pic) {
  document.getElementById(pic).style.borderTop = 'solid 1px #000000';
  document.getElementById(pic).style.borderBottom = 'solid 1px #000000';
}
function linkMouseOut(pic) {
  document.getElementById(pic).style.borderTop = 'solid 1px #FFFFFF';
  document.getElementById(pic).style.borderBottom = 'solid 1px #FFFFFF';
}


function galeriePicMouseOver(pic) {
  document.getElementById(pic).style.border = 'solid 2px #A9D12E';
}
function galeriePicMouseOut(pic) {
  document.getElementById(pic).style.border = 'solid 2px #FFFFFF';
}


function textfieldtagsclose() {
  hodnoty = new Array('b_1','b_2','b_3','b_4');
  zns = new Array('B','I','U','NADPIS');
  zne = new Array('B*','I*','U*','NADPIS*');
  tagse = new Array('[/b]','[/i]','[/u]','[/h3]');
  var b = 4;
  for ( a = 0; a < b; a++ ) {
    if (eval(hodnoty[a]+".value") == zne[a]) {
      text_field.value += tagse[a];
      document.getElementById(hodnoty[a]).style.background = '#87B701';
      i = zns[a];
      eval(hodnoty[a]+".value = i");
    }
  }
  text_field.focus();
  return;
}

function textfieldwrite(name,zn1,zn2,co1,co2) {
  if ( (clientVer >= 4) && is_ie && is_win ) {
    text_field.focus();
		theSelection = document.selection.createRange().text;
		if ( theSelection ) {
		  document.selection.createRange().text = co1 + theSelection + co2;
		  text_field.focus();
		  return false;
		}
		if (eval(name+".value") == zn1 && !theSelection) {
      text_field.value += co1;
      document.getElementById(name).style.background = 'red';
      i = zn2;
      eval(name+".value = i");
      text_field.focus();
      return false;
    }
    if (eval(name+".value") == zn2 && !theSelection) {
      text_field.value += co2;
      document.getElementById(name).style.background = '#87B701';
      i = zn1;
      eval(name+".value = i");
      text_field.focus();
      return false;
    }
	}
	else if (text_field.selectionEnd && (text_field.selectionEnd - text_field.selectionStart > 0)) {
		mozWrap(text_field, co1, co2);
		return false;
	}
	else {
    if (eval(name+".value") == zn1) {
      text_field.value += co1;
      document.getElementById(name).style.background = 'red';
      i = zn2;
      eval(name+".value = i");
      text_field.focus();
      return false;
    }
    if (eval(name+".value") == zn2) {
      text_field.value += co2;
      document.getElementById(name).style.background = '#87B701';
      i = zn1;
      eval(name+".value = i");
      text_field.focus();
      return false;
    }
  }
}

function mozWrap(txtarea, open, close){
	var selLength = txtarea.textLength;
	var selStart = txtarea.selectionStart;
	var selEnd = txtarea.selectionEnd;
	if (selEnd == 1 || selEnd == 2)
		selEnd = selLength;

	var s1 = (txtarea.value).substring(0,selStart);
	var s2 = (txtarea.value).substring(selStart, selEnd)
	var s3 = (txtarea.value).substring(selEnd, selLength);
	txtarea.value = s1 + open + s2 + close + s3;
	return;
}


function texttableshow(co) {
  info_text_input.value = co;
}
