// the functions in this file require the supplementary library lib.js

// These defaults should be changed the way it best fits your site
var _POPUP_FEATURES = '';

// FUNCTIONAL

function map(list, func) {
    var result = [];
    func = func || function(v) {return v};
    for (var i=0; i < list.length; i++) result[result.length] = func(list[i], i, list);
    return result;
}

function filter(list, func) {
    var result = [];
    func = func || function(v) {return v};
    map(list, function(v) { if (func(v)) result[result.length]=v } );
    return result;
}

function relativeX(xVal) {
	if (isInternetExplorer) return window.screenLeft + xVal;
	else if (!isNaN(window.screenX)) return window.screenX + xVal;
}

function relativeY(yVal) {
	if (isInternetExplorer) return window.screenTop + yVal;
	else if (!isNaN(window.screenY)) return window.screenY + yVal;
}

function relPositionString(xVal, yVal) {
	var x1= relativeX(xVal);
	var y1= relativeY(yVal);
	
	return ',top='+y1+',screenY='+y1+',left='+x1+',screenX='+x1;
}


function raw_popup(url, target, features) {
    // pops up a window containing url optionally named target, optionally having features
// TEMPORARILY DISABLED!
    if (!features) features = _POPUP_FEATURES;
    if (!target) target   = '_blank';
	stopMovie();
/*    var theWindow = window.open(url, target, features);
    theWindow.focus();
    return theWindow;*/
    return true;
}

function link_popup(src, features, chromeless) {
    // to be used in an html event handler as in: <a href="..." onclick="link_popup(this,...)" ...
    // pops up a window grabbing the url from the event source's href
	// adds the chromeless suffix if added
	var re = new RegExp("(.*)(.)(htm|html|php|mp3)$");
	var chromelessSuffix = src.getAttribute('href').replace(re, "$1"+(chromeless?_CHROMELESS_SUFFIX:"")+"$2$3");
// TEMPORARILY DISABLED!
//    return raw_popup(chromelessSuffix, src.getAttribute('target') || '_blank', features);
}

function event_popup(features, chromeless) {
    // generates an event listener similar to event_popup, but allowing window features
// TEMPORARILY DISABLED!
//    return function(e) { link_popup(e.currentTarget, features, chromeless); e.preventDefault() }
}

