/** *************************************
 * 
 * Basic functions
 *
 * @author:	Patrick Kanne
 * @email:	mephisto@quaint.info
 *
 * @filename: 		func.basic.js	
 * @version:		20031225 - 001
 * @description:	cross-page javascript functions
 ************************************* **/ 

/*  ------  sitewide globals  ------  */
var mpty = "img/ppx/mpx.gif";
 
/** *************************************
 ** - funcBasic -> openPopUp
 * @access:	public
 * @desc:	opens js-popup window
 * @param: 	name, string, windowname
 			size, [string/array]. dimensions  
					string: [width]x[height]
					array:	('width'=> x, 'height'=>y)
			parent,	string, object parent
					current, string/int, current object, zero
					specs, array, list of subspecs to include.
					
					
 ************************************** */
function openPopUp(name,page,type,size,specs)
{
	//base specs
	var bSpecs = 'toolbar=0,directories=0,menubar=0,status=0,resizable=0,location=0,scrollbars=0,copyhistory=0';
	var winWidth;var winHeight;var tmp;
	//get dimensions:
	if(typeof(size) == 'array')
	{
		winHeight = size['height'];
		winwidth = size['width'];
	}
	else
	{
		tmp = size.split('x');
		winHeight = parseInt(tmp[1])+5;
		winWidth = parseInt(tmp[0]);
	}
	//compile querystring
	var winName = type+'_PP';
	var winSpecs = (specs !=0)? specs:bSpecs;
	winObj = window.open(page ,winName,'height=' + winHeight + ',width=' + winWidth + ',' + winSpecs);
	return winObj;
}
//function openPopUp
 
/** *************************************
 ** - funcBasic -> netscapefloathack
 * @access:	public
 * @desc:	There's a bug in netscape (6/7) that prevents a :relatively 
 			positioned container, which has a float: value, to function 
			as such towards :absolute positioned child-containers. For 
			some reason this DOES however work when the parentcontainer 
			is filled with content when the container is loaded. This 
			hack/function reads the content of a specific container and 
			then puts it back, at run-time. 
 * @param:	id, relative+float container's ID.
 ************************************** */
function netscapeFloatHack(id)
{
	var cont = document.getElementById(id).innerHTML
	document.getElementById(id).innerHTML = cont;
}

/** *************************************
 ** - funcBasic -> changeHtmlContent
 * @access:	public
 * @desc:	simple, changes html-content
 * @param: 	id: container to be written to
 			string: string to be written
 ************************************** */
function changeHtmlContent(id,string)
{
	document.getElementById(id).innerHTML = string;
	return;
}

/* **************************************
 * func: swapImg
 * action:	swaps html-image source
 * vars: 	img, image NAME
 			src, image SRC
 ************************************** */
function swapImg(img,src){
	document.images[img].src = src;
	return;
}
/* **************************************
 * func: swapClass
 * action:	swaps class source
 * vars: 	id, current object
 			cls, classname
 ************************************** */
function swapClass(id,cls){
	document.getElementById(id).className = cls;
	return;
}

/** *************************************
 ** - func.basic -> sendMeMail
 * @access:	public
 * @desc:	spambot circumvention, 
 			asks user for confirmation before
			loading up email prog.
 * @param:  nme, string, user name.
 ************************************** */
function sendMeMail(nme)
{
	var serv = (arguments[1])? arguments[1]:'starlabs.quaint.info';
	var theText = 'This will open your default e-mail client to send mail to: \n';
	var theText = theText + nme + '.\n';
	var theText = theText + 'Do you wish to continue?';
	var okidoki = confirm(theText);
	if (okidoki) document.location.href = 'mailto:' + nme + '@' + serv + '?subject = About your work on Starlabs';
	return;
}
//unction
