	var divCount	= 2;
	var totalImages = 10;

	/**
	 *
	 * @access public
	 * @return void
	 **/
	function add_image()
	{
		var div 		= document.getElementById('holder');
		var php			= new phpToJs();
		var tmp			= div.innerHTML;
		var divlist 	= '';

		if(divCount < totalImages + 1)
		{
			for(var i = 2; i <= divCount; i++)
			{
				divlist += php.preg_replace(':i:', i, tmp);
			}
			document.getElementById('place').innerHTML = divlist;
		}
		divCount++;
	}//eof add_attachment

/**************************** DROPDOWN BOX ON HOME PAGE *************************************/

/**
 * Box Class
 **/
function Box(el, e) {
	if(!$('drop_down_box')) {
	// set globals
	this.event = e;
	this.target = el;
	// save position early
	this.position = this.mouseCoords();
	//init the links
	this.links = [];
	this.links.push({
			tag:'Spartiti'
		},
		{
			tag:'Libri'
		},
		{
			tag:'Altro'
		});
	//create a new div
	this.box = document.createElement('div');
	this.box.id = 'drop_down_box';
	// get the body
	this.body = document.body;
	this.body.appendChild(this.box);
	//this.setPosition();
	this.content = this.createContent();
	this.setContent();
	} else {
		this.out();
	}// IF ELSE
}

Box.prototype = {

	/* fetch mouse coords for tooltip action */
	mouseCoords: function() {
		var x=this.event.clientX, y=this.event.clientY, scrOfX=0, scrOfY=0;
		if(document.body&&(document.body.scrollLeft||document.body.scrollTop)) {
			scrOfY=document.body.scrollTop;
			scrOfX=document.body.scrollLeft;
		} else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)) {
			scrOfY=document.documentElement.scrollTop;
			scrOfX=document.documentElement.scrollLeft;
		}
		y=y+scrOfY;
		x=x+scrOfX;
		return[x,y];
	},// mouseCoords

	/* set the boxes position as a tooltip */
	setPosition: function() {
		this.box.style.left = this.position[0]+'px';
		this.box.style.top = this.position[1]+10+'px';
	},// setPosition

	createContent: function() {
		var div = document.createElement('div'), n=this.links.length, i=0, x={};
		for(i;i<n;i=i+1) {
			//create the link nod
			x = document.createElement('a');
			x.innerHTML = this.links[i].tag;
			x.href = 'javascript:;';
			x.box = this;
			Event.observe(x, 'click', this.executeCommand);
			div.appendChild(x);
		}// FOR
		div.id = 'js_box_content';
		return div;
	},// createContent

	/* value insertion for search forms */
	executeCommand: function() {
		// FOR SEARCH FORM
		var link = $('box_target'), html = this.innerHTML;
		link.innerHTML = html;
		link.title = html;
		if (html === 'Sparititi') {
			link.style.paddingLeft = '10px';
		}
		document.searchForm.searchCat.value = html;
		// FOR ADVANCED SEARCH FORM
		if ($('advancedSearchCatText') !== null) {
			$('advancedSearchCatText').innerHTML = this.innerHTML;
			document.advancedSearchForm.advancedSearchCat.value = this.innerHTML;
			// now switch the input fields
			if (this.innerHTML === 'Spartiti') {
				$('advancedSearchBooks').style.display = 'none';
				$('advancedSearchMusic').style.display = 'block';
			} else {
				$('advancedSearchBooks').style.display = 'block';
				$('advancedSearchMusic').style.display = 'none';
			}// IF ELSE
		}// IF ELSE
		this.box.out();
	},// executeCommand

	out: function() {
		new Effect.Morph('js_box_content', {
		  style: 'margin-top: -110px;', // CSS Properties
		  duration: 0.2 // Core Effect properties
		});
		setTimeout("document.body.removeChild($('drop_down_box'))", 200);
	},

	/* set the inner content of the box */
	setContent: function() {
		this.box.appendChild(this.content);
		new Effect.Morph('js_box_content', {
		  style: 'margin: 0px;', // CSS Properties
		  duration: 0.2 // Core Effect properties
		});
	}// setContent
};

/**************	SLIDER TABBER ON HOME PAGE **************/
/**
 * Slider Object
 **/
function Slider() {
	this.ul = $('sliderTarget');
	this.unit = 140;
	this.ulMargin = 0;
	this.N = 0;
	this.C = 0;
	this.countChildren();
	this.status = 0;
}

Slider.prototype = {
	slideLeft: function() {
		this.status = 1;
		if (this.N > 3 && this.C > 3) {
			this.ulMargin = this.ulMargin + this.unit;
			this.C = this.C - 1;
			this.animate(this.ulMargin);
		}
	},// slideLeft
	slideRight: function() {
		this.status = 1;
		if (this.N > 3 && this.C < (this.N - 1)) {
			this.ulMargin = this.ulMargin - this.unit;
			this.C = this.C + 1;
			this.animate(this.ulMargin);
		}
	},// slideLeft
	animate: function(val) {
		new Effect.Morph('sliderTarget', {
		  style: 'margin-left: ' + val + 'px;', // CSS Properties
		  duration: 0.2 // Core Effect properties
		});
		this.status = 0;
	},
	countChildren: function() {
		var i=0,list = this.ul.childNodes, n = list.length, comp={}, k=1;
		for(i;i<n;i=i+1) {
			if (!(i in comp) && list[i].className === 'targetLi') {
				k = k + 1;
			}
		}// FOR
		if (k > 3) {
			this.C = 3;
		} else {
			this.C = k;
		}// IF ELSE
		this.N = k;
	}// countChildren
};

function timer()
{
	//alert('c:' + objSlider.C + ' n: '+objSlider.N);
	if(objSlider.C != objSlider.N -1 && objSlider.status === 0) objSlider.slideRight();
	else{
		objSlider.ulMargin = objSlider.ulMargin + ((objSlider.N-4)*objSlider.unit);
		objSlider.animate(objSlider.ulMargin);
		objSlider.C = 3;
	}
	var t = setTimeout('timer()',10000);
}

/************************ tabberGallery HOME PAGE ****************************/

/**
 * Object
 **/
function tabberGallery() {
	// init the lists
	this.Gallery = $('tbbr_gallery');
	this.navList = this.Gallery.getElementsByClassName('tbbr');
	this.tabList = this.Gallery.getElementsByClassName('tbbr_tab');
	//init some globals
	this.L = 0;
	this.N = this.navList.length;
	this.active = 0;
	this.arrowL = $('tbbr_arrows_left');
	this.arrowR = $('tbbr_arrows_right');
	/*
		add commands to the arrows
	*/
	this.arrowL.tbbr = this;
	this.arrowR.tbbr = this;
	this.arrowL.onclick = function() {
		this.tbbr.slideLeft();
	};
	this.arrowR.onclick = function() {
		this.tbbr.slideRight();
	};
	/*
		3 are allowed at one time
		show the first 3
	*/
	this.showNav();
	this.showTab();
	this.toggleArrows();
}

tabberGallery.prototype = {
	show: function(obj) {
		if(obj != undefined)
		obj.style.display = 'inline-block';
	},
	hide: function(obj) {
		if(obj != undefined)
		obj.style.display = 'none';
	},
	showNav: function() {
		var i=this.L, x={};
		for(i;i<(this.L+3);i=i+1) {
			x = this.navList[i];
			if (x != undefined) {
				// display
				this.show(x);
				// set active class
				if (i == this.active) {
					x.className = 'tbbr active';
				} else {
					x.className = 'tbbr';
				}
				/*
					add comands to each tab
				*/
				x.index = i;
				x.tbbr = this;
				x.onclick = this.activateTab;
			}
		}// FOR
	},
	showTab: function() {
		this.show(this.tabList[this.active]);
		// this is a good place to make the arrow toogle check
		this.toggleArrows();
	},
	toggleArrows: function() {
		if (this.N > 3 && this.active < (this.N - 1)) {
			this.show(this.arrowR);
		} else {
			this.hide(this.arrowR);
		}
		if (this.active > 0) {
			this.show(this.arrowL);
		} else {
			this.hide(this.arrowL);
		}
	},
	hideTabs: function() {
		var i=0;
		// set all tabs to none
		for (i;i<this.N;i=i+1) {
			x = this.navList[i];
			// hide
			this.hide(x);
		}
		this.hide(this.tabList[this.active]);
	},
	activateTab: function() {
		// hide all
		this.tbbr.hideTabs();
		// the new active tab
		this.tbbr.active = this.index;
		// show 3
		this.tbbr.showNav();
		this.tbbr.showTab();
	},
	slideRight: function() {
		/*
			check if active has to be changed,
			or the tabs have to be shifted
		*/
		if (this.active < (this.N - 1)) {
			if (this.active === (this.L + 2)) {
				// slide nav
				// hide all
				this.hideTabs();
				// slide visible range
				this.L = this.L + 3;
				// the new active tab
				this.active = this.active + 1;
				// show 3
				this.showNav();
				this.showTab();

			} else {
				// slide active
				// hide all
				this.hideTabs();
				// the new active tab
				this.active = this.active + 1;
				// show 3
				this.showNav();
				this.showTab();
			}// IF ELSE
		}// IF
	},
	slideLeft: function() {
		/*
			check if active has to be changed,
			or the tabs have to be shifted
		*/
		if (this.active > 0) {
			if (this.active === this.L) {
				// slide nav
				// hide all
				this.hideTabs();
				// slide visible range
				this.L = this.L - 3;
				// the new active tab
				this.active = this.active - 1;
				// show 3
				this.showNav();
				this.showTab();

			} else {
				// slide active
				// hide all
				this.hideTabs();
				// the new active tab
				this.active = this.active - 1;
				// show 3
				this.showNav();
				this.showTab();
			}// IF ELSE
		}// IF
	}
};


/************************ tabberGallery HOME PAGE - PROMOZIONI****************************/

/**
 * Object
 **/
function tabberGalleryPromizioni() {
	// init the lists
	this.Gallery = $('tbbr_gallery_promo');
	this.navList = this.Gallery.getElementsByClassName('tbbr');
	this.tabList = this.Gallery.getElementsByClassName('tbbr_tab');
	//init some globals
	this.L = 0;
	this.N = this.navList.length;
	this.active = 0;
	this.arrowL = $('tbbr_arrows_left_promo');
	this.arrowR = $('tbbr_arrows_right_promo');
	/*
		add commands to the arrows
	*/
	this.arrowL.tbbr = this;
	this.arrowR.tbbr = this;
	this.arrowL.onclick = function() {
		this.tbbr.slideLeft();
	};
	this.arrowR.onclick = function() {
		this.tbbr.slideRight();
	};
	/*
		3 are allowed at one time
		show the first 3
	*/
	this.showNav();
	this.showTab();
	this.toggleArrows();
}

tabberGalleryPromizioni.prototype = {
	show: function(obj) {
		if(obj != undefined)
		obj.style.display = 'inline-block';
	},
	hide: function(obj) {
		if(obj != undefined)
		obj.style.display = 'none';
	},
	showNav: function() {
		var i=this.L, x={};
		for(i;i<(this.L+3);i=i+1) {
			x = this.navList[i];
			if (x != undefined) {
				// display
				this.show(x);
				// set active class
				if (i == this.active) {
					x.className = 'tbbr active';
				} else {
					x.className = 'tbbr';
				}
				/*
					add comands to each tab
				*/
				x.index = i;
				x.tbbr = this;
				x.onclick = this.activateTab;
			}
		}// FOR
	},
	showTab: function() {
		this.show(this.tabList[this.active]);
		// this is a good place to make the arrow toogle check
		this.toggleArrows();
	},
	toggleArrows: function() {
		if (this.N > 3 && this.active < (this.N - 1)) {
			this.show(this.arrowR);
		} else {
			this.hide(this.arrowR);
		}
		if (this.active > 0) {
			this.show(this.arrowL);
		} else {
			this.hide(this.arrowL);
		}
	},
	hideTabs: function() {
		var i=0;
		// set all tabs to none
		for (i;i<this.N;i=i+1) {
			x = this.navList[i];
			// hide
			this.hide(x);
		}
		this.hide(this.tabList[this.active]);
	},
	activateTab: function() {
		// hide all
		this.tbbr.hideTabs();
		// the new active tab
		this.tbbr.active = this.index;
		// show 3
		this.tbbr.showNav();
		this.tbbr.showTab();
	},
	slideRight: function() {
		/*
			check if active has to be changed,
			or the tabs have to be shifted
		*/
		if (this.active < (this.N - 1)) {
			if (this.active === (this.L + 2)) {
				// slide nav
				// hide all
				this.hideTabs();
				// slide visible range
				this.L = this.L + 3;
				// the new active tab
				this.active = this.active + 1;
				// show 3
				this.showNav();
				this.showTab();

			} else {
				// slide active
				// hide all
				this.hideTabs();
				// the new active tab
				this.active = this.active + 1;
				// show 3
				this.showNav();
				this.showTab();
			}// IF ELSE
		}// IF
	},
	slideLeft: function() {
		/*
			check if active has to be changed,
			or the tabs have to be shifted
		*/
		if (this.active > 0) {
			if (this.active === this.L) {
				// slide nav
				// hide all
				this.hideTabs();
				// slide visible range
				this.L = this.L - 3;
				// the new active tab
				this.active = this.active - 1;
				// show 3
				this.showNav();
				this.showTab();

			} else {
				// slide active
				// hide all
				this.hideTabs();
				// the new active tab
				this.active = this.active - 1;
				// show 3
				this.showNav();
				this.showTab();
			}// IF ELSE
		}// IF
	}
};

/************* AJAC POPUP FOR REVIEW **********************/

function getPageSize() {var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=window.innerWidth+window.scrollMaxX;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}var windowWidth,windowHeight;if(self.innerHeight){if(document.documentElement.clientWidth){windowWidth=document.documentElement.clientWidth;}else{windowWidth=self.innerWidth;}windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}if(xScroll<windowWidth){pageWidth=xScroll;} else {pageWidth=windowWidth;}return pageHeight;}
function getMouseCoords(event){var scrOfX=0,scrOfY=0;if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){scrOfY=document.body.scrollTop;scrOfX=document.body.scrollLeft;}else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){scrOfY=document.documentElement.scrollTop;scrOfX=document.documentElement.scrollLeft;}return scrOfY;}

	function ajaxPopup(type, event) {
		document.getElementById('reviewerName').value		= '';
		document.getElementById('reviewerMail').value		= '';
		document.getElementById('reviewerMsj').value		= '';
		document.getElementById('reviewerCaptcha').value	= '';
		var reviewAjaxBoxError								= document.getElementById('reviewAjaxBoxError');
		reviewAjaxBoxError.style.display					= 'none';
		var reviewAjaxBoxMsj								= document.getElementById('reviewAjaxBoxMsj');
		reviewAjaxBoxMsj.style.display						= 'none';
		var reviewAjaxBoxForm								= document.getElementById('reviewAjaxBoxForm');
		reviewAjaxBoxForm.style.display						= 'block';
		var top												= getMouseCoords(event);
		top													= (top + (getPageSize() / 2) - 200);
		var reviewAjaxBox									= document.getElementById('reviewAjaxBox');
		reviewAjaxBox.style.display							= 'block';
		reviewAjaxBox.style.top								= top + 'px';

		switch (type)
		{
			case 'msj':
				document.getElementById('actionType').value	= 'msj';
				document.getElementById('reviewBoxTitle').innerHTML	= 'Fai una domanda';
				break;
			case 'review':
				document.getElementById('actionType').value	= 'review';
				document.getElementById('reviewBoxTitle').innerHTML	= 'Manda la tua recensione';
				break;
		}//switch

		var url = 'ajax.php?module=review&cmd=getCaptchImg';
		new Ajax.Request(url,
		 {
		   method:'get',
		   onSuccess: function(transport){
		     var response = transport.responseText;
			 var captchaImg	= document.getElementById('captchaImg');
			 captchaImg.src	= response;
		   },
		   onFailure: function(){ }
		 });
	}

	function ajaxReviewRequest() {
		var reviewerName		= document.getElementById('reviewerName').value;
		var reviewerMail		= document.getElementById('reviewerMail').value;
		var reviewerMsj			= document.getElementById('reviewerMsj').value;
		var reviewerCaptcha		= document.getElementById('reviewerCaptcha').value;
		var productArticleId	= document.getElementById('productArticleId').value;
		var actionType			= document.getElementById('actionType').value;
		var table				= document.getElementById('table').value;
		reviewerName			= encodeURIComponent(reviewerName);
		reviewerMail			= encodeURIComponent(reviewerMail);
		reviewerMsj				= encodeURIComponent(reviewerMsj);
		reviewerCaptcha			= encodeURIComponent(reviewerCaptcha);
		actionType				= encodeURIComponent(actionType);
		table					= encodeURIComponent(table);

		var url					= 'ajax.php?module=review&cmd=ajaxReview&captcha=' + reviewerCaptcha + '&reviewerName=' + reviewerName + '&reviewerMail=' + reviewerMail + '&reviewerMsj=' + reviewerMsj + '&productArticleId=' + productArticleId + '&actionType=' + actionType + '&table=' + table;

		new Ajax.Request(url,
		 {
		   method:'get',
		   onSuccess: function(transport){
		     var response = transport.responseText;

		     if (response != '-1')
		     {
		     	var reviewAjaxBoxForm	= document.getElementById('reviewAjaxBoxForm');
		     	reviewAjaxBoxForm.style.display	= 'none';
		     	var reviewAjaxBoxMsj	= document.getElementById('reviewAjaxBoxMsj');
				reviewAjaxBoxMsj.style.display	= 'block';
			}
			else
			{
				var reviewAjaxBoxError	= document.getElementById('reviewAjaxBoxError');
			 	reviewAjaxBoxError.style.display	= 'block';
			 }

		   },
		   onFailure: function(){ }
		 });
	}

/****************** NOTTICE-TRACKING NUMBER POPUP ON ADMIN ORDERS ********************/

/**
* track Object
**/
function track() {
	this.id = 'nottice_popup';
	this.formId = 'notticeForm';
}

track.prototype = {
	show: function(oid) {
		$(this.id).style.display = 'block';
		document.notticeForm.order_id.value = oid;
		var u = '../ajax.php?module=orders';
		new Ajax.Request(u,
		 {
		   method:'get',
		   parameters: $(this.formId).serialize(true),
		   onSuccess: function(transport){
		   	var response = transport.responseText;
			window.t.fill(response.evalJSON());
		   }
		 });
	},
	hide: function() {
		$(this.id).style.display = 'none';
		this.empty();
	},
	empty: function() {
		document.notticeForm.order_id.value = '';
		document.notticeForm.cmd.value = '';
		document.notticeForm.nottice.value = '';
		document.notticeForm.tracking_number.value = '';
	},
	fill: function(obj) {
		if (obj !== false) {
			document.notticeForm.nottice.value = obj.nottice;
			document.notticeForm.tracking_number.value = obj.number;
		} else {
			document.notticeForm.nottice.value = '';
			document.notticeForm.tracking_number.value = '';
		}
	},
	send: function(cmd) {
		document.notticeForm.cmd.value = cmd;
		var u = '../ajax.php?module=orders';
		new Ajax.Request(u,
		 {
		   method:'get',
		   parameters: $(this.formId).serialize(true)
		 });
	}
};


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

function changeDetailsLink(area, id)
{
	var det_link;
	if(area == 'O')
		det_link = 'books-promoaltro-c_'+id+'.html';
	else det_link = 'books-promo-c_'+id+'.html';

	$('promoDetLink').href = det_link;
}
