function showElement(elId){
	var e = document.getElementById(elId);
	var f = document.getElementById(elId + '_q');

  if(e){
		e.style.display = 'block';
	}

	if(f){
		f.style.display = 'none';
	}
}
function hideElement(elId){
	var e = document.getElementById(elId);
  var f = document.getElementById(elId + '_q');
	if(e){
		e.style.display = 'none';
	}
  if(f){
		f.style.display = 'block';
	}
}



var blackBoxContent;
function blackBoxClose(vstup, param)
{
  if (param == 1){
    document.getElementById('flash_obj').style.display = "";
    document.getElementById('flash_obj_white').style.display = "none";
  }
  
  $('#'+vstup).html(blackBoxContent);
  blackBoxContent='';
  $('#blackBox').hide();
  $('#blackBoxContent').html('');
  $('#blackBoxContent').hide();
  $('body').css('overflow','auto');
}

function blackBoxOpen(vstup, param)
{
  if (param == 1){
    document.getElementById('flash_obj').style.display = "none";
    document.getElementById('flash_obj_white').style.display = "";
  }
  
  h=$(window).height();
  w=$(window).width();
  t=0;
  l=0;
  t=(h/2)-250;
  l=(w/2)-240;

  p='fixed';
  //if($.browser.msie && $.browser.version=="6.0") p='absolute';
  if($.browser.msie) p='absolute';

  $('body').css('overflow','hidden');
  $('body').append('<div id="blackBox"></div>');
  $('#blackBox').css({display:'block',height:h,width:'100%',position:p,left:0,top:0,opacity:75/100,zIndex:'9998'});
  $('body').append('<div id="blackBoxContent"></div>');
  $('#blackBoxContent').css({display:'block',position:p,left:l,top:t,opacity:100/100});
  blackBoxContent=$('#'+vstup).html();
  
  var html_text = '<div class="'+vstup+'">'+blackBoxContent+'</div><div id="blackBoxClose"><img src="images/ico_close_black_box.png" alt="" class="blackBoxClose" onclick="blackBoxClose(\''+vstup+'\', '+param+')" /></div>';
  
  $("#blackBoxContent").html(html_text);
}

$(document).ready(function(){

  $('.ponuka_menu').click(function(){
    $('.ponuka_menu').removeClass('on');
    $(this).addClass('on');
    $('.obsah .m').fadeOut('fast');
    $('#'+$(this).attr('rel')).fadeIn('fast');
  });

  $('.ponuka').click(function(){
    $('.ponuka').removeClass('ponuka_on');
    $('.ponuka').addClass('ponuka_off');
    $(this).addClass('ponuka_on');
    $(this).removeClass('ponuka_off');
    hodnota=$(this).attr('rel');
    $('.ponuka_obsah').hide();
    $('#'+hodnota).show();
    $('.ponuka_menu').removeClass('on');
    $('#'+hodnota+' .ponuka_menu:first').addClass('on');
    $('#'+hodnota+' .ponuka_menu:first').click();
  });

  $('#newsletter_button').click(function(){
    hodnota=$('#newsletter_text').attr('value');
    $.get('modules/newsletter/addemail.php?m='+hodnota, function(data) {
      alert(data);
    });
  });

/*
  $('.login_button_webstranky').click(function(){
    $('.login_window').removeClass('login_window_inzerenti');
    $('.login_window').addClass('login_window_webstranky');
    $('.login_window').show('fast');
    $('#send_login_form').attr('action','http://b2m.web2media.sk/');
    $('#send_login_login').attr('name','mf_user');
    $('#send_login_passwd').attr('name','mf_pass');
    $('#send_login_button').attr('name','mf_submit');
  });

  $('.login_button_inzerenti').click(function(){
    $('.login_window').removeClass('login_window_webstranky');
    $('.login_window').addClass('login_window_inzerenti');
    $('.login_window').show('fast');
    $('#send_login_form').attr('action','https://tango.admeta.com/Login.aspx?pn=adguru');
    $('#send_login_login').attr('name','ctl00$DefaultContent$txtUserName');
    $('#send_login_passwd').attr('name','ctl00$DefaultContent$txtPassword');
    $('#send_login_button').attr('name','ctl00$DefaultContent$btnL');
  });
*/
});


function openYouTube(id){
      //YouTube Player Parameters
      var width = 640;
      var height = 505;
      var FullScreen = "no";
      var AutoPlay = "yes";
      var HighDef = "no";

      //Calculate Page width and height
      var pageWidth = window.innerWidth;
      var pageHeight = window.innerHeight;
      if (typeof pageWidth != "number"){
      if (document.compatMode == "CSS1Compat"){
            pageWidth = document.documentElement.clientWidth;
            pageHeight = document.documentElement.clientHeight;
      } else {
            pageWidth = document.body.clientWidth;
            pageHeight = document.body.clientHeight;
            }
      }
      // Make Background visible...
      var divbg = document.getElementById('bg');
      divbg.style.visibility = "visible";

      //Create dynamic Div container for YouTube Popup Div
      var divobj = document.createElement('div');
      divobj.setAttribute('id',id); // Set id to YouTube id
      divobj.className = "popup";
      divobj.style.visibility = "visible";
      var divWidth = width + 4;
      var divHeight = height + 20;
      divobj.style.width = divWidth + "px";
      divobj.style.height = divHeight + "px";
      var divLeft = (pageWidth - divWidth) / 2;
      var divTop = (pageHeight - divHeight) / 2 - 10;
      //Set Left and top coordinates for the div tag
      divobj.style.left = divLeft + "px";
      divobj.style.top = divTop + "px";

      //Create dynamic Close Button Div
      var closebutton = document.createElement('div');
      closebutton.style.visibility = "visible";
      closebutton.innerHTML = "<span onclick=\"closeYouTube('" + id +"')\" class=\"close_button\">X</span>";
      //Add Close Button Div to YouTube Popup Div container
      divobj.appendChild(closebutton);

      //Create dynamic YouTube Div
      var ytobj = document.createElement('div');
      ytobj.setAttribute('id', "yt" + id);
      ytobj.className = "ytcontainer";
      ytobj.style.width = width + "px";
      ytobj.style.height = height + "px";
      if (FullScreen == "yes") FullScreen="&fs=1"; else FullScreen="&fs=0";
      if (AutoPlay == "yes") AutoPlay="&autoplay=1"; else AutoPlay="&autoplay=0";
      if (HighDef == "yes") HighDef="&hd=1"; else HighDef="&hd=0";
      var URL = "http://www.youtube.com/v/" + id + "&hl=en&rel=0&showsearch=0" + FullScreen + AutoPlay + HighDef;
      var YouTube = "<object width=\"" + width + "\" height=\"" + height + "\">";
      YouTube += "<param name=\"movie\" value=\"" + URL + "\"></param>";
      YouTube += "<param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param>";
      YouTube += "<embed src=\"" + URL + "\" type=\"application/x-shockwave-flash\" ";
      YouTube += "allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"" + width + "\" height=\"" + height + "\"></embed></object>";
      ytobj.innerHTML = YouTube;
      //Add YouTube Div to YouTube Popup Div container
      divobj.appendChild(ytobj);

      //Add YouTube Popup Div container to HTML BODY
      document.body.appendChild(divobj);
}
function closeYouTube(id){
      var divbg = document.getElementById('bg');
      divbg.style.visibility = "hidden";
      var divobj = document.getElementById(id);
      var ytobj = document.getElementById("yt" + id);
      divobj.removeChild(ytobj); //remove YouTube Div
      document.body.removeChild(divobj); // remove Popup Div
}

