document.write("<form name='frmGotoUrl' action='' method='get'>");
document.write("<input type='hidden' name='WidCoID' value=''>");
document.write("<input type='hidden' name='WidCoAbbName' value=''>");
document.write("<input type='hidden' name='Month' value=''>");
document.write("<input type='hidden' name='langcode' value=''>");
document.write("</form>");
var warning_c = "";
//ken update
function onleaveupdate()
{
	//if (confirm('Are you sure to leave without save?'))
	//{
		window.location="../user/portfolio_page_c.asp";
	//}
}

function onlogoff(theForm)
{
	if (confirm('Are you sure you want to log out?'))
	{
		theForm.action="logoff_page_e.asp"
		theForm.submit();
	}
}

function onchgpasswd_e(theForm)
{
  	
  if(confirm("Are you sure?"))
  {

// irv 27Sep07 checking only contain valid char set 
    	var mikExp="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    	var InvalidCharSet = 0;
    	
	for (var i = 0; i < theForm.retype_password.value.length; i++)
	{
		var temp = "" + theForm.retype_password.value.substring(i, i + 1);
		if (mikExp.indexOf(temp) == -1)
		{
			InvalidCharSet = 1;
			break;
		}
	}		
//end

	if(theForm.current_password.value=="")
	{
		alert("Please enter your current password.");
		return false;
	}
	else if(theForm.new_password.value=="")
	{
		alert("Please enter your new password.");
		return false;
	}
	else if(theForm.retype_password.value=="")
	{
		alert("Please re-type your new password.");
		return false;
	}
	else if(theForm.retype_password.value!=theForm.new_password.value)
	{
		alert("New password does not match, please re-enter.");
		return false;
	}
	else if (theForm.retype_password.value.length < 6)
	{
		alert("New password length must be between 6 to 8 characters.");
		return false;
	}

// irv 27Sep07 checking only contain valid char set 
	else if (InvalidCharSet)
	{
		alert("Invalid Password format. No special character and space allowed, please try again.");
		return false;
	}
//end
	theForm.action="chgpwd_pro.asp"
	theForm.submit();
	return true;
  }
}

function onchgpasswd_c(theForm)
{
  if(confirm("請確定指示"))
  {

// irv 27Sep07 checking only contain valid char set 
    	var mikExp="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    	var InvalidCharSet = 0;
    	
	for (var i = 0; i < theForm.retype_password.value.length; i++)
	{
		var temp = "" + theForm.retype_password.value.substring(i, i + 1);
		if (mikExp.indexOf(temp) == -1)
		{
			InvalidCharSet = 1;
			break;
		}
	}		
//end

	if(theForm.current_password.value=="")
	{
		alert("請輸入現在的密碼。");
		return false;
	}
	else if(theForm.new_password.value=="")
	{
		alert("請輸入新密碼。");
		return false;
	}
	else if(theForm.retype_password.value=="")
	{
		alert("請再次輸入新密碼。");
		return false;
	}
	else if(theForm.retype_password.value!=theForm.new_password.value)
	{
		alert("新密碼不相符﹐請再次輸入。");
		return false;
	}
	else if (theForm.retype_password.value.length < 6)
	{
		alert("新密碼必須介乎6至8個位。");
		return false;
	}
// irv 27Sep07 checking only contain valid char set 
	else if (InvalidCharSet)
	{
		alert("密碼不合格式。");
		return false;
	}
//end
	theForm.action="chgpwd_pro.asp"
	theForm.submit();
  }
  return true;
}

function old_change_language(present_location) {

	var loc=new String(present_location)
	var loc1= loc.split(".");
	var loc2= loc1[loc1.length-2].split("_");
	var newloc=""
	for(i=0;i<loc2.length-1;i++)
	{
		if(newloc!="")
			newloc=newloc + "_";
		newloc=newloc + loc2[i];
	}
	for(i=0;i<loc1.length-2;i++)
	{
		newloc=loc1[i]+"."+newloc+"_c.";
	}
	alert(newloc)
//irv web site revamp 09
//	parent.mainFrame.location.href=newloc;
//	parent.leftFrame.location.href="left_c.asp";
//	parent.topFrame.location.href="top_c.asp";
//end
	//parent.leftFrame.location.reload();
}

function onlogin(theForm)
{
   missingRequired = new Boolean(false)

   if (check_login_name_e(document.login_form.WidUwLogin.value)==false) {
   	missingRequired = true;
   	//alert("Incorrect user name format.");
   	document.login_form.WidUwLogin.focus();
   }

   if (isNull(document.login_form.WidUwLogin.value) && missingRequired == false) {
      	 missingRequired = true;
         	 alert("Login name is required. Please enter.");
         	 document.login_form.WidUwLogin.focus();
   }

   if (missingRequired==false) {
	theForm.submit();
//Site Revamp 09 removed
//	parent.leftFrame.location.href="/invest/left_e.asp";
//end
   }
   
}

function onlogin_c(theForm)
{
	missingRequired = new Boolean(false)
	
	if (check_login_name_c(document.login_form.WidUwLogin.value)==false) {
	   	missingRequired = true;
	   	//alert("Incorrect user name format.");
	   	document.login_form.WidUwLogin.focus();
	   }
	   
	   if (isNull(document.login_form.WidUwLogin.value) && missingRequired == false) {
	      	 missingRequired = true;
	         alert("用戶名稱格式不正確﹐請再次查閱。");
		 document.login_form.WidUwLogin.focus();
	   }
	   
   if (missingRequired==false) {
	theForm.submit();
//irv 2009 revamp
//	parent.leftFrame.location.href="/invest/left_c.asp";
//end
    }
    
}


function old_change_language_c(present_location) {

	var loc=new String(present_location)
	var loc1= loc.split(".");
	var loc2= loc1[loc1.length-2].split("_");
	var newloc=""
	for(i=0;i<loc2.length-1;i++)
	{
		if(newloc!="")
			newloc=newloc + "_";
		newloc=newloc + loc2[i];
	}
	newloc=newloc+"_e."+loc1[1];
	alert(newloc);
//irv 2009 Revamp
//	parent.mainFrame.location.href=newloc;
//	parent.leftFrame.location.href="/invest/left_e.asp";
//	parent.topFrame.location.href="/invest/top_e.asp";
//end
	//parent.leftFrame.location.reload();
}

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];
        //alert(i + a[i]);
     }
  }
}

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_findObj(n, d) { //v3.0
  //alert("MM_findObj");
  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); 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 check_update_form_e() {
   if(confirm("Are you sure?"))
   {
   	missingRequired = new Boolean(false)
   	notnumeric = new Boolean(false)
   	if (document.ud_profile.WidUwMobile.value.length != 0)
   	{
      		if ((document.ud_profile.WidUwMobile.value.length < 8) && missingRequired == false)
      		{
   	   		missingRequired = true;
   	   		alert("Incorrect format for mobile number. Please check again.");
   	   		document.ud_profile.WidUwMobile.focus();	
      		};
   	}
   
	if ((document.ud_profile.WidUwSMS.checked) && (document.ud_profile.WidUwMobile.value == "") && missingRequired == false)
   	{
   		missingRequired = true;
   		alert("Please enter your mobile number if you select SMS alert.");
   		document.ud_profile.WidUwMobile.focus();	
   	}

   	if (isNull(document.ud_profile.WidUrEmail.value) && missingRequired == false) {
		missingRequired = true;
      	 	alert("Email address is required, please enterd.");
      	 	document.ud_profile.WidUrEmail.focus();
   	} else {
        	if ( check_emailaddress_e(document.ud_profile.WidUrEmail.value) == false && missingRequired == false) {
            		missingRequired = true;
            		//alert("E-mail address is invalid. Please re-enter.");
            		document.ud_profile.WidUrEmail.focus();
         	}
   	}

   	for(var i=0;i<document.ud_profile.WidUwMobile.value.length; i++)
   	{
		var digit=document.ud_profile.WidUwMobile.value.charAt(i)
		if(! (digit>="0" && digit<="9") )
		{
			notnumeric=true;
			missingRequired=true;
		}
   	}
   	if(notnumeric==true)
   		alert("Mobile number should be numeric");

	if (missingRequired == false) {
         if (document.ud_profile.WidUwSMS.checked) {
               //alert("SMS is checked");
   	       //alert(document.new_registration.WidUwCaID.options[document.new_registration.WidUwCaID.selectedIndex].value);

/* NPA 08Mar07
               if(document.ud_profile.WidUwCaID.options[document.ud_profile.WidUwCaID.selectedIndex].value=="1")
               		open_popupWindow("../carrier/smartone", "e")
               else if(document.ud_profile.WidUwCaID.options[document.ud_profile.WidUwCaID.selectedIndex].value=="2")
               		open_popupWindow("../carrier/newworld", "e")
               else if(document.ud_profile.WidUwCaID.options[document.ud_profile.WidUwCaID.selectedIndex].value=="3")
               		open_popupWindow("../carrier/sunday", "e")
               else if(document.ud_profile.WidUwCaID.options[document.ud_profile.WidUwCaID.selectedIndex].value=="4")
               		open_popupWindow("../carrier/1010", "e")
               else if(document.ud_profile.WidUwCaID.options[document.ud_profile.WidUwCaID.selectedIndex].value=="5")
               		open_popupWindow("../carrier/one2free", "e")
               else if(document.ud_profile.WidUwCaID.options[document.ud_profile.WidUwCaID.selectedIndex].value=="6")
               		open_popupWindow("../carrier/orange", "e")
               else if(document.ud_profile.WidUwCaID.options[document.ud_profile.WidUwCaID.selectedIndex].value=="7")
               		open_popupWindow("../carrier/people", "e")
end npa */          		
   	       //open_popupWindow(document.new_registration.WidUwCaID.options[document.new_registration.WidUwCaID.selectedIndex].value, "c")
   	       document.ud_profile.submit();
         }
         else
         	//return false;
         	document.ud_profile.submit();

	}   

//   	if (missingRequired == false) {
//        	document.ud_profile.submit();
//   	}
   }
}


function check_update_form_c() {
  if(confirm("請確定指示"))
  {
   	missingRequired = new Boolean(false)
   	notnumeric = new Boolean(false)
   	if (document.ud_profile.WidUwMobile.value.length != 0)
   	{
      		if ((document.ud_profile.WidUwMobile.value.length < 8) && missingRequired == false)
      		{
           		missingRequired = true;
   	   		alert("手電號碼不可以少於八個數字。");
   	   		document.ud_profile.WidUwMobile.focus();	
      		};
   	}
   
	if ((document.ud_profile.WidUwSMS.checked) && (document.ud_profile.WidUwMobile.value == "") && missingRequired == false)
   	{
   		missingRequired = true;
   		alert("如選用'手機提示'功能﹐請輸入流動電話號碼。");
   		document.ud_profile.WidUwMobile.focus();	
   	}
   
	if (isNull(document.ud_profile.WidUrEmail.value) && missingRequired == false) {
   		missingRequired = true;
      	 	alert("電郵地址格式不正確﹐請再次查閱。");
      	 	document.ud_profile.WidUrEmail.focus();
   	} else {
         	if ( check_emailaddress_c(document.ud_profile.WidUrEmail.value)==false && missingRequired == false) {
            		missingRequired = true;
            		//alert("電子郵箱不正確。");
            		document.ud_profile.WidUrEmail.focus();
         	}
   	}
   
	for(var i=0;i<document.ud_profile.WidUwMobile.value.length; i++)
	{
		var digit=document.ud_profile.WidUwMobile.value.charAt(i)
		if(! (digit>="0" && digit<="9") )
		{
			notnumeric = true;
			missingRequired=true;
		}
   	}
   	if(notnumeric==true)
	   	alert("流動電話號碼不正確﹐請再次查閱 ");

	if (missingRequired == false) {
         if (document.ud_profile.WidUwSMS.checked) {
               //alert("SMS is checked");
   	       //alert(document.new_registration.WidUwCaID.options[document.new_registration.WidUwCaID.selectedIndex].value);
/* NPA 08Mar07
               if(document.ud_profile.WidUwCaID.options[document.ud_profile.WidUwCaID.selectedIndex].value=="1")
               		open_popupWindow("../carrier/smartone", "c")
               else if(document.ud_profile.WidUwCaID.options[document.ud_profile.WidUwCaID.selectedIndex].value=="2")
               		open_popupWindow("../carrier/newworld", "c")
               else if(document.ud_profile.WidUwCaID.options[document.ud_profile.WidUwCaID.selectedIndex].value=="3")
               		open_popupWindow("../carrier/sunday", "c")
               else if(document.ud_profile.WidUwCaID.options[document.ud_profile.WidUwCaID.selectedIndex].value=="4")
               		open_popupWindow("../carrier/1010", "c")
               else if(document.ud_profile.WidUwCaID.options[document.ud_profile.WidUwCaID.selectedIndex].value=="5")
               		open_popupWindow("../carrier/one2free", "c")
               else if(document.ud_profile.WidUwCaID.options[document.ud_profile.WidUwCaID.selectedIndex].value=="6")
               		open_popupWindow("../carrier/orange", "c")
               else if(document.ud_profile.WidUwCaID.options[document.ud_profile.WidUwCaID.selectedIndex].value=="7")
               		open_popupWindow("../carrier/people", "c")
end npa */               		
   	       //open_popupWindow(document.new_registration.WidUwCaID.options[document.new_registration.WidUwCaID.selectedIndex].value, "c")
   	       document.ud_profile.submit();
         }
         else
         	//return false;
         	document.ud_profile.submit();
         
	}


//   	if (missingRequired == false) {
//         	document.ud_profile.submit();
//   	}
  }
}

function change_chart_info_c(input)
{

   missingRequired = new Boolean(false)

   if (isNull(document.stock_info.WidCoID.value) && isNull(document.stock_info.WidCoAbbName.value)) {
   	 missingRequired = true;
      	 alert("請輸入代號或上市公司名稱.");
      	 document.stock_info.WidCoID.focus();
   }
   
   if (check_number(document.stock_info.WidCoID.value)==false)
   {
   	missingRequired = true;
   	alert("“股份代號”錯誤。");
   	document.stock_info.WidCoID.focus();
   }

   if (missingRequired == false) {
      if (input == "profile") {
//   	location.href = "profile_page_c.asp?WidCoID=" + escape(document.stock_info.WidCoID.value) + "&WidCoAbbName=" + escape(document.stock_info.WidCoAbbName.value)+"&langcode=c";

// site revamp 09
//	document.frmGotoUrl.action = "/invest/company/profile_page_c.asp";
	document.frmGotoUrl.action = "profile_page_c.asp";	
//
	document.frmGotoUrl.WidCoID.value = document.stock_info.WidCoID.value;
	document.frmGotoUrl.WidCoAbbName.value = document.stock_info.WidCoAbbName.value;
	document.frmGotoUrl.langcode.value = "c";
	document.frmGotoUrl.submit();
      } else if (input == "quote") {
//      	location.href = "quote_page_c.asp?WidCoID=" + escape(document.stock_info.WidCoID.value) + "&WidCoAbbName=" + escape(document.stock_info.WidCoAbbName.value) + "&Month=1&langcode=c";


// site revamp 09
//	document.frmGotoUrl.action = "/invest/company/quote_page_c.asp";
	document.frmGotoUrl.action = "quote_page_c.asp";	
//
	
	document.frmGotoUrl.WidCoID.value = document.stock_info.WidCoID.value;
	document.frmGotoUrl.WidCoAbbName.value = document.stock_info.WidCoAbbName.value;
	document.frmGotoUrl.Month.value = "1";
	document.frmGotoUrl.langcode.value = "c";
	document.frmGotoUrl.submit();
      } else if (input == "report") {
//        location.href = "report_page_c.asp?WidCoID=" + escape(document.stock_info.WidCoID.value) + "&WidCoAbbName=" + escape(document.stock_info.WidCoAbbName.value) + "&Month=1&langcode=c";
// site revamp 09
	//document.frmGotoUrl.action = "/invest/company/report_page_c.asp";
	document.frmGotoUrl.action = "report_page_c.asp";	
//
	document.frmGotoUrl.WidCoID.value = document.stock_info.WidCoID.value;
	document.frmGotoUrl.WidCoAbbName.value = document.stock_info.WidCoAbbName.value;
	document.frmGotoUrl.Month.value = "1";
	document.frmGotoUrl.langcode.value = "c";
	document.frmGotoUrl.submit();
      } else if (input == "chart") {
//      	location.href = "chart_page_c.asp?WidCoID=" + escape(document.stock_info.WidCoID.value) + "&WidCoAbbName=" + escape(document.stock_info.WidCoAbbName.value) + "&Month=3&langcode=c";
//site revamp 09
//	document.frmGotoUrl.action = "/invest/company/chart_page_c.asp";
	document.frmGotoUrl.action = "chart_page_c.asp";	
//	
	
	document.frmGotoUrl.WidCoID.value = document.stock_info.WidCoID.value;
	document.frmGotoUrl.WidCoAbbName.value = document.stock_info.WidCoAbbName.value;
	document.frmGotoUrl.Month.value = "3";
	document.frmGotoUrl.langcode.value = "c";
	document.frmGotoUrl.submit();
      } else if (input == "intraday") {
//      	 location.href = "intradaychart_page_c.asp?WidCoID=" + escape(document.stock_info.WidCoID.value) + "&WidCoAbbName=" + escape(document.stock_info.WidCoAbbName.value) + "&Month=1&langcode=c";
//site revamp 09
//	document.frmGotoUrl.action = "/invest/company/intradaychart_page_c.asp";
	document.frmGotoUrl.action = "intradaychart_page_c.asp";
//		
	document.frmGotoUrl.WidCoID.value = document.stock_info.WidCoID.value;
	document.frmGotoUrl.WidCoAbbName.value = document.stock_info.WidCoAbbName.value;
	document.frmGotoUrl.Month.value = "1";
	document.frmGotoUrl.langcode.value = "c";
	document.frmGotoUrl.submit();
      } else {
   	alert("請撰擇股票資料。");
      }
   }
      
}

function change_chart_info_e(input)
{

   missingRequired = new Boolean(false)

   if (isNull(document.stock_info.WidCoID.value) && isNull(document.stock_info.WidCoAbbName.value)) {
   	 missingRequired = true;
      	 alert("Please enter stock code or company name to search for company information.");
      	 document.stock_info.WidCoID.focus();
   }
   
   if (check_number(document.stock_info.WidCoID.value)==false)
   {
   	missingRequired = true;
   	alert("Invalid stock code.");
   	document.stock_info.WidCoID.focus();
   }

   if (missingRequired == false) {
      if (input == "profile") {
//	location.href = "profile_page_e.asp?WidCoID=" + escape(document.stock_info.WidCoID.value) + "&WidCoAbbName=" + escape(document.stock_info.WidCoAbbName.value)+"&langcode=e";
	document.frmGotoUrl.action = "profile_page_e.asp";
	document.frmGotoUrl.WidCoID.value = document.stock_info.WidCoID.value;
	document.frmGotoUrl.WidCoAbbName.value = document.stock_info.WidCoAbbName.value;
	document.frmGotoUrl.langcode.value = "e";
	document.frmGotoUrl.submit();
      } else if (input == "quote") {
//	 location.href = "quote_page_e.asp?WidCoID=" + escape(document.stock_info.WidCoID.value) + "&WidCoAbbName=" + escape(document.stock_info.WidCoAbbName.value) + "&Month=1&langcode=e";
	document.frmGotoUrl.action = "quote_page_e.asp";
	document.frmGotoUrl.WidCoID.value = document.stock_info.WidCoID.value;
	document.frmGotoUrl.WidCoAbbName.value = document.stock_info.WidCoAbbName.value;
	document.frmGotoUrl.Month.value = "1";
	document.frmGotoUrl.langcode.value = "e";
	document.frmGotoUrl.submit();
      } else if (input == "report") {
// 	 location.href = "report_page_e.asp?WidCoID=" + escape(document.stock_info.WidCoID.value) + "&WidCoAbbName=" + escape(document.stock_info.WidCoAbbName.value) + "&Month=1&langcode=e";
	document.frmGotoUrl.action = "report_page_e.asp";
	document.frmGotoUrl.WidCoID.value = document.stock_info.WidCoID.value;
	document.frmGotoUrl.WidCoAbbName.value = document.stock_info.WidCoAbbName.value;
	document.frmGotoUrl.Month.value = "1";
	document.frmGotoUrl.langcode.value = "e";
	document.frmGotoUrl.submit();
      } else if (input == "chart") {
//	location.href = "chart_page_e.asp?WidCoID=" + escape(document.stock_info.WidCoID.value) + "&WidCoAbbName=" + escape(document.stock_info.WidCoAbbName.value) + "&Month=3&langcode=e";
	document.frmGotoUrl.action = "chart_page_e.asp";
	document.frmGotoUrl.WidCoID.value = document.stock_info.WidCoID.value;
	document.frmGotoUrl.WidCoAbbName.value = document.stock_info.WidCoAbbName.value;
	document.frmGotoUrl.Month.value = "3";
	document.frmGotoUrl.langcode.value = "e";
	document.frmGotoUrl.submit();
      } else if (input == "intraday") {
//      	 location.href = "intradaychart_page_e.asp?WidCoID=" + escape(document.stock_info.WidCoID.value) + "&WidCoAbbName=" + escape(document.stock_info.WidCoAbbName.value) + "&Month=1&langcode=e";
	document.frmGotoUrl.action = "intradaychart_page_e.asp";
	document.frmGotoUrl.WidCoID.value = document.stock_info.WidCoID.value;
	document.frmGotoUrl.WidCoAbbName.value = document.stock_info.WidCoAbbName.value;
	document.frmGotoUrl.Month.value = "1";
	document.frmGotoUrl.langcode.value = "e";
	document.frmGotoUrl.submit();
      } else {
   	 alert("Please choose a stock information from the menu.");
      }
   }
      
}

function change_chart(input, WidCoID, WidCoAbbName, Month, language)
{
   location.href = input + "?WidCoID=" + escape(WidCoID) + "&Month=" + Month + "&langcode=" + language

}

function retrieve_quote()
{
	//alert('retrieve quote:' + document.stock_info.WidCoID.value + ', ' + document.stock_info.WidCoAbbName.value);
	//location.href = "stkquote_pro_e.asp?WidCoID=" + document.stock_info.WidCoID.value + "&WidCoAbbName=" + document.stock_info.WidCoAbbName.value;
	location.href = "stkquote_pro_e.asp?WidCoID=" + document.stock_info.WidCoID.value + "&WidCoAbbName=" + document.stock_info.WidCoAbbName.value
}

function retrieve_chart()
{
	//alert('retrieve chart:' + document.stock_info.WidCoID.value + ', ' + document.stock_info.WidCoAbbName.value);
	location.href = "3mth_pro_e.asp?WidCoID=" + document.stock_info.WidCoID.value + "&WidCoAbbName=" + document.stock_info.WidCoAbbName.value
}

function retrieve_news()
{
	//alert('retrieve news:' + document.stock_info.WidCoID.value + ', ' + document.stock_info.WidCoAbbName.value);
	location.href = "retrieve_quote.asp?WidCoID=" + document.stock_info.WidCoID.value + "&WidCoAbbName=" + document.stock_info.WidCoAbbName.value
}

function retrieve_profile()
{
	//alert('retrieve profile:' + document.stock_info.WidCoID.value + ', ' + document.stock_info.WidCoAbbName.value);
	location.href = "profile_pro_e.asp?WidCoID=" + document.stock_info.WidCoID.value + "&WidCoAbbName=" + document.stock_info.WidCoAbbName.value
}

function isDigit(input)
{
	var digit = "0123456789";
	for (var i = 0; i < digit.length; i++)
	{
		if (input == digit.charAt(i)) return true;
	}
	return false;
}
	
function check_sign(thisform)
{
  var email = thisform.update.value

  if(email.indexOf("@") == -1)
    alert("Incorrect format for email address. Please check again.");
  else
    thisform.submit();

}

function isNull(obj) 
{
	if (obj == "")
		return true;
	else
		return false;
}


function check_forgot_form_e() {

   missingRequired = new Boolean(false)
   
   if (check_emailaddress_e(document.pass.WidUrEmail.value) == false)
   {
   	missingRequired = true;
   	//alert("Incorrect format for email address. Please check again.");
   	document.pass.WidUrEmail.focus();
   }

   if (missingRequired == false) {
     	document.pass.submit();
   }
}


function check_forgot_form_c() {


   missingRequired = new Boolean(false)
   
   if (check_emailaddress_c(document.pass.WidUrEmail.value) == false)
   {
   	missingRequired = true;
   	//alert("電郵地址格式不正確﹐請再次查閱。");
   	document.pass.WidUrEmail.focus();
   }

   if (missingRequired == false) {
     	document.pass.submit();
   }
}


function check_login_name_e(str) {
	//var str = document.new_registration.WidUwLogin.value
	
        if (str.indexOf(" ") >= 0)
        {
        	alert("Login name does not allow any empty space");
        	return false;
        }
        
	for(var i=0;i<str.length; i++)
	{
		var digit=str.charAt(i)
		if(! ((digit>="0" && digit<="9") || (digit>="a" && digit<="z") || (digit>="A" && digit<="Z") || digit=="_") )
		{
			alert("Login name only accept '0-9','a-z','A-Z'");
			return false;
		}
	}
	return true;
}


function check_login_name_c(str) {
	//alert("check_login_name");
	//var str = document.new_registration.WidUwLogin.value
	
		
        if (str.indexOf(" ") >= 0)
        {
        	alert("用戶名稱格式不正確﹐請再次查閱。");
        	return false;
        }
        
	for(var i=0;i<str.length; i++)
	{
		var digit=str.charAt(i)
		if(! ((digit>="0" && digit<="9") || (digit>="a" && digit<="z") || (digit>="A" && digit<="Z") || digit=="_") )
		{
			alert("用戶名稱只接受 '0-9','a-z','A-Z'");
			return false;
		}
	}
	return true;
}

function check_number(value) {
	var str=value
	for(var i=0;i<str.length; i++)
	{
		var digit=str.charAt(i)
		if(digit<"0" || digit>"9") 
			return false;
	}
	return true;
}

function check_emailaddress_e(value) {
	
	var str0=value
	var str1=str0.split("@")
	
        if (value.indexOf(" ") >= 0)
        {
        	alert("E-mail address does not allow any empty space");
        	return false;
        }
        
	if(str1.length != 2)
	{
		//alert(str.length)
		alert("The format of e-mail address should have '@' symbol, please try again.");
		return false
	}
	else
	{
		//alert("1")
		if(str1[1].charAt(0)==".")
		{
			//alert("invalid");
			alert("E-mail address does not allow '.' in the beginning of your domain");
			return false;
		}
		var str2=str1[1].split(".")
		for(var i=0;i<str2.length;i++)
		{
			if(str2[i].length==0)
			{
				alert("E-mail address does not allow consecutive '.'");
				return false;
			}

		}
		return true;
	}
	return false
}

function check_emailaddress_c(value) {
	
	var str0=value
	var str1=str0.split("@")
	
        if (value.indexOf(" ") >= 0)
        {
        	warning_c +="電郵地址格式不正確﹐請再次查閱。\n";
        	return false;
        }
        
	if(str1.length != 2)
	{
		//alert(str.length)
		warning_c +="電郵地址格式不正確﹐請再次查閱。\n";
		return false
	}
	else
	{
		//alert("1")
		if(str1[1].charAt(0)==".")
		{
			//alert("invalid");
			warning_c +="電郵地址格式不正確﹐請再次查閱。\n";
			return false;
		}
		var str2=str1[1].split(".")
		for(var i=0;i<str2.length;i++)
		{
			if(str2[i].length==0)
			{
				warning_c +="電郵地址格式不正確﹐請再次查閱。\n";
				return false;
			}

		}
		return true;
	}
	return false
}

function check_registration_form_e() {

   missingRequired = new Boolean(false)

/*
   ScArray = new Array(20)
   for (var i = 0; i < 20; i++) {
      if (eval("document.new_registration.WidIsScCode_" + (i + 1) + ".value") != "") {
      	 ScArray[i] = eval("document.new_registration.WidIsScCode_" + (i + 1) + ".value")
      	 //alert("ScArray: " + ScArray[i]);
      	 for (var j = 0; j < i; j++) {
      	    if (ScArray[j] == eval("document.new_registration.WidIsScCode_" + (i + 1) + ".value")) {
               //alert("Equal. array: " + ScArray[j] + " value: " + eval("document.new_registration.WidIsScCode_" + (i + 1) + ".value"));
               alert("Please do not enter duplicated stock code.");
               document.new_registration.WidIsScCode_1.focus();
               missingRequired = true;
            }
         }
      }
   }
   */


   if (check_emailaddress_e(document.new_registration.WidUrEmail.value)==false)
   {
   	missingRequired=true;
   	//alert("Invalid email address input.");
   	document.new_registration.WidUrEmail.focus();
   }
   
   if (check_login_name_e(document.new_registration.WidUwLogin.value)==false) {
   	missingRequired = true;
   	//alert("Incorrect user name format.");
   	document.new_registration.WidUwLogin.focus();
   }
   
/*   
   if (check_number(document.new_registration.WidUwMobile.value)==false)
   {
   	missingRequired = true;
   	alert("Incorrect format for mobile number. Please check again.");
   	document.new_registration.WidUwMobile.focus();
   }

   
   if (document.new_registration.WidUwMobile.value.length != 0)
   {
      if ((document.new_registration.WidUwMobile.value.length < 8) && missingRequired == false)
      {
   	missingRequired = true;
   	alert("Incorrect format for mobile number. Please check again.");
   	document.new_registration.WidUwMobile.focus();	
      }
   }


   if ((document.new_registration.WidUwSMS.checked) && (document.new_registration.WidUwMobile.value == "") && missingRequired == false)
   {
   	missingRequired = true;
   	alert("Please enter your mobile number if you select SMS alert.");
   	document.new_registration.WidUwMobile.focus();	
   }
   
   if ((document.new_registration.WidUwSMS.checked) && (document.new_registration.WidUwCaID.options[document.new_registration.WidUwCaID.selectedIndex].value == "-1") && (missingRequired == false))
   {
   	missingRequired = true;
   	alert("Please select a mobile carrier if you select SMS alert.");
   	document.new_registration.WidUwCaID.focus();	
   }
*/

   if (isNull(document.new_registration.WidUwLogin.value) && missingRequired == false) {
   	 missingRequired = true;
      	 alert("User name is required. Please enter.");
      	 document.new_registration.WidUwLogin.focus();
   }
   
   if ((document.new_registration.WidUrLoID.options[document.new_registration.WidUrLoID.selectedIndex].value == "-1") && missingRequired == false) {
   	 missingRequired = true;
      	 alert("Location is required. Please select.");
      	 document.new_registration.WidUrLoID.focus();
   }
     
   if (isNull(document.new_registration.WidUrEmail.value) && missingRequired == false) {
   	 missingRequired = true;
      	 alert("Email address is required, please enterd.");
      	 document.new_registration.WidUrEmail.focus();
   } else {
         if ((document.new_registration.WidUrEmail.value.indexOf("@") == -1) && missingRequired == false) {
            missingRequired = true;
            alert("E-mail address is invaild. Please re-enter.");
            document.new_registration.WidUrEmail.focus();
         }
   }
   
   if ((document.new_registration.WidUwLanguage.options[document.new_registration.WidUwLanguage.selectedIndex].value == "-1") && missingRequired == false) {
   	 missingRequired = true;
      	 alert("Language is required. Please select.");
      	 document.new_registration.WidUwLanguage.focus();
   }

/*
   if ( (document.new_registration.WidIsScCode_1.value != "" || document.new_registration.WidIsScCode_2.value !="" || document.new_registration.WidIsScCode_3.value != "" || document.new_registration.WidIsScCode_4.value !="" || document.new_registration.WidIsScCode_5.value != "" || document.new_registration.WidIsScCode_6.value !="" || document.new_registration.WidIsScCode_7.value != "" || document.new_registration.WidIsScCode_8.value !="" || document.new_registration.WidIsScCode_9.value != "" || document.new_registration.WidIsScCode_10.value !="" || document.new_registration.WidIsScCode_11.value != "" || document.new_registration.WidIsScCode_12.value !="" || document.new_registration.WidIsScCode_13.value != "" || document.new_registration.WidIsScCode_14.value !="" || document.new_registration.WidIsScCode_15.value != "" || document.new_registration.WidIsScCode_16.value !="" || document.new_registration.WidIsScCode_17.value != "" || document.new_registration.WidIsScCode_18.value !="" || document.new_registration.WidIsScCode_19.value != "" || document.new_registration.WidIsScCode_20.value !="" ) && !document.new_registration.WidUwSMS.checked && !document.new_registration.WidUwEmailAlert.checked )
   {
   	missingRequired = true;
   	alert("Please select either email alert or SMS alert.");
   }
*/
   
   if (missingRequired == false) {
/*
	if (document.new_registration.WidUwSMS.checked) {

/* NPA 08Mar07
               if(document.new_registration.WidUwCaID.options[document.new_registration.WidUwCaID.selectedIndex].value=="1")
               		open_popupWindow("../carrier/smartone", "e")
               else if(document.new_registration.WidUwCaID.options[document.new_registration.WidUwCaID.selectedIndex].value=="2")
               		open_popupWindow("../carrier/newworld", "e")
               else if(document.new_registration.WidUwCaID.options[document.new_registration.WidUwCaID.selectedIndex].value=="3")
               		open_popupWindow("../carrier/sunday", "e")
               else if(document.new_registration.WidUwCaID.options[document.new_registration.WidUwCaID.selectedIndex].value=="4")
               		open_popupWindow("../carrier/1010", "e")
               else if(document.new_registration.WidUwCaID.options[document.new_registration.WidUwCaID.selectedIndex].value=="5")
               		open_popupWindow("../carrier/one2free", "e")
               else if(document.new_registration.WidUwCaID.options[document.new_registration.WidUwCaID.selectedIndex].value=="6")
               		open_popupWindow("../carrier/orange", "e")
               else if(document.new_registration.WidUwCaID.options[document.new_registration.WidUwCaID.selectedIndex].value=="7")
               		open_popupWindow("../carrier/people", "e")
end npa   	       
   	       //open_popupWindow(document.new_registration.WidUwCaID.options[document.new_registration.WidUwCaID.selectedIndex].value, "e")
   	       document.new_registration.submit();
         }
*/

         	//window.open('terms_page_e.asp', 'table','scrollbars=yes,width=500,height=500');
         	document.new_registration.submit();
         	//return false;


         
   }

}


function check_registration_form_c() {

   //alert(document.new_registration.WidIsScCode_1_Na.checked)
   //alert(document.new_registration.WidUwLogin.value);
   //alert(document.new_registration.WidUrLoID.options[document.new_registration.WidUrLoID.selectedIndex].value);
   //alert(document.new_registration.WidUrEmail.value);
   clearform(document.new_registration);
   missingRequired = new Boolean(false)
   /*
   ScArray = new Array(20)
   for (var i = 0; i < 20; i++) {
      if (eval("document.new_registration.WidIsScCode_" + (i + 1) + ".value") != "") {
      	 ScArray[i] = eval("document.new_registration.WidIsScCode_" + (i + 1) + ".value")
      	 //alert("ScArray: " + ScArray[i]);
      	 for (var j = 0; j < i; j++) {
      	    if (ScArray[j] == eval("document.new_registration.WidIsScCode_" + (i + 1) + ".value")) {
               //alert("Equal. array: " + ScArray[j] + " value: " + eval("document.new_registration.WidIsScCode_" + (i + 1) + ".value"));
               alert("請不要輸入相同的股份代號.");
               document.new_registration.WidIsScCode_1.focus();
               missingRequired = true;
            }
         }
      }
   }
   */

   if (isNull(document.new_registration.WidUwLogin.value)) {
   	 missingRequired = true;
      	 warning_c += "請輸入用戶名稱。\n";
		 document.new_registration.WidUwLogin.style.background = "yellow"
      	 document.new_registration.WidUwLogin.focus();
   }
   
   if (check_login_name_c(document.new_registration.WidUwLogin.value)==false) {
   	missingRequired = true;
   	//alert("用戶名稱不正確。");
	document.new_registration.WidUwLogin.style.background = "yellow"
   	document.new_registration.WidUwLogin.focus();
   }
   /*
   if (check_number(document.new_registration.WidUwMobile.value)==false)
   {
   	missingRequired = true;
   	alert("流動電話號碼不正確﹐請再次查閱 ");
   	document.new_registration.WidUwMobile.focus();
   }
 
   
   if (document.new_registration.WidUwMobile.value.length != 0)
   {
      if ((document.new_registration.WidUwMobile.value.length < 8) && missingRequired == false)
      {
   	missingRequired = true;
   	alert("流動電話號碼不正確﹐請再次查閱 ");
   	document.new_registration.WidUwMobile.focus();	
      }
   }

   if ((document.new_registration.WidUwSMS.checked) && (document.new_registration.WidUwMobile.value == "") && missingRequired == false)
   {
   	missingRequired = true;
   	alert("如選用“手機提示”功能﹐請輸入流動電話號碼。");
   	document.new_registration.WidUwMobile.focus();	
   }
   
   if ((document.new_registration.WidUwSMS.checked) && (document.new_registration.WidUwCaID.options[document.new_registration.WidUwCaID.selectedIndex].value == "-1") && (missingRequired == false))
   {
   	missingRequired = true;
   	alert("如選用“手機提示”功能﹐請選擇流動電話供應商。");
   	document.new_registration.WidUwCaID.focus();	
   }
  */

   if ((document.new_registration.WidUrLoID.options[document.new_registration.WidUrLoID.selectedIndex].value == "-1")) {
   	 missingRequired = true;
      	 warning_c += "必須揀選地區一攔。\n";
		 document.new_registration.WidUrLoID.style.background = "yellow"
      	 document.new_registration.WidUrLoID.focus();
   }
     
   if (isNull(document.new_registration.WidUrEmail.value)) {
   	 missingRequired = true;
      	 warning_c +="請輸入電郵地址。\n";
		 document.new_registration.WidUrEmail.style.background = "yellow"
      	 document.new_registration.WidUrEmail.focus();
   } else {
         if ((document.new_registration.WidUrEmail.value.indexOf("@") == -1)) {
            missingRequired = true;
			document.new_registration.WidUrEmail.style.background = "yellow"
            warning_c +="電郵地址格式不正確﹐請再次查閱。\n";
            document.new_registration.WidUrEmail.focus();
         }
	 else
         if (check_emailaddress_c(document.new_registration.WidUrEmail.value)==false)
	 {
            missingRequired=true;
           //alert("電子郵箱不正確。");
           document.new_registration.WidUrEmail.style.background = "yellow"
           document.new_registration.WidUrEmail.focus();
         }
   }
   
   
   if ((document.new_registration.WidUwLanguage.options[document.new_registration.WidUwLanguage.selectedIndex].value == "-1")) {
   	 missingRequired = true;
      	 warning_c +="請選擇語言。\n";
		 document.new_registration.WidUwLanguage.style.background = "yellow"
      	 document.new_registration.WidUwLanguage.focus();
   }
   
/*
   if (document.new_registration.WidUwEmailAlert.checked && isNull(document.new_registration.WidUwMobile.value) && (missingRequired == false)    ) {
   	 missingRequired = true;
      	 alert("Please enter your mobile number and subscribed mobile carrier if you choose to use E-mail alert.");
      	 document.new_registration.WidUwMobile.focus();
   }*/
/*   if ((((document.new_registration.MeansOfAlert.options[document.new_registration.MeansOfAlert.selectedIndex].value == "1") || (document.new_registration.MeansOfAlert.options[document.new_registration.MeansOfAlert.selectedIndex].value == "3")) && (document.new_registration.WidUwCaID.options[document.new_registration.WidUwCaID.selectedIndex].value == "-1")) && (missingRequired == false)) {
   	 missingRequired = true;
      	 alert("Please enter your subscribed mobile carrier if you choose to use SMS alert.");
      	 document.new_registration.WidUwMobile.focus();
   }*/
/*
   if ( (document.new_registration.WidIsScCode_1.value != "" || document.new_registration.WidIsScCode_2.value !="" || document.new_registration.WidIsScCode_3.value != "" || document.new_registration.WidIsScCode_4.value !="" || document.new_registration.WidIsScCode_5.value != "" || document.new_registration.WidIsScCode_6.value !="" || document.new_registration.WidIsScCode_7.value != "" || document.new_registration.WidIsScCode_8.value !="" || document.new_registration.WidIsScCode_9.value != "" || document.new_registration.WidIsScCode_10.value !="" || document.new_registration.WidIsScCode_11.value != "" || document.new_registration.WidIsScCode_12.value !="" || document.new_registration.WidIsScCode_13.value != "" || document.new_registration.WidIsScCode_14.value !="" || document.new_registration.WidIsScCode_15.value != "" || document.new_registration.WidIsScCode_16.value !="" || document.new_registration.WidIsScCode_17.value != "" || document.new_registration.WidIsScCode_18.value !="" || document.new_registration.WidIsScCode_19.value != "" || document.new_registration.WidIsScCode_20.value !="" ) && !document.new_registration.WidUwSMS.checked && !document.new_registration.WidUwEmailAlert.checked )
   {
   	missingRequired = true;
   	alert("您必須選擇電郵提示或流動電話提示.");
   }
*/

   if (missingRequired == false) {
       /* if (document.new_registration.WidUwSMS.checked) {
 NPA 08Mar07
               if(document.new_registration.WidUwCaID.options[document.new_registration.WidUwCaID.selectedIndex].value=="1")
               		open_popupWindow("../carrier/smartone", "c")
               else if(document.new_registration.WidUwCaID.options[document.new_registration.WidUwCaID.selectedIndex].value=="2")
               		open_popupWindow("../carrier/newworld", "c")
               else if(document.new_registration.WidUwCaID.options[document.new_registration.WidUwCaID.selectedIndex].value=="3")
               		open_popupWindow("../carrier/sunday", "c")
               else if(document.new_registration.WidUwCaID.options[document.new_registration.WidUwCaID.selectedIndex].value=="4")
               		open_popupWindow("../carrier/1010", "c")
               else if(document.new_registration.WidUwCaID.options[document.new_registration.WidUwCaID.selectedIndex].value=="5")
               		open_popupWindow("../carrier/one2free", "c")
               else if(document.new_registration.WidUwCaID.options[document.new_registration.WidUwCaID.selectedIndex].value=="6")
               		open_popupWindow("../carrier/orange", "c")
               else if(document.new_registration.WidUwCaID.options[document.new_registration.WidUwCaID.selectedIndex].value=="7")
               		open_popupWindow("../carrier/people", "c")               		
end NPA 08Mar07 
   	       //open_popupWindow(document.new_registration.WidUwCaID.options[document.new_registration.WidUwCaID.selectedIndex].value, "c")

   	       document.new_registration.submit();
         }
         else*/
         	//return false;
         	document.new_registration.submit();
         
   }
   if (warning_c != "")
	alert(warning_c);
   warning_c ="";
}

function open_popupWindow(value, language)
{
	var theURL=value + "_page_" + language + ".asp"
	MM_openBrWindow(theURL,'temp','resizable=yes,width=550,height=500');
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function check_registration_form_submit()
{
	document.new_registration.submit();
}

function clearform(form)
{
	var form_elements = form.elements; 
	for (i = 0; i < form_elements.length; i++)  
	{  
		field_type = form_elements[i].type.toLowerCase();  
		switch (field_type)  
		{  
		case "text":  
		case "password":  
		case "textarea":  
		case "hidden":    
		case "radio":  
		case "checkbox":  
		case "select-one": 
			form_elements[i].style.background = "White";  
			break;  
		default:  
			break;  
		}  
    }  

}
