 
    if (navigator.cookieEnabled == 0) {
      alert("You need to enable cookies for this site to load properly!");
    }
        
    var myAgency=new Array("AD Travel","Apple Holidays","Concepts Travel","Creative Tours","CS Travel","Executive Travel","Fairworld","Flying Eagle","Gasi Travel","Giamso Travel","Ho Wah Travel","Kingdom Travel","Kong Sam Ho","Lotus Travel","Pegasus Travel","Ren Ren Travel","Sunshine Travel","Travel 8","Travel Holidays","Travelhub","Travelmart","Travelstar","UOBTP");    
       
    function validate_form ( )
    {
        if ( document.login_form.LName.value == "" )
        {
            alert ( "Please fill in the 'Your Name' box." );
            document.login_form.LName.focus();
            return false;
        }
        if ( document.login_form.LPassword.value == "" )
        {
            alert ( "Please fill in the 'Your Password' box." );
            document.login_form.LPassword.focus();
            return false;
        }
        if (document.login_form.LName.value != "" && document.login_form.LPassword.value != "" )
        {
            if ( document.login_form.LName.value == "Guest" && document.login_form.LPassword.value == "Seminar" ) 
            {
                setCookie('username',document.login_form.LName.value,365);
                return true;
            }
            else
            {
                alert ( "Invalid Login Name Or Password." );
                return false;
            }
        }
        return false;
    }
    

    function validate_form2 ( )
    {
        /*
        if ( document.getElementById("cmbAgencyName").selectedIndex == "0" )
        {
            alert ( "Please Select your Agency Name." );            
            return false;
        }
        *
        /*
        else{
            alert(document.getElementById("cmbAgencyName").options[document.getElementById("cmbAgencyName").selectedIndex].value);
            return false;
        }
        */
        
        if ( document.getElementById("txtContactPerson").value == "" )
        {
            alert ( "Please Enter Contact Person." );
            document.personalInfo_form.txtContactPerson.focus();
            return false;
        } 
        
        if ( document.getElementById("txtContactNo").value == "" )
        {
            alert ( "Please Enter your Contact No." );
            document.personalInfo_form.txtContactNo.focus();
            return false;
        } 
             
        var emailID=document.getElementById("txtEmail")
        if ((emailID.value==null)||(emailID.value==""))
        {
		    alert("Please Enter your Email ID.");
		    emailID.focus();
		    return false;
	    }
	    if (echeck(emailID.value)==false)
	    {
		    emailID.value="";
		    emailID.focus();
		    return false;
	    }             
        
        
        /*if (document.getElementById("cmbAgencyName").selectedIndex != "" && document.getElementById("txtContactNo").value != "" && document.getElementById("txtEmail").value != "" )*/
        if (document.getElementById("txtContactPerson").value != "" && document.getElementById("txtContactNo").value != "" && document.getElementById("txtEmail").value != "" )
        {
            //setCookie('agencyName@',document.getElementById("cmbAgencyName").options[document.getElementById("cmbAgencyName").selectedIndex].value,365);
            setCookie('contactPerson@',document.getElementById("txtContactPerson").value,365);
            setCookie('contactNo@',document.getElementById("txtContactNo").value,365);
            setCookie('email@',document.getElementById("txtEmail").value,365);
            return true;            
        }    
        return false;
    }    

    function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
	
    function validate_form3 ( )
    {
        if ( document.getElementById('chk0').checked ) 
        {
           if ( document.getElementById("txtWS_chk0").value == "" )
            {
                alert ( "Please fill in the 'No. of WorkStations' box." );
                document.getElementById("txtWS_chk0").focus();
                return false;
            }
            else
            {
                if (!IsNumeric(document.getElementById("txtWS_chk0").value))
                {
                    alert ( "Please fill Numeric value in the 'No. of WorkStations' box." );
                    document.getElementById("txtWS_chk0").focus();
                    return false;
                }                
            }
        }        
        if ( document.getElementById('chk1').checked ) 
        {
           if ( document.getElementById("txtWS_chk1").value == "" )
            {
                alert ( "Please fill in the 'No. of WorkStations' box." );
                document.getElementById("txtWS_chk1").focus();
                return false;
            }  
            else
            {
                if (!IsNumeric(document.getElementById("txtWS_chk1").value))
                {
                    alert ( "Please fill Numeric value in the 'No. of WorkStations' box." );
                    document.getElementById("txtWS_chk1").focus();
                    return false;
                }                
            }
        }      
        if ( document.getElementById('chk2').checked ) 
        {
           if ( document.getElementById("txtWS_chk2").value == "" )
            {
                alert ( "Please fill in the 'No. of WorkStations' box." );
                document.getElementById("txtWS_chk2").focus();
                return false;
            }
            else
            {
                if (!IsNumeric(document.getElementById("txtWS_chk2").value))
                {
                    alert ( "Please fill Numeric value in the 'No. of WorkStations' box." );
                    document.getElementById("txtWS_chk2").focus();
                    return false;
                }                
            }              
        }      
        if ( document.getElementById('chk3').checked ) 
        {
           if ( document.getElementById("txtWS_chk3").value == "" )
            {
                alert ( "Please fill in the 'No. of WorkStations' box." );
                document.getElementById("txtWS_chk3").focus();
                return false;
            } 
            else
            {
                if (!IsNumeric(document.getElementById("txtWS_chk3").value))
                {
                    alert ( "Please fill Numeric value in the 'No. of WorkStations' box." );
                    document.getElementById("txtWS_chk3").focus();
                    return false;
                }                
            } 
        }      
        if ((!document.getElementById('chk0').checked) && (!document.getElementById('chk1').checked) && (!document.getElementById('chk2').checked) && (!document.getElementById('chk3').checked))
        {
            alert("No boxes checked!");
            return false;
        }
        else
        {
           // location.href="thanks_email.asp";
           return true;
        }
       
        return false;
    }   
    
    function IsNumeric(sText)
    {
       var ValidChars = "0123456789";
       var IsNumber=true;
       var Char;
     
       for (i = 0; i < sText.length && IsNumber == true; i++) 
          { 
            Char = sText.charAt(i); 
            if (ValidChars.indexOf(Char) == -1) 
            {
                IsNumber = false;
            }
          }
        return IsNumber;       
    }
    
    
    function check_uncheck(chkId, selId) 
    {
    	var chkObj = document.getElementById(chkId);
    	var selObj = document.getElementById(selId);
    	
    	if( chkObj.checked )
    	{	     
	        selObj.readOnly = false;
	        selObj.focus();
	    }
	    else
	    {	        
	        selObj.value = "";
	        selObj.readOnly = true;	        
	    }
    }
    
    function getCookie(c_name)
    {
    if (document.cookie.length>0)
      {
      c_start=document.cookie.indexOf(c_name + "=");
      if (c_start!=-1)
        {
        c_start=c_start + c_name.length+1;
        c_end=document.cookie.indexOf(";",c_start);
        if (c_end==-1) c_end=document.cookie.length;
        return unescape(document.cookie.substring(c_start,c_end));
        }
      }
    return "";
    }

    function setCookie(c_name,value,expiredays)
    {
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    //document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
    document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "");
    }
    
    function gup( name )
    {
      name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
      var regexS = "[\\?&]"+name+"=([^&#]*)";
      var regex = new RegExp( regexS );
      var results = regex.exec( window.location.href );
      if( results == null )
        return "";
      else
        return results[1];
    }
    
    function include(arr, obj) {
      for(var i=0; i<arr.length; i++) {
        if (arr[i] == obj) return true;
      }
      return false;
    }

    function redirectGDSPage()
    {
        var ln_param = num_to_str(gup( 'ln' ));
        var lp_param = num_to_str(gup( 'lp' ));
        var la_param = num_to_str(gup( 'la' ));   
        
        if ( ln_param == "Guest" && lp_param == "Seminar" && include(myAgency,la_param))
        {
            setCookie('username',ln_param,365);
            setCookie('agencyName@',la_param,365);  
            window.location = "memberSurvey.html";  
        }
        else
        {
            window.location = "index.html";          
        }
    }
    
    
    function checkCookie()
    {
    
    username=getCookie('username');
    if (username!=null && username!="")
      {        
	    document.getElementById("LoginForm").style.visibility="hidden";
	    document.getElementById("LogoutForm").style.visibility="visible";
        //alert('Welcome '+username+'!');
        
        var sPath = window.location.pathname;
        var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
        sPage = sPage.toUpperCase();
        if ( sPage.indexOf("MEMBERINFO.HTML") != -1 )
        {
            agencyName=getCookie('agencyName@');
            if (agencyName!=null && agencyName!="")
            {
                document.getElementById("gdslink").style.visibility="visible";
            }
            else
            {
                document.getElementById("gdslink").style.visibility="hidden";
            }                      
        }  
        if ( sPage.indexOf("MEMBERSURVEY.HTML") != -1 )
        {
            agencyName=getCookie('agencyName@');
            if (agencyName!=null && agencyName!="")
            {
               document.getElementById("lblAgencyName").innerHTML = agencyName;
               
               contactPerson=getCookie('contactPerson@');
               if (contactPerson!=null && contactPerson!="")
               {
                document.getElementById("txtContactPerson").value = contactPerson;
               }
               
               contactNo=getCookie('contactNo@');
               if (contactNo!=null && contactNo!="")
               {
                document.getElementById("txtContactNo").value = contactNo;
               }
               
               username2=getCookie('email@');
               if (username2!=null && username2!="")
               {
                document.getElementById("txtEmail").value = username2;
               }               
               
            }
            else
            {
               window.location = "memberInfo.html";
            }                      
        }      
        if ( sPage.indexOf("GDSTOOLS.HTML") != -1 )
        {
            agencyName=getCookie('agencyName@');
            username=getCookie('contactPerson@');
            username1=getCookie('contactNo@');
            username2=getCookie('email@');
            if ( agencyName!=null && agencyName!="" && username!=null && username!="" && username1!=null && username1!="" && username2!=null && username2!="")            
            {
               document.getElementById("lblAgencyName").innerHTML = agencyName;
               document.getElementById("Hid_lblAgencyName").value = agencyName;
               
               document.getElementById("lblContactPerson").innerHTML = username;
               document.getElementById("Hid_lblContactPerson").value = username;
               
               document.getElementById("lblContactNo").innerHTML = username1;
               document.getElementById("Hid_lblContactNo").value = username1;
               
               document.getElementById("lblEmail").innerHTML = username2;
               document.getElementById("Hid_lblEmail").value = username2;
            }
            else
            {
               window.location = "memberSurvey.html";
            }                      
        } 
      }
    else
      {
        var sPath = window.location.pathname;
        var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
        sPage = sPage.toUpperCase();
        
                     
        if ( sPage.indexOf("MEMBERINFO.HTML") != -1 || sPage.indexOf("TRAININGCOURSES.HTML") != -1 || sPage.indexOf("FAQ.HTML") != -1 || sPage.indexOf("MEMBERSURVEY.HTML") != -1 || sPage.indexOf("GDSTOOLS.HTML") != -1 || sPage.indexOf("MAIL.PHP") != -1)
        {
            window.location = "index.html";
        }        
        else
        {
            document.getElementById("LoginForm").style.visibility="visible";
	        document.getElementById("LogoutForm").style.visibility="hidden";              
        }       
     
      //username=prompt('Please enter your name:',"");
      //if (username!=null && username!=""){ setCookie('username',username,365);}
      }
    }
    
    
    function backPage()
    {
        window.location = "memberInfo.html";
    }
    
    function clearCookie()
    {
        var mydate = new Date();
        mydate.setTime(mydate.getTime() - 1);
        document.cookie = "username=; expires=" + mydate.toGMTString();
        
        document.cookie = "agencyName@=; expires=" + mydate.toGMTString(); 
        document.cookie = "contactPerson@=; expires=" + mydate.toGMTString(); 
        document.cookie = "contactNo@=; expires=" + mydate.toGMTString();
        document.cookie = "email@=; expires=" + mydate.toGMTString();
         
        checkCookie();
    }
    
    function clearFormCookie()
    {
        var mydate = new Date();
        mydate.setTime(mydate.getTime() - 1);
        document.cookie = "contactPerson@=; expires=" + mydate.toGMTString(); 
        document.cookie = "contactNo@=; expires=" + mydate.toGMTString();
        document.cookie = "email@=; expires=" + mydate.toGMTString();
        checkCookie();
    }


    
/*  
The JavaScript Source: Password Protection: Character Encoder  
http://javascript.internet.com/passwords/character-encoder.html

<!-- Original:  Mike McGrath (mike_mcgrath@lineone.net) -->
<!-- Web Site:  http://website.lineone.net/~mike_mcgrath/ -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
*/

        var str_in;
        var str_out = ""; 
        var num_in;
        var num_out = "";
        var e = "";

        function str_to_num(input_value) {
        num_out = "";
        if(input_value == "") return e;
        else {
        str_in = escape(input_value);
        for(i = 0; i < str_in.length; i++) {
        num_out += str_in.charCodeAt(i) - 23;
        }
        return num_out;        
           }
        }

        function num_to_str(output_value) {
        str_out = "";
        if(output_value == "") return e;
        else {
        num_out = output_value;  
        for(i = 0; i < num_out.length; i += 2) {
        num_in = parseInt(num_out.substr(i,[2])) + 23;
        num_in = unescape('%' + num_in.toString(16));
        str_out += num_in;
        }
        return unescape(str_out);        
           }
        }

