
window.addEvent('domready', function() {

/* OPTIONAL */

var default_bg = 'images/wallpaper/wallpaper4'; /* Here we set default background img */
var default_ext = '.jpg'; /* Default extension for default background */
var days = 10; /* How many days should cookie be saved? */

/* Event for object with id wallpaper1 */

$$('#wallpaper1').each(function(wo){
wo.addEvent('click', function() {
	Cookie.write('demobg', 'images/wallpaper/wallpaper1', {duration: days}); /* 'background' is name for cookie, 'wallpaper1' is image name without extension */
	$$('body').setStyle('background-image', 'url(\'images/wallpaper/wallpaper1'+default_ext+'\')'); /* Here css value for background-image is set */
});
},this);

/* Event for object with id wallpaper2 */

$$('#wallpaper2').each(function(wo){
wo.addEvent('click', function() {
	Cookie.write('demobg', 'images/wallpaper/wallpaper2', {duration: days}); /* 'background' is name for cookie, 'wallpaper2' is image name without extension */
	$$('body').setStyle('background-image', 'url(\'images/wallpaper/wallpaper2'+default_ext+'\')'); /* Here css value for background-image is set */
});
},this);

/* Event for object with id wallpaper3 */

$$('#wallpaper3').each(function(wo){
wo.addEvent('click', function() {
	Cookie.write('demobg', 'images/wallpaper/wallpaper3', {duration: days}); /* 'background' is name for cookie, 'wallpaper3' is image name without extension */
	$$('body').setStyle('background-image', 'url(\'images/wallpaper/wallpaper3'+default_ext+'\')'); /* Here css value for background-image is set */
});
},this);

/* Event for object with id wallpaper4 */

$$('#wallpaper4').each(function(wo){
wo.addEvent('click', function() {
	Cookie.write('demobg', 'images/wallpaper/wallpaper4', {duration: days}); /* 'background' is name for cookie, 'wallpaper3' is image name without extension */
	$$('body').setStyle('background-image', 'url(\'images/wallpaper/wallpaper4'+default_ext+'\')'); /* Here css value for background-image is set */
});
},this);

if (Cookie.read('demobg')) 
{ 
$$('body').setStyle('background-image', 'url(\''+Cookie.read('demobg')+default_ext+'\')'); /* If cookie is set, it'll load this */
}
else {
$$('body').setStyle('background-image', 'url(\''+default_bg+default_ext+'\')'); /* If not, it loads default background image. */
}

/* MOUSEENTER AND MOUSELEAVE EVENT FOR ELEMENT WITH ID CHANGE */

$('change').setStyle('margin-top', '-45px'); /* This set object top -45 */

$('change').addEvents({
	'mouseenter': function(){
		this.set('tween', {
			duration: 300,
			transition: Fx.Transitions.Sine.easeIn
		}).tween('margin-top', '0px'); /* When you go over with cursor this value changes */
	},
	'mouseleave': function(){
		this.set('tween', {
			duration: 300,
			transition: Fx.Transitions.Sine.easeOut
		}).tween('margin-top', '-45px'); /* When you move away your cursor from div this value changes */
	}
});

/* OPTIONAL */

$$('.opacity').setStyle('opacity', 0.7);

$$('.opacity').each(function(el){
el.addEvent('mouseenter', function() {
	el.set('tween', {duration: 300});
	el.tween('opacity', [0.7, 1]);
});
el.addEvent('mouseleave', function() {
	el.set('tween', {duration: 300});
	el.tween('opacity', [1, 0.7]);
});
},this);

});
