//if (mp3url) MP3Ukazka();

//**** fixdiv roller.
var ie = navigator.userAgent.toLowerCase().indexOf("msie") != -1;
var fixdiv = document.getElementById('fixdiv')
var lastscroll = new Date();



do_resize();
function do_resize() {
  var etwidth = fixdiv.offsetWidth;

  if (ie) {
    window.onscroll = myscroll;
    window.onresize = myscroll;
    fixdiv.style.position = 'absolute'
    fixdiv.style.visibility = 'hidden'
    fixdiv_show();
  } else {
    fixdiv.style.position = 'fixed'
  };

  var loc = ''+document.location
};

function fixdivonmouseover() { if (ie) fixdiv.style.filter=''; else fixdiv.style.MozOpacity='1'; };
function fixdivonmouseout()  { if (ie) fixdiv.style.filter='alpha(opacity=70)'; else fixdiv.style.MozOpacity='.7'; };

function fixdiv_show() {
  var now = new Date();
  if (now.getTime() - lastscroll.getTime() < 500 ) {
    window.setTimeout('fixdiv_show()', 500);
  } else {
    if (fixdiv.style.visibility != 'visible') {
      fixdiv.style.filter = 'revealTrans(duration=2),alpha(opacity=75)'
      fixdiv.filters[0].Apply();
      fixdiv.style.visibility = 'visible'
      fixdiv.filters[0].transition=12; 
      fixdiv.filters[0].Play();
       
      
    };
  }
}

function myscroll() {
  fixdiv.style.top = document.body.scrollTop + document.body.clientHeight - fixdiv.offsetHeight - 0;
  fixdiv.style.visibility = 'hidden'
  lastscroll = new Date();
  window.setTimeout('fixdiv_show()', 500);
}



//**************** MP3 player
function GetplayerHTML() {
  var sourceElement = document.getElementById('player_source');
  if (sourceElement) return sourceElement.value; 
}

function MP3Ukazka() {
  var playerMasterElement = document.getElementById('player_div');
  if (playerMasterElement) {
    var playerHTML = GetplayerHTML();
    //
    playerMasterElement.innerHTML = playerHTML + popis; 
  }
}

function HtmlKodHide(){
  var HtmlSourceDiv = document.getElementById('HtmlSourceDiv');
  if (HtmlSourceDiv) HtmlSourceDiv.style.display = 'none'

  var player_div = document.getElementById('player_div');
  if (player_div)player_div.style.visibility = 'visible';
} 

function HtmlKodUkazka(title) {
  var player_div = document.getElementById('player_div');
  player_div.style.visibility = 'hidden';

  var playerHTML = GetplayerHTML();
  playerHTML = playerHTML.replace(/-sound-/g,'-ext-sound-');
  playerHTML += popis;
  showSourceDialog(playerHTML, title, 'MP3 ukázka ' + title + '. Vlož tento html kód na svoje WWW stránky nebo blog. HTML kód obsahuje MP3 přehrávač s ukázkou zdarma.')
}

function escapeHTML (str){
   var div = document.createElement('div');
   var text = document.createTextNode(str);
   div.appendChild(text);
   return div.innerHTML;
}; 


var Screen = {
  ie : document.all,
  scrollLeft:function(){
    return typeof(document.body.scrollTop) != "undefined" ? document.body.scrollLeft : window.pageXOffset;
  },
  scrollTop:function(){
    return typeof(document.body.scrollTop) != "undefined" ? document.body.scrollTop : window.pageYOffset;
  },
  Width:function(){
    return typeof(window.innerWidth)!="undefined"?window.innerWidth:(document.body.clientWidth?document.body.clientWidth:document.documentElement.clientWidth);
  },
  Height:function(){
    return typeof(window.innerHeight)!="undefined"?window.innerHeight:(document.body.clientHeight?document.body.clientHeight:document.documentElement.clientHeight);
  }
  
} 

function docategoryhtml(categoryHtmlId, title, description) {
 var htmlElement = document.getElementById('category_'+categoryHtmlId);
 if (htmlElement) {
  var html = htmlElement.innerHTML;
  html = cistiHTML(html);
  html = '<img src="http://data.logotip.cz/obrazky/nic-ext-cat.gif" alt="Void" />'+html;
  
  showSourceDialog(html, title, description);
 }

 
 return false;
}

function cistiHTML(html) {
  html = html.replace(/\t/g,' ');
  html = html.replace(/\r/g,' ');
  html = html.replace(/\n/g,' ');
  html = html.replace(/<strong>/g,'');
  html = html.replace(/<\/strong>/g,'');
  html = html.replace(/  /g,' ');
  html = html.replace(/  /g,' ');
  html = html.replace(/  /g,' ');
  html = html.replace(/  /g,' ');
  return html;
}

function HtmlKodDeatil(image_element, title, url) {
//  html = cistiHTML(html);
  var e = document.getElementById('image_element');
  if (e) {
  
    html = e.innerHTML
    if (html) {
      html = html.replace(/-preview-/g,'-ext-preview-');
      html = '<a href="' + url + '">' + html + '</a>';
    //html += '<img src="http://data.logotip.cz/obrazky/nic-ext-cat.gif" alt="Void" />';
      showSourceDialog(html, title, '');
    };
  }
  return false;
  
  
}


function showSourceDialog(html, title, description) {


 var categoryHtmlDiv = document.getElementById('HtmlSourceDiv');

 var textareaHtml = document.getElementById('textareaHtml');
 //alert(window.pageXOffset)
 
 if (categoryHtmlDiv && textareaHtml) {
  var HtmlSourceDescription = document.getElementById('HtmlSourceDescription');
  
  if (HtmlSourceDescription) {
    if (!description) description = 'HTML kód s obrázky a ukázkami na mobil. Zkopíruj tento kód do schránky a vlož na svoje stránky nebo blog .';
    var dhtml = '<h2>' + title + ' - HTML kód</h2>';
    dhtml += '&nbsp;&nbsp;&nbsp;&nbsp; ' + description;
    HtmlSourceDescription.innerHTML=dhtml; 
  }
 
  
  html = html.replace(/href=\"\//g, 'href="http://'+document.location.host+'\/');
  html = html.replace(/src=\"\//g, 'src="http://'+document.location.host+'\/');
  textareaHtml.value = html; 

  categoryHtmlDiv.style.display = "block";

  var x = Screen.scrollLeft() + (Screen.Width() / 2) - (categoryHtmlDiv.offsetWidth / 2);
  var y = Screen.scrollTop() +  (Screen.Height() / 2) - (categoryHtmlDiv.offsetHeight / 2);
  
  categoryHtmlDiv.style.top = y+'px';
  categoryHtmlDiv.style.left = x+'px';
 }
 return false;
}




// ************************ zbozi
function zobrazzbozi(html) {
  //alert(html);
  //zbozisource = document.getElementById('zbozi_source');
  zbozimain = document.getElementById('zbozi_main');
  if (zbozimain ) {
    var width =getWidth(); 
    if (width>1100) {
      zbozimain.innerHTML = html;
      zbozimain.style.display = 'block';
    } else if (width>980) {
      //container = document.getElementById('container');
      //container.style.margin = '0px';
      zbozimain.innerHTML = html;
      zbozimain.style.display = 'block';
      //alert((width-760)/2);
      zbozimain.style.width = (width-810)/2 +'px'; 
    }
    
  }
}

function getWidth() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return myWidth;
  
}
function openurl(url) {
//
   
  try {

   
   if (url.indexOf('.eslova.cz')<0) {
     url='http://www.eslova.cz/jinam.aspx?' + escape(url)
    };
   
   document.location=url; 
  } catch (err) {
	}
 return false;
};

function add_qs(url, addstr) {
 if (url.indexOf(addstr) >=0) {
  return url;//uz obsahuje
 } else {
  if (url.indexOf('?') >=0) url+='&'; else url+='?';  
  return url+addstr;
 }
}


