var closeImgPath = 'http://mybiz.pl.ua/globals/hacks/shutdown.jpg';
function openPopup(u,w,h)
{
	popleft = Math.round(screen.availWidth/2)  - Math.round(w/2);
  poptop  = Math.round(screen.availHeight/2) - Math.round(h/2);
  popup = window.open(u,'popup_window','width='+w+',height='+h+',location=0,status=1,toolbar=0,resize=0,scrollbars=1,top='+poptop+',left='+popleft);
  popup.focus();
}
var w_t;
var h_t;
function windowsize()
{

  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

	return {width:myWidth,height:myHeight};
}

function showPopUp(u,w,h) {

	w_t=w;
	h_t=h;



	var cdiv = document.createElement('div');
	cdiv.setAttribute('id', 'popupdiv');
	popleft = Math.round(windowsize().width/2)  - Math.round(w/2);
	poptop  = Math.round(windowsize().height/2) - Math.round(h/2);
	cdiv.setAttribute("style", 'border:0px; background:white; z-index:1005; position:fixed; width:'+w+'px; height:'+h+'px; top:'+poptop+'px; left:'+popleft+'px');
	cdiv.style.cssText = 'border:0px; background:white;z-index:1005;position:fixed; width:'+w+'px; height:'+h+'px; top:'+poptop+'px; left:'+popleft+'px';

	var link = document.createElement('iframe');
			link.setAttribute('id', 'videodiv');
	link.setAttribute('src', u);
	link.setAttribute('frameBorder', '0');
	link.setAttribute('border', '0');
	link.setAttribute("style", 'border:0 none ;height:'+(h-27)+'px; width:'+w+'px;');
	link.style.cssText = 'border:0 none;height:'+(h-27)+'px; width:'+w+'px;';

	var topdiv = document.createElement('div');
			topdiv.setAttribute('id', 'popupdiv_topdiv');
	topdiv.setAttribute("style", 'height:20px; width:'+w+'px; background:white');
	topdiv.style.cssText = 'height:20px; width:'+w+'px; background:white';
	topdiv.innerHTML="<a id='div_shutdown' style='float:right; margin-top:2px; margin-right:2px; display:block; height:25px; width:25px; padding-left:2px;padding-right:2px;' href='javascript:closeCurrDiv();' ><img src='"+closeImgPath+"' alt='close' title='close window' /></a>";

	var bgdiv = document.createElement('div');
	bgdiv.setAttribute('id', 'bgdiv');
	bgdiv.setAttribute("style", 'position: fixed; top: 0; left: 0; overflow: hidden; padding: 0; margin: 0; background-color: #000; filter: alpha(opacity=60); opacity: 0.5; display: block; z-index: 1000; width: 100%; height: 100%');
	bgdiv.style.cssText = 'position: fixed;  top: 0; left: 0; overflow: hidden; padding: 0; margin: 0; background-color: #000; filter: alpha(opacity=60); opacity: 0.5; display: block; z-index: 1000; width: 100%; height: 100%';

	IE6=(navigator.userAgent.toLowerCase().indexOf('msie 6') != -1) &&(navigator.userAgent.toLowerCase().indexOf('msie 7') == -1);

	if (IE6) {
		document.documentElement.scrollTop=0;
		//var ddivpos=0;
		window.attachEvent("onscroll", scrollingdivs);
		bgdiv.style.position='absolute';
		cdiv.style.position='absolute';
		document.body.style.height='100%';


	}
	document.body.appendChild(bgdiv);

	document.body.appendChild(cdiv);
	cdiv.appendChild(topdiv);
	cdiv.appendChild(link);

}

function scrollingdivs() {

	if (document.getElementById('bgdiv')&&document.getElementById('popupdiv')) {
		document.documentElement.scrollTop=0;
	}
}

function openVideo(u,w,h) {
	var link = document.createElement('div');
	link.setAttribute('id', 'videodiv');
	link.setAttribute("style", 'border:0px;height:'+h+'px; width:'+w+'px;');
	link.style.cssText = 'border:0px;height:'+h+'px; width:'+w+'px;';


	var cdiv = document.createElement('div');
	cdiv.setAttribute('id', 'popupdiv');
	popleft = Math.round(windowsize().width/2)  - Math.round(w/2);
	poptop  = Math.round(windowsize().height/2) - Math.round((h+20)/2);
	cdiv.setAttribute("style", 'background:white; z-index:1005; position:fixed; width:'+w+'px; height:'+(h+20)+'px; top:'+poptop+'px; left:'+popleft+'px');
	cdiv.style.cssText = ' background:white;z-index:1005;position:fixed; width:'+w+'px; height:'+(h+20)+'px; top:'+poptop+'px; left:'+popleft+'px';

	var topdiv = document.createElement('div');

	topdiv.setAttribute("style", 'height:20px; width:'+w+'px; background:white');
	topdiv.style.cssText = 'height:20px; width:'+w+'px; background:white';
	topdiv.innerHTML="<a  id='div_shutdown' style='float:right; margin-top:2px; margin-right:2px; display:block; height:15px; border:1px solid gray; width:12px; padding-left:3px;font-weight:bold; font-size:12px; color:gray; text-decoration:none;' onclick='closeCurrDiv();' ><img src='"+closeImgPath+"' alt='close' title='close window' /></a>";

	var bgdiv = document.createElement('div');
	bgdiv.setAttribute('id', 'bgdiv');
	bgdiv.setAttribute("style", 'position: fixed; top: 0; left: 0; overflow: hidden; padding: 0; margin: 0; background-color: #000; filter: alpha(opacity=60); opacity: 0.5; display: block; z-index: 1000; width: 100%; height: 100%;');
	bgdiv.style.cssText = 'position: fixed; top: 0; left: 0; overflow: hidden; padding: 0; margin: 0; background-color: #000; filter: alpha(opacity=60); opacity: 0.5; display: block; z-index: 1000; width: 100%; height:100%;';
	IE6=(navigator.userAgent.toLowerCase().indexOf('msie 6') != -1) &&(navigator.userAgent.toLowerCase().indexOf('msie 7') == -1);

	if (IE6) {
		document.documentElement.scrollTop=0;
		//var ddivpos=0;
		window.attachEvent("onscroll", scrollingdivs);
		bgdiv.style.position='absolute';
		cdiv.style.position='absolute';
		document.body.style.height='100%';


	}

	document.body.appendChild(bgdiv);

	document.body.appendChild(cdiv);
	cdiv.appendChild(topdiv);
	cdiv.appendChild(link);

	var s1 = new SWFObject('/modules/jw_flv_player/player.swf','player',w,h,'7');
s1.addParam('allowfullscreen','true');
s1.addParam('allowscriptaccess','always');
s1.addParam('flashvars','file='+u);
s1.write('videodiv');

}

function closeCurrDiv() {
pdiv=document.getElementById('bgdiv');
document.body.removeChild(pdiv);
popdiv=document.getElementById('popupdiv');
document.body.removeChild(popdiv);

}

window.onresize=function (e) {
	if (document.getElementById('bgdiv')&&document.getElementById('popupdiv')) {
		popleft = Math.round(windowsize().width/2)  - Math.round(w_t/2);
		poptop  = Math.round(windowsize().height/2) - Math.round((h_t+20)/2);
		document.getElementById('popupdiv').style.left=popleft+'px';
		document.getElementById('popupdiv').style.top=poptop+'px';
	}

}
