/************** Player Control Script	******************/

document.playerdebug = 0;
var mouseX=null;var mouseY=null;
function Player() {
	this.debug = p_debug;
	this.pstatus = p_current_status;

	this.playercode_ie =   function (url) { return '<OBJECT ID="WMPlayer" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" CODEBASE="http://activex.microsoft.com/activex/ controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" STANDBY="Loading Microsoft Windows Media Player components..." TYPE="application/x-oleobject" WIDTH="1" HEIGHT="1">'
				+ "\n" + '<PARAM NAME="uiMode" VALUE="invisible"/>'
				+ "\n" + '<PARAM NAME="URL" VALUE="' + url + '"/>'
				+ "\n" + '<PARAM NAME="autoStart" VALUE="false"/>'
				+ "\n" + '<PARAM NAME="enabled" VALUE="true"/>'
				+ "\n" + '<PARAM NAME="balance" VALUE="0"/>'
				+ "\n" + '<PARAM NAME="mute" VALUE="false"/>'
				+ "\n" + '<embed type="application/x-mplayer2" name="MediaPlayer" width=0 height=0 src="' + url + '" showcontrols="0">'
				+ "\n" + '</embed>'
				+ "\n" + '</OBJECT>' };
	this.playercode_nn = this.playercode_ie;
	this.findplayer = function () 
	{
		switch(navigator.family) 
		{
			case 'nn4':
			case 'gecko':
			case 'opera':
				if ( document.WMPlayer )
					return document.WMPlayer;
			break;
			case 'ie4':
			case 'safari':
				if ( WMPlayer )
					return WMPlayer;
			break;
		}
		this.debug("Failed to Find Player, unknown browser! " + navigator.family,1);
	};

	this.writeplayer = function (url) 
	{
		w_done = 0;
		switch(navigator.family) {
			case 'nn4':
			case 'gecko':
			case 'safari':
			case 'opera':
				document.open();
				document.write(this.playercode_nn(url));
				document.close();
				w_done = 1;
			break;
			case 'ie4':
				document.write(this.playercode_ie(url));
				w_done = 1;
			break;
		}
		if ( w_done == 1 ) 
		{
			this.debug("Wrote Player");
		}
		else
		{
			this.debug("Failed to Write Player, unknown browser! " + navigator.family,1);
		}
		this.player = this.findplayer();
		if (this.player)
		{
			this.debug("Player Write Success");
		}
	};

	this.chkobj = function () 
	{
		if ( ! this.player ) 
		{
			this.debug('Could not find WindowsMedia Player object',1); return 0;
		}
		else 
		{
			return 1; 
		} 
	};
	
	this.start = function (url) 
	{
		if ( ! this.chkobj()) return;
		this.layer_volslide = MM_findObj('volbar');
		this.layer_clipslide = MM_findObj('posbar');
		this.debug('Setting Source and playing clip Source: ' + url);
		this.isnng = false;
		if (this.isnng) {
			this.player.setURL(url);
			this.player.setUiMode('invisible');
			this.player.setAutoStart(true);
			this.player.getControls().play();
		} else {
			this.player.URL = url;
			this.player.uiMode = 'invisible';
			this.player.autoStart = true;
			this.player.controls.play();
		}
		this.xvolset(40);
//		this.setmute(0);
		this.timer = setTimeout("playerh.tickhandler()",500);
	}
	
	this.play = function () {
		if ( ! this.chkobj()) return;
		if (this.isnng) this.player.getControls().play();
		else            this.player.controls.play();
	};
	
	this.pause = function () {
		if ( ! this.chkobj()) return;
		if (this.isnng) this.player.getControls().pause();
		else            this.player.controls.pause();
	};
	
	this.stop = function () {
		if ( ! this.chkobj()) return;
		if (this.isnng) this.player.getControls().stop();
		else            this.player.controls.stop();
	};
	
	this.nextclip = function () {
		if ( ! this.chkobj()) return;
		this.isnng ? this.player.getControls().next() : this.player.controls.next();
	};
	
	this.prevclip = function () {
		if ( ! this.chkobj()) return;
		this.isnng ? this.player.getControls().previous() : this.player.controls.previous();
	};

	this.ismute = function () {
		if ( ! this.chkobj()) return;
		return (this.isnng ? this.player.getSettings().getMute() : this.player.settings.mute);
	};

	this.setmute = function (bool) {
		if ( ! this.chkobj()) return;
		if ( bool ) {
			this.isnng ? this.player.getSettings().setMute(true) : (this.player.settings.mute = true);
		} else {
			this.isnng ? this.player.getSettings().setMute(false) : (this.player.settings.mute = false);
		}
	};

	this.amute = function () {
		if ( ! this.chkobj()) return;
		if ( this.ismute() ) {
			this.setmute(0);
			MM_swapImage('muteimg','','images/mu_f.gif',1);
			window.status = 'Mute Off';
			this.pstatus('Mute Off');
		} else {
			this.setmute(1);
			MM_swapImage('muteimg','','images/c.gif',1);
			window.status = 'Mute On';
			this.pstatus('Mute On');
		}
	};

	this.getvolume = function () {
		if ( ! this.chkobj()) return;
		return (this.isnng ? this.player.getSettings().getVolume() : this.player.settings.volume);
	}
	
	this.setvolume = function (level) {
		if ( ! this.chkobj()) return;
		if ( level < 0 || level > 100 ) return;
		return (this.isnng ? this.player.getSettings().setVolume(level) : (this.player.settings.volume = level));
	};

	this.isinloop = function () {
		if ( ! this.chkobj()) return;
		return (this.isnng ? this.player.getSettings().getMode('loop') : this.player.settings.getMode('loop'));
	};

	this.vstate = null;
	this.vstate_t = null;
	this.getstate = function () {
		if ( ! this.chkobj()) return;
		this.vstate = this.isnng ? this.player.playState() : this.player.playState;
		switch(this.vstate) {
			case 0 :
				this.vstate_t = 'Unknown...';
			break;
			case 1 :
				this.vstate_t = 'Stopped';
			break;
			case 2 :
				this.vstate_t = 'Paused';
			break;
			case 3 :
				this.vstate_t = 'Playing';
			break;
			case 4 :
				this.vstate_t = 'Fast Forwarding...';
			break;
			case 5 :
				this.vstate_t = 'Rewinding...';
			break;
			case 6 :
				this.vstate_t = 'Buffering... ' + this.buffertime();
			break;
			case 7 :
				this.vstate_t = 'Contacting...';
			break;
			case 8 :
				this.vstate_t = 'Done';
			break;
			case 9 :
				this.vstate_t = 'Transitioning...';
			break;
			case 10 :
				this.vstate_t = 'Ready';
			break;
			case 11 :
				this.vstate_t = 'Reconnecting...';
			break;
		}
		
	}
	
	this.tickhandler = function () {
		this.getstate();
		if ( this.vstate_t && document.MM_curDrag != this.layer_volslide) {
			this.xrmpstatus(this.vstate_t);
			window.status = this.vstate_t;
		}
		this.xclipinf(this.gettitle(),this.getauthor());
		this.vclippos = this.clippos();
		this.vcliplen = this.cliplen();
		if ( this.vstate != 6 ) {
			this.xclipposinf(this.vclippos,this.vcliplen);
			this.xclipposmove(this.vclippos,this.vcliplen);
		}
		
		this.timer = setTimeout("playerh.tickhandler()",500);
	};

	this.clippos = function () {
		if ( ! this.chkobj()) return;
		if ( this.vstate == 2 || this.vstate == 3 || this.vstate == 4 || this.vstate == 5 || this.vstate == 6 || this.vstate == 11 ) {
			return ((this.isnng ? this.player.getControls().getCurrentPosition() : this.player.controls.currentPosition) * 1000);
		} else if ( this.vstate == 4 || this.vstate == 5 ) {
			return this.lastseekcmd;
		}
	};

	this.cliplen = function () {
		if ( ! this.chkobj()) return;
		if ( this.vstate == 2 || this.vstate == 3 || this.vstate == 4 || this.vstate == 5 || this.vstate == 6 || this.vstate == 11 ) {
			this.currcliplen = ((this.isnng ? this.player.getCurrentMedia().duration() : this.player.currentMedia.duration) * 1000);
			return this.currcliplen;
		}
	};
	
	this.seek = function (pos,len) {
		lenx = len ? len : this.currcliplen;
		if ( ! this.chkobj() || !lenx ) return;
		if ( pos >= 0 && pos <= lenx ) {
			this.isnng ? this.player.getControls().setCurrentPosition(pos / 1000) : (this.player.controls.currentPosition = pos / 1000);
			this.lastseekcmd = pos;
			time = new calctime( pos );
			this.lastseekcmd_t = (time.hr + '.' + time.min + '.' + time.sec);
			return true;
		} else {
			return;
		}
	};
	
	this.buffertime = function () {
		if ( ! this.chkobj()) return;
		if ( this.vstate == 6 ) {
			return (this.isnng ? this.player.getNetwork().getBufferingProgress() : this.player.network.bufferingProgress) + '%';
		}
	};

	this.getauthor = function () {
		if ( ! this.chkobj()) return;
		if ( this.vstate == 2 || this.vstate == 3 || this.vstate == 4 || this.vstate == 5 || this.vstate == 6 || this.vstate == 11 ) {
			return ( this.isnng ? this.player.getCurrentMedia().getItemInfo('Author') : this.player.currentMedia.getItemInfo('Author') );
		}
	};

	this.gettitle = function () {
		if ( ! this.chkobj()) return;
		if ( this.vstate == 2 || this.vstate == 3 || this.vstate == 4 || this.vstate == 5 || this.vstate == 6 || this.vstate == 11 ) {
			return ( this.isnng ? this.player.getCurrentMedia().getItemInfo('Title') : this.player.currentMedia.getItemInfo('Title') );
		}
	};

	this.avol = p_volume_slider;
	this.xvolset = p_volume_slider_set;
	this.xrmpstatus = p_status_rm_player;
	this.xclipinf = p_status_clipinfo;
	this.xclipposinf = p_clip_pos_inf;
	this.xvolclick = p_volume_click;
	this.xclipposmove = p_clip_pos_move;
	this.xclipposset = p_clip_slider;
	this.xposclick = p_clip_pos_click;	
}

function calctime(mili) {
	if ( ! mili ) {
		this.mili = 0;
		this.sec = 0;
		this.min = 0;
		this.hr = 0;
	} else {
		this.mili = mili;
		this.sec = ( mili / 1000 );
		this.min = ( this.sec / 60 );
		this.hr = Math.floor( this.min / 60 );
		this.min = Math.floor( this.min - ( this.hr * 60 ) );
		this.sec = Math.floor( this.sec - ( this.min * 60 ) );
		this.mili = Math.floor( this.mili - ( this.sec * 1000 ) );
	}
}

function p_volume_slider_set(vol) {

	var layerref = this.layer_volslide,maxvol = 100,left=20,width=118;
	var ratio = (width / maxvol);
	var pos = Math.floor((ratio * vol) + left);
        if (navigator.family == 'nn4') 
        {
        	layerref.left = pos;
        }
        else if (navigator.family == 'gecko' || navigator.family == 'safari' || navigator.family == 'opera' )
        {
        	layerref.style.left = pos;
        }
        else if (navigator.family == 'ie4') 
        {
        	layerref.style.pixelLeft = pos;
        }
        this.setvolume( vol );
        window.status = 'Volume : ' + vol;
        this.pstatus('Volume : ' + vol);
}

function p_volume_click() {
	var maxvol = 100,left=20,width=118;
	var ratio = (width / maxvol);
	var pos = mouseX - left;
	var vol = Math.floor(pos / ratio);
	this.xvolset(vol);
}

function p_clip_pos_inf(curr,total) {
	currobj = new calctime(curr);
	totalobj = new calctime(total);
	write_layer('TimeElasped', twodigits(currobj.hr) + '.' + twodigits(currobj.min) + '.' + twodigits(currobj.sec), 'plain');
	write_layer('TimeTotal', twodigits(totalobj.hr) + '.' + twodigits(totalobj.min) + '.' + twodigits(totalobj.sec), 'plain');
}

function twodigits(n) {
	nt = n + "";
	if ( nt.length == 1 ) {
		return "0" + nt;
	} else if ( nt.length == 2 ) {
		return nt;
	} else {
		return "00";
	}
}

//******** STATUS BAR	************

function p_clip_pos_move(curr,total) {
	layerref = this.layer_clipslide;
	maxsize = 193; minleft = layerref.MM_startL;
	if (document.MM_curDrag == layerref) return;
	if ( curr < 0 ) curr = 0;
	if ( ( ! curr && ! total ) || curr == 'NaN' || total == 'NaN' ) {
        	if (navigator.family == 'nn4') {layerref.left = minleft;}
        	else if (navigator.family == 'gecko' || navigator.family == 'safari' || navigator.family == 'opera' ){layerref.style.left = minleft;}
        	else if (navigator.family == 'ie4') {layerref.style.pixelLeft = minleft;}
	} else {
		maxclip = total; ratio = (maxsize / maxclip);
		pp = Math.floor(curr * ratio); pos = (minleft + pp);
        	if (navigator.family == 'nn4') {layerref.left = pos;}
        	else if (navigator.family == 'gecko' || navigator.family == 'safari' || navigator.family == 'opera' ){layerref.style.left = pos;}
        	else if (navigator.family == 'ie4') {layerref.style.pixelLeft = pos;}
        }
}

function p_clip_slider() {
	var maxsize = 193,maxclip = this.vcliplen; var ratio = (maxsize / maxclip);
	var pos = getdragPos(this.layer_clipslide,1);
	var gpos = Math.floor(pos / ratio);
	this.seek( gpos );
}

function p_clip_pos_click() {
	var maxsize = 218,maxclip = this.vcliplen,layerref = this.layer_clipslide;
	if ( !maxclip ) return;
	var ratio = (maxsize / maxclip);var pos = mouseX - layerref.MM_startL;var gpos = Math.floor(pos / ratio);
	this.seek( gpos );
}

//******** STATUS BAR	************

function getMouseXPos(e) {
  if (document.layers||ns6) {
    return parseInt(e.pageX+10)
  } else {
    return (parseInt(event.clientX+10) + parseInt(document.body.scrollLeft))
  }
}

function getMouseYPos(e) {
  if (document.layers||ns6) {
    return parseInt(e.pageY)
  } else {
    return (parseInt(event.clientY) + parseInt(document.body.scrollTop))
  }
}

function p_volume_slider() {
	maxsize = 118; maxvol = 100; ratio = (maxsize / maxvol);
	pos = getdragPos(this.layer_volslide,1);
	vol = Math.floor(pos / ratio);
	this.setvolume( vol );
	window.status = 'Volume : ' + vol;
	this.pstatus('Volume : ' + vol);
}

function p_status_rm_player(status) {
	this.pstatus(status);
}

function p_status_clipinfo(title,author) {
	if (!title) {
		playerh.current_title = "";
		inf_text = 'No Information Available...';
		if (playerh.vstate == 7) inf_text = 'Contacting Server, please wait ...';
		else if (playerh.vstate == 9) inf_text = 'Transitioning, please wait ...';
		else if (playerh.vstate == 11) inf_text = 'Reconnecting, please wait ...';
		write_layer('disname', inf_text, 'plain');
		return;
	}
	if (playerh.current_title == title) return;
	playerh.current_title = title;
	if (audionum == "")
	{
		write_layer('disname', "Title : " + title + "<br>Presenter : " + prename, 'plain');
	}
	else
	{
		write_layer('disname', "Title : "+ radioch + "<br>Programme : " + prename, 'plain');
	}
		
}

function p_debug(msg,fatal) {
	if ( document.playerdebug == 1 && fatal != 1 ) {
		alert("Debug Message : " + msg);
	} else if ( fatal == 1 ) {
		alert("ERROR : " + msg);
	}
}

function p_current_status(msg) {
	write_layer('DStatus', " &nbsp;Status : " + msg, 'plain');
}

function write_layer(layer,text,base) {
	w_done = 0;
	if (base != 'plain') text = text2imgs(text,base);
	if (navigator.family == 'ie4' ) {
		if ( document.all[layer] ) {
			if ( document.all[layer].innerHTML != text ) {
				document.all[layer].innerHTML = text;
			}
			w_done = 1;
		}
	} else 	if (navigator.family == 'nn4' ) {
		lyr = document.layers[layer].document;
		if ( lyr ) {
			if ( lyr.html != text ) {
				lyr.open();
				lyr.write(text);
				lyr.close();
			}
			w_done = 1;
		}
	} else 	if (document.getElementById && document.body.style) {
		over = document.getElementById([layer]);
		if ( over ) {
			if (over.innerHTML) {
				if (over.innerHTML != text) {
					over.innerHTML = text;
				}
			} else {
				range = document.createRange();
				range.setStartBefore(over);
				domfrag = range.createContextualFragment(text);
				while (over.hasChildNodes()) {
					over.removeChild(over.lastChild);
				}
				over.appendChild(domfrag);
				w_done = 1;
			}
		}
	}
	return w_done;
}

function text2imgs (text,base) {
	base = base ? base : 'alpha';
	base = base;
	text = text.replace(/[^a-zA-Z 0-9.]+/g,'');
	text = text.toLowerCase();
	var cut = text.split('');
	var ret = '';
	for ( i=0; i<cut.length; i++ ) {
		if (cut[i] == '.') cut[i]='dot';
		if (cut[i] == ' ') cut[i]='space';
		ret += '<img src="'+ base +'/'+ cut[i] +'.gif">';
	}
	return ret;
}

function getdragPos(layername,objy){
	layerref = objy ? layername : MM_findObj(layername);
	curpos = layerref.MM_LEFTRIGHT ? layerref.MM_LEFTRIGHT : layerref.MM_UPDOWN;
	if ( curpos < 0 ) {
		curpos = (curpos * -1)
	}
	window.status = curpos;
	return curpos;
}

// Below : Copyright Macromedia

function MM_findObj(n, d) 
{
	var p,i,x;
	if(!d) d=document; 
	if((p=n.indexOf("?"))>0&&parent.frames.length) 
	{
		alert(p);
		d=parent.frames[n.substring(p+1)].document; 
		n=n.substring(0,p);
		alert(n);
	}
	if(!(x=d[n])&&d.all) x=d.all[n]; 
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_dragLayer(objName,x,hL,hT,hW,hH,toFront,dropBack,cU,cD,cL,cR,targL,targT,tol,dropJS,et,dragJS) { //v4.01
  //Copyright 1998 Macromedia, Inc. All rights reserved.
  var i,j,aLayer,retVal,curDrag=null,curLeft,curTop,IE=document.all,NS4=document.layers;
  var NS6=(!IE&&document.getElementById), NS=(NS4||NS6); if (!IE && !NS) return false;
  retVal = true; if(IE && event) event.returnValue = true;
  if (MM_dragLayer.arguments.length > 1) {
    curDrag = MM_findObj(objName); if (!curDrag) return false;
    if (!document.allLayers) { document.allLayers = new Array();
      with (document) if (NS4) { for (i=0; i<layers.length; i++) allLayers[i]=layers[i];
        for (i=0; i<allLayers.length; i++) if (allLayers[i].document && allLayers[i].document.layers)
          with (allLayers[i].document) for (j=0; j<layers.length; j++) allLayers[allLayers.length]=layers[j];
      } else {
        if (NS6) { var spns = getElementsByTagName("span"); var all = getElementsByTagName("div");
          for (i=0;i<spns.length;i++) if (spns[i].style&&spns[i].style.position) allLayers[allLayers.length]=spns[i];}
        for (i=0;i<all.length;i++) if (all[i].style&&all[i].style.position) allLayers[allLayers.length]=all[i];
    } }
    curDrag.MM_dragOk=true; curDrag.MM_targL=targL; curDrag.MM_targT=targT;
    curDrag.MM_tol=Math.pow(tol,2); curDrag.MM_hLeft=hL; curDrag.MM_hTop=hT;
    curDrag.MM_hWidth=hW; curDrag.MM_hHeight=hH; curDrag.MM_toFront=toFront;
    curDrag.MM_dropBack=dropBack; curDrag.MM_dropJS=dropJS;
    curDrag.MM_everyTime=et; curDrag.MM_dragJS=dragJS;
    curDrag.MM_oldZ = (NS4)?curDrag.zIndex:curDrag.style.zIndex;
    curLeft= (NS4)?curDrag.left:(NS6)?parseInt(curDrag.style.left):curDrag.style.pixelLeft;
    if (String(curLeft)=="NaN") curLeft=0; curDrag.MM_startL = curLeft;
    curTop = (NS4)?curDrag.top:(NS6)?parseInt(curDrag.style.top):curDrag.style.pixelTop;
    if (String(curTop)=="NaN") curTop=0; curDrag.MM_startT = curTop;
    curDrag.MM_bL=(cL<0)?null:curLeft-cL; curDrag.MM_bT=(cU<0)?null:curTop-cU;
    curDrag.MM_bR=(cR<0)?null:curLeft+cR; curDrag.MM_bB=(cD<0)?null:curTop+cD;
    curDrag.MM_LEFTRIGHT=0; curDrag.MM_UPDOWN=0; curDrag.MM_SNAPPED=false; //use in your JS!
    document.onmousedown = MM_dragLayer; document.onmouseup = MM_dragLayer;
    if (NS) document.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  } else {
    var theEvent = ((NS)?objName.type:event.type);
    if (theEvent == 'mousedown') {
      mouseX = (NS)?objName.pageX : event.clientX + document.body.scrollLeft;
      mouseY = (NS)?objName.pageY : event.clientY + document.body.scrollTop;
      var maxDragZ=null; document.MM_maxZ = 0;
      for (i=0; i<document.allLayers.length; i++) { aLayer = document.allLayers[i];
        var aLayerZ = (NS4)?aLayer.zIndex:parseInt(aLayer.style.zIndex);
        if (aLayerZ > document.MM_maxZ) document.MM_maxZ = aLayerZ;
        var isVisible = (((NS4)?aLayer.visibility:aLayer.style.visibility).indexOf('hid') == -1);
        if (aLayer.MM_dragOk != null && isVisible) with (aLayer) {
          var parentL=0; var parentT=0;
          if (NS6) { parentLayer = aLayer.parentNode;
            while (parentLayer != null && parentLayer.style.position) {
              parentL += parseInt(parentLayer.offsetLeft); parentT += parseInt(parentLayer.offsetTop);
              parentLayer = parentLayer.parentNode;
          } } else if (IE) { parentLayer = aLayer.parentElement;
            while (parentLayer != null && parentLayer.style.position) {
              parentL += parentLayer.offsetLeft; parentT += parentLayer.offsetTop;
              parentLayer = parentLayer.parentElement; } }
          var tmpX=mouseX-(((NS4)?pageX:((NS6)?parseInt(style.left):style.pixelLeft)+parentL)+MM_hLeft);
          var tmpY=mouseY-(((NS4)?pageY:((NS6)?parseInt(style.top):style.pixelTop) +parentT)+MM_hTop);
          if (String(tmpX)=="NaN") tmpX=0; if (String(tmpY)=="NaN") tmpY=0;
          var tmpW = MM_hWidth;  if (tmpW <= 0) tmpW += ((NS4)?clip.width :offsetWidth);
          var tmpH = MM_hHeight; if (tmpH <= 0) tmpH += ((NS4)?clip.height:offsetHeight);
          if ((0 <= tmpX && tmpX < tmpW && 0 <= tmpY && tmpY < tmpH) && (maxDragZ == null
              || maxDragZ <= aLayerZ)) { curDrag = aLayer; maxDragZ = aLayerZ; } } }
      if (curDrag) {
        document.onmousemove = MM_dragLayer; if (NS4) document.captureEvents(Event.MOUSEMOVE);
        curLeft = (NS4)?curDrag.left:(NS6)?parseInt(curDrag.style.left):curDrag.style.pixelLeft;
        curTop = (NS4)?curDrag.top:(NS6)?parseInt(curDrag.style.top):curDrag.style.pixelTop;
        if (String(curLeft)=="NaN") curLeft=0; if (String(curTop)=="NaN") curTop=0;
        MM_oldX = mouseX - curLeft; MM_oldY = mouseY - curTop;
        document.MM_curDrag = curDrag;  curDrag.MM_SNAPPED=false;
        if(curDrag.MM_toFront) {
          eval('curDrag.'+((NS4)?'':'style.')+'zIndex=document.MM_maxZ+1');
          if (!curDrag.MM_dropBack) document.MM_maxZ++; }
        retVal = false; if(!NS4&&!NS6) event.returnValue = false;
    } } else if (theEvent == 'mousemove') {
      if (document.MM_curDrag) with (document.MM_curDrag) {
        mouseX = (NS)?objName.pageX : event.clientX + document.body.scrollLeft;
        mouseY = (NS)?objName.pageY : event.clientY + document.body.scrollTop;
        newLeft = mouseX-MM_oldX; newTop  = mouseY-MM_oldY;
        if (MM_bL!=null) newLeft = Math.max(newLeft,MM_bL);
        if (MM_bR!=null) newLeft = Math.min(newLeft,MM_bR);
        if (MM_bT!=null) newTop  = Math.max(newTop ,MM_bT);
        if (MM_bB!=null) newTop  = Math.min(newTop ,MM_bB);
        MM_LEFTRIGHT = newLeft-MM_startL; MM_UPDOWN = newTop-MM_startT;
        if (NS4) {left = newLeft; top = newTop;}
        else if (NS6){style.left = newLeft; style.top = newTop;}
        else {style.pixelLeft = newLeft; style.pixelTop = newTop;}
        if (MM_dragJS) eval(MM_dragJS);
        retVal = false; if(!NS) event.returnValue = false;
    } } else if (theEvent == 'mouseup') {
      document.onmousemove = null;
      if (NS) document.releaseEvents(Event.MOUSEMOVE);
      if (NS) document.captureEvents(Event.MOUSEDOWN); //for mac NS
      if (document.MM_curDrag) with (document.MM_curDrag) {
        if (typeof MM_targL =='number' && typeof MM_targT == 'number' &&
            (Math.pow(MM_targL-((NS4)?left:(NS6)?parseInt(style.left):style.pixelLeft),2)+
             Math.pow(MM_targT-((NS4)?top:(NS6)?parseInt(style.top):style.pixelTop),2))<=MM_tol) {
          if (NS4) {left = MM_targL; top = MM_targT;}
          else if (NS6) {style.left = MM_targL; style.top = MM_targT;}
          else {style.pixelLeft = MM_targL; style.pixelTop = MM_targT;}
          MM_SNAPPED = true; MM_LEFTRIGHT = MM_startL-MM_targL; MM_UPDOWN = MM_startT-MM_targT; }
        if (MM_everyTime || MM_SNAPPED) eval(MM_dropJS);
        if(MM_dropBack) {if (NS4) zIndex = MM_oldZ; else style.zIndex = MM_oldZ;}
        retVal = false; if(!NS) event.returnValue = false; }
      document.MM_curDrag = null;
    }
    if (NS) document.routeEvent(objName);
  } return retVal;
}

function MM_preloadImages() 
{
	var d=document;
  	if(d.images)
  	{
  		if(!d.MM_p) d.MM_p=new Array();
  		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
  		for(i=0; i<a.length; i++)
  		{
    			if (a[i].indexOf("#")!=0)
    			{ 
    				d.MM_p[j]=new Image; 
    				d.MM_p[j++].src=a[i];
			}
		}
	}
}

function MM_swapImage() 
{
	var i,j=0,x,a=MM_swapImage.arguments; 
	document.MM_sr=new Array; 
	for(i=0;i<(a.length-2);i+=3)
	{
   		if ((x=MM_findObj(a[i]))!=null)
   		{
   			document.MM_sr[j++]=x; 
   			if(!x.oSrc) x.oSrc=x.src; 
   			if (x.src != a[i+2]) x.src=a[i+2];
   		}
   	}
}
