/**
 * @author Julian
 */


var IMG_PATH_WIDGET_LOGIN_REGISTER		= "Elements/Widgets/Kartenreservierung/";
	
	
var widget_login_register_img			= IMG_PATH_WIDGET_LOGIN_REGISTER + WIDGET_BUTTON_IMG+".png";
var widget_login_register_activ_img 	= IMG_PATH_WIDGET_LOGIN_REGISTER + WIDGET_BUTTON_IMG+"_Active.png";


window.addEvent('domready', function() {
	
	var widget_pos_left = 0;
	
	widget_pos_left += 30;
	
	new WIDGET({
		
		name:"widget_1",
		
		bottom:20,
		right:135,
		
		width:253,
		height:98,
		
		background_active_url: 	widget_login_register_activ_img,
		background_url: 		widget_login_register_img,
		
		event_click: function(name){
			OPEN_AJAX_WINDOW(WIDGET_TITLE,WIDGET_URL);
		}
	});
	
	
	
	if(REGISTER_TICKET_SHOW)
	{
		$('widget_1').setStyle("display","block");
	}else{
		$('widget_1').setStyle("display","none");
	}
	
	
});
 
var WIDGET = new Class({
	Implements: [Options, Events],
	
	options: {
		name:					"",
		
		background_url: 		"",
		background_active_url: 	"",
		
		link:					"",
		
		width:					null,
		height:					null,
		
		top:					null,
		bottom:					null,
		left:					null,
		right:					null,
		
		style:					{
			'position': "fixed"
		},
		
		event_click : null
		
	},

	container: "",


	initialize: function(options){
		this.setOptions(options);
		
		this.preloadElements();
		
		this.createELEMENT();
		this.event_mouseleave();
	},
	
	preloadElements: function(){
		var images = [	this.options.background_url,
				  		this.options.background_active_url];
						
		var loader = new Asset.images(images);
	},
	
	createELEMENT: function()
	{
		this.container = new Element('div', {
			'id': this.options.name,
		    'html': '',
		    'styles': this.options.style,
		    'events': {
		        'click': 		this.options.event_click.bind(this),
		        'mouseenter': 	this.event_mouseenter.bind(this),
				'mouseleave': 	this.event_mouseleave.bind(this)
		    }
		});
		
		this.container.setStyle('width', 	this.options.width);
		this.container.setStyle('height', 	this.options.height);
		
		this.container.setStyle('top', 		this.options.top);
		this.container.setStyle('bottom', 	this.options.bottom);
		this.container.setStyle('left', 	this.options.left);
		this.container.setStyle('right', 	this.options.right);
		
		this.container.setStyle('cursor', 	"pointer");
		
		this.container.inject(document.body);
	},
		
	
	event_mouseenter : function(){
		this.container.setStyle("background", "url("+ this.options.background_active_url +")");
	},
	
	event_mouseleave : function(){
		this.container.setStyle("background", "url("+ this.options.background_url +")");
	}
	
});
