var W3CDOM = (document.createElement && document.getElementsByTagName);
var posuv = 440; 
window.onload = all;
var timerID;
var tempdir = "";

function all()
{
	if (!W3CDOM) return;
  /*
  Cufon.replace('h1', {textShadow: '0px -1px #000'} );
  Cufon.replace('h1 > span> strong', {textShadow: '0px -1px #000',  fontFamily: 'Fisch'} );
  Cufon.replace('h1 > em', {fontSize: '18px'} );  
  Cufon.replace('h2', {textShadow: '0px -1px #000'} );
  Cufon.replace('h2 > span> strong', {textShadow: '0px -1px #000',  fontFamily: 'Fisch'} );
  Cufon.replace('h3', {textShadow: '0px 1px #fff',  fontFamily: 'Fisch', fontSize: '20px'}) ;
  */
 

 
	new_window_link();
	
		  	 if(document.getElementById('back')){   
         var back = document.getElementById('back');
         back.onclick = moveback;
          back.style.display = 'none';
         }
	  	   if(document.getElementById('ffwd')){
         var ffwd = document.getElementById('ffwd');
         ffwd.onclick = moveffwd;
         checkEnds();
         } 
	
}




// loga vertical

function checkEnds(){
 var cinema = document.getElementById('cinema');
 var actualmargin = cinema.offsetTop;
 var back = document.getElementById('back');
 var backnone = document.getElementById('backnone'); 
 var ffwd = document.getElementById('ffwd'); 
 var ffwdnone = document.getElementById('ffwdnone'); 
 if(actualmargin >= 0){ 
  backnone.style.display = 'block'; 
  back.style.display = 'none'; 
  } 
  else { 
  back.style.display = 'block'; 
  backnone.style.display = 'none';
  }
//alert((((cinema.offsetHeight*-1)/2)+(posuv)) + 'ok' + actualmargin);
 if(actualmargin <= (((cinema.offsetHeight*-1)/2)+(posuv))) { 
 ffwd.style.display = 'none'; 
 ffwdnone.style.display = 'block';
 } else { 
 ffwd.style.display = 'block';
 ffwdnone.style.display = 'none';
 }
 }

 
function moveback(){
 var cinema = document.getElementById('cinema');
 var actualmargin = cinema.offsetTop;
 var newmargin = actualmargin + posuv;
 movebottom(newmargin);
 return false;
}
function moveffwd(){
 var cinema = document.getElementById('cinema');
 var actualmargin = cinema.offsetTop;
 var newmargin = actualmargin - posuv;
 movetop(newmargin);
 return false;
}
function movetop(newmargin){
 var cinema = document.getElementById('cinema');
 var actualmargin = cinema.offsetTop; 
 steptop = actualmargin - 50;
 cinema.style.marginTop = steptop + 'px';
 if(cinema.offsetTop > newmargin){
 setTimeout("movetop("+newmargin+")",1);
 }
 else{
 cinema.style.marginTop = newmargin + 'px';
 checkEnds();
 }
}
function movebottom(newmargin){
 var cinema = document.getElementById('cinema');
 var actualmargin = cinema.offsetTop; 
 steptop = actualmargin + 50;
 cinema.style.marginTop = steptop + 'px';
 if(cinema.offsetTop < newmargin){
 setTimeout("movebottom("+newmargin+")",1);
 }
 else{
 cinema.style.marginTop = newmargin + 'px';
 checkEnds(); 
 }
}

 
var path_to_icon 		= '/images/exlink.gif';
var link_alt_text 		= 'Otevřít odkaz v novém okně';
var link_title_text 	= 'Otevřít odkaz v novém okně';

function new_window_link() {
	if (!document.getElementById || !document.createTextNode || !document.domain || !document.getElementById('content')) return;
	var text = document.getElementById('content');
	var linx = text.getElementsByTagName('a');
	for (var i = 0; i < linx.length; i++)
	{
		// just for off-site links
		if (linx[i].href.length > 0)
		{
			if((linx[i].protocol == 'http:')||(linx[i].protocol == 'https:'))
			{

      	if ((linx[i].href.split('/')[2].replace(/www\./, '') != document.domain.replace(/www\./, '')||(linx[i].href.split('out.php')[1]))
				&& !linx[i].getAttribute('target')
				&& !linx[i].parentNode.id.match(/^copy/)
        && (linx[i].childNodes[0].tagName != 'IMG')
				&& !linx[i].className.match(/^nonww/)        
        )
				{
				linx[i].setAttribute('target', '_blank');
					// create new elements
					var nwl = document.createElement('a');
          var nwl_image = document.createElement('img');
					var space = document.createTextNode(' ');
					// setup image attributes
				nwl_image.setAttribute('src', path_to_icon);
				nwl_image.setAttribute('alt', link_alt_text);
				nwl_image.setAttribute('title', link_title_text);
				nwl_image.style.border = 'none';
				// set link attributes
				nwl.setAttribute('href', linx[i].getAttribute('href'));
				nwl.setAttribute('target', '_blank');
				nwl.setAttribute('title', link_title_text);
				nwl.className = 'new_window_link';
				// append new elements
				nwl.appendChild(nwl_image);
				linx[i].parentNode.insertBefore(space, linx[i].nextSibling);
				linx[i].parentNode.insertBefore(nwl, linx[i].nextSibling.nextSibling);
				}
			}
		}
	}
}
  function clearLogin(){
  var theForm = document.getElementById('mylogin');
  if(document.getElementById('login')){
  document.getElementById('login').onclick = noValue1;
 
  }
  if(document.getElementById('pass')){
  document.getElementById('pass').onclick = noValue2;
 
  }
  }
  function noValue1(){
  document.getElementById('login').value = '';
  }
  function noValue2(){
  document.getElementById('pass').value = '';
  }
  
// Send Reg

 function regFormSave(){
  alert(ok);
  var button = document.getElementById("regbutton");
  button.value  ="Ukládá...";
  button.disabled = true;
  return false;
}
function no(){
	var data = '';
	var form = document.getElementById(formID);
	var f_el = form.getElementsByTagName('input');
	var f_length = f_el.length;
	for(i=0;i<f_length;i++){
		
  if (f_el[i].type == 'checkbox')
  {
  if (f_el[i].checked == true || f_el[i].checked == 'true')
  {
  data += '&'+f_el[i].name+'='+f_el[i].value;
  }
  }
  else{
  data += f_el[i].name + '=' + f_el[i].value + '&';
	}
  
  
  }
	var form = document.getElementById(formID);
	var f_el = form.getElementsByTagName('select');
	var f_length = f_el.length;
	for(i=0;i<f_length;i++){
		data += f_el[i].name + '=' + f_el[i].value + '&';
	}
	var form = document.getElementById(formID);
	var f_el = form.getElementsByTagName('textarea');
	var f_length = f_el.length;
	for(i=0;i<f_length;i++){
	data += f_el[i].name + '=' + f_el[i].value + '&';

	}
 


	url='/pages/saveForm.php';
	if (window.ActiveXObject)
	{
		httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		httpRequest = new XMLHttpRequest();
	}
	httpRequest.open("POST", url, true);
	httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	httpRequest.send(data);
	httpRequest.onreadystatechange= function () {processRequestGAx(); } ;
	return false;

}

