var _IE6 = false;
if((navigator.appName.indexOf('Microsoft Internet Explorer') != -1) && (parseInt(navigator.appVersion) < 7)) _IE6 = true;

var _IE6_mod = false;
var _isIE = false;
if(navigator.appName.indexOf('Microsoft Internet Explorer') != -1)
{
	_isIE = true;
	if(navigator.userAgent.match('MSIE 6'))
	{ 
		_IE6_mod = true;
		_isIE = false;
	}
}

/*--- promo gallery function ---*/
function PromoGall(){
	var _hold = $('promo-gall');
	if(_hold){
		var _list = _hold.select('ul.promo-list > li');
		var btn_prev = _hold.select('ul.promo-nav a.promo-prev')[0];
		var btn_next = _hold.select('ul.promo-nav a.promo-next')[0];
		var nav_info = _hold.select('ul.promo-nav .nav-info')[0];
		if(_list.length <= 1){
			_hold.select('ul.promo-nav')[0].style.display = 'none';
		}
		else if(_list.length && btn_prev && btn_next && nav_info){
			var _a = -1;
			for(var i = 0; i < _list.length; i++){
				if(_list[i].hasClassName('active')) _a = i;
			}
			if(_a == -1) _a = 0;
			for(var i = 0; i < _list.length; i++){
				if(i == _a){
					_list[i].setOpacity(1);
					_list[i].addClassName('active');
				}
				else{
					_list[i].setOpacity(0);
					_list[i].removeClassName('active');
				}
				if(_list[i].hasClassName('active')) _a = i;
			}
			$(document.body).addClassName('style' + _a);
			nav_info.innerHTML = (_a+1)+' / '+(_list.length);
			btn_prev.onclick = function(){
				if(_a > 0) changeEl(_a - 1);
				else changeEl(_list.length - 1);
				return false;
			}
			btn_next.onclick = function(){
				if(_a < _list.length -1) changeEl(_a + 1);
				else changeEl(0);
				return false;
			}
			function changeEl(_ind){
				if(_ind != _a){
				  // Making astyle on purpose.
					$(document.body).removeClassName('style' + _a).addClassName('astyle' + _ind);
					_list[_a].removeClassName('active');
					_list[_ind].addClassName('active');
					if(_IE6){
						_list[_a].setOpacity(0);
						_list[_ind].setOpacity(1);
					}
					else{
						new Effect.Opacity(_list[_a], {to: 0, duration: 1});
						new Effect.Opacity(_list[_ind], {to: 1, duration: 1});
					}
					nav_info.innerHTML = (_ind+1)+' / '+(_list.length);
					_a = _ind;
				}
			}
		}
	}
}
/*--- New Brands Gallery ---*/
function NewBrandsGall(){
	var _hold = $('carusel');
	if(_hold){
		var btn_prev = _hold.select('a.link-prev')[0];
		var btn_next = _hold.select('a.link-next')[0];
		var list_h = _hold.select('div > ul')[0];
		if(btn_prev && btn_next && list_h){
			var _step = list_h.parentNode.offsetWidth;
			var _list = list_h.childElements();
			var _w = _list.length * _list[0].offsetWidth;
			if(_w > _step){
				for(var i = 0; i < _list.length; i++){ list_h.appendChild(_list[i].cloneNode(true));}
				for(var i = 0; i < _list.length; i++){ list_h.appendChild(_list[i].cloneNode(true));}
				var _m = _w;
				list_h.style.left = -_m + 'px';
				btn_prev.onclick = function(){
					moveEl(false);
					return false;
				}
				btn_next.onclick = function(){
					moveEl(true);
					return false;
				}
			}
			var _flag = true;
			function moveEl(_f){
				if(_flag){
					_flag = false;
					if(_f){
						if(_m + _step > 3*_w -_step){
							_m -= _w;
							list_h.style.left = -_m + 'px';
						}
						_m += _step;
						new Effect.Move(list_h, {
							duration: 0.6,
							x: -_step,
							'afterFinish':function(){
								_flag = true;
							}
						});
					}
					else{
						if(_m - _step < 0){
							_m += _w;
							list_h.style.left = -_m + 'px';
						}
						_m -=_step;
						new Effect.Move(list_h, {
							duration: 0.6,
							x: _step,
							'afterFinish':function(){
								_flag = true;
							}
						});
					}
				}
			}
		}
	}
}

function in_Array(needle, haystack) {
    var length = haystack.length;
    for(var i = 0; i < length; i++) {
        if(haystack[i] == needle) return true;
    }
    return false;
}

/*--- popup function ---*/
function FeaturedPopup(){
	var _popup = $('featured-popup');
	var _popup_inner = $('feature-prod-inner');
		
	//	_popup_inner.style.display = 'block';

	if(_popup){
		_popup.style.display = 'none';
		_popup.setOpacity(0);
		var popup_c = _popup.select('div.popup-inn')[0];
		
		var popup_top = _popup.select('div.popup-top')[0];
		var popup_cnt = _popup.select('div.popup-cnt')[0];
		var popup_btm = _popup.select('div.popup-btm')[0];
				
		var _t;
		var _cnt = 0;
		var _popId;
		var _cell = new Array("3", "4", "5", "9", "10", "11", "15", "16", "17");
			
		$$('div.products > ul > li').each(function(_el){
			var _text = _el.select('div.info-box')[0];

			if(_text){

				//alert(_cnt);
				_el.onmouseover = function(){
					
					// ie: 330;
					if(_IE6_mod){
						if(this.offsetLeft > 330){
							popup_top.style.background = "none";
							popup_top.style.filter = "progid:dximagetransform.microsoft.alphaimageloader(src='/skin/frontend/default/moxsiev2/images/popup-top_flip.png', sizingmethod='crop')";
							popup_cnt.style.background = "none";
							popup_cnt.style.filter = "progid:dximagetransform.microsoft.alphaimageloader(src='/skin/frontend/default/moxsiev2/images/popup-bg_flip.png', sizingmethod='scale')";
							popup_btm.style.background = "none";
							popup_btm.style.filter = "progid:dximagetransform.microsoft.alphaimageloader(src='/skin/frontend/default/moxsiev2/images/popup-btm_flip.png', sizingmethod='crop')";
							popup_c.style.marginLeft = "7px";
						
						}else{
							popup_top.style.background = "none";
							popup_top.style.filter = "progid:dximagetransform.microsoft.alphaimageloader(src='/skin/frontend/default/moxsiev2/images/popup-top.png', sizingmethod='crop')";
							popup_cnt.style.background = "none";
							popup_cnt.style.filter = "progid:dximagetransform.microsoft.alphaimageloader(src='/skin/frontend/default/moxsiev2/images/popup-bg.png', sizingmethod='scale')";
							popup_btm.style.background = "none";
							popup_btm.style.filter = "progid:dximagetransform.microsoft.alphaimageloader(src='/skin/frontend/default/moxsiev2/images/popup-btm.png', sizingmethod='crop')";

							popup_c.style.marginLeft = "9px";

						}

						//_popup.style.left =  findPosX(this) - 276 + 'px';
					
					}else if(_isIE){

						if(this.offsetLeft > 330 ){
							popup_top.style.background = 'url(/skin/frontend/default/moxsiev2/images/popup-top_flip.png) no-repeat';
							popup_cnt.style.background = 'url(/skin/frontend/default/moxsiev2/images/popup-bg_flip.png) repeat-y';
							popup_btm.style.background = 'url(/skin/frontend/default/moxsiev2/images/popup-btm_flip.png) no-repeat';
							popup_c.style.marginLeft = "11px";

						}else{
							popup_top.style.background = 'url(/skin/frontend/default/moxsiev2/images/popup-top.png) no-repeat';
							popup_cnt.style.background = 'url(/skin/frontend/default/moxsiev2/images/popup-bg.png) repeat-y';
							popup_btm.style.background = 'url(/skin/frontend/default/moxsiev2/images/popup-btm.png) no-repeat';
							popup_c.style.marginLeft = "17px";

						}

					}else{

						//alert(this.offsetLeft);
						if(this.offsetLeft > 700 ){
						//if( in_Array(_cnt, _cell) ){
							popup_top.style.background = 'url(/skin/frontend/default/moxsiev2/images/popup-top_flip.png) no-repeat';
							popup_cnt.style.background = 'url(/skin/frontend/default/moxsiev2/images/popup-bg_flip.png) repeat-y';
							popup_btm.style.background = 'url(/skin/frontend/default/moxsiev2/images/popup-btm_flip.png) no-repeat';
							popup_c.style.marginLeft = "11px";

						}else{
							popup_top.style.background = 'url(/skin/frontend/default/moxsiev2/images/popup-top.png) no-repeat';
							popup_cnt.style.background = 'url(/skin/frontend/default/moxsiev2/images/popup-bg.png) repeat-y';
							popup_btm.style.background = 'url(/skin/frontend/default/moxsiev2/images/popup-btm.png) no-repeat';
							//popup_c.style.marginLeft = "17px";
							popup_c.style.marginLeft = "17px";

						}
						
					}
					
					if(_t) clearTimeout(_t);
					_popup.style.top = findPosY(this) + 'px';
					//alert(document.getElementById('page').offsetLeft);
					_popup.style.left =  findPosX(this) + 'px';

					popup_c.innerHTML = _text.innerHTML;
					_popup.style.display = 'block';
					//_popup.style.border = '1px solid #333';
					//popup_c.style.border = '1px solid #333';
					//popup_c.bgColor = '#dddddd';
					
					if(_IE6) _popup.setOpacity(1);
					else new Effect.Opacity(_popup, {to: 1, duration: 0.3});
				}
				_el.onmouseout = function(){
									
					_t = setTimeout(function(){
						if(_IE6){
							_popup.setOpacity(0);
							_popup.style.display = 'none';
						}
						else new Effect.Opacity(_popup, {to: 0, duration: 0.3, 'afterFinish': function(){ _popup.style.display = 'none';}});
					}, 100);
				}
						
				_cnt++;
			
			}

		});
		_popup.onmouseover = function(){
			if(_t) clearTimeout(_t);
			//alert(findPosX(this));
			//if(_IE6) _popup.setOpacity(1);
			//else new Effect.Opacity(_popup, {to: 1, duration: 0.3});
			
			//_popup.setOpacity(0);
			//_popup.style.display = 'none';
			/*_t = setTimeout(function(){
				if(_IE6){
					_popup.setOpacity(0);
					_popup.style.display = 'none';
				}
				else new Effect.Opacity(_popup, {to: 0, duration: 0.3, 'afterFinish': function(){ _popup.style.display = 'none';}});
			}, 100);
			*/
			//setTimeout("$('featured-popup').style.display = 'none';", 500);
			//alert(this.mouseX);
			//	$('featured-popup').setOpacity(1);
			//	$('featured-popup').style.display = 'block';
			
			//alert(_popup.offsetLeft);

		}
		_popup.onmouseout = function(){
			_t = setTimeout(function(){
				if(_IE6){
					_popup.setOpacity(0);
					_popup.style.display = 'none';
				}
				else new Effect.Opacity(_popup, {to: 0, duration: 0.3, 'afterFinish': function(){ _popup.style.display = 'none';}});
			}, 100);
		}
		
	}
	function findPosY(obj){
		var posTop = 0;
		while (obj.offsetParent) {posTop += obj.offsetTop; obj = obj.offsetParent;}
		return posTop;
	}
	function findPosX(obj){
		var posLeft = 0;
		var postLeft_flip;

		if(_IE6_mod || _isIE){
			if(obj.offsetLeft > 330)
			{
				postLeft_flip = true;
			}
		}else{
			if(obj.offsetLeft > 700)
			{
				postLeft_flip = true;			
			}
		}
		while (obj.offsetParent) {
			posLeft += obj.offsetLeft;
			obj = obj.offsetParent;
		}

		if(postLeft_flip)
		{
			posLeft = posLeft - 276;
		}
		return posLeft;
	}
}
/*--- faid banner function ---*/
function faidBanner(){
	var stay_time = 10000; //in ms
	$$('ul.promo-banner').each(function(_hold){
		var _list = _hold.childElements();
		var _a = -1;
		for(var i = 0; i < _list.length; i++){
			if(_list[i].hasClassName('active') && _a == -1) _a = i;
			else _list[i].setOpacity(0);
		}
		if(_a == -1){
			_a = 0;
			_list[_a].setOpacity(1);
		}
		var _ind;
		setInterval(function(){
			if(_a < _list.length - 1) _ind = _a + 1;
			else _ind = 0;
			_list[_a].removeClassName('active');
			_list[_ind].addClassName('active');
			new Effect.Opacity(_list[_a], {to:0});
			new Effect.Opacity(_list[_ind], {to:1});
			_a = _ind;
		}, stay_time);
	});
}

/*--- form animate ---*/
function formAnimate(){
	var _customers = $('customers');
	var _register = $('register');
	var _btCreateAccount = $('createAccount');
	var _btForgotPassword = $('forgotPassword');
	var _closeCustomers = $('closeCustomers');
	var _closeAccount = $('closeAccount');
	var _formHolder = $('formHolder');
	var _durationSlide = .5;
	
	if(_customers && _btForgotPassword){
		_btForgotPassword.onclick = function(){
			_formHolder.addClassName('customers-active');
			new Effect.Morph(_customers, {
				style: {'marginLeft': '-408px'},
				duration: _durationSlide
			})
			return false;
		}
		_closeCustomers.onclick = function(){
			new Effect.Morph(_customers, {
				style: {'marginLeft': '0px'},
				duration: _durationSlide,
				afterFinish: function(){
					_formHolder.removeClassName('customers-active');
				}
			})
			return false;
		}
	}
	if (_register && _btCreateAccount) {
		_btCreateAccount.onclick = function(){
			_formHolder.addClassName('register-active');
			new Effect.Morph(_register, {
				style: {'marginLeft': '0px'},
				duration: _durationSlide
			})
			return false;
		}
		_closeAccount.onclick = function(){
			new Effect.Morph(_register, {
				style: {'marginLeft': '-492px'},
				duration: _durationSlide,
				afterFinish: function(){
					_formHolder.removeClassName('register-active');
				}
			})
			return false;
		}
	}
}
/*--- form animate ---*/
function formAnimate2(){
	var _hold = $('estimate-box');
	var btn_open = $('btn-open');
	var btn_close = $('btn-close');
	var _durationSlide = .5;
	
	if (_hold && btn_open && btn_close){
		var _w = _hold.getStyle('marginLeft');
		btn_open.onclick = function(){
			new Effect.Morph(_hold, {
				style: {'marginLeft': '0px'},
				duration: _durationSlide
			});
			this.style.display = 'none';
			return false;
		}
		btn_close.onclick = function(){
			new Effect.Morph(_hold, {
				style: {'marginLeft': _w},
				duration: _durationSlide,
				afterFinish: function(){
					btn_open.style.display = 'block';
				}
			});
			return false;
		}
	}
}
/*--- accordion ---*/
function initAccordion(){
	if (typeof accordion == 'function') {
		var horizontalAccordion = new accordion('accordion', {
			// The speed of the accordion
			resizeSpeed : 8,
			// The classnames to look for
			classNames : {
				// The standard class for the title bar
				toggle : 'view',
				// The class used for the active state of the title bar
				toggleActive : 'hide',
				// The class used to find the content
				content : 'inside'
			},
			// Should the accordion activate on click or say on mouseover? (apple.com)
			onEvent : 'click'
		});
	}
}

/*--- book-box ---*/
function bookBox(){
	var _bookBox = $$('.book-box');
	_bookBox.each(function(box, i){
		box.removeClassName('edite');
		var _bt = box.select('a.btn');
		_bt.each(function(bt, i){
			bt.onclick = function(){
				if (box.hasClassName('edite')) {
					box.removeClassName('edite');
				} else {
					box.addClassName('edite');
				}
				return false;
			}
		});
	});
}

function initSelectTest() {
	var _select = $('sort-select');
	if(_select) {
		_select.onchange = function(){
			alert('select change');
		}
	}
}
/*--- more animation ---*/
function initMoreAnim(){
	var _a = -1;
	var _ff = true;
	var list_hold = $$('ul.detail-list > li');
	list_hold.each(function(_this, _i){
		var _btn = _this.select('div.more a')[0];
		var _box = _this.select('div.popup2')[0];
		var _t;
		if(_btn && _box){
			_box.setOpacity(0);
			var btn_close = _box.select('a.close')[0];
			_btn.onclick = function(){
				if(_ff){
					_ff = false;
					if(!_box.offsetWidth){
						if(_a != -1){
							if(_IE6){
								_a.style.display = 'none';
								_ff = true;
							}
							else{
								new Effect.Morph(_a, {style: {'opacity': '0'}, duration: 0.3, afterFinish: function(){ if(_a != _box) _a.style.display = 'none';}});
							}
						}
						_box.style.display = 'block';
						if(_IE6){
							_box.setOpacity(1);
							_ff = true;
							if(_a != -1) _a.style.display = 'none';
							_a = _box;
						}
						else{
							new Effect.Morph(_box, {style: {'opacity': '1'}, duration: 0.3, afterFinish: function(){
								_ff = true;
								if(_a != -1) _a.style.display = 'none';
								_a = _box;
							}});
						}
					}
					else{
						_a = -1;
						if(_IE6){
							_box.style.display = 'none';
							_ff = true;
						}
						else{
							new Effect.Morph(_box, {style: {'opacity': '0'}, duration: 0.3, afterFinish: function(){ _box.style.display = 'none'; _ff = true;}});
						}
					}
				}
				return false;
			}
			if(btn_close){
				btn_close.onclick = function(){
					if(_ff){
						_ff = false;
						_a = -1;
						if(_IE6){
							_box.style.display = 'none';
							_ff = true;
						}
						else{
							new Effect.Morph(_box, {style: {'opacity': '0'}, duration: 0.3, afterFinish: function(){ _box.style.display = 'none'; _ff = true;}});
						}
					}
					return false;
				}
			}
		}
	});
	$(document).observe('mousedown', function(e){
		if(_a != -1){
			e = e || event;
			var _fff = false;
			var t = e.target || e.srcElement;
			while(t != document.body){
				if(t == _a.parentNode) _fff = true;
				t = t.parentNode;
			}
			if(!_fff && _a){
				_a.style.display = 'none';
				_ff = true;
				if(!_IE6) _a.setOpacity(0);
				_a = -1;
			}
		}
	});
}
function initTestimonial(){
	var _hold = $('testimonial-list');
	_duration = 5000;
	if(_hold){
		_list = _hold.select('li');
		var _a = 0;
		_list[_a].addClassName('active');
		if(_list.length > 1){
			for(var i = 0; i < _list.length; i++){
				if(i != _a) _list[i].setOpacity(0);
			}
			setInterval(function(){
				if(_a < _list.length - 1) _ind = _a + 1;
				else _ind = 0;
				_list[_a].removeClassName('active');
				_list[_ind].addClassName('active');
				new Effect.Opacity(_list[_a], {to: 0, duration: 0.7});
				new Effect.Opacity(_list[_ind], {to: 1, duration: 0.7});
				_a = _ind;
			}, _duration);
		}
	}
}
function shipAddress(){
	var _hold = $('shipping-address');
	if(_hold){
		var _h = _hold.offsetHeight;
		var _f = false;
		$$('#checkout-step-billing div.ship input:radio').each(function(_this, _i){
			if(_i == 0 && _this.checked){
				_hold.style.display = 'none';
				_f = false;
			}
			else if(_i == 1 && _this.checked){
				_hold.style.display = 'block';
				_f = true;
			}
			_this.onchange = function(){
				if(_i == 0 && _f){
					_f = false;
					_hold.style.height = _hold.offsetHeight + 'px';
					new Effect.Morph(_hold, {
						style: {'height': '0px'},
						duration: 0.3,
						afterFinish: function(){
							_hold.style.display = 'none';
							_hold.style.height = 'auto';
						}
					});
				}
				else if(_i == 1 && !_f){
					_f = true;
					if(_hold.offsetHeight == 0){
						_hold.style.display = 'block';
						_h = _hold.offsetHeight;
						_hold.style.height = '0px';
					}
					new Effect.Morph(_hold, {
						style: {'height': _h+'px'},
						duration: 0.3,
						afterFinish: function(){
							_hold.style.height = 'auto';
						}
					});
				}
			}
		});
	}
	
}
/*--- ---*/
function checkoutLogin(){
	var _hold1 = $('login_register');
	var _hold2 = $('guest_inf');
	var _hold3 = $('create-account');
	var _hold4 = $('registered-customers');
	var _hold5 = $$('#checkout-step-login div.row1')[0];
	if(_hold1 && _hold2 && _hold3 && _hold4){
		_hold1.style.display = 'block';
		_hold2.style.display = 'block';
		_hold3.style.display = 'none';
		_hold4.style.display = 'block';
		var _btn1 = $('btn_login_reg');
		var _btn2 = _hold3.select('a.close')[0];
		var _f = true;
		if(_btn1){
			_btn1.onclick = function(){
				if(_f){
					_f = false;
					if(_hold5) _hold5.style.height = _hold5.offsetHeight - 17 + 'px';
					_hold1.setOpacity(1);
					new Effect.Morph(_hold1, {style: {'opacity': '0'}, duration: 0.5, afterFinish: function(){ _hold1.style.display = 'none';}});
					_hold2.setOpacity(1);
					new Effect.Morph(_hold2, {style: {'opacity': '0.5'}, duration: 0.5});
					_hold4.setOpacity(1);
					new Effect.Morph(_hold4, {style: {'opacity': '0'}, duration: 0.5, afterFinish: function(){
						_hold4.style.display = 'none';
						_hold3.setOpacity(0);
						_hold3.style.display = 'block';
						if(_hold5) _hold5.style.height = 'auto';
						new Effect.Morph(_hold3, {style: {'opacity': '1'}, duration: 0.5, afterFinish: function(){
							_f = true;
						}});
					}});
				}
				return false;
			}
		}
		if(_btn2){
			_btn2.onclick = function(){
				if(_f){
					_f = false;
					if(_hold5) _hold5.style.height = _hold5.offsetHeight - 17 + 'px';
					_hold3.setOpacity(1);
					new Effect.Morph(_hold3, {style: {'opacity': '0'}, duration: 0.5, afterFinish: function(){
						_hold3.style.display = 'none';
						_hold1.setOpacity(0);
						_hold1.style.display = 'block';
						if(_hold5) _hold5.style.height = 'auto';
						new Effect.Morph(_hold1, {style: {'opacity': '1'}, duration: 0.5});
						_hold2.setOpacity(0.5);
						new Effect.Morph(_hold2, {style: {'opacity': '1'}, duration: 0.5});
						_hold4.setOpacity(0);
						_hold4.style.display = 'block';
						new Effect.Morph(_hold4, {style: {'opacity': '1'}, duration: 0.5, afterFinish: function(){
							_f = true;
						}});
					}});
				}
				return false;
			}
		}
	}
}


function preloadImages()
{
  preloadBrowserBG0 = new Image();
  preloadBrowserBG0.src = "/skin/frontend/default/moxsiev2/images/opacity02-upd1.png";
  preloadBrowserBG1 = new Image();
  preloadBrowserBG1.src = "/skin/frontend/default/moxsiev2/images/opacity03-upd2.png";
  
}
/*--- arrivals popups ---*/
function arrivalsPopups(){
	var _list = $$('#arrivals-list a.illustration');
	var info_popup = $('thinner-popup');
	if(info_popup){
		var info_popup_t = info_popup.select('div.white-popup')[0];
		var bag_popup = $('confirm-popup1');
		var list_popup = $('confirm-popup2');
		var bag_fader = $('addtobag-popup');
		var list_fader = $('addtolist-popup');
		var _t;
		if(!_IE6){
			info_popup.setOpacity(0);
			bag_popup.setOpacity(0);
			list_popup.setOpacity(0);
			bag_fader.setOpacity(0);
			list_fader.setOpacity(0);
		}
		for(var i = 0; i < _list.length; i++){
			_list[i]._url = _list[i].href;
            _list[i]._id = _list[i].id;			
			_list[i]._box = false;
			_list[i].onclick = function(){
				displayPopup(this);
				return false;
			}
		}
		bag_popup.select('a.btn-close')[0].onclick = function(){
			closeAll();
			return false;
		}
		list_popup.select('a.btn-close')[0].onclick = function(){
			closeAll();
			return false;
		}
		function initSA(e){
			if(info_popup.offsetWidth){
				e = e || event;
				var t = e.target || e.srcElement;
				do{
					if(t == info_popup || t == bag_popup || t == list_popup || t == bag_fader || t == list_fader) return false;
					if(t.className && t.className.indexOf('illustration') != -1) return false;
					t = t.parentNode;
				}
				while(t);
				closeAll();
			}
		}
		if (window.addEventListener) document.body.addEventListener("mousedown", initSA, false);
		else if (window.attachEvent && !window.opera) document.body.attachEvent("onmousedown", initSA);
		
	/*--- ---*/
	function displayPopup(_btn){
		// if(_btn._box){
			info_popup_t.innerHTML = popupContent[_btn._id];
			MagicZoom.refresh();			
			dynamicDataUrl = '/v2browsepopup_ajax?id=' + _btn._id;
			new Ajax.Request(dynamicDataUrl, {
                method: 'get',
                onSuccess: function(transport){
					 eval(transport.responseText);
                }
            });
			
			
			initAct();
		//}
		//else{
		//	 new Ajax.Request(_btn._url, {
    //            method: 'get',
    //            onSuccess: function(transport){
    //                _btn._box = transport.responseText;
    //                info_popup_t.innerHTML = popupContent[_btn._url];
		//			initAct();
    //            }
    //        });
		// }
	}
	/*--- ---*/
		function initAct(){
			info_popup.style.top = getCurrentYPos() + 'px';
			bag_popup.style.top = getCurrentYPos() + 'px';
			list_popup.style.top = getCurrentYPos() + 'px';
			bag_fader.style.top = getCurrentYPos() + 'px';
			list_fader.style.top = getCurrentYPos() + 'px';
			if(info_popup.offsetWidth == 0){
				info_popup.style.display = 'block';
				if(!_IE6) new Effect.Opacity(info_popup, {from: 0, to: 1, duration: 0.3});
			}
			else{
				if(_t) clearTimeout(_t);
				bag_popup.style.display = 'none';
				list_popup.style.display = 'none';
				bag_fader.style.display = 'none';
				list_fader.style.display = 'none';
				
				bag_popup.setOpacity(0);
				list_popup.setOpacity(0);
				bag_fader.setOpacity(0);
				list_fader.setOpacity(0);
				
			}
			if(typeof(VSA_initScrollbars) == 'function') VSA_initScrollbars();
			info_popup.select('a.btn-close')[0].onclick = function(){
				closeAll();
				return false;
			}
			info_popup.select('a.btn-add-bag')[0].onclick = function(){
			//addToBag();
			if($('configurableoptions').select('select')[0]){
				if($('configurableoptions').select('select')[0].selectedIndex ==0){
					$('select-super-attribute').style.borderColor="#ff0000";
					$('popup-req-field').style.display='block';
					return;
				}
			}
			$('product_addtocart_form').request({
		  		onComplete: function(){ 
			  		window.frames['iframe-2'].location='/shopping_bag_ajax';
			  		bag_popup.style.display = 'block';
			  		info_popup.style.display = 'none';
			  		bag_fader.style.display = 'none';
					if(!_IE6) new Effect.Opacity(bag_popup, {from: 0, to: 1, duration: 0.5});
					if(_t) clearTimeout(_t);
					_t = setTimeout(function(){
						closeAll();
					}, 5000);
		  		}
			});
			bag_fader.style.height = info_popup.offsetHeight -10 + 'px';
			bag_fader.style.display = 'block';
			if(!_IE6){
				new Effect.Opacity(bag_fader, {from: 0, to: 1, duration: 0.5});
			}
			else{
				for(var i = 0; i < info_popup.select('select').length; i++){
					info_popup.select('select')[i].style.visibility = 'hidden';
				}
			}
			if(_t) clearTimeout(_t);
			/*
			_t = setTimeout(function(){
				bag_popup.style.display = 'block';
				if(!_IE6) new Effect.Opacity(bag_popup, {from: 0, to: 1, duration: 0.5});
				if(_t) clearTimeout(_t);
				_t = setTimeout(function(){
					closeAll();
				}, 5000);
			}, 2500);
			*/
			return false;
		}
		/*
		info_popup.select('a.btn-add-list')[0].onclick = function(){
				list_fader.style.height = info_popup.offsetHeight -10 + 'px';
				list_fader.style.display = 'block';
				if(!_IE6){
					new Effect.Opacity(list_fader, {from: 0, to: 1, duration: 0.5});
				}
				else{
					for(var i = 0; i < info_popup.select('select').length; i++){
						info_popup.select('select')[i].style.visibility = 'hidden';
					}
				}
				if(_t) clearTimeout(_t);
				_t = setTimeout(function(){
					list_popup.style.display = 'block';
					if(!_IE6) new Effect.Opacity(list_popup, {from: 0, to: 1, duration: 0.5});
					if(_t) clearTimeout(_t);
					_t = setTimeout(function(){
						closeAll();
					}, 3000);
				}, 2500);
				return false;
		}
		*/
			
	}
		/*--- ---*/
		function closeAll(){
			if(_t) clearTimeout(_t);
			if(_IE6){
				info_popup.style.display = 'none';
				bag_popup.style.display = 'none';
				list_popup.style.display = 'none';
				bag_fader.style.display = 'none';
				list_fader.style.display = 'none';
			}
			else{
				if(info_popup.offsetWidth){
					new Effect.Opacity(info_popup, {
						from: 1,
						to: 0,
						duration: 0.2,
						afterFinish: function(){
							info_popup.setOpacity(0);
							info_popup.style.display = 'none';
						}
					});
				}
				if(bag_popup.offsetWidth){
					new Effect.Opacity(bag_popup, {
						from: 1,
						to: 0,
						duration: 1.0,
						afterFinish: function(){
							bag_popup.setOpacity(0);
							bag_popup.style.display = 'none';
						}
					});
				}
				if(list_popup.offsetWidth){
					new Effect.Opacity(list_popup, {
						from: 1,
						to: 0,
						duration: 0.2,
						afterFinish: function(){
							list_popup.setOpacity(0);
							list_popup.style.display = 'none';
						}
					});
				}
				if(bag_fader.offsetWidth){
					new Effect.Opacity(bag_fader, {
						from: 1,
						to: 0,
						duration: 0.2,
						afterFinish: function(){
							bag_fader.setOpacity(0);
							bag_fader.style.display = 'none';
						}
					});
				}
				if(list_fader.offsetWidth){
					new Effect.Opacity(list_fader, {
						from: 1,
						to: 0,
						duration: 0.2,
						afterFinish: function(){
							list_fader.setOpacity(0);
							list_fader.style.display = 'none';
						}
					});
				}
			}
		}
	}
}
function pageH(){
	var _h = 0;
	if (window.innerHeight) _h = window.innerHeight;
	else _h = document.documentElement.clientHeight;
	if(_h < document.getElementById('main').offsetHeight) _h = document.getElementById('main').offsetHeight;
	if(_h < document.body.offsetHeight) _h = document.body.offsetHeight;
	return _h;
}
function getCurrentYPos(){
	var _offset = 0;
	if (document.body && document.body.scrollTop) _offset =  document.body.scrollTop;
	if (document.documentElement && document.documentElement.scrollTop) _offset = document.documentElement.scrollTop;
	if (window.pageYOffset) _offset =  window.pageYOffset;
	return _offset;
}
/*--- scroll block height/width ---*/
function initScrollH(){
	var main_hold = $('scroll-holder');
	if(main_hold){
		var _hold = main_hold.select('div.long')[0];
		if(_hold){
			var _w = 0;
			var _h = 0;
			_hold.childElements().each(function(_this){
				_w += _this.offsetWidth;
				if(_h < _this.offsetHeight) _h = _this.offsetHeight;
			});
			main_hold.style.height = _h + 'px';
			_hold.style.height = _h + 'px';
			_hold.style.width = _w + 'px';
			if(_IE6) _hold.childElements()[_hold.childElements().length - 1].style.marginRight = '-5px';
		}
		setTimeout(function(){
			main_hold.onmouseover = function(){
				$(this).addClassName('hover');
			}
			main_hold.onmouseout = function(){
				$(this).removeClassName('hover');
			}
		}, 500);
		
	}
}
if (window.addEventListener) window.addEventListener("load", initScrollH, false);
else if (window.attachEvent && !window.opera) window.attachEvent("onload", initScrollH);
document.observe("dom:loaded", function(){
	if (typeof initCastomForms == 'function') initCastomForms();

	PromoGall();
	/*NewBrandsGall();*/
	FeaturedPopup();
	preloadImages();
	faidBanner();
	formAnimate();
	formAnimate2();
	initAccordion();
	bookBox();
	initSelectTest();
	
	initMoreAnim();
	initTestimonial();
	shipAddress();
	checkoutLogin();
	var sourcestring = document.location.href;
	if(sourcestring.match('/browse')){
		if(typeof createPopupContent == 'function') {	createPopupContent(); }
		// if(typeof preloadBrowseImages == 'function') { preloadBrowseImages();}
		arrivalsPopups();
	};
});
