function MM_openBrWindow(theURL,winName,features) {  
  lastWinObj = window.open(theURL,winName,features);
}

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 viewCode(str){
	if (str=="box"){ 
	 	if (document.getElementById('navBoxLatest').style.display=="none" ){		
			document.getElementById('navBoxLatest').style.display="block";
		 	document.getElementById('navBoxTop50').style.display="block"; 
		}else{
			if (document.getElementById('navBoxLatest').style.display=="block" ){		
				document.getElementById('navBoxLatest').style.display="none";
			 	document.getElementById('navBoxTop50').style.display="none";
			 
			}
		} 
	}
	
	if (str=="cs"){ 
		if (document.getElementById('nav_cs_table').style.display=="none" ){		
			document.getElementById('nav_cs_table').style.display="block";
			document.getElementById('nav_cs_flow').style.display="block";
		 	document.getElementById('nav_cs_delivery').style.display="block"; 
		 	document.getElementById('nav_cs_charge').style.display="block";
		 	document.getElementById('nav_cs_duties').style.display="block"; 
		 	document.getElementById('nav_cs_return').style.display="block";
		 	document.getElementById('nav_cs_slip').style.display="block"; 
		 	document.getElementById('nav_cs_trackorder').style.display="block";
		 	document.getElementById('nav_cs_gift').style.display="block"; 
		}else{
			if (document.getElementById('nav_cs_table').style.display=="block" ){		
				document.getElementById('nav_cs_table').style.display="none";
				document.getElementById('nav_cs_flow').style.display="none";
		 		document.getElementById('nav_cs_delivery').style.display="none"; 
		 		document.getElementById('nav_cs_charge').style.display="none";
		 		document.getElementById('nav_cs_duties').style.display="none"; 
		 		document.getElementById('nav_cs_return').style.display="none";
		 		document.getElementById('nav_cs_slip').style.display="none"; 
		 		document.getElementById('nav_cs_trackorder').style.display="none";
		 		document.getElementById('nav_cs_gift').style.display="none"; 
			}
		} 
	}
} 

function send_to_friend()
{	 
	document.insert_subscription.link.value=  window.location.pathname ;
	document.insert_subscription.action="sendtofriend.asp";
	document.insert_subscription.submit();
}

function Clear_Friend_Email(){
	document.sendFriend.senderName.value="";
	document.sendFriend.SenderMessage.value="";
	document.sendFriend.SenderEmail.value="";
	document.sendFriend.receiverEmail.value=""; 
}

 
function RTrim(str)
{
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      var i = s.length - 1;       // Get length of string
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      s = s.substring(0, i+1);
   }

   return s;
}

function LTrim(str)

{
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(0)) != -1) { 

      var j=0, i = s.length; 
      
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++; 
      s = s.substring(j, i);
   }
   return s;
}

function Trim(str) 
{
   return RTrim(LTrim(str));
}

function Check_Friend_Email(){
	x = document.sendFriend.SenderEmail.value
	y = document.sendFriend.receiverEmail.value
	
	if ((x.charAt(0)=="@" || x.charAt(x.length-1)=="@" )||(y.charAt(0)=="@" || y.charAt(y.length-1)=="@" ))
		{ 	
			if  (x.charAt(0)=="@" || x.charAt(x.length-1)=="@" ){
				locationErr=" 你的電郵地址中的 @ 位置不對 ! \n";   
			}
			if (y.charAt(0)=="@" || y.charAt(y.length-1)=="@" ){
				locationErr = locationErr + " 朋友電郵地址中的 @ 位置不對 ! " ;
			}
			alert(locationErr);
	  		return; 
	  		
	  	} 
	 
	flagx = 0; 
	 
	for ( i=2 ; i < (x.length-2) ; i++ )
	{ if (x.charAt(i)=="@")
	 	{ flagx += 1 ; }
	} 
	 
	flagy = 0;
	for ( i=2 ; i < (y.length-2) ; i++ )
	{ if (y.charAt(i)=="@")
		 { flagy += 1 ; }
	}
	
	if ((flagx==0) || (flagx >1) || (flagy==0) ){
		if (flagx==0) { NumErr = " 你的電郵地址中沒有 @ 字符 ! \n" ; }
		
		if (flagx >1) { NumErr = NumErr + " 你的電郵地址中有多過一個 @ 字符 ! \n" ; }  
		
		if (flagy==0) { NumErr = NumErr + " 朋友電郵地址中沒有 @ 字符 ! \n";  } 
		
		alert(NumErr);
	  	return;  
	} 
	
	if ((flagx==1) && (flagy>=1))
	{ 	alert("  謝謝！你的推介已成功寄出。 ") ;
		document.sendFriend.action="sendtoFriendProcess.asp";
		document.sendFriend.submit();
	}
	 
}

function Movie_Pics(hTarget){
	var hMovie_Pics;
	hMovie_Pics = window.open("Graphics/Data/Information/" + hTarget, "Movie_Pics", "width=390,height=274,alwaysRaised=yes, directories=no, location=no, menubar=no, personalbar=no, resizable=no, scrollbars=yes, titlebar=yes, toolbar=no, status=yes");
}

function Pop_Member(hWay){
	var hPop_Member;
	hPop_Member = window.open("Member.asp?hWay=" + hWay, "Pop_Member", "width=195,height=110,alwaysRaised=yes, directories=no, location=no, menubar=no, personalbar=no, resizable=no, scrollbars=no, titlebar=yes, toolbar=no, status=no");
}

function Pop_Email(){
	var hPop_Email;
	hPop_Email = window.open("Exceed.htm", "Pop_Email", "width=320,height=150,alwaysRaised=yes, directories=no, location=no, menubar=no, personalbar=no, resizable=no, scrollbars=no, titlebar=yes, toolbar=no, status=no");
}

function Pop_Note() {
	var hPop_Note;

	hPop_Note = window.open("Trade_Note.asp", "Pop_Note", "width=607,height=405,alwaysRaised=yes, directories=no, location=no, menubar=no, personalbar=no, resizable=no, scrollbars=yes, titlebar=yes, toolbar=no, status=yes");
}

function Pop_Trade(hParam){
	var hPop_Trade;

	hPop_Trade = window.open("Post_Trade.asp?hType=" + hParam, "Pop_Trade", "width=607,height=405,alwaysRaised=yes,directories=no,location=no,menubar=no,personalbar=no,resizable=no,scrollbars=yes,titlebar=yes,toolbar=no,status=no");
}

function Pop_Cert(){
	var hPop_Cert;

	if (document.Veno.hCert_ID.value == '') {
		alert("請輸入購物禮券號碼及先按「確認」，再按「付帳」");
	} else {
		hPop_Cert = window.open("Pop_Cert.asp?hID=" + document.Veno.hCert_ID.value + "&hCan_B=" + document.Veno.Can_B.value, "Pop_Cert", "width=200,height=50,alwaysRaised=yes,directories=no,location=no,menubar=no,personalbar=no,resizable=no,scrollbars=yes,titlebar=yes,toolbar=no,status=no");
	}
}

function Check_Form(){
	
	if (document.Veno.Use_Cert.checked) {
		if (document.Veno.hCert_ID_Used.value == '') {
			alert("請輸入購物禮券號碼及先按「確認」，再按「付帳」");
			return false;
		} else {
			return true;
		}
	} else {
		if (document.Veno.hCert_ID.value != '') {
			alert("請按一下「使用購物禮券」的方格，再按「付帳」");
			return false;
		} else {
			return true;
		}
	}
}

function Pop_P_Member(hTarget) {
	var hPop_P_Member;
		 
	if (hTarget == 'PM') {	 
		if (Trim(document.Veno_Member.hUsername.value) == "") {
			alert("Please Enter your Username");
		} else {
			hPop_P_Member = window.open("Member_Proccess.asp?hType=PM", "Pop_P_Member", "width=165,height=100,alwaysRaised=yes, directories=no, location=no, menubar=no, personalbar=no, resizable=no, scrollbars=yes, titlebar=yes, toolbar=no, status=yes");
		}
		
	} else {
		if (document.Veno_Member.hUsername.value == "") {
			alert("In Order to retrieve your Password. Please Enter your Username");
		} else {
			hPop_P_Member = window.open("Member_Proccess.asp?hType=FP", "Pop_P_Member", "width=165,height=100,alwaysRaised=yes, directories=no, location=no, menubar=no, personalbar=no, resizable=no, scrollbars=yes, titlebar=yes, toolbar=no, status=yes");
		}
	}
}

function Pop_Super_Star(hTarget) {
	var hPop_Super_Star;

	hPop_Super_Star = window.open(hTarget, "Pop_Super_Star", "width=380, height=460, alwaysRaised=yes, directories=no, location=no, menubar=no, personalbar=no, resizable=no, scrollbars=yes, titlebar=yes, toolbar=no, status=yes");
}

var hEmail;
var hUsername;
var hPassword;
var hSymbols = "`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/? ";

function Check_Input(hTarget, hError){
	var i;
	if (hTarget.length < 6) {
		alert(hError);
		return false;
	} else {
		for (i = 0; i < hTarget.length; i++) {
			var c = hTarget.charAt(i);
			if (hSymbols.indexOf(c) > -1) {
				alert(hError);
				return false;
			}
		}
		
		return true;
	}
}

function CheckForm(){
	if (document.Veno.Full_Name.value == "") {
		alert("Please enter your Name!");
		return false;
	}
	
	if (document.Veno.Username.value == "") {
		alert("Please enter your Username!");
		return false;
	} else {
		if (!Check_Input(document.Veno.Username.value, 'Invalid Username Entry')) {
			return false;
		}
	}
	
	if (document.Veno.Password_1.value == "") {
		alert("Please enter your Password!");
		return false;
	} else {
		if (!Check_Input(document.Veno.Password_1.value, 'Invalid Password Entry')) {
			return false;
		}
	}
	
	if (document.Veno.Password_1.value != document.Veno.Password_2.value) {
		alert("Invalid Password Entry");
		return false;
	}
	
	if (document.Veno.Address.value.length>255) {
		alert("Your Address is too long!!");
		return false;
	}

	if (document.Veno.Email.value == "") {
		alert("Invalid Email Entry!");
		return false;
	} else {
		hEmail = document.Veno.Email.value;
		if (hEmail.search(/@/i) <=  -1) {
			alert("Invalid Email Entry!");
			return false;
		}
	}
	
	if (document.Veno.Phone_Number.value == "") {
		alert("Please enter your Phone Number!");
		return false;
	}
	
	if (document.Veno.Country.value == "") {
		alert("Please select your country!");
		return false;
	}

	return true;
}

function CheckTrackForm(){
	if (document.Veno.Phone_Number.value == "") {
		alert("Please enter your Phone Number!");
		return false;
	}
	
	if (document.Veno.Email.value == "") {
		alert("Invalid Email Entry!");
		return false;
	} else {
		hEmail = document.Veno.Email.value;
		if (hEmail.search(/@/i) <=  -1) {
			alert("Invalid Email Entry!");
			return false;
		}
	}
	
	return true;
}

function TrackformSubmit(){
	if(CheckTrackForm()){
		document.Veno.submit(); 
	}
}

function formSubmit(){
	if(CheckForm()){
		document.Veno.submit(); 
	}
}

function GoNewMember(){
	top.opener.window.location.href = "member_register.asp";
	top.window.close();
}

function CheckUser(){
	if (document.Veno.hUsername.value == "") {
		alert("In Order to retrieve your Password. Please Enter your Username");
	} else {
		document.Email.hUsername.value = document.Veno.hUsername.value;
		document.Email.submit();
	}
}

function SubmitForm(){
	alert("If your username exist, your Login Information will be e-mail to your email as your registered with MovieSuper!");
	top.window.close();
}

function CheckShippingForm(){
	if (document.Veno.Shipping_Full_Name.value == "") {
		alert("Please enter your name!");
		return false;
	}
	
	if (document.Veno.Shipping_Address.value == "") {
		alert("Please enter your shipping address!");
		return false;
	}
	
	if (document.Veno.Shipping_City.value == "") {
		alert("Please enter your shipping city!");
		return false;
	}
	
	return true;
}

function ShippingformSubmit(){
	if(CheckShippingForm()){
		document.Veno.submit(); 
	}
}


//******************* Scroll Text in Front Page *******************//
var bw=lib_bwcheck()
var px = bw.ns4||window.opera?"":"px";

lstart=549
newsLoop=true 
newsSpeed=400
pr_step=5

function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=(navigator.userAgent.indexOf("Opera")>-1 && document.getElementById)?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}

function scroll(speed){
	if (scrolltextLoaded){
		loop = true;
		if (speed>0) oScroll.down(speed)
		else oScroll.up(speed)
	}
}

function newsScrollInit(){
	oNewsCont=new makeNewsObj('divNewsCont')
	oNewsScroll=new makeNewsObj('divNewsText','divNewsCont')
	oNewsScroll.moveIt(lstart,0)
	oNewsCont.css.visibility='visible'
	oNewsScroll.newsScroll(newsSpeed)
}

function makeNewsObj(obj,nest){
    nest=(!nest) ? '':'document.'+nest+'.'
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
  	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
	this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
	this.scrollWidth=bw.ns4?this.css.document.width:this.el.offsetWidth
	this.newsScroll=newsScroll;
	this.moveIt=b_moveIt; this.x; this.y;
    this.obj = obj + "Object"
    eval(this.obj + "=this")
    return this
}

function moveIt(x,y){
	this.x = x
	this.y = y
	this.css.left = this.x+px
	this.css.top = this.y+px
}

function b_moveIt(x,y){
	this.x=x
	this.y=y
	this.css.left=this.x
	this.css.top=this.y
}

function newsScroll(newsSpeed){
// alert(this.x+":"+this.scrollWidth);
	if(this.x> - this.scrollWidth){
		this.moveIt(this.x-pr_step,0)
		setTimeout(this.obj+".newsScroll("+newsSpeed+")",newsSpeed)
	}else if(newsLoop) {
		this.moveIt(lstart,0)
		eval(this.obj+".newsScroll("+newsSpeed+")")
	}
} 

function addBreakLine(bodyContent){
	var strLenght=bodyContent.length;
	var strContent=bodyContent;
	var breakPoint=45;
	var outStr="";
	var k=0;
	
	for(var i=0;i<=strLenght;i++){
		if(k!=breakPoint){
			outStr+=strContent.charAt(i, i+1);
			k++;
		}else{
			outStr+="<br>";
			outStr+=strContent.charAt(i, i+1);
			k=0;
		}
	}
	
	return outStr;
}
//******************* Scroll Text in Front Page *******************//

function FindNow(filmName, movieName){
	document.ticketForm.FilmName.value = filmName.toString();
	document.ticketForm.MovieName.value = movieName.toString();
	document.ticketForm.SeqFlag.value = 'C';
    document.ticketForm.submit();
}

function PassRegion(i){
	document.form1.menu1.value=i;
	document.form1.submit();
}

function frmSubmit(){
	document.frm.hTarget_Name.value = document.frm.hTarget[document.frm.hTarget.selectedIndex].text;
	document.frm.submit();
}