/*
 * rokbox (for jQuery)
 * version: 1.1 (03/01/2008)
 * @requires jQuery v1.2 or later
 *
 * Examples at http://famspam.com/rokbox/
 *
 * Licensed under the MIT:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Copyright 2007, 2008 Chris Wanstrath [ chris@ozmm.org ]
 *
 * Usage:
 *  
 *  jQuery(document).ready(function() {
 *    jQuery('a[rel*=rokbox]').rokbox() 
 *  })
 *
 *  <a href="#terms" rel="rokbox">Terms</a>
 *    Loads the #terms div in the box
 *
 *  <a href="terms.html" rel="rokbox">Terms</a>
 *    Loads the terms.html page in the box
 *
 *  <a href="terms.png" rel="rokbox">Terms</a>
 *    Loads the terms.png image in the box
 *
 *
 *  You can also use it programmatically:
 * 
 *    jQuery.rokbox('some html')
 *
 *  This will open a rokbox with "some html" as the content.
 *    
 *    jQuery.rokbox(function() { ajaxes })
 *
 *  This will show a loading screen before the passed function is called,
 *  allowing for a better ajax experience.
 *
 */

	  pathArray = window.location.pathname.split( '/' );
	  var pathName = pathArray[1]; 

(function($) {
  $.rokbox = function(data, klass) {
    $.rokbox.init()
    $.rokbox.loading()
    $.isFunction(data) ? data.call($) : $.rokbox.reveal(data, klass)
  }

  $.rokbox.settings = {
    loading_image : window.location.protocol+'//'+window.location.host+'/public/lightbox/light/ajax-loader.gif',
    close_image   : window.location.protocol+'//'+window.location.host+'/public/lightbox/light/close.gif',
    image_types   : [ 'png', 'jpg', 'jpeg', 'gif' ],
    rokbox_html  : '\
  <div id="rokbox" style="display:none;"> \
		<div id="innerdivid" style="visibility: visible; opacity: 0.9; position: absolute;left: 0px; cursor: pointer; background-color: rgb(0, 0, 0);width:100%;filter:alpha(opacity = 90);"> \
	</div>\
    <div class="popup"> \
      <table cellspacing="0" cellpadding="0" border="0"> \
        <tbody> \
	       <tr> \
            <td class="tl"/><td class="tm"/><td class="tr"/> \
          </tr> \
          <tr> \
            <td class="ml" /> \
            <td class="body" valign="middle"> \
	   <div style="float:right; margin-right:18px;"> <a href="#" class="close" style="margin-right:-10px;"> <img src="'+this.close_image+'" title="close" class="close_image" /></a>\
   </div>\
              <div class="content" style="width:390px; height:auto; padding-bottom:15px"> \
              </div> \
              <div> \
                <a href="#" class="close"> \
                  \
                </a> \
              </div> \
            </td> \
            <td class="mr"/> \
          </tr> \
          <tr> \
            <td class="bl"/><td class="bm"/><td class="br"/> \
          </tr> \
        </tbody> \
      </table> \
    </div> \
  </div>'
  }

  $.rokbox.loading = function() {
    if ($('#rokbox .loading').length == 1) return true
     pokusnew(); 
    $('#rokbox .content').empty()
  $('#rokbox .body').children().hide().end().
      append('<div class="loading"><img src="'+$.rokbox.settings.loading_image+'"/></div>')

    var pageScroll = $.rokbox.getPageScroll()
    $('#rokbox').css({
      top:	pageScroll[1] + ($.rokbox.getPageHeight() / 10),
      left:	pageScroll[0]		 
    }).show()

    $(document).bind('keydown.rokbox', function(e) {
      if (e.keyCode == 27) $.rokbox.close()
    })
  }

  $.rokbox.reveal = function(data, klass) {
    if (klass) $('#rokbox .content').addClass(klass)
    $('#rokbox .content').append(data)
    $('#rokbox .loading').remove()
    $('#rokbox .body').children().fadeIn('normal')
  }

  $.rokbox.close = function() {
    $(document).trigger('close.rokbox')
    return false
  }

  $(document).bind('close.rokbox', function() {
    $(document).unbind('keydown.rokbox')
    $('#rokbox').fadeOut(function() {
      $('#rokbox .content').removeClass().addClass('content')
    })
  })

  $.fn.rokbox = function(settings) {
    
    var image_types = $.rokbox.settings.image_types.join('|')
    image_types = new RegExp('\.' + image_types + '$', 'i')

    function click_handler() {
      $.rokbox.loading(true)

      // support for rel="rokbox[.inline_popup]" syntax, to add a class
      var klass = this.rel.match(/rokbox\[\.(\w+)\]/)
      if (klass) klass = klass[1]

      // div
      if (this.href.match(/#/)) {
        var url    = window.location.href.split('#')[0]
        var target = this.href.replace(url,'')
        $.rokbox.reveal($(target).clone().show(), klass)

      // image
      } else if (this.href.match(image_types)) {
        var image = new Image()
        image.onload = function() {
          $.rokbox.reveal('<div class="image"><img src="' + image.src + '" /></div>', klass)
        }
        image.src = this.href

      // ajax
      } else {
        $.get(this.href, function(data) { $.rokbox.reveal(data, klass) })
      }

      return false
    }

    this.click(click_handler)
    return this
  }

  $.rokbox.init = function(settings) {
    if ($.rokbox.settings.inited) {
      return true
    } else {
      $.rokbox.settings.inited = true
    }

    if (settings) $.extend($.rokbox.settings, settings)
    $('body').append($.rokbox.settings.rokbox_html)

    var preload = [ new Image(), new Image() ]
    preload[0].src = $.rokbox.settings.close_image
    preload[1].src = $.rokbox.settings.loading_image

    $('#rokbox').find('.b:first, .bl, .br, .tl, .tr').each(function() {
      preload.push(new Image())
      preload.slice(-1).src = $(this).css('background-image').replace(/url\((.+)\)/, '$1')
    })

    $('#rokbox .close').click($.rokbox.close)
    $('#rokbox .close_image').attr('src', $.rokbox.settings.close_image)
  }

  // getPageScroll() by quirksmode.com
  $.rokbox.getPageScroll = function() {
    var xScroll, yScroll;
    if (self.pageYOffset) {
      yScroll = self.pageYOffset;
      xScroll = self.pageXOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
      yScroll = document.documentElement.scrollTop;
      xScroll = document.documentElement.scrollLeft;
    } else if (document.body) {// all other Explorers
      yScroll = document.body.scrollTop;
      xScroll = document.body.scrollLeft;	
    }
    return new Array(xScroll,yScroll) 
  }

  // adapter from getPageSize() by quirksmode.com
  $.rokbox.getPageHeight = function() {
    var windowHeight
    if (self.innerHeight) {	// all except Explorer
      windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
      windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
      windowHeight = document.body.clientHeight;
    }	
    return windowHeight
  }
})(jQuery);



//alert(window.screen.height)

function height_window() {
			var windowHeight = 0;
			if (typeof(window.innerHeight) == 'number') {
				windowHeight = window.screen.height;
			}
			else {
				if (document.documentElement && document.documentElement.clientHeight) {
					windowHeight = window.screen.height;
				}
				else {
					if (document.body && document.body.clientHeight) {
						windowHeight = window.screen.height;
					}
				}
			}
			return windowHeight;
		}

var isIE=0;
var isOtherBrowser=0;

function pokusnew() {

if(navigator.appName.indexOf('Microsoft Internet Explorer')!=-1)
{isIE=1;
var height_div=document.getElementById("rokbox").scrollHeight;
height=height_window();
document.getElementById('innerdivid').style.top=-((height)/2)+'px';
document.getElementById('innerdivid').style.height=(2*height)+'px';
}
else
{isOtherBrowser =1;

var height_div= document.getElementById("rokbox").scrollHeight;
height=height_window();
document.getElementById('innerdivid').style.top=-((height)/2)+'px';
document.getElementById('innerdivid').style.height=(2*height)+'px';
zmena_okna = setTimeout("pokusnew()", 1);

}
}
