
// --- begin: common (from auddi origional) ------------------------
function getProps(obj, doSort) {
  if (typeof(obj) != 'object')  // Not an object
    return obj;
  if (doSort != true)
    doSort = false;
  var propArr = new Array();
  var i = 0;
  for (var propName in obj)
    propArr[i++] = propName + ' = ' + obj[propName];
  if (doSort)
    propArr.sort();
  return propArr.toString();
} 

function eenc_dec(varr) {
	var s = '';
	for (i=0; i< varr.length; i++) {
		var  st = (varr[i] < 100) ? '&#0' : '&#';
		s += st + varr[i] +';'
	}
	return s;
}
// i: id tag;  t: true for hyper link   // mask in the future
function eenc(i, t, e, d) {
	obj = document.getElementById(i);

	var s = eenc_dec(e) + eenc_dec([64]) + eenc_dec(d); // : 058
	if (t) s = '<a href=' + eenc_dec([109,97,105,108,116,111, 58]) + s + '>' + s + '</a>';
	obj.innerHTML = s;
}

// showImage() does the actual work of displaying the actual image.
// This function general and shared for card and paintings display.
// It's called to display an image:
//    imgUrl: the URL of the displaying image. It could be specified as a relative filename.
//  imgTagId: the id specified in the source <img> tag.
function showImage(imgUrl, imgTagId) {
	imgdisp = document.getElementById(imgTagId);
	imgdisp.src = imgUrl;
}

// Create a map with an array of objects, the object in the array must have a member called basename
function init_map_with_basename(arr) {
	map = { };
	for (i=0; i < arr.length; i++) {
		obj = arr[i];
		if (obj != null)
			map[obj.basename] = i;
	}
	return map;
}
function copyright(margin) {
	document.writeln('<div class="copyright"');
	more_styles = (arguments.length <= 1)? '' : ';' + arguments[1];
	if (arguments.length > 0)
		document.write(' style="margin-top:' + arguments[0] + more_styles + '"');
	document.writeln('>Copyright &copy;  2009 &nbsp;Austin Lan.  &nbsp;All rights reserved.</div>');
}

// ---   end: common ----------------------------

/* --- begin :from dubhe's common.js ------------------ */
/* 
function copyright(margin) {
	document.writeln('<div class="copyright"');
	if (arguments.length > 0)
		document.write(' style="margin-top:' + arguments[0] + '"');
	document.writeln('>Copyright &copy;  2008 &nbsp;Austin Lan.  &nbsp;All rights reserved.</div>');
}
*/

// history.back(-1) or to the alternative url if no history
// specify no arguments or '' if no alternative
function hback(alternative) {
	if (history.length <= 1) { /* the history.length is 1 if no history */
		if (arguments.length > 0 && alternative != '')
			location.href = alternative;
	} else
		history.back(-1);
}

function playvideo(tagid, videofile, w, h) {
	o = document.getElementById(tagid);
	wh = ' width="' + w + '" height="' + h + '"';
	o.innerHTML = '<embed src="' + videofile + '"' + wh + ' autostart="true" loop="false" />';
}


function imagerSwap(name, image_name) {
		document.images[name].src = image_name;
		// document[name].src = image_name;
}

function imagerCreate(name, image0, image1) {
	s = '<img name="' + name + '" border="0" src="' + image0
		+ '" onMouseOver="imagerSwap(\'' + name + '\', \'' + image1 
		+ '\')" onMouseOut="imagerSwap(\'' + name + '\', \'' + image0 + '\')">';
	document.write(s);
}
// --- end: common (from auddi origional) ------------------------


/* --- end :from dubhe's common.js ------------------ */
