function getMouseX(e) {  if (!e) e = window.event;   if (e)  {    if (e.pageX || e.pageY)    {       mousex = e.pageX;      mousey = e.pageY;    }    else if (e.clientX || e.clientY)    {       mousex = e.clientX + document.body.scrollLeft;      mousey = e.clientY + document.body.scrollTop;    }  }  return mousex;}function getMouseY(e){  if (!e) e = window.event;  if (e)  {    if (e.pageX || e.pageY)    {      mousex = e.pageX;      mousey = e.pageY;    }    else if (e.clientX || e.clientY)    {      mousex = e.clientX + document.body.scrollLeft;      mousey = e.clientY + document.body.scrollTop;    }  }  return mousey;}
function trimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );
  return sInString.replace( /\s+$/g, "" );
}

function dump(arr,level) {
var dumped_text = "";
if(!level) level = 0;
var level_padding = "";
for(var j=0;j<level+1;j++) level_padding += "    ";

if(typeof(arr) == 'object') { 
 for(var item in arr) {
  var value = arr[item];

  if(typeof(value) == 'object') {
   dumped_text += level_padding + "'" + item + "' ...\n";
   dumped_text += dump(value,level+1);
  } else {
   dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
  }
 }
} else { 
 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
}
return dumped_text;
}

function windowsize(){
		var myWidth = 0, myHeight = 0;

		 if( typeof( window.innerWidth ) == 'number' ) {
			
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}
		arrayPageSize = new Array(myWidth,myHeight)
    	return arrayPageSize;
}


function getdivsize(id){
var myWidth = 0, myHeight = 0;

myWidth =  document.getElementById(id).offsetWidth;
myHeight = document.getElementById(id).offsetHeight

arrayPageSize = new Array(myWidth,myHeight)
return arrayPageSize;
}

function getDivDimension(div){
var myWidth = 0, myHeight = 0;

myWidth =  div.offsetWidth;
myHeight = div.offsetHeight

arrayPageSize = new Array(myWidth,myHeight)
return arrayPageSize;
}

function ajax_message(message) {

if(efect_finish == 1){
efect_finish = 0;
message_ajax_container.style.backgroundColor='#fad163';
message_ajax_container.innerHTML = message;
efekt_plynny = new Fx.Style('bigCalendarAjax','opacity',{duration: 4000, onComplete: function(){efect_finish = 1;}, fps: 100 });
efekt_plynny._start(1,0);
}
}

function ajax_message_loading(message) {

if(efect_finish == 1){
efect_finish = 0;
message_ajax_container.style.backgroundColor='#fad163';
message_ajax_container.innerHTML = message;

efect_finish = 1;
}
}

function ajax_message_hide(message) {
message_ajax_container.innerHTML = message;
efekt_plynny = new Fx.Style('bigCalendarAjax','opacity',{duration: 4000, onComplete: function(){efect_finish = 1;}, fps: 100 });
efekt_plynny._start(1,0);
}


function strip_tags(str, allowed_tags) {

var key = '', tag = '';
var matches = allowed_array = [];
var allowed_keys = {};


if (allowed_tags) {
allowed_tags  = allowed_tags.replace(/[\<\> ]+/g, '');;
allowed_array = allowed_tags.split(',');

for (key in allowed_array) {
tag = allowed_array[key];
allowed_keys['<' + tag + '>']   = true;
allowed_keys['<' + tag + ' />'] = true;
allowed_keys['</' + tag + '>']  = true;
}
}


    matches = str.match(/(<\/?[^>]+>)/gi);

    for (key in matches) {        tag = matches[key].toString();        if (!allowed_keys[tag]) {            reg = RegExp(tag, 'g');            str = str.replace(reg, '');        }    }
    return str;
}

function daysBetween(date1, date2) {
var DSTAdjust = 0;

oneMinute = 1000 * 60;
var oneDay = oneMinute * 60 * 24;

date1.setHours(0);
date1.setMinutes(0);
date1.setSeconds(0);
date2.setHours(0);
date2.setMinutes(0);
date2.setSeconds(0);

if (date2 > date1) {
DSTAdjust =
	(date2.getTimezoneOffset() - date1.getTimezoneOffset()) * oneMinute;
} else {
DSTAdjust =
	(date1.getTimezoneOffset() - date2.getTimezoneOffset()) * oneMinute;
    }
    var diff = Math.abs(date2.getTime() - date1.getTime()) - DSTAdjust;
    return Math.ceil(diff/oneDay);
}

function LTrim( value ) {

var re = /\s*((\S+\s*)*)/;
return value.replace(re, "$1");

}


function RTrim( value ) {

var re = /((\s*\S+)*)\s*/;
return value.replace(re, "$1");

}

function trim( value ) {

	return LTrim(RTrim(value));

}


function showToolTip(e,inputDiv){

	if(!inputDiv)inputDiv = this;
	if(!popupWindowUrl)return;
	if(inputDiv.id.indexOf('new_')>=0)return;

	if(!popupWindowUrl)return;

	currentAppointmentDiv = this.parentNode;


	if(document.all)e = event;

	var obj = document.getElementById('bubble_tooltip');
	var obj2 = document.getElementById('bubble_tooltip_content');

	label = inputDiv.innerHTML;
	obj2.innerHTML = '<a href="#" onclick="hideToolTip()">Close</a> '+ '<a href="#" onclick="editownia('+currentAppointmentDiv.id+')">Edit</a> '+ trim(strip_tags(label));

	obj.style.display = 'block';
	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
	if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0;
	var leftPos = e.clientX - 100;
	if(leftPos<0)leftPos = 0;
	obj.style.left = leftPos + 'px';
	obj.style.top = e.clientY - obj.offsetHeight -1 + st + 'px';

}
function hideToolTip(){	document.getElementById('bubble_tooltip').style.display = 'none';}
function scroll(){
	if(gdzie_y<(32+appointmentsOffsetTop) && document.getElementById('weekScheduler_content').scrollTop >0){		document.getElementById('weekScheduler_content').scrollTop -=5;		mouse_y +=5;		topPos = (32 - mouse_y + el_y - appointmentsOffsetTop);		topPos = el_y - mouse_y;		if(topPos<0) topPos = 0;		currentAppointmentDiv.style.top = topPos + 'px';		currentTimeDiv.innerHTML = '<span>' + getTime(currentAppointmentDiv) + '</span>';		setTimeout("scroll()",80);	}}function scroll4(){	if(gdzie_y<(32+appointmentsOffsetTop) && document.getElementById('weekScheduler_content').scrollTop >0){		document.getElementById('weekScheduler_content').scrollTop -=5;		mouse_y +=5;		topPos = (32 - mouse_y + el_y - appointmentsOffsetTop);		currentAppointmentDiv.style.top = topPos + 'px';		currentTimeDiv.innerHTML = '<span>' + getTime(currentAppointmentDiv) + '</span>';		setTimeout("scroll()",80);	}}function scroll2(){	  if(gdzie_y+currentAppointmentDiv.offsetHeight>500){		document.getElementById('weekScheduler_content').scrollTop +=5;		mouse_y -=5;		topPos = document.getElementById('weekScheduler_content').scrollTop + 500 - currentAppointmentDiv.offsetHeight;		currentAppointmentDiv.style.top = topPos + 'px';		currentTimeDiv.innerHTML = '<span>' + getTime(currentAppointmentDiv) + '</span>';		setTimeout("scroll2()",80);	}}

Array.prototype.getMax = function()
{
var max = Number.MIN_VALUE, v, len = this.length, i = 0;
for (; i < len; ++i)
if (typeof (v = this[i]) == 'number')
max = Math.max(max, v);
return max;
}

Array.prototype.getMin = function()
{
var min = Number.MAX_VALUE, v, len = this.length, i = 0;
for (; i < len; ++i)
if (typeof (v = this[i]) == 'number')
min = Math.min(min, v);
return min;
}







