var _W=window,_D=document,_P=parent,is,xmlhttp=false,popupEl,nrSteps=15,dragObj,dragX,dragY,dragZ=1,close_n=new Image(13,13),close_h=new Image(13,13);

_D.onmouseup=function(){try{dragObj=_D.onselectstart=_D.onmousemove=null}catch(e){}};

close_h.src = 'pics/close_hi.gif';
close_n.src = 'pics/close.gif';

function sniff(){
	var t=this,T=true,F=false,n=navigator,ua=n.userAgent.toLowerCase();
	t.ver=parseInt(n.appVersion);
	t.mac=ua.indexOf('mac')!=-1;
	t.win=!t.mac&&ua.indexOf('wind')!=-1||ua.indexOf('16bit')!=-1;
	t.safari=ua.indexOf('safari')!=-1&&t.mac;
	t.konq=ua.indexOf('konqueror')!=-1;
	t.khtml=t.safari||t.konq;
	t.opera=_W.opera?T:F;
	t.opera5=ua.indexOf('opera 5')!=-1||ua.indexOf('opera/5')!=-1;
	t.opera6=ua.indexOf('opera 6')!=-1||ua.indexOf('opera/6')!=-1;
	t.opera7=t.opera&&_D.createComment?T:F;
	t.ie5=t.ie55=t.ie6=F;
	t.ie=_D.all&&!t.opera&&ua.indexOf('msie')!=-1?T:F;
	if(t.ie){
		t.ieBox=_D.compatMode!='CSS1Compat';
		t.ie5=!_D.fireEvent?T:F;
		t.ie55=_D.fireEvent&&!_D.createComment?T:F;
		t.ie6=_D.fireEvent&&_D.createComment?T:F
	}
	t.gecko=!t.khtml&&!_D.all&&!t.opera&&_D.getElementById?T:F;
	t.ns4=n.appName=='Netscape'&&t.ver==4
}
is=new sniff();
op=is.opera;
function gE(e){if(_D.getElementById)return _D.getElementById(e);if(_D.all)return _D.all[e]}
function sE(e){e.style.visibility='visible'}
function hE(e){e.style.visibility='hidden'}
function SE(e){e.style.display=''}
function HE(e){e.style.display='none'}
function sX(e,x){op?e.style.pixelLeft=x:e.style.left=x+'px'}
function sY(e,y){op?e.style.pixelTop=y:e.style.top=y+'px'}
function sW(e,w){op?e.style.pixelWidth=w:e.style.width=w+'px'}
function sH(e,h){op?e.style.pixelHeight=h:e.style.height=h+'px'}
function wH(e,h){e.innerHTML=h}

function getWinSize(what) {
	if (what == 'height')
		return (is.ie) ? (is.ieBox) ? _D.body.clientHeight : _D.documentElement.clientHeight : _W.innerHeight;
	if (what == 'width')
		return (is.ie) ? (is.ieBox) ? _D.body.clientWidth : _D.documentElement.clientWidth : _W.innerWidth;
}

function setEvent(el,evt,state,fn) {
	if (state) {
		if (el.addEventListener)
			el.addEventListener(evt,fn,false);
		if (el.attachEvent)
			el.attachEvent('on'+evt,fn);
	}
	else {
		if (el.removeEventListener)
			el.removeEventListener(evt,fn,false);
		if (el.detachEvent)
			el.detachEvent('on'+evt,fn);
	}
}


function makePopup(e, width, height, title, url) {
	killPopup(1);
	height += 24;
	var wh = getWinSize('height'), ww = getWinSize('width'), st, sl;
	if (!e) {
		e = new Object();
		e.clientX = ww/2-width/2;
		e.clientY = wh/2-height/2;
	}
	var top = e.clientY, left = e.clientX;
	if (is.ie) {
		sl = (is.ieBox) ? _D.body.scrollLeft : _D.documentElement.scrollLeft;
		st = (is.ieBox) ? _D.body.scrollTop  : _D.documentElement.scrollTop;
	}
	else {
		
    sl = _W.pageXOffset;
		st = _W.pageYOffset;
	}
	if (e.clientX + width > ww)
		//left = ww-width-5;
		left = 450
	if (e.clientY + height > wh)
		//top = wh-height+5;
		top = 30

	popupEl = _D.createElement('div');
	popupEl.onmousedown=function(event){dragStart(event,this)};
	popupEl.className = 'popup';
	_D.body.appendChild(popupEl);
	sizePopup(title,url,left+sl,top+st,width,height,nrSteps);
}

function sizePopup(title,url,left,top,width,height,step) {
	// New and improved: with slomogrow effect!
	var html, mouse;
	if (step < 0) {
		if (is.ie) {
			sW(popupEl, width+2);
			sH(popupEl, height+2);
		}
		mouse = (is.ie) ? 'onmouseover="this.src=close_h.src" onmouseout="this.src=close_n.src"' : '';
		html  = '<table class="popupCaption" cellpadding="0" cellspacing="3" border="0"><tr>';
		html += '<td width="90%" align="center">'+title+'</td>';
		html += '<td width="10%" align="right"><img src="pics/close.gif" class="ptr" width="13" height="13" vspace="2" alt="Close" onclick="killPopup(0)" '+mouse+' /></td>';
		html += '</tr></table>';
		wH(popupEl, html+'<iframe name="popupcontent" frameborder="0" scrolling="auto" src="'+url+'" style="width:'+width+'px;height:'+(height-24)+'px"></iframe>');
		return;
	}
	sX(popupEl, left + step*width/nrSteps/2);
	sY(popupEl, top + step*height/nrSteps/2);
	sW(popupEl, width - step*width/nrSteps);
	sH(popupEl, height - step*height/nrSteps + (is.safari?2:0));
	setTimeout("sizePopup('"+title+"','"+url+"',"+left+","+top+","+width+","+height+","+(step-1)+")",0);
}

function killPopup(now) {
	if (popupEl) {
		var code = '_D.body.removeChild(popupEl);popupEl=null;';
		if (now)
			eval(code);
		else
			setTimeout(code,10);
	}
}

function checkpopup(newpoploc) {
if (popupEl) {
gE('popupcontent').contentWindow.location=newpoploc;
}
}



/*@cc_on @*/
/*@if (@_jscript_version >= 5)
	try {
		xmlhttp=new ActiveXObject('Msxml2.XMLHTTP')
	} catch(e) {
		try {
			xmlhttp=new ActiveXObject('Microsoft.XMLHTTP')
		} catch(e) {
			xmlhttp=false
		}
	}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	xmlhttp = new XMLHttpRequest();
}

function dragStart(e,el) {
	if (!e)e=_W.event;
	dragObj = el;
	dragObj.style.zIndex = dragZ++;
	dragX = e.clientX - dragObj.offsetLeft;
	dragY = e.clientY - dragObj.offsetTop;
	_D.onmousemove=dragMove;
	_D.onselectstart=function(){return false};
}


function dragMove(e) {
	if (!e)e=_W.event;
	if(dragObj) {
		sX(dragObj,e.clientX - dragX);
		sY(dragObj,e.clientY - dragY);
	}
}

function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  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=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function setTextOfLayer(objName,x,newText) { //v4.01
   if ((obj=findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

function iFrameHeight() {
var h = 0;
if ( !document.all ) {
h = document.getElementById('iframe1').contentDocument.height;
document.getElementById('iframe1').style.height = h + 60 + 'px';
} else if( document.all ) {
h = document.frames('iframe1').document.body.scrollHeight;
document.all.iframe1.style.height = h + 20 + 'px';
}
}

function updateiframe(framename, frameloc) { 
frames[framename].location.href = frameloc;
	}

function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=10;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)+ ";expires="+expire.toGMTString()+";path=/";
}

function fullScreen() {
   var el = _D.getElementById('playerFrame').contentWindow.document.getElementById('MediaPlayer'); 
     if (el.fullScreen==false) { 
     el.fullScreen=true;
    } else el.fullScreen=false;

}

function Mute() {
   var el = document.getElementById('MediaPlayer'); 
     if (el.settings.mute==false) { 
     el.settings.mute=true;
    } else el.settings.mute=false;

}
