/*

	License information: 	
	
		Copyright © by  A n d r é  A  h  n  e r
		For contact and further information visit: www.xitroMEDIA.com
		
		All rights reserved by copyright owner. Not any license given to anybody.	
	
		This script/software code is protected by German and international law.
		You are not allowed to copy, modify or use this script/software code wholly or partly in 
		any way without explicit and in written authorization for that by the owner of the Copyright !
	
		File name: "xitroVISUAL.js"
		Module name: "xitroVISUAL"
		Description: JS-library with visual methods
		File version: 1.0 build 13
		File release date: 2011/10/30
	
	Technical remarks:
	
		uses:
		
			xitroBASE.js must be loaded and initialized
	
			jQuery >=1.6.4 (required),
			jQuery-UI-datepicker (optional)	

*/

var d=window.document;

// xitroBASE.js-module must already be initialized
if (typeof(xitroBASE)=='undefined') {

	window.alert("Error [xitroVISUAL.js: 001]:\nRequired module missing: xitroBASE.js");
}

// create and init global hash if not yet done
if (typeof(xitroVISUAL)=='undefined') {

	xitroVISUAL={};
}

// extend xitroVISUAL.h-hash with parameters
xitroVISUAL.h=jQuery.extend(

	{
		// URI to the directory with pics used by this module
		'uri_pics_dir': '',

		// name of loading img
		'loading_img_n': 'loading-small.gif',

		// DO NOT modify below

		'loading_imgs_a': [],
		'loading_hidden_els_a': [],

		'pop_h': {

			'active': false,
			's': 500,
			'initialized': false
		}
	},
	xitroVISUAL.h
);


// extend xitroVISUAL-hash with methods
xitroVISUAL=jQuery.extend(

	xitroVISUAL,
	{


_loading_display_set: function(_h) {
/*******************************
build 2

creates and shows a loading image on a specific place, e.g. hides a submit button and shows that image instead

Input: 

	hash={
	
		'this_o': element-object or ID-string
		'uri': (optional) URI to the loading image; can be declared globally
		txt: (optional) any text to display additionally to the loading img
		class_container: (optional) css-class set to container-SPAN around loading IMG and -text
	}

*/

var o={
};

// we need the clicked element´s object
if (! (o.this_o=xitroBASE._get_el(_h.this_o))) {

	window.alert("Error [xitroVISUAL.js: 002]:\nEs ist ein Fehler aufgetreten.");
	return false;
}

// create container SPAN-el which contains loading-IMG-el and loading-text

// create P-container
o.wait_o=d.createElement('SPAN');

// add css-class if defined
if (typeof(_h.class_container)=='string') {

	o.wait_o.className=_h.class_container;
}

// append loading-img if URI-declared
if (this.h.uri_pics_dir) {

	// create loading img
	o.img_o=new Image();
	o.img_o.src=this.h.uri_pics_dir + this.h.loading_img_n;
	
	// append img to the P-container
	o.wait_o.appendChild(o.img_o);
}

// if additional text shall be displayed after the loading-img
if (typeof(_h.txt)=='string') {

	o.txt_o=d.createElement('SPAN');
	o.txt_o.style.marginLeft='1em';
	o.txt_o.innerHTML=_h.txt;

	// append loading-text to the container
	o.wait_o.appendChild(o.txt_o);
}

// make old el invisible
jQuery(o.this_o).hide();

// insert element before the clicked element
o.this_o.parentNode.insertBefore(o.wait_o,o.this_o);

// collect modified elements
this.h.loading_imgs_a.push(o.wait_o);
this.h.loading_hidden_els_a.push(o.this_o);

return true;
},


_loading_display_reset: function(_h) {
/**************************
build: 1

Resets all modifications done when loading

Input: 

	hash={
	
	}

Returns:

	true on success, else false

*/

var o={
};

// remove added imgs
while (o.el_o=this.h.loading_imgs_a.shift()) {

	o.el_o.parentNode.removeChild(o.el_o);
}

// make hidden els visible
while (o.el_o=this.h.loading_hidden_els_a.shift()) {

	jQuery(o.el_o).show();
}

return true;
},


_blink: function(_h) {
/**************************
build: 1

Lets an element blink a specific amount

Input: 

	hash={
	
		s: (optional) speed in ms; default 500
		amount: (optional) amount of repeating blinks, default 3
	}

Returns:

	true on success, else false

*/

var o={ 

	'count': 1,

	's': typeof(_h.s)=='number'

		? _h.s
		: 500,

	'amount': typeof(_h.amount)=='number'
	
		? _h.amount
		: 3
};

if (! (o.this_o=xitroBASE._get_el(_h.this_o))) {

	window.alert("Error [xitroVISUAL.js: 003]:\nEs ist ein Fehler aufgetreten.");
	return false;
}

// save border-color
o.border=o.this_o.style.border;

// set highlighting border-color
o.this_o.style.border='2px solid #00ff00';

for (o.i=_h.amount; o.i>0; o.i--) {

	jQuery(o.this_o).animate(
	
		{
			opacity: 0
		},
		o.s
	
	).animate(
	
		{
			opacity: 1
		},
		o.s,
	
		function() {	

			// after last run
			if (o.count++==_h.amount) { 

				// reset highlighted border-color
				o.this_o.style.border=o.border
					? o.border
					: '';

				// run callback if existing
				if (typeof(_h.callb_f)=='function') {
				
					_h.callb_f();
				}
			}
		}
	);
}	
return true;
},


_toggle: function(_h) {
/**************************
build 6

Toggle an element´s or several elements visibility. Different effects for each element are possible as well as diffferent speeds, delays and animation-types.

Input: 

	hash={

		els_a: (optional) array with hashes with definitions of elements that have to be made visible or hidden as follows:

			[
				{
					el: (required) element-object or ID-string of element that has to be toggled	
					fx: (optional) effect to use which can be 'toggle','slide' or 'fade'; 'toggle' by default
					s: (optional) speed of fx in ms,
					delay: (optional) set to false if toggling this el shall not wait for the previous el to be finished; default is true
					_cb_before:  (optional) callback-function run before toggling this el
					_cb_after:  (optional) callback-function run after toggling this el
				},
				{
					next hash ... and so on;
				},
				null or undefined -  els_a-item can also be null or undefined and will be skipped; this allows to dynamically create the 'els_a' by simply adding nulls for els to be skipped
			]

		s: (optional) speed of all effects in ms that is redundant to the el-specific setting
		_cb_finish: (optional) callback-function run when finished everything

		txt_el: (optional) element-object or ID-string of an element whose txt has to be toggled	

		txt: (optional) text to display after the element has been clicked; existing text will be saved and restored when toggling back;
			Works only if 'els_hide_a' is not defined, because only then we have a single and clickable el that needs to get a visible status change.
			We do not need this if toggling between several els.
	}

Returns:

	true on success, else false

*/

var o={

	// valid effects that can be used with the els
	fxs_h: {

		toggle: '',
		hide: '',
		show: '',
		fadeToggle: '',
		fadeOut: '',
		fadeIn: '',
		slideToggle: '',
		slideUp: '',
		slideDown: ''
	},

	s:  typeof(_h.s)=='number'

		? _h.s
		: 300,

	i_h: {}
};

// we need at least one el
if (
	typeof(_h.els_a) != 'object'
	|| ! _h.els_a.length
) {
	window.alert("Error [xitroVISUAL.js: 004]:\nEs ist ein Fehler aufgetreten.");
	return false;
}

// go through all els, get el-objects and bind counter to them; remove null or undefined items and rebuild array 
for (o.i=0, o.j=_h.els_a.length-1; o.i<=o.j; ) {

	// shorten
	o.el_h=_h.els_a[o.i];

	// if array-item is null or undefined
	if (! o.el_h) {

		// remove item from array and continue
		_h.els_a.splice(o.i,1);

		o.j--;
		continue;
	}

	// get el and store in hash
	if (! (o.el_h.el_o=xitroBASE._get_el(o.el_h.el))) {	

		window.alert("Error [xitroVISUAL.js: 013]:\nEs ist ein Fehler aufgetreten.");
		return false;
	}

	// store some other params in hash

	// store index; save in array because some els can occure multiple
	if (
		typeof(o.i_h[o.el_h.el_o.id])=='object'
		&& o.i_h[o.el_h.el_o.id].length
	) {
		o.i_h[o.el_h.el_o.id].push(o.i);
	}
	else {
		o.i_h[o.el_h.el_o.id]=[o.i];
	}

	o.el_h.el_jo=jQuery(o.el_h.el_o);

	o.i++;
}

// create toggle function
o._cb=function(i) {

	var s_o={
	};

	// shorten
	s_o.el_h=_h.els_a[i];
	s_o.next_el_h=_h.els_a[i+1];

	// store if this is last el
	s_o.is_last=typeof(s_o.next_el_h)=='undefined';

	// shall next el not wait for toggling until current el finishes ?
	s_o.no_delay=

		! s_o.is_last
		&& typeof(s_o.next_el_h.delay) != 'undefined'
		&& ! s_o.next_el_h.delay;

	// run callback if defined
	if (typeof(s_o.el_h._cb_before)=='function') {

		s_o.el_h._cb_before();
	}

	// toggle el´s visibility
	 s_o.el_h.el_jo[(

		// get valid fx for this el and use corresponding function
		typeof(s_o.el_h.fx)=='string'
		&& typeof(o.fxs_h[s_o.el_h.fx]) != 'undefined'
	
			? s_o.el_h.fx
			: 'slideToggle'
	)](		
		// get speed
		typeof(s_o.el_h.s)=='number'

			? s_o.el_h.s
			: o.s,

		'',

		// run delayed callb for this el
		function() {

			var ss_o={

				el_i: o.i_h[this.id].shift()
			};

			// run not if delay not wanted
			if (! s_o.no_delay) {

				// run callback if defined
				if (typeof(_h.els_a[ss_o.el_i]._cb_after)=='function') {
				
					_h.els_a[ss_o.el_i]._cb_after();
				}
	
				// run next el not if the current el is the last one, but delete helper array saved in el
				if (! s_o.is_last) {

					// go on with next el and count up seen_h for this el
					o._cb(ss_o.el_i+1);
				}
			}
		}
	);

	// no delay, then go on with next el immediately
	if (s_o.no_delay) {

		// run callback if defined
		if (typeof(s_o.el_h._cb_after)=='function') {
		
			s_o.el_h._cb_after();
		}

		// run next el not if the current el is the last one
		if (! s_o.is_last) {

			o._cb(i+1);
		}
	}

	return true;
};

// run callb for the first el and hand over el-object like jQ-does the same when calling callb
if (! o._cb(0)) {	

	window.alert("Error [xitroVISUAL.js: 014]:\nEs ist ein Fehler aufgetreten.");
	return false;
}


// if some text of an el shall be toggled too, e.g. of a clicked A
if (o.txt_el_o=xitroBASE._get_el(_h.txt_el)) {

	// we need an ID to the evented-object
	if (typeof(o.txt_el_o.id)=='undefined') {
	
		window.alert("Error [xitroVISUAL.js: 007]:\nEs ist ein Fehler aufgetreten.");
		return false;
	}

	// shorten
	o.rest_o=xitroBASE.h.els_h[o.txt_el_o.id];

	// save original text of txt-el if not yet done
	if (typeof(o.rest_o.toggled)=='undefined') {

		// init toggled-status
		o.rest_o.toggled=false;

		// node=text
		if (o.txt_el_o.nodeType==3) {
		
			// save current text and node-type
			o.rest_o.toggled_txt=o.txt_el_o.nodeValue;
			o.rest_o.type=3;
		}
		// node=any el
		else if (o.txt_el_o.nodeType==1) {

			o.rest_o.toggled_txt=o.txt_el_o.innerHTML;
			o.rest_o.type=1;
		}
		else {
			// not a usable node, but must be saved
			o.rest_o.type=0;
		}
	}			

	// set new text depending on node-type and toggle status
	if (o.rest_o.type==3) {
	
		o.txt_el_o.nodeValue=o.rest_o.toggled

			? o.rest_o.toggled_txt
			: _h.txt;	
	}
	else if (o.rest_o.type==1) {

		o.txt_el_o.innerHTML=o.rest_o.toggled

			? o.rest_o.toggled_txt
			: _h.txt;
	}			
	// save new toggle-status
	o.rest_o.toggled=o.rest_o.toggled
	
		? false
		: true;		
}

// run callb if defined
if (typeof(_h._cb_finish)=='function') {
	
	_h._cb_finish();
}

return true;
},


_datepicker: function(_h) {
/*******************************
build: 1

Applies a jQuery datepicker to a specific element.
This function must not be combined with an event applied to an element because it applies 
its own onlick event.

Input: 

	hash={

		this_o: object or ID of that element the datepicker will be applied to
	}

*/

var o={ 
};

// jQuery-UI-datepicker must be loaded
if (typeof(jQuery.datepicker)=='undefined') {

	window.alert("Error [xitroVISUAL.js: 005]:\nRequired module missing: jQuery-UI-datepicker");
	return false;
}

if (! (o.this_o=xitroBASE._get_el(_h.this_o))) {

	window.alert("Error [xitroVISUAL.js: 006]:\nEs ist ein Fehler aufgetreten.");
	return false;
}

// init datepicker			
jQuery(o.this_o).datepicker({ 

	dateFormat: 'dd-mm-yy',
	dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
	dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
	monthNames: ['Januar','Februar','Maerz','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'],

	// start with specific day, e.g. Monday=1
	firstDay: 1,

	// highlight currently selected day
	gotoCurrent: true,

	minDate: 0
});

return true;
},


_accordion: function(_h) {
/**************************
build 2

Initializes accordion-functionality to UL with subs

Input: 

	hash=(

	)

Returns:

	true on success, false on error

Sets:

	Applies an 'open'-event to the As that menu can be handled outside of onclick, e.g. by callback functions.
	Must be called like: 

		jQuery('a[href=#anchorname]').trigger('open');

*/

var o={

	'fx': typeof(_h.fx)=='string'

		? _h.fx
		: 'slideToggle',

	's':  typeof(_h.s)=='number'

		? _h.s
		: 300,

	'class_active_li': typeof(_h.class_active_li)=='string'

		? _h.class_active_li
		: 'xitro_accordion_active_li',

	'class_current_li': typeof(_h.class_current_li)=='string'

		? _h.class_current_li
		: 'xitro_accordion_current_li'
};

// create helper function
o._activate=function(_s_h) {

	// removes active-class from LIs on same hierarchy and slides up all child-ULs and DIVs
	_s_h.el_jo.parent('li').siblings().removeClass(o.class_active_li).children('ul,div').slideUp(o.s);

	// slide as needed
	_s_h.el_jo.siblings('ul,div')[(_s_h.fx || o.fx)](

		o.s,

		// callback for each el
		function() {
		
			if (_s_h.el_jo.siblings('ul,div').is(':visible')) {

				_s_h.el_jo.parents('li'). not(o.el_jo.parents()).addClass(o.class_active_li);
			} 
			else {
				_s_h.el_jo.parent('li').removeClass(o.class_active_li);
			}
		
			if (_s_h.fx=='show') {

				_s_h.el_jo.parents('li').not(o.el_jo.parents()).addClass(o.class_active_li);
			}
		
			_s_h.el_jo.parents().show();
		}
	);
};

// get accordion-object
if (! (o.el_o=xitroBASE._get_el(_h.el))) {

	window.alert("Error [xitroVISUAL.js: 008]:\nEs ist ein Fehler aufgetreten.");
	return false;
}

//apply jQuery functionality to el
o.el_jo=jQuery(o.el_o),

// hide all els by default
jQuery.each(

	o.el_jo.find('ul,li>div'),

	function() {
	
		jQuery(this).hide();
	}
);

// add functionality
jQuery.each(

	o.el_jo.find('a'),

	function() {
	
		// add onclick event
		jQuery(this).click(
	
			function(e) {

				o._activate({

					'el_jo': jQuery(this),
					'fx': o.fx
				});

				return void(0);
			}
		);

		// add trigger event to A for being able to manually change status, e.g. by callbacks 
		jQuery(this).bind(

			'activate_current',

			function() {

				var s_o={
				
					'this_o': jQuery(this)
				};

				o.el_jo.find('ul,div').not(s_o.this_o.parents()).not(s_o.this_o.siblings()).slideUp(o.s);

				o._activate({

					'el_jo': s_o.this_o,
					'fx': 'slideDown'
				});
			}
		);
	}
);

// activate requested anchor or that with current class
if (
	(
		o.active_el_o=(location.hash)
	
			? o.el_jo.find('a[href=' + location.hash + ']')[0]
			: o.el_jo.find('li.' + o.class_current_li + ' a')[0]
	)
) {
	o._activate({

		'el_jo': jQuery(o.active_el_o),
		'fx': o.fx
	});
}

return true;
},


_popup_init: function(_h) {
/*******************************
build: 3

Displays a popup and applies some events for its functionality

Input: 

	hash={

		uri: URI to the pics used by the popup to work, e.g. navi-buttons

		bg_div_el: ID of background-DIV that will be shown behind the popup; default 'xitro_popup_bg_div'

		cont_div_id: ID of the DIV which is the container around the popup´s content; default 'xitro_popup_cont_div'
		cont_cont_div_id: ID of the DIV which holds the popup´s mixed content; default 'xitro_popup_cont_cont_div'
		cont_img_div_id: ID of that DIV which holds the popup´s IMG; default 'xitro_popup_cont_img_div'

		but_close_id:  ID of the close-button; default 'xitro_popup_but_close'

		s: speed the elements fade with

	}

*/

var o={

	'p_h': this.h.pop_h,

	'uri': typeof(_h.uri)=='string'
	
		? _h.uri
		: '',

	// individual el-IDs can be set
	'bg_div_id': typeof(_h.bg_div_id)=='string'
	
		? _h.bg_div_id
		: 'xitro_popup_bg_div',

	'cont_div_id': typeof(_h.cont_div_id)=='string'
	
		? _h.cont_div_id
		: 'xitro_popup_cont_div',

	'cont_cont_div_id': typeof(_h.cont_cont_div_id)=='string'
	
		? _h.cont_cont_div_id
		: 'xitro_popup_cont_cont_div',

	'cont_img_div_id': typeof(_h.cont_img_div_id)=='string'
	
		? _h.cont_img_div_id
		: 'xitro_popup_cont_img_div',

	'but_close_id': typeof(_h.but_close_id)=='string'
	
		? _h.but_close_id
		: 'xitro_popup_but_close'
};

// create some required els and append to DOM

o.p_h.bg_div_o=d.createElement('DIV');
o.p_h.bg_div_o.id=o.bg_div_id;

o.p_h.but_close_o=new Image();
o.p_h.but_close_o.id=o.but_close_id;
o.p_h.but_close_o.src=o.uri + 'but-close.png';

o.p_h.cont_div_o=d.createElement('DIV');
o.p_h.cont_div_o.id=o.cont_div_id;

o.p_h.cont_cont_div_o=d.createElement('DIV');
o.p_h.cont_cont_div_o.id=o.cont_cont_div_id;

o.p_h.cont_img_div_o=d.createElement('DIV');
o.p_h.cont_img_div_o.id=o.cont_img_div_id;

o.p_h.cont_img_o=new Image();

o.p_h.bg_div_o.appendChild(o.p_h.but_close_o);

o.p_h.cont_img_div_o.appendChild(o.p_h.cont_img_o);

o.p_h.cont_div_o.appendChild(o.p_h.cont_img_div_o);
o.p_h.cont_div_o.appendChild(o.p_h.cont_cont_div_o);

o.fragm_o=d.createDocumentFragment();
o.fragm_o.appendChild(o.p_h.bg_div_o);
o.fragm_o.appendChild(o.p_h.cont_div_o);

d.getElementsByTagName('BODY').item(0).appendChild(o.fragm_o);

// create jQuery from existing objects
o.p_h.bg_div_jo=jQuery(o.p_h.bg_div_o);
o.p_h.cont_div_jo=jQuery(o.p_h.cont_div_o);

// set some styles
o.p_h.bg_div_o.style.opacity='0.9';
o.p_h.bg_div_o.style.filter='alpha(opacity=90)';

// add popup-close event to close-but and IMG and text-DIV
o.p_h.but_close_o.onclick=
o.p_h.cont_img_o.onclick=
o.p_h.cont_cont_div_o.onclick=this._popup_deactivate;

// mark that popup has been initialized
o.p_h.initialized=true;

return true;
},


_popup_activate: function(_h) {
/*******************************
build: 2

Opens the popup and shows the content

Input: 

	hash={

		cont: any formatted content (text, html) to display
		src: if set, then an IMG will be displayed; if 'cont' is set, then it is assumed that is is the caption of the IMG

	}

*/

var o={

	'p_h': xitroVISUAL.h.pop_h,

	'cont': typeof(_h.cont)=='string'

		? _h.cont
		: ''
};

// popup functionality must already be initialized 
if (! o.p_h.initialized) {

	window.alert("Error [xitroVISUAL.js: 009]:\nEs ist ein Fehler aufgetreten.");
	return false;
}

// activate popup only if not currently active
if (! o.p_h.active) {

	// fade in bg
	o.p_h.bg_div_jo.fadeIn(o.p_h.s); 

	// set IMG-src if there is an IMG to pop-up
	if (
		typeof(_h.src)=='string'
		&& _h.src
	) {
		o.p_h.cont_img_o.src=_h.src;
	}
	// hide IMG-DIV if there is no IMG
	else {	
		o.p_h.cont_img_div_o.style.display='none';
	}

	// fade content in after bg has finished fading
	setTimeout(
	
		function() {
		 
			// fade in content-container-DIV
			o.p_h.cont_div_jo.fadeIn(o.p_h.s);

			o.p_h.cont_img_div_o.style.display='block';

			// if there is any content to display, then show it as it is 
			if (o.cont) {

				o.p_h.cont_cont_div_o.innerHTML=o.cont;
				o.p_h.cont_cont_div_o.style.display='block';
			}
			else {
				o.p_h.cont_cont_div_o.style.display='none';
			}

			// center cont-container DIV
			xitroVISUAL._center({

				'el': o.p_h.cont_div_o,
			});

			// mark that popup is opened now	 
			o.p_h.active=true;
		},
		o.p_h.s
	);
}

return true;
},


_popup_deactivate: function(_h) {
/*******************************
build: 2

Closes the popup

Input: 

	hash={

	}

*/

var o={

	p_h: xitroVISUAL.h.pop_h
};

// popup functionality must already be initialized 
if (! o.p_h.initialized) {

	window.alert("Error [xitroVISUAL.js: 010]:\nEs ist ein Fehler aufgetreten.");
	return false;
}

// activate popup only if not currently active
if (o.p_h.active) {

	o.p_h.cont_div_jo.fadeOut(250);  

	// fade content in after bg has finished fading
	setTimeout(
	
		function() {

			o.p_h.bg_div_jo.fadeOut(100); 	

			// mark that popup is closed now	 
			o.p_h.active=false;
		},
		250
	);
}

return true;
},


_center: function(_h) {
/*******************************
build: 1

Centers an element horizontally and/or vertically

Input: 

	hash={

		el: element-object or ID-string of element that has to be centered
		v_only: center only vertically
		h_only: center only horizontally,
	}

*/

var o={
};

// get el
if (! (o.el_o=xitroBASE._get_el(_h.el))) {

	window.alert("Error [xitroVISUAL.js: 011]:\nEs ist ein Fehler aufgetreten.");
	return false;
}

// shorten
o.el_style_o=o.el_o.style;

// center horizontally if there shall not only vertically be centered
if (typeof(_h.v_only)=='undefined') {

	o.el_style_o.left='50%';
	o.el_style_o.marginLeft='-' + ((o.el_o.offsetWidth)/2) + 'px';
}
// visa versa
if (typeof(_h.h_only)=='undefined') {

	o.el_style_o.top='50%';
	o.el_style_o.marginTop='-' + ((o.el_o.offsetHeight)/2) + 'px';
}

return true;
},


_dims_max_set: function(_h) {
/*******************************
build: 1

Sets new dimensions to an element depending on any set maximum dimensions

Input: 

	hash={

		el: element-object or ID-string of element whose dimensions have to be set

		max_el: element-object or ID-string of element whose dimensions will be used to get the max-dimensions
		max_w = (required) maximum width the element is allowed to be
		max_h = (required) maximum height the element is allowed to be
	}

Returns:

	true on success, else false

*/

var o={

	'max_el_o': null
};

// get el and max-el if declared'
if (
	! (o.el_o=xitroBASE._get_el(_h.el))
	|| (
		typeof(_h.max_el) != 'undefined'
		&& ! (o.max_el_o=xitroBASE._get_el(_h.max_el))
	)
) {
	window.alert("Error [xitroVISUAL.js: 012]:\nEs ist ein Fehler aufgetreten.");
	return false;
}

// get jQuery objects
o.el_jo=jQuery(o.el_o);

if (o.max_el_o) {

	o.max_el_jo=jQuery(o.max_el_o);
}

// get new dimensions
o.dims_h=xitroVISUAL._dims_max_get({

	'w': (o.el_w=o.el_jo.width()),
	'h': (o.el_h=o.el_jo.height()),

	'max_w': o.max_el_o

		? o.max_el_jo.width()
		: (
			typeof(_h.max_w)=='number'
			
				? _h.max_w
				: o.el_w
		),

	'max_h': o.max_el_o

		? o.max_el_jo.height()
		: (
			typeof(_h.max_h)=='number'
			
				? _h.max_h
				: o.el_h
		)
});

// set calculated dimensions
o.el_o.style.width=o.dims_h.w;
o.el_o.style.height=o.dims_h.h;

return true;
},


_dims_max_get: function(_h) {
/*******************************
build: 1

Calculates maximum dimensions by given dimensions

Input: 

	hash={

		w = (required) width of element
		h = (required) height of element
		max_w = (required) maximum width the element is allowed to be
		max_h = (required) maximum height the element is allowed to be
	}

Returns:

	hash={
	
		ratio = w/h ratio
		w = newly, by max_w calculated width
		h = newly, by max_h calculated height
	}

*/

var o={

	ratio: _h.w/_h.h,
	w: _h.w,
	h: _h.h
};

// if w and h is smaller than max values
if (
	o.w<=_h.max_w 
	&& o.h<=_h.max_h
) {
	return o;
}

// else calc new values
if (o.ratio>(_h.max_w/_h.max_h)) {

	o.w=_h.max_w;
	o.h=_h.max_w*(1/o.ratio);
}
else {
	o.w=_h.max_h*o.ratio;
	o.h=_h.max_h;
}

return o;
}




// end jQuery extend
	}
);


/*****************************

	Following some unmodified  JS-scripts from third party vendors.
	The copyrights keep untouched as they are given by these vendors.  

*****************************/



