if(browser != "ie"){document.captureEvents(Event.MOUSEMOVE); document.captureEvents(Event.MOUSEUP); document.captureEvents(Event.MOUSEDOWN);}
document.onmousemove		= mousePos; 
document.onmouseup 		= stopMov;
document.onmousedown 		= getMouseY;

var halfwidth;
var halfheight;
var moving = 0;
var firstc = 0;
var hh;
var ww = 720;
var sheight= 0; 
var swidth = 360;
var ww2;
var hh2;
var x_stop = 0;
var y_stop = 0;

var MYmausY = 0;
var takenHeight;

function getMouseY(e) {

    var MouseYPos;
    if(e){
    	MouseYPos = e.pageY;
    } 
    else{
    	// IE
    	MouseYPos = window.event.y;
    }
    MYmausY = MouseYPos;
    //alert(MYmausY);
}

function mousePos(e) {

    var MouseXPos;
    var MouseYPos;
    var hhStopUnder;
    if(e){
    	MouseXPos = e.pageX;
    	MouseXPos = MouseXPos - ((window.innerWidth - ww) / 2);
    } 
    else{
    	// IE
    	MouseXPos = window.event.x;
    }
    if(e){
    	MouseYPos = e.pageY;
    } 
    else{
    	// IE
    	MouseYPos = window.event.y;
    }
    mausY = MouseYPos;
    xPos = MouseXPos - 180;
    yPos = MouseYPos - 16;
    
    if(browser == "ie"){
       hh = document.body.clientHeight;
    }
    else{
       hh = window.innerHeight;
    }
    hhStopUnder = hh; 
    if(takenHeight > hh){hhStopUnder = takenHeight;}
    hhStopUnder -= 376;
    
    //alert(hh + " : " + takenHeight);
   
    if(moving == 1){  
    	  if(xPos < 4){xPos = 4 ;}
    	  if(xPos > ww - swidth -14){xPos = ww - swidth - 14 ;}
    	  if(yPos > hhStopUnder ){yPos = hhStopUnder;}
    	  if(yPos < 40 ){yPos = 40;}
    	  xStr = '\'' + xPos + 'px\'';
    	  yStr = '\'' + yPos + 'px\'';
    	  modLayer('player', '.left=', xStr);
    	  modLayer('player', '.top=',  yStr);
    	  //window.status = hhStopUnder;
    }      
}

function moveDiv(c){
    if(c == 0){
    	moving = 0;
    }
    if(c == 1){
    	moving = 1;
    }
    noTextSelect();
}

function stopMov() {
    moving = 0;
    noTextSelect();
}

function noTextSelect(){
    disableSelection(document.body);
}

function showPopup(fll, h){

    // h = headertext
    var mausY;
    if(browser == "ie"){
       ww = 720; //document.body.clientWidth;
       hh = document.body.clientHeight;
    }
    else{
       ww = 720; //window.innerWidth;
       hh = window.innerHeight;
    }
    
    swidth = 360;
    sheight= 300;    
		
    var headertxt = '&#160;&#160;' + h;
    bt = document.getElementById("balken");
    bt.innerHTML  = headertxt;
    modLayer('player', '.visibility=','\'visible\'');
    
    wa = document.getElementById("player");
    halfwidth = swidth  / 2;
    halfheight= sheight / 2; 
    ww2 =  ( ww / 2 )  - halfwidth ;
    //hh2 =  ( hh / 2 )  - halfheight ;
    hh2 = MYmausY - 150;
       
    var hhStopUnder = hh;
    if(takenHeight > hh){hhStopUnder = takenHeight;}
    hhStopUnder -= 376;

    div_x = wa.style.left;	div_x = (div_x).split("px");	div_x = div_x[0];

    
    if(div_x > (ww - swidth  - x_stop ) ){ww2 = (ww - swidth  - x_stop );	firstc = 0;}
    if(hh2 < 40 ){
    	hh2 = 40;
    }
    if(hh2 > hhStopUnder ){
    	hh2 = hhStopUnder;
    }
    
    ww2 = parseInt(ww2) + 'px';	// global gespeichert
    hh2 = parseInt(hh2) + 'px';	// global gespeichert
   
    if(firstc == 0 ){ 
    	modLayer('player', '.left=','ww2');
    }
    if(fll == 1 ){ 
    	modLayer('player', '.top=','hh2');
    } 
    firstc = 1;
    //trace(hh2);
}

function closePopup(){
    wa 	= document.getElementById("pcontent");
    wa.innerHTML  = "";
    modLayer('player', '.visibility=','\'hidden\'');	
}

/***********************************************
* Disable Text Selection script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

function disableSelection(target){
if (typeof target.onselectstart!="undefined") //IE route
	target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
	target.style.MozUserSelect="none"
else //All other route (ie: Opera)
	target.onmousedown=function(){return false}
	target.style.cursor = "default"
}
