var IE4=(document.all)? 1:0;
var IE5=(IE4 && document.getElementById)? 1:0;
var NS4=(document.layers)? 1:0;
var NS6=(!IE4 && document.getElementById)? 1:0;
var VR4=(IE4 || NS4 || NS6)? 1:0;

var bStarted = false;

function getObj(){
	if(!bStarted) return
	if(NS6) return document.getElementById(arguments[arguments.length-1]);
	if(IE4)	return document.all[arguments[arguments.length-1]];
	l = arguments.length;
	r = '';
	for(var i=0;i<l;i++){
		r += "document.layers['"+arguments[i]+"']";
		if(i != l-1) r+='.';
	}
	return eval(r);
}

function getStyle(){	
	if(!bStarted) return
	if(NS6) return document.getElementById(arguments[arguments.length-1]).style;
	if(IE4)	return document.all[arguments[arguments.length-1]].style;
	l = arguments.length;
	r = '';
	for(var i=0;i<l;i++){
		r += "document.layers[\'"+arguments[i]+"\']";
		if(i != l-1) r+='.';
	}
	return eval(r);
}

function moveTo(stl,x,y){
	if(NS4) stl.moveTo(x,y);
	else{
		stl.left = x;
		stl.top = y;
	}
}

function moveBy(stl,x,y){
	if(NS4) stl.moveBy(x,y)
	if(NS6){
		stl.left = parseInt(stl.left) + x;
		stl.top = parseInt(stl.top) + y;
	}
	if(IE4){
		stl.pixelLeft += x;
		stl.pixelTop += y;
	}
}

function hide(stl){ stl.visibility='hidden'; }

function show(stl){ if(bStarted) stl.visibility='visible'; }

function openWin(URL,name,width,height,left,top){
	if(!width) width=400;
	height_opt= height ? ',height='+height : '';
	left_opt= left ? ',left='+left : '';
	top_opt= top ? ',top='+top : '';
	open(URL,name,'width='+width+height_opt+left_opt+top_opt+'location=no,menubar=no,titlebar=no,status=no,resizable=no,scrollbars=no');
}
function open_mainWin(href){
	window.opener.document.location.href=href
	window.close()
}
function setErrMsg(ref,msg){
	ref.focus();
	alert(msg);
	return false;
}
function trim(e){
	while(''+e.value.charAt(0)==' ') e.value=e.value.substr(1);
	while(''+e.value.charAt(e.value.length-1)==' ') e.value=e.value.substr(0,e.value.length-1);
	return e.value;
}

function openPlayer(speed){
	if(parent.frames.length==2){
		parent.frames.bottomFrame.document.location.href='empty.html'
	}
  var w=0,h=0,s;
	s=speed.substring(speed.length-2,speed.length-1)=="v"
	for (var i = 0; i < openPlayer.arguments.length; i++) {
		if(i==1) w=openPlayer.arguments[i]
		if(i==2) h=openPlayer.arguments[i]
	}
	if(w==0) w=(s?324:281)
	if(h==0) h=(s?310:400)

	if(s) openWin('ys_real.php?speed='+speed,'real_viewer1',w,h,1,1);  //video width*height
  else openWin('ys_real.php?speed='+speed,'real_viewer1',w,h,1,1);  //audio
	/*
	if(speed.substring(speed.length-2,speed.length-1)=="v")	openWin('ys_real.php?speed='+speed,'real_viewer1',304,310,1,1);  //video width*height
  else  openWin('ys_real.php?speed='+speed,'real_viewer1',281,400,1,1);  //audio
	*/
}

function windowResize() {
  if (document.all) {
	var wide = window.screen.availWidth;
	var high = window.screen.availHeight;
	self.resizeTo(wide,high);
	MediaPlayer.Play();
 }
}