var WinPop;

function PopUpNew(URL){
	if (WinPop != null) {
		WinPop.close();
	}
	WinPop=window.open(
	URL,"WinPop","screenx=100,screeny=10,left=100,top=10,width=500,height=570,scrollbars=no,resize=no,toolbar=no,status=no,menubar=no");
	rePopUp();
}

function rePopUp() {
	if (WinPop != null) {
		if (!WinPop.closed) WinPop.focus();
	}
	return true;
}

var WinPop2;

function PopUp2(URL){
	if (WinPop2 != null) {
		WinPop2.close();
	}
	WinPop2=window.open(
	URL,"WinPop2","screenx=100,screeny=10,left=100,top=10,width=500,height=570,scrollbars=yes,resize=no,toolbar=no,status=no,menubar=no");
	rePopUp2();
}

function rePopUp2() {
	if (WinPop2 != null) {
		if (!WinPop2.closed) WinPop2.focus();
	}
	return true;
}

var CopyrWinPop;

function PopUpCopyr(URL){
	if (CopyrWinPop != null) {
		CopyrWinPop.close();
	}
	CopyrWinPop=window.open(
	URL,"CopyrWinPop","screenx=200,screeny=70,left=200,top=70,width=350,height=350,scrollbars=no,resize=no,toolbar=no,status=no,menubar=no");
	CopyrrePopUp();
}

function CopyrrePopUp() {
	if (CopyrWinPop != null) {
		if (!CopyrWinPop.closed) CopyrWinPop.focus();
	}
	return true;
}

function right(e) {
	if (navigator.appName == 'Netscape' && 
		(e.which == 3 || e.which == 2))
		return false;
	else if (navigator.appName == 'Microsoft Internet Explorer' && 
		(event.button == 2 || event.button == 3)) {
		alert("Right mouse-click has been disabled!");
		return false;
		}
	return true;
	}

// document.onmousedown=right;
// document.onmouseup=right;
// if (document.layers) window.captureEvents(Event.MOUSEDOWN);
// if (document.layers) window.captureEvents(Event.MOUSEUP);
// window.onmousedown=right;
// window.onmouseup=right;

function end() {
	window.close(self);
}

function fullscreen() {
	//self.document.MediaPlayer.DisplaySize=3;
	self.document.MediaPlayer.fullScreen = 'true';
}

function resize350() {
	self.window.moveTo(100, 1);
	if (self.name.length > 0) self.window.resizeTo(520, 550);
	else self.window.resizeTo(520, 620);
}

function resize100() {
	self.window.moveTo(150, 30);
	if (self.name.length > 0) self.window.resizeTo(380, 420);
	else self.window.resizeTo(380, 500);
}

function resizemain() {
	self.window.moveTo(0, 0);
	self.window.resizeTo(810, 598);
}

function resizecopyr() {
	self.document.window.moveTo(200, 70);
	self.document.window.resizeTo(350, 350);
}

function switchEngBig5() {
	var selfUrl = self.location.pathname;
	if (selfUrl.indexOf('eng', 0) > 0) {	//-1 not found
		pos = selfUrl.indexOf('eng', 0);
		targetUrl = selfUrl.substring(0, pos)+'big5'+selfUrl.substring(pos+3,selfUrl.length);
		self.location.href = targetUrl;
	} else if (selfUrl.indexOf('big5', 0) > 0) {	//-1 not found
		pos = selfUrl.indexOf('big5', 0);
		targetUrl = "//tv.icac.org.hk/eng"+selfUrl.substring(pos+4,selfUrl.length);
		self.location.href = targetUrl;
	} else {
		self.location.href = selfUrl;
	}
}

// for Kanhan
function switchGb_Kanhan() {
	var selfUrl = "";
	selfUrl = self.location.toString();
	if (selfUrl.indexOf('gb', 0) > 0) {	//-1 not found
		pos = selfUrl.indexOf('tv.icac.org.hk', 0);
		tempUrl = "//"+selfUrl.substring(pos,selfUrl.length);
		if (tempUrl.indexOf('gb', 0) > 0) {	//-1 not found
			pos1 = tempUrl.indexOf('gb', 0);
			targetUrl = tempUrl.substring(0, pos1)+'big5'+tempUrl.substring(pos1+2,tempUrl.length);
			self.location.href = targetUrl;
		}
		else {self.location.href = tempUrl;}
	} else if (selfUrl.indexOf('big5', 0) > 0) {	//-1 not found
		pos = selfUrl.indexOf('big5', 0);
		targetUrl = "http://sc.icac.org.hk/gb/tv.icac.org.hk/"+selfUrl.substring(pos,selfUrl.length);
		self.location.href = targetUrl;
	} else if (selfUrl.indexOf('eng', 0) > 0) {	//-1 not found
		pos = selfUrl.indexOf('eng', 0);
		targetUrl = "http://sc.icac.org.hk/gb/tv.icac.org.hk/big5/"+selfUrl.substring(pos+4,selfUrl.length);
		self.location.href = targetUrl;
	} else {
		alert (targetUrl);
		self.location.href = selfUrl;
	}
}

function check_sub(inputform) {

	  var ok = true;

  	  var d = inputform.email.value;

	  if ((ok != false) && (d.length == 0)) {
		alert ("ﾽппﾹqﾶlﾦaﾧ}!"); 
		// focus_email();
		ok = false;
		}

	  if ((ok != false) && (d.length > 0) && (emailCheck(d) == false)) {
		ok = false;
		}
		
	  if (ok == true) {
		inputform.submit();
		}
	}
	
function check_email(email) {

	  if (emailCheck(email) == false) {
		//focus_email();
		return false;
		}
}

function focus_email() {
	document.survey.email.focus();
	document.survey.email.select();
}

function jump_news_clip(inputform) {
	eval(inputform.news_select.value);
}

function jump_drama_clip(inputform) {
	eval(inputform.drama_select.value);
}

function jump_people_clip(inputform) {
	eval(inputform.people_select.value);
}

function jump_icac_clip(inputform) {
	eval(inputform.icac_select.value);
}

function jump_c_clip(inputform) {
	eval(inputform.c_select.value);
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var js1, js2, js3, js4;
var posit, newpath;

posit=self.location.toString().lastIndexOf('/');
newpath=self.location.toString().substring(0, posit+1);

function tv_DoFSCommand(command, args) {
  var tvObj = InternetExplorer ? tv : document.tv
  eval (command);								
}

function link1() {
  eval (js1);
}

function link2() {
  eval (js2);
}

function link3() {
  eval (js3);
}

function link4() {
  eval (js4);
}

function link5() {
  eval (js5);
}

function link6() {
  eval (js6);
}

function link7() {
  eval (js7);
}

if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
	  navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<SCRIPT LANGUAGE=VBScript> \n');
	document.write('on error resume next \n');
	document.write('Sub tv_FSCommand(ByVal command, ByVal args)\n');
	document.write('  call tv_DoFSCommand(command, args)\n');
	document.write('end sub\n');
	document.write('<\/script> \n');
}
