function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// start of personal function ----------------------------------------------------

function xtractFile_sans(){
	var data = window.location.href;
	var m = data.match(/(.*)[\/\\]([^\/\\]+)\.\w+$/);
	var section = m[1].substring(0, m[1].lastIndexOf('/'));
	section = section.substring(section.lastIndexOf('/')+1);
	var categ = m[1].substring(m[1].lastIndexOf('/')+1);
	return {section: section, categ: categ, file: m[2]}
}

function chooseLanguageEng(){
	var pageName = xtractFile_sans();
	g_section = pageName.section; // define global var
	g_category = pageName.categ; // define global var
	g_model = pageName.file; // define global var
	var _content = '<a href="../../../ENG/' + g_section + '/' + g_category + '/' + pageName.file + '.htm">';
	document.write(_content);
}

function chooseLanguageIta(){
	var pageName = xtractFile_sans();
	g_section = pageName.section; // define global var
	g_category = pageName.categ; // define global var
	g_model = pageName.file; // define global var
	var _content = '<a href="../../../ITA/' + g_section + '/' + g_category + '/' + pageName.file + '.htm">';
	document.write(_content);
}

function switch_acc_box_on() {
	this.className='acc_box_border_on';
}

function switch_acc_box_off() {
	this.className='acc_box_border_off';
}

function switch_row_on() {
	this.className='submenu_panel_hover';
}

function switch_row_off() {
	this.className='submenu_panel';
}

function empty() {
}

function acc_box_init() {
	var a_image_box=document.getElementsByName("image_box");
	for(var i=0;i<a_image_box.length;i++){
		addEvent(a_image_box[i], 'mouseover', switch_acc_box_on);
		addEvent(a_image_box[i], 'mouseout', switch_acc_box_off);
	}
}

function submenu_init() {
	// add events
	var a_submenu_model=document.getElementsByName("submenu_model");
	for(var i=0;i<a_submenu_model.length;i++){
		if (a_submenu_model[i].parentNode.id == g_model) {
			a_submenu_model[i].parentNode.className = 'submenu_panel_hover';
		}
		else {
			addEvent(a_submenu_model[i].parentNode, 'mouseover', switch_row_on);
			addEvent(a_submenu_model[i].parentNode, 'mouseout', switch_row_off);
		}
	}
	// choose accordion panel to open
	var a_section=new Array("02_BCDS","04_REGULATORS","06_INSTRUMENTS","08_CYLINDERS","10_VALVES","12_DIVING_SUITS","14_GLOVES","16_BOOTS","18_HOODS","20_MASKS","22_SNORKELS","24_FINS","25_SNORKELING_SET","28_BAGS","30_KNIVES","32_TORCHES","34_BUOYS","36_REELS","38_LIFTING_BAGS","40_ACCESSORIES");
	for(var i=0;i<a_section.length;i++){
		if (a_section[i] == g_section) {
			var open_panel = i;
			break;
		}
	}
	return open_panel
}

function addEvent( obj, type, fn ) {
	if (obj.addEventListener) {
		obj.addEventListener( type, fn, false );
		EventCache.add(obj, type, fn);
	}
	else if (obj.attachEvent) {
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
		EventCache.add(obj, type, fn);
	}
	else {
		obj["on"+type] = obj["e"+type+fn];
	}
}

var EventCache = function(){
	var listEvents = [];
	return {
		listEvents : listEvents,
		add : function(node, sEventName, fHandler){
			listEvents.push(arguments);
		},
		flush : function(){
			var i, item;
			for(i = listEvents.length - 1; i >= 0; i = i - 1){
				item = listEvents[i];
				if(item[0].removeEventListener){
					item[0].removeEventListener(item[1], item[2], item[3]);
				};
				if(item[1].substring(0, 2) != "on"){
					item[1] = "on" + item[1];
				};
				if(item[0].detachEvent){
					item[0].detachEvent(item[1], item[2]);
				};
				item[0][item[1]] = null;
			};
		}
	};
}();
addEvent(window,'unload',EventCache.flush);

var _console = null;
function f_trace(msg) {
	if ((_console == null) || (_console.closed)) {
		_console = window.open("","console","width=600,height=300,resizable");
		_console.document.open("text/plain");
	}
	_console.focus()
	_console.document.writeln(msg);
}