
var add_dot_recursion = 0;
var count_novinky_moving = 0;
var count_novinky_moving_pausing = 5;
var count_novinky_moving_direction = 0;
var move_bestseller_direction = 'none';
function add_dot()
{
  document.getElementById('for_onunload').firstChild.nextSibling.nextSibling.data=document.getElementById('for_onunload').firstChild.nextSibling.nextSibling.data+' .';
  if (add_dot_recursion<5) setTimeout("add_dot()", 200);
  document.add_dot_recursion++;
}

function for_onunload_func()
{
  if (document.getElementById('sorting')) {document.getElementById('sorting').style.display='none';}
  if (document.getElementById('for_onunload').firstChild.data.length < 10)
  {
    document.getElementById('for_onunload').firstChild.data='Příprava stránky';
  }
  document.getElementById('for_onunload').style.top = document.body.scrollTop;
  document.getElementById('for_onunload').style.display='block';
  setTimeout("add_dot()", 1000);
  return 1;
}

var help_is_showed = false;

function show_help(e, help)
{

/*  if (document.getElementById('help_div').firstChild.content)
    document.getElementById('help_div').firstChild.value = help;
  else*/
    /*var text = document.getElementById('help_div').firstChild;
    for (var i in text) {
      alert ( i + " = " + text[i] + "\n");
   }*/
  
  document.getElementById('help_div').firstChild.data = help;
  
  var myscroll_x = 0;
  var myscroll_y = 0;
	if (window.pageYOffset) // all except Explorer
	{
		myscroll_x = window.pageXOffset;
		myscroll_y = window.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		myscroll_x = document.documentElement.scrollLeft;
		myscroll_y = document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		myscroll_x = document.body.scrollLeft;
		myscroll_y = document.body.scrollTop;
	}
  
  document.getElementById('help_div').style.top = e.clientY+myscroll_y+35+'px';
  document.getElementById('help_div').style.left = e.clientX+myscroll_x-60+'px';
  document.help_is_showed = true;
  document.getElementById('help_div').style.display = 'block';
}

function hide_help()
{
  document.getElementById('help_div').style.display = 'none';
  document.help_is_showed = false;
}

function my_on_move(e)
{
  if (document.help_is_showed)
  {
	  var myscroll_x = 0;
	  var myscroll_y = 0;
		if (window.pageYOffset) // all except Explorer
		{
			myscroll_x = window.pageXOffset;
			myscroll_y = window.pageYOffset;
		}
		else if (document.documentElement && document.documentElement.scrollTop)
			// Explorer 6 Strict
		{
			myscroll_x = document.documentElement.scrollLeft;
			myscroll_y = document.documentElement.scrollTop;
		}
		else if (document.body) // all other Explorers
		{
			myscroll_x = document.body.scrollLeft;
			myscroll_y = document.body.scrollTop;
		}
	  
	  document.getElementById('help_div').style.top = e.clientY+myscroll_y+35+'px';
	  document.getElementById('help_div').style.left = e.clientX+myscroll_x-60+'px';
  }
  return true;
}

var agt=navigator.userAgent.toLowerCase();

	if  (agt.indexOf("msie")!=-1)
	{
		document.write('<link rel="StyleSheet" href="/yo-store_msie_override.css" type="text/css" media="screen" />');
	}

function check_registration(theform)
	{
		var thereturn = true;
		if (!theform.name.value) thereturn=false;
		if (!theform.email.value) thereturn=false;
		if (!theform.dotaz.value) thereturn=false;
		
		if(!thereturn) alert('Vyplňte prosím všechna povinná pole (pole označená *).');
		return thereturn;
	}
	
function open_diskuze_form(id_parent, titulek)
{
	document.getElementById('diskuze_form_div').style.display = 'block';
	document.getElementById('diskuze_id_parent').value=id_parent;
	if (titulek && titulek.substr(0,3) != 'Re:')
	{
		document.getElementById('diskuze_titulek').value='Re: '+titulek;
	}
	else
	{
		document.getElementById('diskuze_titulek').value=titulek;
	}
	document.getElementById('diskuze_jmeno').focus();
}

function check_diskuze_form(theForm)
{
	var rt = true;
	if (!theForm.titulek.value || !theForm.jmeno.value || !theForm.dotaz.value)
	{
		rt = false;
		alert('Prosím vyplňte jméno, nadpis i komentář.');
	}
	return rt;
}

function kosik_vlozeno(get_vlozeno, ks_celk)
{
	if (get_vlozeno > 0 && ks_celk==get_vlozeno)
	{
		alert('Zboží bylo přidáno do košíku.\n\nKošík naleznete v pravé horní části každé stránky.');	
	}
}

function opravdu_cizi_jazyk()
{
	return confirm('Vkládáte do košíku knihu v cizím jazyce. Je to Váš záměr?');
}


function opravdu_jine_medium(medium)
{
	return confirm('Nevkládáte do košíku knihu, ale '+medium+'. Je to Váš záměr?');
}


function show_help_dostupnost(event)
{
	show_help(event, 'Dostupnost je stanovena dynamicky mimo jiné i na základě aktuálního času a konkrétního titulu. Naši dodavatelé jsou dostatečně spolehliví, proto je uvedená dostupnost ve více než 96% případů v souladu se skutečností.');
	//show_help(event, 'Předvánoční expediční lhůty mohou být delší. Děkujeme za pochopení.');
	
}

function move_novinky(count)
{
	if (document.getElementById('moving_novinka'))
	{
		var timeout_seconds = 35;
		if (count_novinky_moving_pausing>=70)
		{
			count_novinky_moving_direction++;
			count_novinky_moving_pausing=0;
			timeout_seconds = 4000;
			if (count_novinky_moving_direction>=howmany_moving_novinka)
			{
				count_novinky_moving_direction=0;
				document.getElementById('moving_novinka').style.top='5px';
			}
			
		}
		count_novinky_moving_pausing+=5;
		//document.getElementById('moving_novinka').firstChild.data = help;
		var top_pos = document.getElementById('moving_novinka').style.top.replace('px', '');
		top_pos-=5;
		//alert(top_pos);
		document.getElementById('moving_novinka').style.top = top_pos+'px';
		if (count<8)
		{
			window.setTimeout("move_novinky(1)",timeout_seconds);
		}
	}
}

function move_bestseller(direction)
{
	var timeout_seconds = 100;
	if (direction)
	{
		if (move_bestseller_direction == 'none' && direction != 'none')
		{
			move_bestseller_direction=direction;
			window.setTimeout("move_bestseller('')",timeout_seconds);
		}
		else
		{
			move_bestseller_direction=direction;
		}
	}
	else
	{
		var top_pos = document.getElementById('moving_bestsellers').style.top.replace('px', '');
		if (move_bestseller_direction == 'up')
		{
			top_pos=top_pos-0+5;
			if (top_pos>0) top_pos=0;
			
			document.getElementById('moving_bestsellers').style.top = top_pos+'px';
			window.setTimeout("move_bestseller('')",timeout_seconds);
			
		}
		else if (move_bestseller_direction == 'down')
		{
			top_pos-=5;

			//alert(top_pos);
//			/alert(document.getElementById('moving_bestsellers').offsetHeight);
			if (top_pos<116-document.getElementById('moving_bestsellers').offsetHeight) top_pos=116-document.getElementById('moving_bestsellers').offsetHeight;
			document.getElementById('moving_bestsellers').style.top = top_pos+'px';
			window.setTimeout("move_bestseller('')",timeout_seconds);
		}
		else
		{
			
		}
		
	}
}

var newimwindow='';

function newimwindow_pop(url) {
if (newimwindow.location && !newwindow.closed) {
    newimwindow.close(); }

    newimwindow=window.open(url,'htmlname','width=600,height=400,resizable=1');
}

function show_bonus_img(e, img_src)
{

/*  if (document.getElementById('help_div').firstChild.content)
    document.getElementById('help_div').firstChild.value = help;
  else*/
    /*var text = document.getElementById('help_div').firstChild;
    for (var i in text) {
      alert ( i + " = " + text[i] + "\n");
   }*/
  
  document.getElementById('bonus_big_image_img').src =  img_src;
  
  var myscroll_x = 0;
  var myscroll_y = 0;
	if (window.pageYOffset) // all except Explorer
	{
		myscroll_x = window.pageXOffset;
		myscroll_y = window.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		myscroll_x = document.documentElement.scrollLeft;
		myscroll_y = document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		myscroll_x = document.body.scrollLeft;
		myscroll_y = document.body.scrollTop;
	}
  
  document.getElementById('bonus_big_image').style.top = e.clientY+myscroll_y-135+'px';
  document.getElementById('bonus_big_image').style.left = e.clientX+myscroll_x+100+'px';
  document.help_is_showed = true;
  document.getElementById('bonus_big_image').style.display = 'block';
}

function hide_bonus_img()
{
  document.getElementById('bonus_big_image_img').src =  'http://knihy.abz.cz/imgs/trn.gif';
  document.getElementById('bonus_big_image').style.display = 'none';
  document.help_is_showed = false;
}

function fbs_click() {u=location.href;t=document.title; window.open('http://www.facebook.com/sharer.php?u=' +encodeURIComponent(u)+'&t='+ encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436'); return false; } 