
warn_firstname   = "";
warn_lastname    = "";
warn_fullname    = "";
warn_company    = "";
warn_qib    = "";

warn_email       = "";
warn_phone       = "";
warn_address     = "";
warn_city        = "";
warn_zip		 = "";
warn_country     = "";
warn_autobiography ="";
//in job application form
warn_position       = "";
warn_salary       = "";
warn_experience ="";
warn_resume ="";
warn_gender       = "";
warn_birthday ="";
warn_cell ="";

getInputData();
//invalidMessage ();

function getInputData() {
	queryString = this.location.href;
	separator = queryString.indexOf('?');
	queryString = queryString.substring(separator + 1);
	if (separator > 0)
	{
		_query_string = queryString;
	}
	text1 = "&";
	strLength = queryString.length;
	txtLength = text1.length;

	i = queryString.indexOf(text1);

	while (i+txtLength < strLength) {
		if (i > 0) {
			splitString(queryString.substring(0,i),"=");
		} else {
			splitString(queryString,"=");
		}
		queryString = queryString.substring(i+txtLength,strLength);
		i = queryString.indexOf(text1);
		if (i < 1) {
			i = strLength + 1;
		}
	}
	splitString(queryString,"=");

	if (separator > 0) {
		containsGetData = true;

		}
	} // end function getInputData()

function splitString(string,text) {
	name = string.substring(0,string.indexOf(text));
	value = string.substring(string.indexOf(text) + 1);
	eval("query_" + name + " = unescape(value);");
}

var mPrefix = "Empty input - "
var mSuffix = " field. This is a required field. Please enter it now."
function warnEmpty (theField, s){  
    alert(mPrefix + s + mSuffix);
}

 
		 
function CheckTWID( twid){
		 var ErrString = "" ;
		 var ID1 = twid.toUpperCase();   
		var IDdigit = new Array(10);
		 for (var i=0; i<10; i++) { IDdigit[i] = ID1.charAt(i); }
		 var CharEng = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		 IDdigit[0]   = CharEng.indexOf(IDdigit[0]);
		 if (IDdigit[0] == -1){
		    alert("身分證字號第一位為錯誤英文字母 !");
		    document.faqForm.ssn.focus();
		    return false;
		 }
		 if (IDdigit[1] !=1 && IDdigit[1] !=2)  {
		    alert("身分證字號無法辨識性別 !");
		    document.faqForm.ssn.focus();
		    return false;
		 }
		 var Array1  = new Array(26);
		 Array1[0]   = 1 ; Array1[1]  = 10; Array1[2]  = 19;
		 Array1[3]   = 28; Array1[4]  = 37; Array1[5]  = 46;
		 Array1[6]   = 55; Array1[7]  = 64; Array1[8]  = 39;
		 Array1[9]   = 73; Array1[10] = 82; Array1[11] = 2 ;
		 Array1[12]  = 11; Array1[13] = 20; Array1[14] = 48;
		 Array1[15]  = 29; Array1[16] = 38; Array1[17] = 47;
		 Array1[18]  = 56; Array1[19] = 65; Array1[20] = 74;
		 Array1[21]  = 83; Array1[22] = 21; Array1[23] = 3 ;
		 Array1[24]  = 12; Array1[25] = 30;
		 var result = Array1[IDdigit[0]];
		 for (var i=1; i<10; i++)		    {
			    var Number = "0123456789";
			    IDdigit[i] = Number.indexOf(IDdigit[i]);
			    if (IDdigit[i] == -1)		      {
			      alert("身分證字號錯誤 !");
			      document.faqForm.ssn.focus();
			      return false;
			    }
			    else {		 result += IDdigit[i] * (9-i);		 }
		  }
		
		  result += 1 * IDdigit[9];
		  //alert(result);
		  if (result % 10 != 0)		    {
		         alert("身分證字號錯誤 !");
				 document.faqForm.ssn.focus();
		         return false;
		  }		   
		  else{return true;}
}
function invalidMessage (inForm) {
    if( (!isSignedInteger(document.faqForm.phone.value, false)) || 
		(!isSignedInteger(document.faqForm.fax.value, true)) ||
	    (!isEmail(document.faqForm.email.value, false)) || 
	    (!isPositiveInteger(document.faqForm.zip.value, true))    
	 ){
		   if (!isSignedInteger(document.faqForm.phone.value, false))  {
				warn_phone = "Invalid input - Phone Number  are numbers leading + or - allowed only ";
   				alert(warn_phone);
				document.faqForm.phone.focus();	
				return false;}		
		   if (!isSignedInteger(document.faqForm.fax.value, true))  {
				warn_fax = "Invalid input - Fax Number  are numbers leading + or - allowed only ";
   				alert(warn_fax);
				document.faqForm.fax.focus();	
				return false;}		
		   if (!isEmail(document.faqForm.email.value, false))  {
				warn_email = "Invalid input - Not a valid Email Address ";
				alert(warn_email);
				document.faqForm.email.focus();	
				return false;	   }	
		   if(!isPositiveInteger(document.faqForm.zip.value, true)) {
				warn_zip = "Invalid input - Zip Code is Integer only.";
				alert(warn_zip);
				document.faqForm.zip.focus();		
				return false;							   
		   }   				
	}
     else	return true; 
}

function verifyForm (inForm) {			
		if( document.faqForm.fullname.value.length <= 1||							 
            document.faqForm.email.value.length <= 1  ||
			document.faqForm.country.value.length <=1 ||
			document.faqForm.question1.value.length >= 255 ||    
			document.faqForm.question1.value.length <=1){

				if (document.faqForm.fullname.value.length <= 1) {
				    warnEmpty ("document.faqForm.fullname", " Full Name");
					document.faqForm.fullname.focus();	
					return false;
			    }		
											
				if (document.faqForm.email.value.length <=1) {
					warnEmpty ("document.faqForm.email", " Email Address");
					document.faqForm.email.focus();					
					return false;
				}							
			    if(document.faqForm.country.value.length <=1 ){
					warnEmpty ("document.faqForm.country", " Country");
					document.faqForm.country.focus();					
					return false;
				}			
				if (document.faqForm.question1.value.length <1) {
					warnEmpty ("document.faqForm.question1", " Question");
					 document.faqForm.question1.focus();	
					return false;
				}
				if (document.faqForm.question1.value.length >=255) {
				    alert("Invalid Input -  Question is letters less than 255");
					document.faqForm.question1.focus();	
					document.faqForm.question1.select();						
					return false;
			    }	

		}		
		else if (document.faqForm.morequestion.checked == true && (document.faqForm.question2.value.length >= 255 ||    
			 document.faqForm.question2.value.length <=1) ){
			   if (document.faqForm.question2.value.length <=1) {
					warnEmpty ("document.faqForm.question2", " Question");
					document.faqForm.question2.focus();	
					return false;
				}
				if (document.faqForm.question2.value.length >=255) {
				    alert("Invalid Input -  Question is letters less than 255");
					document.faqForm.question2.focus();	
					document.faqForm.question2.select();				
					return false;
			    }			
		
		}
		 else	return true; 
} // end function verifyForm

gray = false;


function getHeaderDate () {
	var date = new Date();
	months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
	returnval = date.getYear() +"/"+date.getMonth()+"/"+date.getDate()  ;
	return returnval;

	} // end getHeaderDate()

