
	var Site = {
		
		init: function()
		{
			// Newsletter code
			Extend.addEvent(window, "load", 	function()
															{
																Site.reccomendation.bindTo( 1, {
																		input: 'recommendationMail',
																		button: 'reccomendationSubmitButton1',
																		form: 'reccomendationForm1'
																});
																
																Site.reccomendation.bindTo( 2, {
																		input: 'recommendationMail',
																		button: 'reccomendationSubmitButton2',
																		form: 'reccomendationForm2'
																});
																
																Site.reccomendation.bindTo( '', {
																		input: "emailField",
																		form: "loginForm",
																		button: "loginButton"
																});
																
																Site.misc.enableExpiredPromotions();
																
																Site.misc.getRandomBanner();
															});
		},
		
		cookie:
		{
			set: function( c_name, value, expiredays )
			{
				if( !expiredays )
				{
					var expiredays = 365;
				}
				
				var exdate=new Date();
				
				exdate.setDate( exdate.getDate() + expiredays );
				document.cookie = c_name+ "=" +escape(value)+ ( (expiredays==null) ? "" : ";expires="+exdate.toUTCString() );
			},
			
			get: function( c_name )
			{
				if(document.cookie.length == 0)
				{
					return false;
				}
				
				c_start=document.cookie.indexOf(c_name + "=");
				
				if(c_start!=-1)
				{
					c_start=c_start + c_name.length+1;
					c_end=document.cookie.indexOf( ";", c_start );
					
					if (c_end==-1)
					{
						c_end = document.cookie.length;
					}
					
					return unescape(document.cookie.substring(c_start,c_end));
				}
				
				return false;
			}
		},
		
		facebook:
		{
			init: function()
			{
				window.fbAsyncInit = 	function()
												{
													FB.init({appId: Config.facebookAPI , status: true, cookie: true, xfbml: true});
												};
				
				var facebookDiv = document.createElement( "div" );
				facebookDiv.setAttribute( "id", "fb-root" );
				
				document.body.appendChild( facebookDiv );
				
				(function()
				{
					var e = document.createElement('script');
					
					e.async = true;
					e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
					
					facebookDiv.appendChild(e);
				}());
			}
		},
		
		forms:
		{
			requiredObjects: new Array(),
			
			markRequired: function( objectName )
			{
				for(var i=0;i<Site.forms.requiredObjects.length;i++)
				{
					if(Site.forms.requiredObjects[ i ] != objectName)
					{
						continue;
					}
					
					return false;
				}
				
				Site.forms.requiredObjects[ Site.forms.requiredObjects.length ] = objectName;
				
				return true;
			},
			
			markOk: function( objectName )
			{
				for(var i=0;i<Site.forms.requiredObjects.length;i++)
				{
					if(Site.forms.requiredObjects[i] != objectName)
					{
						continue;
					}
					
					Site.forms.requiredObjects.splice(i, 1);
					
					return true;
				}
				
				return false;
			},
			
			checkOk: function()
			{
				if(Site.forms.requiredObjects.length == 0)
				{
					return true;
				}
				
				return false;
			},
			
			send: function( formName )
			{
				var formObject = document.getElementById( formName );
				
				formObject.submit();
			}
		},
		
		reccomendation:
		{
			bindTo: function( objectNumber, prefixes )
			{
				if( !prefixes )
				{
					var prefixes = {
						input: 'recommendationMail',
						button: 'reccomendationSubmitButton1',
						form: 'reccomendationForm1'
					};
				}
				
				var object = document.getElementById( prefixes.input + objectNumber );
				var objectSubmit = document.getElementById( prefixes.button );
				var objectForm = document.getElementById( prefixes.form );
				
				if( !object || !objectForm || !objectSubmit )
				{
					return false;
				}
				
				Extend.addEvent( object, "focus", 	function()
																{
																	if( !object.initValue )
																	{
																		object.initValue = object.value;
																	}
																	
																	if( object.value == object.initValue && !object.getAttribute("erase") )
																	{
																		object.className = "";
																		object.value = '';
																	}
																});
				
				Extend.addEvent( object, "blur", 	function()
																{
																	if( object.value.length == 0 )
																	{
																		object.value = object.initValue;
																	}
																	
																	object.className = "blurred";
																});
				
				Extend.addEvent( objectSubmit, "click", 	function()
																{
																	inputNumber = 1;
																	
																	while( inputObject = document.getElementById( prefixes.input + inputNumber) )
																	{
																		if( inputObject.value == inputObject.initValue )
																		{
																			inputObject.value='';
																			
																		}
																		
																		inputNumber++;
																	}
																	
																	objectForm.submit();
																});
			}
		},
		
		misc:
		{
			enableExpiredPromotions: function()
			{
				var allExpiredPromotionsObject = document.getElementById('allExpiredPromotions');
				var hideAllExpiredPromotionsObject = document.getElementById('hideAllExpiredPromotions');
				
				if( !allExpiredPromotionsObject )
				{
					return false;
				}
				
				var _clickFunction = 	function()
												{
													var i = 0;
													while( true )
													{
														i++;
														
														var inactiveLabelImageObject = document.getElementById('inactiveLabelImage_' + i);
														
														if( !inactiveLabelImageObject )
														{
															break;
														}
														
														if( !inactiveLabelImageObject.getAttribute("hiddenSrc") )
														{
															continue;
														}
														
														if( inactiveLabelImageObject.getAttribute("changed") == "true" )
														{
															inactiveLabelImageObject.setAttribute("src", "/content/img/empty.gif" );
															inactiveLabelImageObject.setAttribute("changed", "false");
														}
														else
														{
															inactiveLabelImageObject.setAttribute("src", inactiveLabelImageObject.getAttribute("hiddenSrc") );
															inactiveLabelImageObject.setAttribute("changed", "true");
														}
													}
												}
				
				allExpiredPromotionsObject.onclick = 	function()
																	{
																		_clickFunction();
																		
																		allExpiredPromotionsObject.className = "hidden";
																		hideAllExpiredPromotionsObject.className = "";
																	}
				
				hideAllExpiredPromotionsObject.onclick = 	function()
																	{
																		_clickFunction();
																		
																		allExpiredPromotionsObject.className = "";
																		hideAllExpiredPromotionsObject.className = "hidden";
																	}
			},
			
			fillDropdowns: function()
			{
				var selectObjects = document.getElementsByTagName("select");
				
				for(var i=0;i<selectObjects.length;i++)
				{
					var selectDefaultValue = selectObjects[i].getAttribute("defaultValue");
					
					if(!selectDefaultValue)
					{
						continue;
					}
					
					for(var j=0;j<selectObjects[i].options.length;j++)
					{
						if(selectObjects[i].options[j].value != selectDefaultValue)
						{
							continue;
						}
						
						selectObjects[i].options[j].selected = true;
						break;
					}
				}
			},
			
			confirmAction: function( args )
			{
				return confirm( args.confirmText );
			},
			
			setMainPhoto: function( args )
			{
				var mainPhotoPlaceHolder = document.getElementById( "mainPhoto" );
				mainPhotoPlaceHolder.setAttribute("src", args.src);
				
				var zoomPhotoPlaceHolder = document.getElementById( "jqzoom" );
				zoomPhotoPlaceHolder.setAttribute("href", args.bigSrc);
			
			},
			
			showBigPic: function()
			{
				var mainPhotoPlaceHolder = document.getElementById( "mainPhoto" );
				
				document.getElementById('bigPicHolderImage').setAttribute("src", mainPhotoPlaceHolder.getAttribute("bigPic"));
				document.getElementById('bigPicHolderContainer').className = 'bigPicHolder visible';
				document.getElementById('leftColumn').className = 'hidden';
				document.getElementById('rightColumn').className = 'hidden';
			},
			
			hideBigPic: function()
			{
				document.getElementById('bigPicHolderContainer').className = 'bigPicHolder hidden';
				document.getElementById('leftColumn').className = 'leftcolumn';
				document.getElementById('rightColumn').className = 'rightcolumn';
			},
			
			changeMaximumValue: function( args )
			{
				var quantityObject = document.getElementById( "quantity" );
				var quantityText = document.getElementById( "maximumQuantityText" );
				
				quantityObject.setAttribute("maxquantity", args.value);
				quantityText.innerHTML = args.value;
			},
			
			changeMaximumValueDropdown: function()
			{
				var dropdownObjects = document.getElementById("productAttributes").getElementsByTagName("select");
				
				var minValue = null;
				for(var i=0;i<dropdownObjects.length;i++)
				{
					var selectedIndexValue = parseFloat(dropdownObjects[i].options[ dropdownObjects[i].selectedIndex ].getAttribute("amount"));
					
					if(selectedIndexValue == 0 || isNaN(selectedIndexValue))
					{
						continue;
					}
					
					if(minValue == null || minValue > selectedIndexValue)
					{
						minValue = selectedIndexValue;
					}
				}
				
				var quantityText = document.getElementById( "maximumQuantityText" );
				
				if(minValue == null)
				{
					minValue = 0;
				}
				
				quantityText.innerHTML = minValue;
			},
			
			checkBox: function( args )
			{
				if( !args.area )
				{
					args.area = "";
				}
				
				var orderFormObject = document.getElementById('orderForm');
				
				orderFormObject.setAttribute( "action", orderFormObject.getAttribute("action") + args.area )
				
				orderFormObject.submit();
			},
			
			resizeArea: function( textareaObject )
			{
				var rows = document.getElementById(textareaObject).value.split('\n').length + 1;
				
				if( rows * 14 > Site.misc.getElementHeight(textareaObject) )
				{
					document.getElementById(textareaObject).style.height = rows * 13 + 'px';
					document.getElementById('middleLeft').style.height = rows * 13 + 'px';
					document.getElementById('middleRight').style.height = rows * 13 + 'px';
				}
				
			},
			
			getElementHeight: function( Elem )
			{
				if(document.getElementById)
				{
					var elem = document.getElementById(Elem);
				}
				else if (document.all)
				{
					var elem = document.all[Elem];
				}
				
				xPos = elem.offsetHeight;
			
				return xPos;
			},
			
			addInput: function(fieldValue)
			{
				var emailRowObject = document.getElementById('emailRow').cloneNode(true);
				emailRowObject.removeAttribute('id');
				
				
				//remove button
				var divChild = emailRowObject.getElementsByTagName('div');
				for( var i = 0; i < divChild.length; i++ )
				{
					if( divChild[i].getAttribute('id') != 'addMore' )
					{
						continue;
					}
					
					emailRowObject.removeChild(divChild[i]);
				}
				
				document.getElementById('emailsTable').appendChild(emailRowObject);
				
				//modify input
				var inputObject = emailRowObject.getElementsByTagName('input');
				for( i = 0; i < inputObject.length; i++ )
				{
					if( inputObject[i].getAttribute('id') != 'emailField1' )
					{
						continue;
					}
					
					
					inputObject[i].setAttribute('id', 'emailField' + emailFieldCounter);
					inputObject[i].value = fieldValue;
					inputObject[i].initValue = fieldValue;
					
					Site.reccomendation.bindTo( emailFieldCounter , {
												input: "emailField" ,
												form: "recommendForm",
												button: "submitButton"
										});
										
				}
				
				emailFieldCounter++;
			},
			
			inputOnChange: function(inputObject, fieldValue)
			{
				var inputNo = parseInt( inputObject.getAttribute('id').substr(10,1) );
				if( !inputChanged[inputNo - 1])
				{
					Site.misc.addInput(fieldValue);
					inputChanged[inputChanged.length] = 0;
					inputChanged[inputNo - 1] = 1;
				}
			},
			
			pressMoreInput:function(fieldValue)
			{
				for(var i = 0; i < inputChanged.length; i++)
				{
					inputChanged[i] = 1;
				}
				
				Site.misc.addInput(fieldValue);
				inputChanged[inputChanged.length] = 0;
			},
			
			getRandomBanner:function()
			{
				var randomBanner =  Math.floor( Math.random() * 10 ) % 4 + 1;
				
				if(  bannerObject = document.getElementById('banner' + randomBanner) )
				{
					bannerObject.style.display =  'block';
					
					Site.misc.startTransition( randomBanner );
				}
			},
			
			startTransition:function( index )
			{
				$("#banner" + index).fadeOut('slow', function()
								{
									if( index == 5 )
									{
										index = 1;
									}
									else
									{
										index++;
									}
									
									$("#banner" + index).fadeIn('slow');	
								});
				
				
				
				
				
				setTimeout(function()
					 {
						Site.misc.startTransition( index );
					 },
					 15000);
				
			}
			
			
		}
		
	}
		
	var BrowserDetect = {
		
		init: function ()
		{
			this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
			this.version = this.searchVersion(navigator.userAgent)
				|| this.searchVersion(navigator.appVersion)
				|| "an unknown version";
			this.OS = this.searchString(this.dataOS) || "an unknown OS";
		},
		
		searchString: function (data)
		{
			for (var i=0;i<data.length;i++)	{
				var dataString = data[i].string;
				var dataProp = data[i].prop;
				this.versionSearchString = data[i].versionSearch || data[i].identity;
				if (dataString) {
					if (dataString.indexOf(data[i].subString) != -1)
						return data[i].identity;
				}
				else if (dataProp)
					return data[i].identity;
			}
		},
		
		searchVersion: function (dataString)
		{
			var index = dataString.indexOf(this.versionSearchString);
			if (index == -1) return;
			return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
		},
		
		dataBrowser:
		[
			{
				string: navigator.vendor,
				subString: "Apple",
				identity: "Safari"
			},
			{
				prop: window.opera,
				identity: "Opera"
			},
			{
				string: navigator.vendor,
				subString: "iCab",
				identity: "iCab"
			},
			{
				string: navigator.vendor,
				subString: "KDE",
				identity: "Konqueror"
			},
			{
				string: navigator.userAgent,
				subString: "Firefox",
				identity: "Firefox"
			},
			{	// for newer Netscapes (6+)
				string: navigator.userAgent,
				subString: "Netscape",
				identity: "Netscape"
			},
			{
				string: navigator.userAgent,
				subString: "MSIE",
				identity: "Explorer",
				versionSearch: "MSIE"
			},
			{
				string: navigator.userAgent,
				subString: "Gecko",
				identity: "Mozilla",
				versionSearch: "rv"
			},
			{ 	// for older Netscapes (4-)
				string: navigator.userAgent,
				subString: "Mozilla",
				identity: "Netscape",
				versionSearch: "Mozilla"
			}
		],
		
		dataOS : 
		[
			{
				string: navigator.platform,
				subString: "Win",
				identity: "Windows"
			},
			{
				string: navigator.platform,
				subString: "Mac",
				identity: "Mac"
			},
			{
				string: navigator.platform,
				subString: "Linux",
				identity: "Linux"
			}
		]
	
	};
	
	var Extend = {
		
		addEvent: new Function(),
		removeEvent: new Function(),
		removeNode: new Function(),
		findPos: new Function(),
		copyToClipboard: new Function(),
		createDOMRoot: new Function(),
		createDOMChild: new Function(),
		
		misc:
		{
			scrollBarWidth: new Number(5)
		},
		
		serialize:
		{
			string: new Function(),
			
			IE:
			{
				string: function(xmlNode)
				{
					return xmlNode.xml;
				}
			},
			
			FF:
			{
				string: function(xmlNode)
				{
					return ( new XMLSerializer() ).serializeToString(xmlNode);
				}
			}
		},
		
		selectText:
		{
			range: new Function(),
			
			IE:
			{
				range: function(element, start, end)
				{
					var sel = element.createTextRange();
					sel.collapse(true);
					sel.moveStart("character", start);
					sel.moveEnd("character", end);
					sel.select();
				}
			},
			
			FF:
			{
				range: function(element, start, end)
				{
					element.selectionStart = start;
					element.selectionEnd = end;
				}
			}
		},
		
		currentStyle:
		{
			get: new Function(),
			
			IE:
			{
				get: function(block, property)
				{
					return block.currentStyle[property];
				}
			},
			
			FF:
			{
				get: function(block, property)
				{
					return document.defaultView.getComputedStyle(block, null).getPropertyValue(property);
				}
			}
		},
		
		findPosFF: function(obj)
		{
			var curleft = curtop = new Number(0);
			
			if(obj.offsetParent)
			{
				curleft = obj.offsetLeft;
				curtop = obj.offsetTop;
				
				while (obj = obj.offsetParent)
				{
					curleft += obj.offsetLeft - obj.scrollLeft;
					curtop += obj.offsetTop - obj.scrollTop;
				}
			}
			
			return {left:curleft, top:curtop + document.body.scrollTop};
		},
		
		findPosIE: function(obj)
		{
			var curleft = curtop = new Number(0);
			
			if(obj.offsetParent)
			{
				curleft = obj.offsetLeft;
				curtop = obj.offsetTop;
				
				while (obj = obj.offsetParent)
				{
					/*
					var objectBorder = new Number(0);
					
					if(/^[A-Z]*$/i.test(obj.currentStyle.borderWidth))
					{
						objectBorder = new Number(0);
					}
					else
					{
						objectBorder = parseInt(obj.currentStyle.borderWidth.replace(/![0-9]+/, ''));
					}
					
					curleft += obj.offsetLeft + objectBorder - obj.scrollLeft;
					curtop += obj.offsetTop + objectBorder - obj.scrollTop;
					
					curleft += obj.offsetLeft + objectBorder - obj.scrollLeft;
					curtop += obj.offsetTop + objectBorder - obj.scrollTop;
					*/
					
					curleft += obj.offsetLeft - obj.scrollLeft;
					curtop += obj.offsetTop - obj.scrollTop;
				}
			}
			
			return {left:curleft + document.body.scrollLeft, top: curtop + document.body.scrollTop};
		},
		
		copyToClipboardIE: function(text)
		{
			// the IE-manier
			window.clipboardData.setData("Text", text);
		},
		
		copyToClipboardFF: function(text)
		{
			netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
			
			var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
			if (!clip)
			{
				return;
			}
			
			// maak een transferable
			var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
			if (!trans)
			{
				return;
			}
			
			trans.addDataFlavor('text/unicode');
			
			var str = new Object();
			var len = new Object();
			
			var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
			str.data = text;
			trans.setTransferData("text/unicode", str, text.length * 2);
			
			var clipid = Components.interfaces.nsIClipboard;
			if (!clip) return false;
			
			clip.setData(trans, null, clipid.kGlobalClipboard);
		},
		
		createDOMRootIE: function()
		{
			return new ActiveXObject("Msxml2.DOMDocument.3.0");
		},
		
		createDOMChildIE: function(root, name)
		{
			return root.createElement(name);
		},
		
		createDOMTextNodeIE: function(root, value)
		{
			return root.createTextNode(value);
		},
		
		createDOMRootFF: function(objname)
		{
			return document.createElementNS("http://www.emotionconcept.eu", objname);	
		},
		
		createDOMChildFF: function(root, name)
		{
			return document.createElementNS("http://www.emotionconcept.eu", name);
		},
		
		createDOMTextNodeFF: function(root, value)
		{
			return document.createTextNode(value);
		},
		
		init: function()
		{
			// Generic addEvent
			if(document.addEventListener)
			{
				this.addEvent = function(element, type, handler)
								{
									element.addEventListener(type, handler, false);
								};
								
				this.removeEvent = 	function(element, type, handler)
									{
										element.removeEventListener(type, handler, false);
									};
			}
			else if(document.attachEvent)
			{
				this.addEvent = function(element, type, handler)
								{
									element.attachEvent("on" + type, handler);
								};
								
				this.removeEvent = 	function(element, type, handler)
									{
										element.detachEvent("on" + type, handler);
									};
			}
			else
			{
				//Not supported
				alert('No Event Listener');
			}
			
			if(BrowserDetect.browser == "Explorer")
			{
				this.findPos = this.findPosIE;
				this.copyToClipboard = this.copyToClipboardIE;
				this.selectText.range = this.selectText.IE.range;
				this.serialize.string = this.serialize.IE.string;
				
				this.createDOMRoot = this.createDOMRootIE;
				this.createDOMChild = this.createDOMChildIE;
				this.createDOMTextNode = this.createDOMTextNodeIE;
				
				this.currentStyle.get = this.currentStyle.IE.get;
			}
			else
			{
				this.findPos = this.findPosFF;
				this.copyToClipboard = this.copyToClipboardFF;
				this.selectText.range = this.selectText.FF.range;
				this.serialize.string = this.serialize.FF.string;
				
				this.createDOMRoot = this.createDOMRootFF;
				this.createDOMChild = this.createDOMChildFF;
				this.createDOMTextNode = this.createDOMTextNodeFF;
				
				this.currentStyle.get = this.currentStyle.FF.get;
			}
			
			// removeNode Mozilla emulation
			if(window.Node)
			{
				Node.prototype.removeNode = function( removeChildren )
				{
					var self = this;
					if ( Boolean( removeChildren ) )
					{
						return this.parentNode.removeChild( self );
					}
					else
					{
						var range = document.createRange();
						range.selectNodeContents( self );
						return this.parentNode.replaceChild( range.extractContents(), self );		
					}
				}
			}
			
			/*
				Scroll width
			*/
			
			function getScrollerWidth()
			{
				var scr = null;
				var inn = null;
				var wNoScroll = 0;
				var wScroll = 0;
			
				// Outer scrolling div
				scr = document.createElement('div');
				scr.style.position = 'absolute';
				scr.style.top = '-100px';
				scr.style.left = '-100px';
				scr.style.width = '100px';
				scr.style.height = '50px';
				// Start with no scrollbar
				scr.style.overflow = 'hidden';
			
				// Inner content div
				inn = document.createElement('div');
				inn.style.width = '100%';
				inn.style.height = '200px';
			
				// Put the inner div in the scrolling div
				scr.appendChild(inn);
				// Append the scrolling div to the doc
				document.body.appendChild(scr);
				
				// Width of the inner div sans scrollbar
				wNoScroll = inn.offsetWidth;
				// Add the scrollbar
				scr.style.overflow = 'scroll';
				
				// Width of the inner div width scrollbar
				wScroll = inn.offsetWidth;
			
				// Remove the scrolling div from the doc
				document.body.removeChild(document.body.lastChild);
			
				// Pixel width of the scroller
				return (wNoScroll - wScroll);
			}
			
//			this.misc.scrollBarWidth = getScrollerWidth();
			
			/*
				Extend Array
			*/
			
			Array.prototype.in_array_minus = 	function(search_term)
												{
													var i = this.length;
													if (i > 0) 
													{
														do
														{
															if (this[i] === search_term)
															{
																return true;
															}
														} while (i--);
													}
													
													return false;
												}
			/*
			// Mozilla event offsets
			Event.prototype.__defineGetter__("offsetX", function ()
														{
														   return this.layerX;
														});
			
			Event.prototype.__defineGetter__("offsetY", function () 
														{
														   return this.layerY;
														});
			
			Event.prototype.__defineGetter__("srcElement", 	function ()
															{
															   var node = this.target;
															   while (node.nodeType != 1) node = node.parentNode;
															   return node;
															});
			
			Event.prototype.__defineSetter__("cancelBubble", 	function(b)
																{
																   	if(b)
																   	{
																		this.stopPropagation();
																	}
																});
			*/
		}
		
	}
	
	/*
		Date functions
	*/
	
	var _lang = (navigator.systemLanguage || navigator.userLanguage || navigator.language || navigator.browserLanguage || '').replace(/-.*/,'');
	switch (_lang) {
		case 'de':
			Date._l10n = {
				days: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
				months: ['Januar','Februar','M\u00E4rz','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'],
				date: '%e.%m.%Y',
				time: '%H:%M:%S'};
			break;
		case 'es':
			Date._l10n = {
				days: ['Domingo','Lunes','Martes','Miércoles','Jueves','Viernes','S\u00E1bado'],
				months: ['enero','febrero','marcha','abril','puede','junio','julio','agosto','septiembre','octubre','noviembre','diciembre'],
				date: '%e.%m.%Y',
				time: '%H:%M:%S'};
			break;
		case 'fr':
			Date._l10n = {
				days: ['dimanche','lundi','mardi','mercredi','jeudi','vendredi','samedi'],
				months: ['janvier','f\u00E9vrier','mars','avril','mai','juin','juillet','ao\u00FBt','septembre','octobre','novembre','decembre'],
				date: '%e/%m/%Y',
				time: '%H:%M:%S'};
			break;
		case 'it':
			Date._l10n = {
				days: ['domenica','luned\u00EC','marted\u00EC','mercoled\u00EC','gioved\u00EC','venerd\u00EC','sabato'],
				months: ['gennaio','febbraio','marzo','aprile','maggio','giugno','luglio','agosto','settembre','ottobre','novembre','dicembre'],
				date: '%e/%m/%y',
				time: '%H.%M.%S'};
			break;
		case 'pt':
			Date._l10n = {
				days: ['Domingo','Segunda-feira','Ter\u00E7a-feira','Quarta-feira','Quinta-feira','Sexta-feira','S\u00E1bado'],
				months: ['Janeiro','Fevereiro','Mar\u00E7o','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
				date: '%e/%m/%y',
				time: '%H.%M.%S'};
			break;
		case 'en':
		default:
			Date._l10n = {
				days: ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
				months: ['January','February','March','April','May','June','July','August','September','October','November','December'],
				date: '%Y-%m-%e',
				time: '%H:%M:%S'};
			break;
	}
	Date._pad = function(num, len) {
		for (var i = 1; i <= len; i++)
			if (num < Math.pow(10, i))
				return new Array(len-i+1).join(0) + num;
		return num;
	};
	Date.prototype.format = function(format) {
		if (format.indexOf('%%') > -1) { // a literal `%' character
			format = format.split('%%');
			for (var i = 0; i < format.length; i++)
				format[i] = this.format(format[i]);
			return format.join('%');
		}
		format = format.replace(/%D/g, '%m/%d/%y'); // same as %m/%d/%y
		format = format.replace(/%r/g, '%I:%M:%S %p'); // time in a.m. and p.m. notation
		format = format.replace(/%R/g, '%H:%M:%S'); // time in 24 hour notation
		format = format.replace(/%T/g, '%H:%M:%S'); // current time, equal to %H:%M:%S
		format = format.replace(/%x/g, Date._l10n.date); // preferred date representation for the current locale without the time
		format = format.replace(/%X/g, Date._l10n.time); // preferred time representation for the current locale without the date
		var dateObj = this;
		return format.replace(/%([aAbhBcCdegGHIjmMnpStuUVWwyYzZ])/g, function(match0, match1) {
			return dateObj.format_callback(match0, match1);
		});
	}
	Date.prototype.format_callback = function(match0, match1) {
		switch (match1) {
			case 'a': // abbreviated weekday name according to the current locale
				return Date._l10n.days[this.getDay()].substr(0,3);
			case 'A': // full weekday name according to the current locale
				return Date._l10n.days[this.getDay()];
			case 'b':
			case 'h': // abbreviated month name according to the current locale
				return Date._l10n.months[this.getMonth()].substr(0,3);
			case 'B': // full month name according to the current locale
				return Date._l10n.months[this.getMonth()];
			case 'c': // preferred date and time representation for the current locale
				return this.toLocaleString();
			case 'C': // century number (the year divided by 100 and truncated to an integer, range 00 to 99)
				return Math.floor(this.getFullYear() / 100);
			case 'd': // day of the month as a decimal number (range 01 to 31)
				return Date._pad(this.getDate(), 2);
			case 'e': // day of the month as a decimal number, a single digit is preceded by a space (range ' 1' to '31')
				return Date._pad(this.getDate(), 2);
			/*case 'g': // like %G, but without the century
				return ;
			case 'G': // The 4-digit year corresponding to the ISO week number (see %V). This has the same format and value as %Y, except that if the ISO week number belongs to the previous or next year, that year is used instead
				return ;*/
			case 'H': // hour as a decimal number using a 24-hour clock (range 00 to 23)
				return Date._pad(this.getHours(), 2);
			case 'I': // hour as a decimal number using a 12-hour clock (range 01 to 12)
				return Date._pad(this.getHours() % 12, 2);
			case 'j': // day of the year as a decimal number (range 001 to 366)
				return Date._pad(this.getMonth() * 30 + Math.ceil(this.getMonth() / 2) + this.getDay() - 2 * (this.getMonth() > 1) + (!(this.getFullYear() % 400) || (!(this.getFullYear() % 4) && this.getFullYear() % 100)), 3);
			case 'm': // month as a decimal number (range 01 to 12)
				return Date._pad(this.getMonth() + 1, 2);
			case 'M': // minute as a decimal number
				return Date._pad(this.getMinutes(), 2);
			case 'n': // newline character
				return '\n';
			case 'p': // either `am' or `pm' according to the given time value, or the corresponding strings for the current locale
				return this.getHours() < 12 ? 'am' : 'pm';
			case 'S': // second as a decimal number
				return Date._pad(this.getSeconds(), 2);
			case 't': // tab character
				return '\t';
			case 'u': // weekday as a decimal number [1,7], with 1 representing Monday
				return this.getDay() || 7;
			/*case 'U': // week number of the current year as a decimal number, starting with the first Sunday as the first day of the first week
				return ;
			case 'V': // The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week. (Use %G or %g for the year component that corresponds to the week number for the specified timestamp.)
				return ;
			case 'W': // week number of the current year as a decimal number, starting with the first Monday as the first day of the first week
				return ;*/
			case 'w': // day of the week as a decimal, Sunday being 0
				return this.getDay();
			case 'y': // year as a decimal number without a century (range 00 to 99)
				return this.getFullYear().toString().substr(2);
			case 'Y': // year as a decimal number including the century
				return this.getFullYear();
			/*case 'z':
			case 'Z': // time zone or name or abbreviation
				return ;*/
			default:
				return match0;
		}
	}
	
	BrowserDetect.init();
	Extend.init();
	Site.init();
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
