// Thumbnail - Image Loader

var origWidth, origHeight;
if (document.layers) {
	origWidth = window.innerWidth; 
	origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

var cur_lyr;

function swapLayers(lnk,id) {
	if (cur_lyr) hideLayer(cur_lyr);
	showLayer(id);
	cur_lyr = id;
}

function swapLayersAfter(lnk,id) {
	if (cur_lyr) hideLayer(cur_lyr);
	showLayer(id);
	cur_lyr = id;
	//var classe = color + '_box';
	//document.all['left_box'].className = classe;
	//classe = color + '_box_middle';
	//document.all['middle_box'].className = classe;
	//document.all['right_box'].className = classe;
}

function showLayer(id) {
	var lyr = getElemRefs(id);
	if (lyr && lyr.css) lyr.css.visibility = 'visible';
}

function hideLayer(id) {
	var lyr = getElemRefs(id);
	if (lyr && lyr.css) lyr.css.visibility = 'hidden';
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (documnet.all)? documnet.all[id]: (document.layers)? getLyrRef(id,document): null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

function getLyrRef(lyr,doc) {
	if (document.layers) {
		var theLyr;
		for (var i=0; i<doc.layers.length; i++) {
			theLyr = doc.layers[i];
			if (theLyr.name == lyr) return theLyr;
			else if (theLyr.document.layers.length > 0)
			if ((theLyr = getLyrRef(lyr,theLyr.document)) != null)
				return theLyr;
			}
			return null;
	}
}

function init(id,lyr) {
	var lnk = getElemRefs(id);
	swapLayers(lnk,lyr);
}

/* Pop up Function */

function newWindow(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen) {
  var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
  var int_windowTop = (screen.height - a_int_windowHeight) / 2;
  var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
  var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties)
    if (parseInt(navigator.appVersion) >= 4) {
      obj_window.window.focus();
    }
}
