var dom =
{
  gE : function (el)
  {
    try
    {
      return document.getElementById(el);
    }
    catch(e)
    {
      alert('Chyba v souboru btl.js ve funkci dom.gE. pri nacteni elementu s id='+el, e);
      return (null);
    }
  }
}

function isFunction(a)
{
  return (typeof(a) == 'function');
}

function isObject(a)
{
  return ((a && typeof(a) == 'object') || isFunction(a));
}

function hidePerex(id)
{
  var more = dom.gE('more'+id);
  var hide = dom.gE('hide'+id);

  more.style.display = 'inline';
  hide.style.display = 'none';
} // function

function viewPerex(id)
{
  var more = dom.gE('more'+id);
  var hide = dom.gE('hide'+id);

  more.style.display = 'none';
  hide.style.display = 'inline';
} // function


function popupImg(link, width, height)
{
	var param;
	var wokno;

	param = "width="+width+",height="+height+",resizable=no";

	wokno = window.open( link, "", param);

	return (typeof(wokno)=='object')?true:false;
}

/*
	Skrývání a odkrývání textu
*/
var last = null;
function more(obj)
{
	//najdeme span
	var otevrit = obj.previousSibling.style.display!='none';
	
	//zavreme otevrene
	if (last && otevrit)
		more(last);

	//tecky
	obj.previousSibling.style.display = otevrit?'none':'inline';
	
	//text
	obj.previousSibling.previousSibling.style.display = otevrit?'inline':'none';
	
	//obj.innerHTML = otevrit?'hide':'show';
	obj.className = otevrit?'hide':'show';
	last = otevrit?obj:null;
	
	return false;
}

function downloads(obj)
{
	//vsechny vetve pozavirame
	var docs = document.getElementById('content-2').getElementsByTagName('H3');
	var div;
	var otevrit = obj.className=='show';
	
	for (var i=0;i<docs.length;i++)
	{
		docs[i].getElementsByTagName('A')[0].className = 'show';
		div = docs[i].nextSibling;
		if (div.nodeName!='DIV') div = div.nextSibling;
		div.style.display = 'none';	
	}

	div = obj.parentNode.nextSibling;
	if (div.nodeName!='DIV') div = div.nextSibling;

	obj.className = otevrit?'hide':'show';
	div.style.display = otevrit?'block':'none';
	
	if (document.all)
	{
		document.getElementById('footerBlock').style.position = 'relative';
		document.getElementById('footerBlock').style.position = 'absolute';
	}
	
	return false;
}

/*
	Pomocná fce pro konfigurátor
*/

function configurator1(obj, therapy, series)
{
	var test1, test2;
	
	//kontrola, zda-li je vybrana therapie
	test1 = obj['elements'][0].checked || obj['elements'][1].checked || obj['elements'][2].checked || obj['elements'][3].checked;
	if (!test1)
	{
		alert(therapy);
		return false;
	}
	//kontrola, zda-li je vybrana rada
	test2 = obj['elements'][4].checked || obj['elements'][5].checked;
	if (!test2)
	{
		alert(series);
		return false;
	}
	
	return true;
}

//chyba v IE7
function onloadWindow()
{
	var footer = document.getElementById('footerBlock');
	if (document.all)
	{
		footer.style.position = 'relative';
		footer.style.position = 'absolute';
	} 
}

/**
 * Nastavuje cookie dodaneho jmena na dodanou hodnotu po dalsich N dnu.
 */
function setCookie(c_name,value,exdays)
{
  var exdate=new Date();
  exdate.setDate(exdate.getDate()+exdays);
  var c_value=escape(value)+((exdays==null) ? "" : "; expires="+exdate.toUTCString());
  document.cookie=c_name+"="+c_value+"; path=/";
}
//------------------------------------------------------------------------------------------------

/**
 * Vraci hodnotu cookie. Pokud ji nenajde tak vraci null.
 */
function getCookie(c_name)
{
  var i,x,y,ARRcookies=document.cookie.split(";");
  for (i=0;i<ARRcookies.length;i++)
    {
      x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
      y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
      x=x.replace(/^\s+|\s+$/g,"");
      if (x==c_name) return unescape(y);
    }
  return null;
}
//------------------------------------------------------------------------------------------------

window.onload = onloadWindow;

// Document ready
$(function(){

	/* Obsluha spuštění flashe se soutěží
	  	- stránka soutez-flash.html byla zduplikována z důvodů načítání rozdílných XML souborů
	  	- exilis-soutez-liposukce-flash-frame-3.xml - má v sobě příznak (JumpTo) který rovnou zobrazí poslední snímek flashe
	*/
	// Jsme na stránce se soutěží?
	/*
	if($("#link-exilis-contest").length){
		$("#link-exilis-contest").fancybox({
			'width'				: 900,
			'height'			: 506,
		    'padding'           : 0,
	        'autoScale'     	: true,
	        'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'type'				: 'swf', 
			'swf'				: {'flashvars': 'xmlPath=http://www.exilis.cz/swf/exilis-liposukce.xml'},
			'titleShow'			: false
		});
	} */

	// Po načtení stránky se flash automaticky zobrazí v modálním okně
	$('.flash-show-in-window a').trigger('click');
	
	
	
/////// EN verze - Aesthetic
	// Jsme na stránce se soutěží?
	/*
	if($("#aesthetics-link-exilis-contest").length){
		$("#aesthetics-link-exilis-contest").fancybox({
			'width'				: 900,
			'height'			: 506,
		    'padding'           : 0,
	        'autoScale'     	: true,
	        'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'type'				: 'swf', 
			'swf'				: {'flashvars': 'xmlPath=http://www.btlaesthetics.com/swf/aesthetics/data.xml'},
			'titleShow'			: false
		});
	} */
	
  //Inicializace FancyBoxu (lightboxu)
  $("a[rel^='lightbox']").fancybox();

	// Po načtení stránky se flash automaticky zobrazí v modálním okně
	//$('#aesthetics-link-exilis-contest').trigger('click');	
	
	//Zobrazeni upozorneni pokud je prilozeno a pokud navstevnik neodmackl ze je specialista
  if ($('#specialist-selection').size())
    {
      var specialist=getCookie('specialist');
      if (specialist!=1)
        $('#specialist-selection').trigger('click');
    }
	
});
