function display(id){
  if(document.getElementById(id)){
  	var display = document.getElementById(id).style.display;
  	if(display=='block'){
  	  document.getElementById(id).style.display='none';
  	} else {
  	  document.getElementById(id).style.display='block';
  	}		
	}
}

function hide(id){
  if(document.getElementById(id)){
  	document.getElementById(id).style.display='none';
	}
}


function changeColor(id){
	if(id.style.backgroundColor == 'rgb(255, 255, 255)'){
	  id.style.background = 'rgb(247, 246, 244)';
	} else {
	  id.style.background = 'rgb(255, 255, 255)';
	}
}

function play(file){
  var path = getPath();
	if(path == '../'){
	  swfobject.embedSWF(path+'public/video_player_2.swf?video_source='+file+'', 'video', '236', '200', '9.0.0', path+'public/expressInstall.swf',{}, {allowfullscreen:'true'});
	} else {
	  swfobject.embedSWF('public/video_player.swf?video_source='+file+'', 'video', '236', '200', '9.0.0', path+'public/expressInstall.swf',{}, {allowfullscreen:'true'});
  }
}

function play2(file, id){
  var path = getPath();
	if(path == '../'){
	  swfobject.embedSWF(path+'public/video_player_big_2.swf?video_source='+file+'', id, '440', '380', '9.0.0', path+'public/expressInstall.swf',{}, {allowfullscreen:'true'});
	} else {
	  swfobject.embedSWF(path+'public/video_player_big.swf?video_source='+file+'', id, '440', '380', '9.0.0', 'public/expressInstall.swf',{}, {allowfullscreen:'true'});
 }
}



var http_request = false;

function createRequest(method, url, parameters, callback) // request 
{
	http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
	   	http_request = new XMLHttpRequest();
	   	if (http_request.overrideMimeType) {
	       	http_request.overrideMimeType('text/html');
	   	}
	} else if (window.ActiveXObject) { // IE
	   	try {
	       	http_request = new ActiveXObject("Msxml2.XMLHTTP");
	   	} catch (e) {
	      	try {
		   		http_request = new ActiveXObject("Microsoft.XMLHTTP");
	       	} catch (e) {}
	   	}
	}
	if (!http_request) {
	   	return false;
	}
    				      	
	http_request.onreadystatechange = callback;
	http_request.open(method, url + parameters, true);      
}
			
function anketa(){   
	if (http_request.readyState == 4) {
    if (http_request.status == 200) {
    	document.getElementById('anketa').innerHTML = http_request.responseText;	   
    }
  }
}
function anketaHlasuj(idAnkety, hlas, path){
	createRequest('GET', getPath()+'./public/anketa.php', '?id_ankety='+idAnkety+'&hlas='+hlas+'&path='+path, function(){anketa();});
	http_request.send(null);
}


function fotoalbum(){   
	if (http_request.readyState == 4) {
    if (http_request.status == 200) {
    	document.getElementById('fotoalbum').innerHTML = http_request.responseText;	
      // a();b();c();

    }
  }
}
function fotoalbumPrepni(idAlbumu, limit, path){
	createRequest('GET', getPath()+'./public/fotoalbum.php', '?galeryId='+idAlbumu+'&limit='+limit+'&path='+path, function(){fotoalbum();});
	http_request.send(null);
}

function login(){   
	if (http_request.readyState == 4) {
    if (http_request.status == 200) {
    	var response = http_request.responseText;
    	if(response){
    		eval(response);
    	} 
    }
  }
}
function logindo(user, pass, remember, path){
	//alert(remember);
	createRequest('GET', getPath()+'./public/login.php', '?user='+user+'&pass='+pass+'&remember='+remember+'&path='+path, function(){login();});
	http_request.send(null);
}
function logout(){   
	if (http_request.readyState == 4) {
    if (http_request.status == 200) {
    	var response = http_request.responseText;
    	if(response=='ok'){
    		document.getElementById('login_form').style.display = 'block';
    		document.getElementById('message_form').style.display = 'none';
    	} 
    }
  }
}
function logoutdo(){
	createRequest('GET', getPath()+'./public/login.php', '?action=logout', function(){logout();});
	http_request.send(null);
}


// otevira odkazy s ref=external v novem okne - kvuli nevalidite target=_blank v XHTML
function externalLinks() 
{
  if( !document.getElementsByTagName ) return;
  var anchors = document.getElementsByTagName('a');
  for( var i=0; i<anchors.length; i++ ) {
    var anchor = anchors[i];
    if( anchor.getAttribute('href') && anchor.getAttribute('rel') == 'external' )
       	anchor.target = '_blank';
    }
}

function addEvent2(elm, evType, fn, useCapture)
{
 if (elm.addEventListener){
   elm.addEventListener(evType, fn, useCapture);
   return true;
 } else if (elm.attachEvent){
   var r = elm.attachEvent("on"+evType, fn);
   return r;
 }
}

addEvent2(window,'load',externalLinks);


function fotoalbumPrepniNew(idAlbumu, limit, path){
	createRequest('GET', getPath()+'./public/fotoalbum.php', '?galeryId='+idAlbumu+'&limit='+limit+'&path='+path, function(){fotoalbumNew();});
	http_request.send(null);
}
function fotoalbumNew(){   
	if (http_request.readyState == 4) {
    if (http_request.status == 200) {
    	//document.getElementById('fotoalbum').innerHTML = http_request.responseText;
    	eval(http_request.responseText);
      // a();b();c();
    }
  }
}