function fbLogin(appID,cancelURL,redirectURL){
	window.open("https://www.facebook.com/dialog/oauth?client_id="+appID+"&redirect_uri="+redirectURL+"&scope=email&display=popup", "nove", "width=500,height=300,menubar=no,resizable=no");
}

function ajaxUpdate(elementID,url,data,question,onSubmitFunc,onSuccessFunc,onErrorFunc){
	if(url.indexOf('/', 0) < 0) url = '/servis/data/wdu/lightWDU.php?path=templates%2Fshared%2F'+url+'.php';
	if(question) ixfwConfirm('Potvrďte',question,'ajaxUpdateOK(\''+url+'\',\''+data+'\',\''+elementID+'\',\''+onSubmitFunc+'\',\''+onSuccessFunc+'\',\''+onErrorFunc+'\')');
	else ajaxUpdateOK(url, data, elementID, onSubmitFunc, onSuccessFunc, onErrorFunc);
}

function ajaxUpdateOK(docUrl,data,elementID,onSubmitFunc,onSuccessFunc,onErrorFunc){
	if(onSubmitFunc != '') eval(onSubmitFunc);
	$.ajax({
		type: "POST",
		url: docUrl,
		data: data,
		success: function(msg){
			if(elementID != '') $('#'+elementID).html(msg);
			if(onSuccessFunc != '') eval(onSuccessFunc);
		},
		error: function(){
			if(onErrorFunc != '') eval(onErrorFunc);
		}
	});
}

(function($){
$.fn.interactiveTable = function(options){
var defaults = {
	highlightColor: '#CCDFFF'
};
var o = $.extend(defaults, options);
return this.each(function(){
	var obj = $(this);
	obj.find('tr').mouseenter(function(){$(this).addClass('highlighted');});
	obj.find('tr').mouseleave(function(){$(this).removeClass('highlighted');});
});
}})(jQuery);

function saveFormInput(formname,obj){
	ajaxUpdate('', '/servis/data/wdu/inpupdate.php', 'fname='+formname+'&inpname='+obj.name+'&inpval='+urlencode(obj.value));
}

(function($){
$.fn.autoSlider = function(options){
var defaults = {
	delay: 2000,
	animationDelay: 200,
	selectedIdx: 0,
	effect: 'fade'
};
var o = $.extend(defaults, options);
return $(this).each(function(){
	var nLists = 0;
	var _animate = function(){
		var newIdx = o.selectedIdx+1;
		if(newIdx >= nLists) newIdx = 0;
		if(o.effect == 'fade'){
			if(!$.browser.msie || parseInt($.browser.version) >= 7){
				$('#'+obj.attr('id')+'x'+o.selectedIdx).fadeOut(o.animationDelay, function(){
					$(this).hide();
				});

				$('#'+obj.attr('id')+'x'+newIdx).fadeIn(o.animationDelay, function(){
					$(this).show();
					o.selectedIdx = newIdx;
				});
			}
			else{
				$('#'+obj.attr('id')+'x'+o.selectedIdx).hide();
				$('#'+obj.attr('id')+'x'+newIdx).show();
				o.selectedIdx = newIdx;
			}
		}
	}
	
	var obj = $(this);
	var idx = 0;
	obj.children('li').each(function(){
		var t = $(this);
		t.attr("id",obj.attr("id")+'x'+idx);
		if(idx == o.selectedIdx) t.show();
		else t.hide();
		idx++;
	});
	nLists = idx;
	$(document).everyTime(o.delay, function(i){
		_animate();
	});
});
}})(jQuery);

$.easing.drop = function (x, t, b, c, d) {
	return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
};

$.tools.overlay.addEffect("drop", function(css, done) { 
   
   // use Overlay API to gain access to crucial elements
   var conf = this.getConf(),
       overlay = this.getOverlay();           
   
   // determine initial position for the overlay
   if (conf.fixed)  {
      css.position = 'fixed';
   } else {
      css.top += $(window).scrollTop();
      css.left += $(window).scrollLeft();
      css.position = 'absolute';
   } 
   
   // position the overlay and show it
   overlay.css(css).show();
   
   // begin animating with our custom easing
   overlay.animate({top: '+=55',  opacity: 1,  width: '+=20'}, 400, 'drop', done);
   
   /* closing animation */
   }, function(done) {
      this.getOverlay().animate({top:'-=55', opacity:0, width:'-=20'}, 300, 'drop', function() {
         $(this).hide();
         done.call();      
      });
   }
);
