// this code enables audio players all over the place
function AudioPlayer(obj) {
    // first clean up any existing player(s)
    var id = obj.id +'_p';
    sendEvent('stop');

    $('div.audioplayer').empty().hide();
    idApCurrent = null;

    var ap = new SWFObject('/media/layout/flash/jw_mp3player.swf', 'line', '240', '20', '7');
    ap.addVariable('file', obj.href);
    ap.addVariable('autostart', 'true');
    ap.addVariable('showdigits', 'true');
    ap.addVariable('enablejs', 'true');
    ap.addVariable('javascriptid', 'mpl');
    ap.addVariable('showdownload', 'false');
    ap.addVariable('width', '240');
    ap.addVariable('height', '20');

    idApCurrent = id;
    ap.write(id);
    $('#'+id).show();
} // AudioPlayer

$(function(){
    // this code is executed when the onReady event fires for the page
    $(".loadaudio")
	.click(function(){
	    AudioPlayer(this);
	    return false;
	});
});



// compile REs once
var reOver = /_over\./;
var reOverReplace = /\.([^.]+)$/;

function GoToUrl(url, base) {
    if (base != undefined)
	url = base + url
    if (! url.match(/\.html$/) && ! url.match(/\/$/) )
	url += '/'
    document.location.href = url;
}

$(function() {
    $('img.rollover')
	    .each(function(i) {
		    // preload the _over image
		    var img = new Image();
		    img.src = this.src.replace(reOverReplace, '_over.$1');
		    })
	    .hover(
		    function() {
			this.src = this.src.replace(reOverReplace, '_over.$1');
		    },
		    function() {
			this.src = this.src.replace(reOver, '.');
		    }
		    );
    $('a.external').each(function(){
	    this.target = "_blank";
	    });
});

function undef(obj) { return(typeof obj == 'undefined'); }

function AddLoadEvent(code) {
    if (code != 'function')
        code = eval('function(){' + code + '}');
    $(document).ready(code);
} // AddLoadEvent 

function ClearDefault(item) {
    // clear the default value of a form element
    if (item.defaultValue == undefined)
	item.defaultValue = item.value;
    if (item.defaultValue == item.value)
        item.value = '';
} // ClearDefault

function SetDefault(item) {
    // if item is empty, restore the default value
    if (item.value == '')
	item.value = item.defaultValue;
} // SetDefault

$(document).ready(function() {
    $(".cleardefault")
        .mouseover(function(){
            ClearDefault(this);
        })
    $(".setcleardefault")
        .mouseover(function(){
            ClearDefault(this);
        })
        .mouseout(function(){
            SetDefault(this);
        });
    /*
    */
});

var winComment = null; 
function comment_pop() {
    winComment = window.open('/feedback/{{referer}}', 'feedback', 'width=700,height=600,scrollbars=no,staus=no');
    winComment.focus();
    return false;
}
