﻿// JScript File
function chknewusr(as)
{
    var errormsg="";
    var x=0;
    var msg="Please fill the following fields :-"+"\n\n";
    if(document.getElementById('txt_UserName').value=="")
    {
        document.getElementById('txt_UserName').focus();
        errormsg=errormsg+"Username"+"\n";
        x=1;
    }  
    if(document.getElementById('txt_Password').value=="")
    {
        document.getElementById('txt_Password').focus();
        errormsg=errormsg+"Password"+"\n";
        x=1;
    }
    if(document.getElementById('txt_ConfPassword').value=="")
    {
        document.getElementById('txt_ConfPassword').focus();
        errormsg=errormsg+"Confirm password"+"\n";
        x=1;
    }
    if(document.getElementById('txt_Password').value !=document.getElementById('txt_ConfPassword').value)
    {
        document.getElementById('txt_Password').focus();
        errormsg=errormsg+"Password Mismatch"+"\n";
        x=1;
    }
    if(document.getElementById('txt_FName').value=="")
    {
        document.getElementById('txt_FName').focus();
        errormsg=errormsg+"First name"+"\n";
        x=1;
    }
    if(as=="room")
    {   
        if(document.getElementById('txt_LName').value=="")
        {
            document.getElementById('txt_LName').focus();
            errormsg=errormsg+"Last name"+"\n";
            x=1;
        }
    }    
    if(document.getElementById('txt_Email').value=="")
    {
        document.getElementById('txt_Email').focus();
        errormsg=errormsg+"Email "+"\n";
        x=1;
    }
    if(document.getElementById('txt_Email').value!="")
    {
        var a=document.getElementById('txt_Email').value;
        if(a.indexOf("@")== -1 || a.indexOf(".")== -1)
        {
            document.getElementById('txt_Email').focus();
            errormsg=errormsg+"Email "+"\n";
            x=1;
        }
    }
    if(document.getElementById('txt_Phone').value=="")
    {
        document.getElementById('txt_Phone').focus();
        errormsg=errormsg+"Phone No. "+"\n";
        x=1;
    }
    
    if(document.getElementById('txt_Phone').value!="")
    {
        var b=document.getElementById('txt_Phone').value;
        var a=document.getElementById('txt_Phone').value.length;
        if((a>14) || (a<7))
        {
           document.getElementById('txt_Phone').focus();
           errormsg=errormsg+"Phone No. "+"\n";
           x=1;  
        }
        if(a>0)
        {   
                var c,i,stat=0;  
                for(i=0;i<a;i++)
                {
                    c=b.charAt(i);
                    if (((c < "0") || (c > "9")))
                    {
                        stat=1;
                    }
                }
                if(stat=="1")
                {
                    document.getElementById('txt_Phone').focus();
                    errormsg=errormsg+"Phone No."+"\n";
                    x=1;
                }
                
        }
    }
    if(document.getElementById('txt_Mobile').value=="")
    {
        document.getElementById('txt_Mobile').focus();
        errormsg=errormsg+"Mobile No. "+"\n";
        x=1;
    }
    if(document.getElementById('txt_Mobile').value!="")
    {
        var mob=document.getElementById('txt_Mobile').value;
        var moblen=document.getElementById('txt_Mobile').value.length;
        if((mob.length>14) || (mob.length<10))
        {
            document.getElementById('txt_Mobile').focus();
            errormsg=errormsg+"Mobile No. "+"\n";
            x=1;
        }
        if(moblen>0)
        {   
                var c,i,stat=0;  
                for(i=0;i<moblen;i++)
                {
                    c=mob.charAt(i);
                    if (((c < "0") || (c > "9")))
                    {
                       stat=1; 
                    }
                }
                if(stat=="1")
                {
                        document.getElementById('txt_Mobile').focus();
                        errormsg=errormsg+"Mobile No. "+"\n";
                        x=1;
                }
        }
        
    }
    if(document.getElementById('txt_Address').value=="")
    {
        document.getElementById('txt_Address').focus();
        errormsg=errormsg+"Address"+"\n";
        x=1;
    }
    if(document.getElementById('txt_City').value=="")
    {
        document.getElementById('txt_City').focus();
        errormsg=errormsg+"City"+"\n";
        x=1;
    }
    if(document.getElementById('txt_State').value=="")
    {
        document.getElementById('txt_State').focus();
        errormsg=errormsg+"State"+"\n";
        x=1;
    }
    if(x=="1")
    {
        alert(msg+errormsg); 
        return false;
    }
    else
    {
        return true;
    }
   
}
function chklogin()
{
    var x=0;
    var errormsg="";
    var msg="Please fill the following fields"+"\n\n";
    if(document.getElementById('TxtUsr').value=="")
    {
        errormsg=errormsg+"Username"+"\n";
        x=1;
    }
    if(document.getElementById('TxtPasswd').value=="")
    {
        errormsg=errormsg+"Password"+"\n";
        x=1;
    }
    if(x=="1")
    {
        alert(msg+errormsg);
        document.getElementById('TxtUsr').focus();
        return false;
    }
    else
    {
        return true;    
    }
}
function checktrip()
{  
    if(document.getElementById('RdBtnTwo').checked==true)
    {
        if(document.getElementById('TxtDept').value=="")
        {
            alert("Please enter Depart Date");
            document.getElementById('TxtDept').focus();
            return false;
        }
        if(document.getElementById('TxtRetrn').value=="")
        {
            alert("Please enter Return Date");
            document.getElementById('TxtRetrn').focus();
            return false;
        }
    }
    else if(document.getElementById('RdBtnOne').checked==true)
    {
        if(document.getElementById('TxtDept').value=="")
        {
            alert("Please enter Depart Date");
            document.getElementById('TxtDept').focus();
            return false;
        }
    }
    return true;
}
function chktrain()
{
    if(document.getElementById('RdbTwo').checked==true)
    {
        if(document.getElementById('TxtTDept').value=="")
        {
            alert("Please enter Depart Date");
            document.getElementById('TxtTDept').focus();
            return false;
        }
        if(document.getElementById('TxtTRetrn').value=="")
        {
            alert("Please enter Return Date");
            document.getElementById('TxtTRetrn').focus();
            return false;
        }
    }
    else if(document.getElementById('RdbOne').checked==true)
    {
        if(document.getElementById('TxtTDept').value=="")
        {
            alert("Please enter Depart Date");
            document.getElementById('TxtTDept').focus();
            return false;
        }
    }
    return true;

}




function chkroomdate()
{
        if(document.getElementById('DdlRoomType').options[document.getElementById('DdlRoomType').selectedIndex].value=="--Select--")
        {
            alert("Please select Room Type");
            document.getElementById('DdlRoomType').focus();
            return false;
        }
        if(document.getElementById('DdlRoomName').options[document.getElementById('DdlRoomName').selectedIndex].value=="--Select--")
        {
            alert("Please select Room Name");
            document.getElementById('DdlRoomName').focus();
            return false;
        }
        if(document.getElementById('DdlFood').options[document.getElementById('DdlFood').selectedIndex].value=="--Select--")
        {
            alert("Please select Room Food");
            document.getElementById('DdlFood').focus();
            return false;
        }
        if(document.getElementById('DdlNoRooms').options[document.getElementById('DdlNoRooms').selectedIndex].value=="--Select--")
        {
            alert("Please select No. of Rooms");
            document.getElementById('DdlNoRooms').focus();
            return false;
        }
        if(document.getElementById('DdlNoGuests').options[document.getElementById('DdlNoGuests').selectedIndex].value=="--Select--")
        {
            alert("Please select No. of Guests");
            document.getElementById('DdlNoGuests').focus();
            return false;
        }
        if(document.getElementById('TxtChkIn').value=="")
        {
            alert("Please enter Checkin Date");
            document.getElementById('TxtChkIn').focus();
            return false;
        }
        if(document.getElementById('TxtChkOut').value=="")
        {
            alert("Please enter Checkout Date");
            document.getElementById('TxtChkOut').focus();
            return false;
        }
        return true;
    
}
