
function toggleDisp() {
    for (var i=0;i<arguments.length;i++){
        var d = $(arguments[i]);
        if (d.style.display == 'none')
            d.style.display = 'block';
        else
            d.style.display = 'none';
    }
}
/*-----------------------------------------------------------
    Toggles tabs - Closes any open tabs, and then opens current tab
    Input:     1.The number of the current tab
                    2.The number of tabs
                    3.(optional)The number of the tab to leave open
                    4.(optional)Pass in true or false whether or not to animate the open/close of the tabs
    Output: none 
    ---------------------------------------------------------*/
function toggleTab(num,numelems,opennum,animate) {
    if ($('tabContent'+num).style.display == 'none'){
        for (var i=1;i<=numelems;i++){
            if ((opennum == null) || (opennum != i)){
                var temph = 'tabHeader'+i;
                var h = $(temph);
                if (!h){
                    var h = $('tabHeaderActive');
                    h.id = temph;
                }
                var tempc = 'tabContent'+i;
                var c = $(tempc);
                if(c.style.display != 'none'){
                    if (animate || typeof animate == 'undefined')
                        Effect.toggle(tempc,'blind',{duration:0.5, queue:{scope:'menus', limit: 3}});
                    else
                        toggleDisp(tempc);
                }
            }
        }
        var h = $('tabHeader'+num);
        if (h)
            h.id = 'tabHeaderActive';
        h.blur();
        var c = $('tabContent'+num);
        c.style.marginTop = '2px';
        if (animate || typeof animate == 'undefined'){
            Effect.toggle('tabContent'+num,'blind',{duration:0.5, queue:{scope:'menus', position:'end', limit: 3}});
        }else{
            toggleDisp('tabContent'+num);
        }
    }
}

function showPopup(id,video, width, height) {
	var closeTag = "<p class=\"close\" onClick=\"closePopup(this.parentNode);\">X</p>";
	var videoStr="<embed src='mms://stream.onnurila.com/onnurila/media/anc_staff/" + video + "' menu='false' quality='high' width='320' height='280' type='video/x-ms-asf' showstatusbar='true' autostart='true'/></embed>";
	element = document.getElementById(id);
	if (element.style.visibility == 'visible') return;
	var x = document.body.clientWidth/2 + document.body.scrollLeft - width/2;
	var y = document.body.clientHeight/2 + document.body.scrollTop - height/2;
	element.style.left = x.toString() + 'px';
	element.style.top = y.toString() + 'px';
	element.style.width = width + 'px';
	element.style.height = height + 'px';
	element.style.visibility = 'visible';
	element.originalHTML = element.innerHTML;
	element.innerHTML = closeTag + videoStr;
}

function closePopup(popup) {
	popup.style.visibility="hidden";
	popup.innerHTML = popup.originalHTML;
}

function mediaWrite(url, autoplay, width, height) {
  if (autoplay == undefined) autoplay = 'true';
  if (autoplay == 0) autoplay == 'false';
  if (autoplay == 1) autoplay == 'true';
  if (width == undefined) width = '300';
  if (height == undefined) height = '20';
	var flashStr=
	"<div id='mediaspace'>This text will be replaced</div>"+
	"<script type='text/javascript'>"+
	"  var so = new SWFObject('/common/mediaplayer/player.swf','ply','"+width+"','"+height+"','9','#ffffff');"+
	"  so.addParam('allowfullscreen','true');"+
	"  so.addParam('allowscriptaccess','always');"+
	"  so.addParam('wmode','opaque');"+
	"  so.addVariable('file','"+url+"');"+
	"  so.addVariable('autostart','"+autoplay+"');"+
	"  so.write('mediaspace');"+
	"</script>";
	document.write(flashStr);
}
