selOpen = function(active, id) {
		$A($(id).getElementsByTagName("li")).each(function(el) {
				$(el).removeClassName('on shown');
		});
		$(active).up().addClassName('shown');
		selShow(id);
}
selShow = function(id) {
	if ($(id).hasClassName('shown')) {
		$A($(id).getElementsByTagName("li")).each(function(el) {
			if (!$(el).hasClassName('opener')) {
				$(el).removeClassName('on');
				if ($(el).hasClassName('shown')) {
					$(el).removeClassName('shown');
					$(el).addClassName('on');
				}
			}
		});
		$(id).removeClassName('shown');
	} else {
		$A($(id).getElementsByTagName("li")).each(function(el) {
			if (!$(el).hasClassName('opener')) {
				if ($(el).hasClassName('on')) {
					$(el).addClassName('shown');
				} else {
					$(el).addClassName('on');
				}
			}
		});
		$(id).addClassName('shown');
	}
	return false;
}

delRow = function(active) {
	$(active).up(1).remove();
	return false;
}
delDiv = function(active) {
	$(active).up().remove();
	return false;
}
switchMap = function(active) {
	if ($(active).up(1).hasClassName('ajaxopen')) {$(active).up(1).addClassName('on');}
	$$('div.ajax').each(function(el){$(el).removeClassName('ajaxopen');});
	if ($(active).up(1).hasClassName('on')) {
		$(active).up(1).removeClassName('on');
	} else {
		$(active).up(1).addClassName('ajaxopen');
	}
	return false;
}
switchMap2 = function(active, hrefa, flah) {
	$$('ul.map_r li').each(function(el){
		$(el).removeClassName('on');
		$(el).up().next().removeClassName('mapb');
	});
	$(active).up().addClassName('on');
	if (flah) {
		$(active).up(1).next().addClassName('mapb');
	} else {
		$(active).up(1).next().removeClassName('mapb');
	}
	$('map_link').href=hrefa;
	return false;
}

hoverer = function () {

	$$('table.orderbin tbody th').each(function(el){
		$(el).onmouseover=function() {
						$(el).up().addClassName('on');
					}
			$(el).onmouseout=function() {
						$(el).up().removeClassName('on');
					}
	});
	$$('table.orderbin td.data div.hf').each(function(el){
		$(el).onmouseover=function() {
						$(el).addClassName('on');
					}
			$(el).onmouseout=function() {
						$(el).removeClassName('on');
					}
	});
}

addShower = function(active) {
	$$('div.add_size').each(function(el){
		$(el).setStyle({display:'none'});
		$(el).next().setStyle({display:'block'});
	});
	$(active).up().setStyle({display:'none'});
	$(active).up().previous().setStyle({display:'block'});
	return false;
}
emptyBin = function() {
	$$('table.orderbin tbody tr').each(function(el){
		if (!$(el).hasClassName('nothing')) {$(el).remove();} else {$(el).show();}
	});
	return false;
}
objShift = 0;
scrollIt = function(sval) {
	var uloffset = $('scrollist').getWidth() - $('scrollist').up().getWidth();
	objShift = objShift + sval;
	$('scrollist').style.marginLeft = objShift + 'px';
	
}

var handleProductMarkers = function () {
	setTimeout(function () {
		
		var flashObj = document["product"] || window["product"],
			markerClassName = 'ref-marker',
			offsetGap = 25, // title css gap
			markers = $$('[class*=' + markerClassName + ']'),
			flashElement = $('product-wrapper');
		
		var align = function () {
			markers.each(function(el, i) {
				var c = el.className;
				var idx = c.substr(markerClassName.length, c.length);
				var posY = $(el).cumulativeOffset()[1];
				var offsetY = $(flashElement).cumulativeOffset()[1];
				flashObj.SetVariable("location" + idx + "Y", posY - offsetY + offsetGap);
			});
		}
		
		align();
		
		Event.observe(window, 'resize', function () {
			align();
		});
		
	}, 1000);
}

var handleProductPoints = function (data) {
	
	var setFlashVars = function (data) {
		
		var flash = document["product"] || window["product"];
		
		flash.SetVariable("point1X", data.point1[0]);
		flash.SetVariable("point1Y", data.point1[1]);
		flash.SetVariable("point2X", data.point2[0]);
		flash.SetVariable("point2Y", data.point2[1]);
		flash.SetVariable("point3X", data.point3[0]);
		flash.SetVariable("point3Y", data.point3[1]);
		flash.SetVariable("point4X", data.point4[0]);
		flash.SetVariable("point4Y", data.point4[1]);
		flash.SetVariable("szPathToPic", data.img);
		
	}
	
	// set initial variables
	setFlashVars(data[0][0]);
	
	$$('.boot_spec_holder ul').each(function (block, block_idx) {
		block.select('li').each(function (item, item_idx) {
			item.select('a')[0].observe('click', function (e) {
				
				var flash = document["product"] || window["product"];
				
				this.up('ul').select('li').invoke('removeClassName', 'on');
				this.up('li').addClassName('on');
				
				setFlashVars(data[block_idx][item_idx]);
				
			});
		});
	});
	
}
