
// JavaScript Document
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function NewWindow(mypage,myname,w,h,pos,infocus){
	var win=null;
	if(pos=="random") {
		myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
	}

	if(pos=="center") {
		myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;
	} else if((pos!='center' && pos!="random") || pos==null) {
		myleft=0;mytop=20
	}

	settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no";
	win=window.open(mypage,myname,settings);
	win.focus();
}
function NewWindow2(mypage,myname,w,h,pos,infocus){
	var win=null;
	if(pos=="random") {
		myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
	}

	if(pos=="center") {
		myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;
	} else if((pos!='center' && pos!="random") || pos==null) {
		myleft=0;mytop=20
	}

	settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no";
	win=window.open(mypage,myname,settings);
	win.focus();
}

function checkEmail(str) {
    if(str == "")
        return true;
    if (str.charAt(0) == "." || str.charAt(0) == "@" || str.indexOf('@', 0) == -1
        || str.indexOf('.', 0) == -1 || str.lastIndexOf("@") == str.length-1 || str.lastIndexOf(".") == str.length-1)
        return false;
    else
        return true;
}

function checkPublicForm() {
	thename = document.getElementById("sendername");
	if(thename.value == "") {
		alert("你的名稱是必填.");
		return false;
	}
	theemail = document.getElementById("email");
	if(theemail.value == "") {
		alert("電郵地址是必填.");
		return false;
	}
	if(!checkEmail(theemail.value)) {
		alert("電郵地址的格式不正確.");
		return false;
	}

	thetel = document.getElementById("tel");
	if(thetel.value == "") {
		alert("聯絡電話是必填.");
		return false;
	}
	if(thetel.value.length < 8) {
		alert("聯絡電話格式不正確.");
		return false;
	}

	thelink = document.getElementById("link");
	thecomment = document.getElementById("comment");
	if(thelink.value =="" && thecomment.value=="") {
		alert("影片連結或信息內容必須至少填寫一個.");
		return false;
	}
	return true;
}

function checkMailForm() {
	thename = document.getElementById("sendername");
	if(thename.value == "") {
		alert("你的名稱是必填.");
		return false;
	}

	theemail = document.getElementById("email");
	if(theemail.value == "") {
		alert("電郵地址是必填.");
		return false;
	}
	if(!checkEmail(theemail.value)) {
		alert("電郵地址的格式不正確.");
		return false;
	} 

	theemail = document.getElementById("email2");
	if(theemail.value != "" && !checkEmail(theemail.value)) {
		alert("朋友一的電郵地址格式不正確.");
		return false;
	} 
	theemail = document.getElementById("email3");
	if(theemail.value != "" && !checkEmail(theemail.value)) {
		alert("朋友二的電郵地址格式不正確.");
		return false;
	} 
	theemail = document.getElementById("email4");
	if(theemail.value != "" && !checkEmail(theemail.value)) {
		alert("朋友三的電郵地址格式不正確.");
		return false;
	} 
	theemail = document.getElementById("email5");
	if(theemail.value != "" && !checkEmail(theemail.value)) {
		alert("朋友四的電郵地址格式不正確.");
		return false;
	} 
	theemail = document.getElementById("email6");
	if(theemail.value != "" && !checkEmail(theemail.value)) {
		alert("朋友五的電郵地址格式不正確.");
		return false;
	} 
	theemail = document.getElementById("email7");
	if(theemail.value != "" && !checkEmail(theemail.value)) {
		alert("朋友六的電郵地址格式不正確.");
		return false;
	} 


	return true;
} 


floatX=640;
floatY=270;
layerwidth=260;
layerheight=300;
halign="left";
valign="top";
delayspeed=3;

NS6=false;
IE4=(document.all);
if (!IE4) {NS6=(document.getElementById);}
NS4=(document.layers);

function adjust() {
	if ((NS4) || (NS6)) {
	if (lastX==-1 || delayspeed==0) {
		lastX=window.pageXOffset + floatX;
		lastY=window.pageYOffset + floatY;

	if (NS4){
		document.layers['floatlayer'].pageX = lastX;
	}
	if (NS6){
		document.getElementById('floatlayer').style.left=lastX;
	}


	}
	else
	{
		var dx=Math.abs(window.pageXOffset+floatX-lastX);
		var dy=Math.abs(window.pageYOffset+floatY-lastY);
		var d=Math.sqrt(dx*dx+dy*dy);
		var c=Math.round(d/10);
		if (window.pageXOffset+floatX>lastX) {lastX=lastX+delayspeed+c;}
		if (window.pageXOffset+floatX<lastX) {lastX=lastX-delayspeed-c;}
		if (window.pageYOffset+floatY>lastY) {lastY=lastY+delayspeed+c;}
		if (window.pageYOffset+floatY<lastY) {lastY=lastY-delayspeed-c;}
	}
	if (NS4){
		document.layers['floatlayer'].pageY = lastY;
	}
	if (NS6){
		document.getElementById('floatlayer').style.top=lastY;
	}
	}
	else if (IE4){
	if (lastX==-1 || delayspeed==0)
	{
		lastX=document.body.scrollLeft + floatX;
		lastY=document.body.scrollTop + floatY;
		document.all['floatlayer'].style.posLeft = lastX;
	}
	else
	{
		var dx=Math.abs(document.body.scrollLeft+floatX-lastX);
		var dy=Math.abs(document.body.scrollTop+floatY-lastY);
		var d=Math.sqrt(dx*dx+dy*dy);
		var c=Math.round(d/10);
		if (document.body.scrollLeft+floatX>lastX) {lastX=lastX+delayspeed+c;}
		if (document.body.scrollLeft+floatX<lastX) {lastX=lastX-delayspeed-c;}
		if (document.body.scrollTop+floatY>lastY) {lastY=lastY+delayspeed+c;}
		if (document.body.scrollTop+floatY<lastY) {lastY=lastY-delayspeed-c;}
	}
	document.all['floatlayer'].style.posTop = lastY;
	} 
	setTimeout('adjust()',50);
}

function define()
{
	if ((NS4) || (NS6)) 
	{ 
		if (halign=="left") {floatX=ifloatX};
		if (halign=="right") {floatX=window.innerWidth-ifloatX-layerwidth-20};
		if (halign=="center") {floatX=Math.round((window.innerWidth-20)/2)-Math.round(layerwidth/2)};
		if (valign=="top") {floatY=ifloatY};
		if (valign=="bottom") {floatY=window.innerHeight-ifloatY-layerheight};
		if (valign=="center") {floatY=Math.round((window.innerHeight-20)/2)-Math.round(layerheight/2)};
	}
	if (IE4) 
	{
		if (halign=="left") {floatX=ifloatX};
		if (halign=="right") {floatX=document.body.offsetWidth-ifloatX-layerwidth-20}
		if (halign=="center") {floatX=Math.round((document.body.offsetWidth-20)/2)-Math.round(layerwidth/2)}
		if (valign=="top") {floatY=ifloatY};
		if (valign=="bottom") {floatY=document.body.offsetHeight-ifloatY-layerheight}
		if (valign=="center") {floatY=Math.round((document.body.offsetHeight-20)/2)-Math.round(layerheight/2)}
	}
}

//-->