function defPosition(event) {
    var x = y = 0;
    if (document.attachEvent != null) { // Internet Explorer & Opera
//            x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
//            y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
	x = document.body.clientWidth / 2 + document.documentElement.scrollLeft + document.body.scrollLeft;
	y = document.body.clientHeight / 2 + document.documentElement.scrollTop + document.body.scrollTop;
    }
    if (!document.attachEvent && document.addEventListener) { // Gecko
//            x = event.clientX + window.scrollX;
//            y = event.clientY + window.scrollY;
	x = document.body.clientWidth / 2 + window.scrollX;
	y = document.body.clientHeight / 2 + window.scrollY;
    }
    return {x:x, y:y};
}

function ShowVideo(id, title, event) {
//    CloseCommWindow();

    var event = event || window.event;
    var x = defPosition(event).x - 200;
    var y = defPosition(event).y - 200; 

    create_div( 'viddiv','','','','','','#FFFFFF','','' );

    var myDiv = document.getElementById('viddiv'); 

    myDiv.style.left = x;
    myDiv.style.top = y;

//alert(id);


    var divCont;
    divCont =  '<table width=400 cellpadding=1 cellspacing=1><tr><td align=right>';
    divCont += '<a href=# onClick="CloseCommWindow();return false;"><img src="http://www.muzfilm.ru/img/videobox/closelabel.gif" border=0></a></td></tr><tr><td align=center>';
//    divCont += '<embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://www.muzfilm.ru/player/flvplayer.swf" 
// width="400" height="300" type="application/x-shockwave-flash" 
// flashvars="autostart=true&file=http://www.muzfilm.ru/_flvfiles/pref/' + id + '.flv" bgcolor="#FFFFFF" id=objplayer />';

    var rnd = Math.random();

    divCont += '<object type="application/x-shockwave-flash" data="http://www.muzfilm.ru/player/flvplayer.swf" width="400" height="300" z-index="1000">';
    divCont += '<param name="movie" value="http://www.muzfilm.ru/player/flvplayer.swf?autostart=true&file=http://www.muzfilm.ru/_flvfiles/pref/' + id + '.flv" />';
    divCont += '<param name= FlashVars value="autostart=true&file=http://www.muzfilm.ru/_flvfiles/pref/' + id + '.flv" />';
    divCont += '<param name="autostart" value="yes" />';
    divCont += '</object>';

    divCont += '</td></tr><tr><td align=center><p style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: 1A2848;">' + title + '</p></td><img src="http://www.muzfilm.ru/cgi-bin/ajax/clvc.cgi?i=' + id + '&' + rnd + '" width=1 height=1></tr></table>';

    myDiv.innerHTML = divCont;

    myDiv.style.zIndex="190";
    myDiv.style.visibility = "visible";
}


function CloseCommWindow() {
    document.getElementById('viddiv').style.visibility = 'hidden';
    dv = document.getElementById('viddiv');
    document.body.removeChild( dv );
//  var myDiv = document.getElementById('viddiv'); 
//  myDiv.style.visibility = "hidden";
//  myDiv.innerHTML = '';
}


function create_div ( id_name, class_name, left_px, top_px, width_px, height_px, bg_color, text, vis_style ) {
    dv = document.createElement('div'); // create dynamically div tag
    if ( id_name && id_name != '' ) {
	dv.setAttribute('id', id_name ); //give id to it
    }
    if ( class_name && class_name != '' ) {
	dv.className = class_name; // set the style classname  
    }
    dv.style.position="absolute";       
    if ( left_px ) {
	dv.style.pixelLeft = left_px;
    }
    if ( top_px ) {
	dv.style.pixelTop = top_px;
    }
    if ( width_px ) {
	dv.style.pixelWidth = width_px;
    }
    if ( height_px ) {
	dv.style.pixelHeight = height_px;
    }
    if ( bg_color ) {
	dv.style.backgroundColor = bg_color;
    }
    if ( text && text != '' ) {
	dv.innerHTML = text;
    }
    if ( vis_style && vis_style == 'visible' ) {
	dv.style.visibility = 'visible';
    } else {
	dv.style.visibility = 'hidden';
    }

    dv.style.border = 'C4D6E5'; 
    dv.style.zIndex = '200';
    dv.style.filter = 'Alpha(Opacity=85)';
    document.body.appendChild(dv);
}

//<div id=viddiv style="position: absolute; visibility: hidden; background-color: #FFFFFF; border-width: 1px; border-style: solid;">
//</div>