function mail(start, end) {
	return start + '@' + end;
}

function isBadBrowser() {
	return window.ie6;
}

var slideShow;

window.onload = function() {
	
	/* init preview */
	if($('pc_message') != null) {
		var myFx = new Fx.Style('pc_message', 'opacity', {}).start(0, 1);
		hidePreviewMessage.delay(10000);
	}
	
	if ($ES('.editable-component').length > 0) {
		/* clear shadow box in preview */
		var allTag = $ES("*");
		
		for ( var i = 0; i < allTag.length; i++) {
			if (allTag[i].getProperty("rel") != null && allTag[i].getProperty("rel").indexOf('shadowbox') >= 0) {			
				allTag[i].removeProperty("rel");
			}
		}
		$("one-component-edit").setProperty("rel","shadowbox"); // create one shadowbox relation for initialize the shadowbox
	}
	
	if ($ES("#preview_command").length > 0) {
		var draggableOptions = {
			handle: $$('#preview_command .pc_header')[0],
			onStart:function(el)
			    {
					$('preview_command').addClass('pc_dragging');
			    },
			onComplete:function(el)
			    {
			    	$('preview_command').removeClass('pc_dragging');
			    	var data = new Hash.Cookie('javlo_data', {duration: 3600});
			    	data.set("left", $('preview_command').getPosition().x);
			    	data.set("top", $('preview_command').getPosition().y);
			    }			
		};
		var previewCommand = $('preview_command').makeDraggable(draggableOptions);
		
		var data = new Hash.Cookie('javlo_data', {duration: 3600});
		$('preview_command').setStyle("top", data.get("top"));
		$('preview_command').setStyle("left", data.get("left"));
		
	}
	
	/** init 3D thumbnails **/
	
	if ($('3D-container') != null) {			
		var images = $ES('.thumbnails-3D img');
		var imagesPath = [];
		images.each(function(img) {
			var path = img.getAttribute("src");
			imagesPath.push(path);
		});
		new Asset.images(imagesPath, {
		    onComplete: function(){
				new Thumbnails3D({container: $('3D-container'), images: images});
		    }
		});
	}
	
	initShadow(sLanguage);

	
	/* init calendar */
	
	var nLink				= 1;
	var cCalendar;
	if(	typeof(calendar_options) == "function" && typeof(initializeCalendarLink) == "function" && 
		typeof(Calendar) != "undefined" && Calendar != undefined){
		cCalendarDay		= calendar_options(sLanguage, server + "js/calendar/img/calendar/", "no", "DD/MM/YYYY");
		var dDate			= new Date();
		//initializeCalendarLink(cCalendarDay, sLanguage, [{"src":server + "img/start_date.gif", "id":"calendar_", "target":"date_field_", "dateMax":("00/" + (dDate.getMonth() +1) + "/" + dDate.getFullYear() + "")}], nLink, "DD/MM/YYYY");
		cCalendarWeek		= calendar_options(sLanguage, server + "js/calendar/img/calendar/", "yes", "DD/MM/YYYY");
		var dDate			= new Date();
		initializeCalendarLink(cCalendarWeek, sLanguage, [{"src":server + "js/calendar/img/start_date.gif", "idTag":"calendarweek_", "target":"dateweek_field_", "dateMax":("00/" + (dDate.getMonth() +1) + "/" + dDate.getFullYear() + "")}], nLink, "DD/MM/YYYY");
	}

	var baseWidth;
	var baseHeight;

	var rollLink = $ES('img.roll_image');
	// var bgimage = $ES('.background-image');

	var c = 0;

	for ( var i = 0; i < rollLink.length; i++) {

		rollLink[i].addEvent('mouseenter', function() {
			// actual mouseover action
				this.src = this.src.replace('-off-', '-on-');
				// effect is optional
				var opacityChange = new Fx.Style(this, 'opacity', {
					duration :500
				});
				opacityChange.start(0, 1);
			});
		rollLink[i].addEvent('mouseleave', function() {
			// actual mouseover action
				this.src = this.src.replace('-on-', '-off-');
				// effect is optional
				var opacityChange = new Fx.Style(this, 'opacity', {
					duration :500
				});
				opacityChange.start(0, 1);
			});
		
	}

	/* slide show image */
	var slideshowImage = $ES('.slideshow-image');
	if (!isBadBrowser()) {
		for ( var i = 1; i < slideshowImage.length; i++) {
			slideshowImage[i].setStyles("");
			slideshowImage[i].setStyle("position", "absolute");
			slideshowImage[i].setStyle("width", slideshowImage[0]
					.getCoordinates().width);
			slideshowImage[i].setStyle("left", slideshowImage[0]
					.getCoordinates().left);
			slideshowImage[i].setStyle("top", slideshowImage[0]
					.getCoordinates().top);
			slideshowImage[i].setOpacity(0);
		}
	}
	reverseLink = new ReverseLink( {});
	slideShow = new SlideShow( {});
	opacitySlide();
};

var SLIDE_SHOW_TIME = 400;

var pictureInView;
function switchVisibility(itemToHide, itemToView) {
	if (!isBadBrowser()) {
		var opacityChange = new Fx.Style(itemToHide, 'opacity', {
			duration :SLIDE_SHOW_TIME
		});
		opacityChange.start(1, 0);
		var opacityChange = new Fx.Style(itemToView, 'opacity', {
			duration :SLIDE_SHOW_TIME
		});
		opacityChange.start(0, 1);
	} else {
		itemToHide.setStyle("display", "none");
		itemToView.setStyles("");
	}
}

function hidePreviewMessage() {
	var myFx = new Fx.Style('pc_message', 'opacity', {}).start(1, 0);
}

var anim = false;
function animMessage() {
	if (!anim) {
		anim = true;
		var myFx = new Fx.Style('message', 'opacity', {
			onComplete :clearMessage
		}).start(1, 0);// display a transition from transparent to opaque.
	}
}

function hideItem(itemToHide) {
	var opacityChange = new Fx.Style(itemToHide, 'opacity', {
		duration :SLIDE_SHOW_TIME
	});
	opacityChange.start(1, 0);
}

function visibleItem(itemToVisible) {
	var opacityChange = new Fx.Style(itemToVisible, 'opacity', {
		duration :SLIDE_SHOW_TIME
	});
	opacityChange.start(0, 1);
}

function changeVisibility(item) {
	var style = item.getStyle("display");
	if (style == "none") {
		item.setStyle("display", "block");
	} else {
		item.setStyle("display", "none");
	}
}

/* slide */

var slidePos = 0;
var increment = 1;

function animSlide() {
	slidePos = slidePos + increment;
	var slideContainer = $ES('.thumbnails-slide .images');
	slideContainer[0].setStyle("margin-left", slidePos + "px");
	opacitySlide();
}

var change = "*";
function animSlideToCurrentImage() {
	if (pictureInView) {
		var slideContainer = $ES('.thumbnails-slide');
		var center = slideContainer[0].getCoordinates().left
				+ slideContainer[0].getCoordinates().width / 2;
		var imageCenter = pictureInView.getCoordinates().left
				+ pictureInView.getCoordinates().width / 2

		increment = -Math.ceil((imageCenter - center) / 8);

		if (change == "*") {
			change = "+";
		} else {
			change = "*";
		}
	}

	slidePos = slidePos + increment;
	var slideContainer = $ES('.thumbnails-slide .images');
	slideContainer[0].setStyle("margin-left", slidePos + "px");
	opacitySlide();
}

function opacitySlide() {
	/* slide show image */
	var slideContainer = $ES('.thumbnails-slide');
	if (slideContainer.length == 0) {
		return;
	}
	var center = slideContainer[0].getCoordinates().width / 2;
	var left = slideContainer[0].getCoordinates().left;
	var slideImage = $ES('.thumbnails-slide .slide-image img');

	if (slideImage[0].getCoordinates().left > slideContainer[0]
			.getCoordinates().left
			+ center) {
		increment = -increment;
		if (slideImage[slideImage.length - 1].getCoordinates().right < slideContainer[0]
				.getCoordinates().right
				- center) {
			increment = 0;
		}
	} else if (slideImage[slideImage.length - 1].getCoordinates().right < slideContainer[0]
			.getCoordinates().right
			- center) {
		increment = -increment;

	}
	for ( var i = 0; i < slideImage.length; i++) {
		var relativePos = (slideImage[i].getCoordinates().left + slideImage[i]
				.getCoordinates().width / 2)
				- left;
		if (relativePos > 0) {

			var dist = relativePos - center;
			if (dist < 0) {
				dist = -dist;
			}
			var opacity = (center - dist) / center;
			if (opacity < 0) {
				opacity = 0;
			}

			slideImage[i].setOpacity(opacity);
		}
	}
}

/**
 * WARNING: define currentDate in other place (html)
 */
var clientTime = new Date().getTime();
var globalDayStr = '';
function displayDate(dayStr) {

	if (dayStr != null) {
		globalDayStr = dayStr;
	}

	var diffTime = new Date().getTime() - clientTime;

	diffTime = endDate.getTime() - (currentDate.getTime() + diffTime);
	if (diffTime < 0) {
		diffTime = 0;
	}

	var diffDays = Math.floor(diffTime / 1000 / 60 / 60 / 24);
	diffTime = diffTime - diffDays * 1000 * 60 * 60 * 24;
	var diffHours = Math.floor(diffTime / 1000 / 60 / 60);
	diffTime = diffTime - diffHours * 1000 * 60 * 60;
	var diffMinutes = Math.floor(diffTime / 1000 / 60);
	diffTime = diffTime - diffMinutes * 1000 * 60;
	var diffSec = Math.floor(diffTime / 1000);

	$ES('.timer-days')[0].value = diffDays + " " + globalDayStr;
	$ES('.timer-time')[0].value = diffHours + ":" + diffMinutes + ":" + diffSec;
}

/** ****************************** */
/** ********* JS CLASS *********** */
/** ****************************** */

/** 3D THUMB * */

function cancelClick(e)

{
	if(e && e.stopPropagation && e.preventDefault)
	{
		e.stopPropagation();
		e.preventDefault();
	} else if(e && window.event)
	{
		window.event.cancelBubble = true;
		window.event.returnValue = false;
	}
	return false;
}

function nothing() {
	
}

var Thumbnails3D = new Class(
		{

			options : {
				container :$ES('body')[0],
				images :$ES('img')
			},

			init : function() {
				
				// wait last image loading
				/*while ((this.options.images[ this.options.images.length-1 ].getCoordinates().height < 10)) {
					nothing.delay(1000);
				}*/

				/*
				 * this.options.container.setStyle("margin", "0px"); // debug
				 * this.options.container.setStyle("padding", "0px"); // debug
				 * //this.options.container.setStyle("position", "absolute"); //
				 * debug //this.options.container.setStyle("left",
				 * this.options.container.getLeft()); // debug
				 * this.options.container.setStyle("border", "2px red solid"); //
				 * debug
				 */
				var step = Math.PI * 2 / this.options.images.length;

				this.startx = 0; //this.options.container.getCoordinates().left;
				this.starty = 0; //this.options.container.getCoordinates().top;

				this.centerx = this.options.container.getCoordinates().width
						/ 2;
				this.absoluteCenterX = this.options.container.getCoordinates().left + this.options.container.getCoordinates().width
				/ 2;

				/*
				 * for (var i = 0; i < this.options.images.length; i++) {
				 * this.options.images[i].setStyle("position", "absolute");
				 * this.options.images[i].setStyle("left",
				 * this.options.container.getPosition().x + "px"); } return
				 * false; // debug
				 */
				this.r = this.options.container.getCoordinates().width / 2;
				this.options.container.setStyle("height", Math.round(this.r * 1.5) + "px");
				this.options.container.setStyle("overflow", "hidden");
				this.options.container.setStyle("position", "relative");
				this.centery = this.options.container.getCoordinates().height
						/ 2;

				this.step = 0;
				this.direction = 1;
				this.imageTarget = 0;

				this.maxImageWidth = 0;
				this.maxImageHeight = 0;
				this.maxReduction = (this.r / 200) + 1;

				for (i = 0; i < this.options.images.length; i++) {

					this.options.images[i].baseWidth = this.options.images[i]
							.getCoordinates().width;
					this.options.images[i].baseHeight = this.options.images[i]
							.getCoordinates().height;

					this.options.images[i].posy = 10;
					this.options.images[i].num = i;
					this.options.images[i].animation = this;

					this.options.images[i].angle = (i * step - Math.PI / 2);
					this.options.images[i].posx = this.r
							* Math.cos(this.options.images[i].angle);
					this.options.images[i].posz = this.r
							* Math.sin(this.options.images[i].angle) + this.r;

					this.options.images[i].setStyle("position", "absolute");
					this.options.images[i].setStyle("display", "block");
					this.options.images[i].setStyle("margin", "0");
					this.options.images[i].setStyle("padding", "0");
					this.options.images[i].animate = false;
					
					if (i>0) {
						$('3D-description-'+i).setStyle("display", "none");
					}
					
					this.options.images[i].getParent().link = this.options.images[i].getParent().getProperty("href");
					this.options.images[i].getParent().canClick = false;
					this.options.images[i].getParent().shadowBoxOff = true; // no shadow box
					//this.options.images[i].getParent().removeProperty("href");
					
					this.options.images[i].getParent().addEvent('click', function(e) {
						outClick = false;
						if (this.canClick) {
							outClick = true;				
						} else {
							outClick = false;
						}
						this.canClick = true;						
						if (outClick == false) {
							cancelClick(e);
						} 
						$('3D-container').getParent().oldImageTarget.getParent().canClick = false;
						return outClick;
					});

					this.options.images[i].addEvent('mouseover', function() {
						//if (!this.animate) {
							$('3D-container').getParent().oldImageTarget = $('3D-container').getParent().imageTarget;
							$('3D-container').getParent().imageTarget = this;
							$('3D-description-'+this.animation.imageTarget).setStyle("display", "none");
							this.animation.imageTarget = this.num;
							$('3D-description-'+this.num).setStyle("display", "block");
							this.animation.imageClicked = true;
						//}
						return false;
					});

					if (this.maxImageWidth < this.options.images[i]
							.getCoordinates().width) {
						this.maxImageWidth = this.options.images[i]
								.getCoordinates().width;
						this.r = this.options.container.getCoordinates().width
								/ 2 - this.maxImageWidth / 4;
					}

					if (this.maxImageHeight < this.options.images[i]
							.getCoordinates().height) {
						this.maxImageHeight = this.options.images[i]
								.getCoordinates().height;
						this.centery = this.options.container.getCoordinates().height
								/ 2 - this.maxImageHeight / 8;
					}

					this.options.images[i]
							.addEvent(
									'load',
									function() {
										this.setStyle("width", "auto");
										this.setStyle("height", "auto");
										this.setStyle("z-index", "-1"); /*
																		 * no
																		 * flick
																		 * when
																		 * image
																		 * loader
																		 */
										this.baseWidth = this.getCoordinates().width;
										this.baseHeight = this.getCoordinates().height;
										if (this.animation.maxImageWidth < this
												.getCoordinates().width) {
											this.animation.maxImageWidth = this
													.getCoordinates().width;
											this.animation.r = this.animation.options.container
													.getCoordinates().width
													/ 2
													- this.animation.maxImageWidth
													/ 4;
										}
										if (this.animation.maxImageHeight < this
												.getCoordinates().height) {
											this.animation.maxImageHeight = this
													.getCoordinates().height;
											this.animation.centery = this.animation.options.container
													.getCoordinates().height
													/ 2
													+ this.animation.options.container
															.getCoordinates().top
													- this.animation.maxImageHeight
													/ 8;
										}
									});

				}

			},
			projection : function(img) {

				var mx = 1;
				var my = 1;

				var Distance = 10;

				var reduction = (img.posz / 300) + 1;

				var previousLeft = img.getCoordinates().left;

				img.setStyle("width", img.baseWidth / reduction);
				img.setStyle("height", img.baseHeight / reduction);
				img.setStyle("z-index", this.r * 2 - Math.round(img.posz));

				var x = img.posx - ((mx / (img.posz + Distance)) * img.posx);
				//var y = img.posy - ((mx / (img.posz/2 + Distance)) * img.posy);
				var y = img.posy;
				
				var oldX = img.getPosition().x; // move detection
				var oldY = img.getPosition().y; // move detection
				
				img.setStyle("left", x + this.centerx
						- img.getCoordinates().width / 2);
				img.setStyle("top", this.centery - y
						- img.getCoordinates().height / 2);
				
				// move detection
				if (oldX == img.getPosition().x && oldY == img.getPosition().y) { 
					img.animate = false;
					return false;
				} else {
					img.animate = true;
					return true;
				}

			},
			animate : function() {

				var nextStep = 0;

				for ( var i = 0; i < this.options.images.length; i++) {
					this.options.images[i].angle = this.options.images[i].angle
							+ this.step;
					this.options.images[i].posx = this.r
							* Math.cos(this.options.images[i].angle);
					this.options.images[i].posz = this.r
							* Math.sin(this.options.images[i].angle) + this.r; 
					this.options.images[i].posy = (this.r / 5)
							* Math.sin(this.options.images[i].angle);
					var isMouving = this.projection(this.options.images[i]);
					
					if (isMouving) {
						this.options.images[i].getParent().shadowBoxOff = true;
					}

					if (i == this.imageTarget) {
						if (this.imageClicked) {
							if ((this.options.images[i].getCoordinates().left
									+ this.options.images[i].getCoordinates().width
									/ 2 > this.absoluteCenterX)) {
								this.direction = -1;
							} else {
								this.direction = 1;
							}
						}
						if (!isMouving) {
							this.options.images[i].getParent().shadowBoxOff = false; // if no mouving, activate the shadowbox
						}
						if (this.options.images[i].posz > 0) {
							nextStep = (Math
									.log(this.options.images[i].posz * 4) / (this.r / 4))
									* this.direction;
						}

						this.imageClicked = false;
					}
				}
				this.step = nextStep;
			},

			initialize : function(options) {
				this.options = options;
				this.init();
				this.animate.periodical(75, this);
			}
		});

/** preview edit * */

var clickEvent;

var PreviewEdit = new Class( {
	
	initialize : function(options) {
		var components = $ES(".editable-component");
		for ( var i = 0; i < components.length; i++) {
			var component = components[i];
			component.dcID = component.getProperty("id").substring(3)
			/*component.addEvent("dblclick", function(evt) {
				new Event(evt).stop();
				if (clickEvent != null) {
					clickEvent.stop();
				}
				var id = this.dcID;
				var url = ajaxURL + "?webaction=editone&number=" + id;
				editComponent(url);
				return false;
			});*/
			component.addEvent("click", function(evt) {
				new Event(evt).stop();
				if (clickEvent != null) {
					clickEvent.stop();
				}
				var id = this.dcID;
				//var url = ajaxURL + "?webaction=editone&number=" + id;
				//editComponent(url);
				var url = ajaxURL + "?webaction=editoneiframe&number=" + id;
				editComponentIFrame(url);
				return false;
			});
			
		}
	}

});

/** slieshow * */

var SlideShow = new Class( {

	status : {
		slide :0,
		stop :false
	},

	init : function() {

		/* slide show image */
		var newsSlideShow = $ES('.news-slideshow')[0];
		var img = $ES('.news-slideshow a')[0];
		// newsSlideShow.setStyle("position", "relative");

		var link = $ES('.link-0')[0];

		if (link != null) {

			var linkIndice = 0;
			link.addClass("selected");
			var baseLink = link;
			while (link != null) {
				var nextLink = $ES('.link-' + linkIndice)[0];
				if (nextLink != null) {
					nextLink.setStyle("left",
							(baseLink.getCoordinates().left - newsSlideShow
									.getCoordinates().left)
									+ (baseLink.getCoordinates().width + 10)
									* linkIndice);
					nextLink.setStyle("top", 0);
					nextLink.setStyle("position", "absolute");
					nextLinkA = $ES('a', nextLink)[0];
					nextLinkA.setStyle("display", "block");
					nextLinkA.linkIndice = linkIndice;
					nextLinkA.onclick = function(event) {
						slideShow.status.stop = true;
						slideShow.changeSlide(this.linkIndice);
						return false;
					}
				}
				linkIndice++;
				link = nextLink;
			}
			link = $ES('.link-0')[0];
			var slide = $ES('.news-slideshow .slide');

			for ( var i = 0; i < slide.length; i++) {
				slide[i].setStyles("");
				slide[i].setStyle("width", slide[0].getCoordinates().width);
				slide[i].setStyle("left", 0);
				slide[i].setStyle("top", link.getCoordinates().bottom
						- newsSlideShow.getCoordinates().top);
				slide[i].setStyle("position", "absolute");
				slide[i].setStyle("z-index", "0");
				slide[i].setOpacity(0);
			}
			slide[0].setOpacity(1);
			/** design the element * */
			for ( var i = 0; i < slide.length; i++) {
				var img = $ES('.image img', slide[i])[0];
				var body = $ES('.body', slide[i])[0];
				if (body != null) {
					body.setStyle("position", "absolute");
					body.setStyle("width", img.getCoordinates().width
							- img.getCoordinates().width / 1.62);
					body.setStyle("height", img.getCoordinates().height - 8);
					body.setStyle("right", newsSlideShow.getCoordinates().right
							- img.getCoordinates().right + 1);
					if (isBadBrowser()) {
						body.setStyle("right",
								newsSlideShow.getCoordinates().right
										- img.getCoordinates().right);
					}
					body.setStyle("top", 1);
					// body.setStyle("background-color", "#ffffff");
					/*
					 * if (document.selection) { body.setOpacity(1); } else {
					 * body.setOpacity(0.8); }
					 */
					body.setOpacity(0.8);
				}
			}

			slide[0].setStyle("z-index", "1");

			if (img != null) {
				newsSlideShow.setStyle("height", img.getCoordinates().height
						+ link.getCoordinates().height);
			}

		}
	},

	changeSlide : function(slide) {
		var slideshow = $ES('.news-slideshow .slide');
		if (slideshow[slide] == null) {
			slide = 0;
		}
		// slideshow[this.status.slide].setOpacity(0);
	new Fx.Style(slideshow[this.status.slide], 'opacity').start(1, 0);
	// slideshow[slide].setOpacity(1);
	new Fx.Style(slideshow[slide], 'opacity').start(0, 1);
	this.activeSlide(this.status.slide, slide);

	var css = ".link-" + this.status.slide;
	$ES(css)[0].removeClass("selected");
	css = ".link-" + slide;
	$ES(css)[0].addClass("selected");

	this.status.slide = slide;
},

activeSlide : function(oldSlide, newSlide) {
	var slideshow = $ES('.news-slideshow .slide');
	if (slideshow[newSlide] == null) {
		newSlide = 0;
	}
	slideshow[oldSlide].setStyle("z-index", "0");
	slideshow[newSlide].setStyle("z-index", "1");
},

animate : function() {
	if (!this.status.stop) {
		this.changeSlide(this.status.slide + 1);
	}
},

initialize : function(options) {
	if ($ES('.news-slideshow').length > 0) {
		this.init();
		this.animate.periodical(5000, this);
	}
}
});

/** reverse-link in preview * */

var ReverseLink = new Class( {

	initialize : function() {
		var linkList = $ES('.reverselink-info');
		for ( var i = 0; i < linkList.length; i++) {
			var id = linkList[i].getProperty("id").substring(4,
					linkList[i].getProperty("id").length);
			var link = $('link-' + id);
			linkList[i].setStyle("top", link.getCoordinates().top
					- (linkList[i].getCoordinates().height + 50));
			linkList[i].setStyle("left", link.getCoordinates().left
					- (link.getCoordinates().width - linkList[i]
							.getCoordinates().width));
			link.id = id;
			linkList[i].remove = function() {
				this.setStyle("display", "none");
			}.bind(linkList[i]);
			link.addEvent("mouseover", function() {
				$('box-' + this.id).setStyle("display", "block");
			});
			link.addEvent("mouseout", function() {
				$('box-' + this.id).remove.delay(10000);
			});
		}
	}

});

function submitMultipartForm() {
	alert("submit : "+$ES('form[enctype="multipart/form-data"]')[0]);
	$ES('form[enctype="multipart/form-data"]')[0].removeEvent(submit);
	$ES('form[enctype="multipart/form-data"]')[0].submit();
}

function initUpload() {
	
	alert($ES('form[enctype="multipart/form-data"]')[0].onSubmit);
	
	var toHidden = $ES(".hidden-if-js");
	for (var i=0; i<toHidden.length; i++) {
		toHidden[i].setStyle("visibility", "hidden");
		toHidden[i].setStyle("position", "absolute");
	}

	 
	/**
	 * We take the first input with this class we can find ...
	 */
	var input = $('upload-filedata');
 
	/**
	 * Simple and easy
	 *
	 * swf: the path to the swf
	 * container: the object is embedded in this container (default: document.body)
	 *
	 * NOTE: container is only used for the first uploader u create, all others depend
	 * on the same swf in that container, so the container option for the other uploaders
	 * will be ignored.
	 *
	 */
	var flashURL = BASE_PATH+'/js/fancy_upload/Swiff.Uploader.swf'; 
	if (BASE_PATH == '/') {
		flashURL = '/js/fancy_upload/Swiff.Uploader.swf';
	}
	var upload = new FancyUpload(input, {
		swf:  flashURL,
		queueList: 'upload-queue',
		types: {'*.*':'*.*'},
		instantStart: true,		
		limitSize: 15 * 1024 * 1024 // 2Mb
	});
	
	if ($('upload-filedata-submit') != null) {
		$('upload-filedata-submit').setStyle('display', 'none');
	}
			
	/**
	 * We create the clear-queue link on-demand, since we don't know if the user has flash/javascript.
	 *
	 * You can also create the complete xhtml structure thats needed for the queue here, to be sure
	 * that its only in the document when the user has flash enabled.
	 */
	if ($('upload-status') != null) {
		$('upload-status').adopt(new Element('a', {
			'href': '#',
			'events': {
				'click': (function(e) {
					e.stop();
					upload.clearList(false);
				}).bindWithEvent()
			}
		}).setHTML('Clear Completed'));
	}
 
};

/** PREVIEW COMMAND **/

function selectPageToMove() {
	var li = $ES("#preview_command .pc_menu li");
	for (var i=0; i<li.length; i++) {
		li[i].addClass("page-selected");
		li[i].removeClass("page-not-selected");	
	}
}

/*
Copyright (c) Copyright (c) 2007, Carl S. Yestrau All rights reserved.
Code licensed under the BSD License: http://www.featureblend.com/license.txt
Version: 1.0.3
*/
var FlashDetect = new function(){
	var self = this;
	self.installed = false;
	self.raw = "";
	self.major = -1;
	self.minor = -1;
	self.revision = -1;
	self.revisionStr = "";
	var activeXDetectRules = [
		{
			"name":"ShockwaveFlash.ShockwaveFlash.7",
			"version":function(obj){
				return getActiveXVersion(obj);
			}
		},
		{
			"name":"ShockwaveFlash.ShockwaveFlash.6",
			"version":function(obj){
				var version = "6,0,21";
				try{
					obj.AllowScriptAccess = "always";
					version = getActiveXVersion(obj);
				}catch(err){}
				return version;
			}
		},
		{
			"name":"ShockwaveFlash.ShockwaveFlash",
			"version":function(obj){
				return getActiveXVersion(obj);
			}
		}
	];
	var getActiveXVersion = function(activeXObj){
		var version = -1;
		try{
			version = activeXObj.GetVariable("$version");
		}catch(err){}
		return version;
	};
	var getActiveXObject = function(name){
		var obj = -1;
		try{
			obj = new ActiveXObject(name);
		}catch(err){}
		return obj;
	};
	var parseActiveXVersion = function(str){
		var versionArray = str.split(",");//replace with regex
		return {
			"raw":str,
			"major":parseInt(versionArray[0].split(" ")[1], 10),
			"minor":parseInt(versionArray[1], 10),
			"revision":parseInt(versionArray[2], 10),
			"revisionStr":versionArray[2]
		};
	};
	var parseStandardVersion = function(str){
		var descParts = str.split(/ +/);
		var majorMinor = descParts[2].split(/\./);
		var revisionStr = descParts[3];
		return {
			"raw":str,
			"major":parseInt(majorMinor[0], 10),
			"minor":parseInt(majorMinor[1], 10), 
			"revisionStr":revisionStr,
			"revision":parseRevisionStrToInt(revisionStr)
		};
	};
	var parseRevisionStrToInt = function(str){
		return parseInt(str.replace(/[a-zA-Z]/g, ""), 10) || self.revision;
	};
	self.majorAtLeast = function(version){
		return self.major >= version;
	};
	self.FlashDetect = function(){
		if(navigator.plugins && navigator.plugins.length>0){
			var type = 'application/x-shockwave-flash';
			var mimeTypes = navigator.mimeTypes;
			if(mimeTypes && mimeTypes[type] && mimeTypes[type].enabledPlugin && mimeTypes[type].enabledPlugin.description){
				var version = mimeTypes[type].enabledPlugin.description;
				var versionObj = parseStandardVersion(version);
				self.raw = versionObj.raw;
				self.major = versionObj.major;
				self.minor = versionObj.minor; 
				self.revisionStr = versionObj.revisionStr;
				self.revision = versionObj.revision;
				self.installed = true;
			}
		}else if(navigator.appVersion.indexOf("Mac")==-1 && window.execScript){
			var version = -1;
			for(var i=0; i<activeXDetectRules.length && version==-1; i++){
				var obj = getActiveXObject(activeXDetectRules[i].name);
				if(typeof obj == "object"){
					self.installed = true;
					version = activeXDetectRules[i].version(obj);
					if(version!=-1){
						var versionObj = parseActiveXVersion(version);
						self.raw = versionObj.raw;
						self.major = versionObj.major;
						self.minor = versionObj.minor; 
						self.revision = versionObj.revision;
						self.revisionStr = versionObj.revisionStr;
					}
				}
			}
		}
	}();
};


