﻿// JScript File
var isPage=0;

var xmlHttpLogin
var ttoltiploading="<table cellspacing='0' cellpadding='5' border='0' width='200' bgcolor='#D17869'><tr><td align='center' class='buytickettxt'><b>Please wait.. while the information is being loaded. </b></td></tr></table>";
var tooltipup="<table cellspacing='0' cellpadding='0' border='0' width='400' bgcolor='#D17869'>";
var tooltipdown="</table></td></tr></table>";
var strLoginOnHome ="<table border='0' width='220'>";
strLoginOnHome += "<tr><td>";
strLoginOnHome += "<img src='images/arrow_gry.JPG' alt='' />&nbsp;<a href='BookingHistory.aspx' class='NsCsLinks' >Booking History</a>&nbsp;&nbsp;&nbsp;|&nbsp;";
strLoginOnHome += "<img src='images/arrow_gry.JPG' alt='' />&nbsp;<a href='EditProfile.aspx' class='NsCsLinks' >Edit Profile</a></td></tr>";
strLoginOnHome += "<tr><td><img src='images/arrow_gry.JPG' alt='' />&nbsp;<a href='ChangePassword.aspx' class='NsCsLinks'>Change Password</a>&nbsp;|&nbsp;";
strLoginOnHome += "<img src='images/arrow_gry.JPG' alt='' />&nbsp;<a href='javascript:void(0);' class='NsCsLinks' onclick='javascript:LogOut();'>Logout</a>";
strLoginOnHome += "</td></tr>";
strLoginOnHome += "</table>";

var strLogin ="<table>";
strLogin += "<tr><td>";
strLogin += "<a href='EditProfile.aspx' class='Login' class='NsCsLinks'>Edit Profile</a>&nbsp;|&nbsp;";
strLogin += "<a href='BookingHistory.aspx' class='Login' class='NsCsLinks'>Booking History</a>&nbsp;|&nbsp;";
strLogin += "<a href='ChangePassword.aspx' class='Login' class='NsCsLinks'>Change Password</a>&nbsp;|&nbsp;";
strLogin += "<a href='javascript:void(0);' onclick='javascript:LogOut();' class='Login' class='NsCsLinks'>Logout</a>";
strLogin += "</td></tr>";
strLogin += "</table>";

//var strLogout = "<table>";
//strLogout += "<tr><td class='TdLogin1'>";
//strLogout += "<img src='images/arrow_gry.JPG' alt='' />&nbsp;<a href='RegisterUser.aspx' >Register User</a></td>";
//strLogout += "<td class='TdLogin1'>";
//strLogout += "<img src='images/arrow_gry.JPG' alt='' />&nbsp;<a href='RegisterAgent.aspx' >Register Agent</a></td>";
//strLogout += "<td class='TdLogin1'>";
//strLogout += "<img src='images/arrow_gry.JPG' alt='' />&nbsp;<a href='ForgotPassword.aspx' >Forgot Password</a></td>";
//strLogout += "<td class='TdLogin1'>";
//strLogout += "<img src='images/arrow_gry.JPG' alt='' />&nbsp;<a href='javascript:void(0);' onclick='javascript:CheckLogin(event);'>Login</a></td>";
//strLogout += "</table>";

var strLogout = "<table>";
strLogout += "<tr><td class='TdLogin1'>";
strLogout += "<a href='RegisterUser.aspx' class='NsCsLinks' >Register User</a>&nbsp;|&nbsp;";
//strLogout += "<a href='RegisterAgent.aspx' >Register Agent</a>&nbsp;|&nbsp;";
strLogout += "<a href='ForgotPassword.aspx' class='NsCsLinks' >Forgot Password</a>&nbsp;|&nbsp;";
strLogout += "<a href='javascript:void(0);' onclick='javascript:CheckLogin(event);' class='NsCsLinks'>Login</a></td></tr>";
strLogout += "</table>";

var strLogoutOnHome="<table>";
strLogoutOnHome +="<tr><td>";
strLogoutOnHome +="<a class='bodytxt' class='NsCsLinks' href='ForgotPassword.aspx' >Forgot Password</a> / <a class='bodytxt' class='NsCsLinks' href='RegisterUser.aspx' > RegisterUser </a>";
strLogoutOnHome +="</td></tr>";
strLogoutOnHome +="</table>";


var strLoginBox ="<table class='TBbodytxtLeft' width='230' border='0' cellpadding='0' cellspacing='0'>";
strLoginBox +="<tr>";
strLoginBox +="<td class='bodytxt' width='57' height='27'>User ID</td>";
strLoginBox +="<td class='bodytxt' width='129'><label><input name='txtname' id='txtname' size='16' onclick='javascript:clearText();' type='text'></label></td>";
strLoginBox +="<td width='34'>&nbsp;</td>";
strLoginBox +="</tr>";
strLoginBox +="<tr>";
strLoginBox +="<td class='bodytxt'>Password</td>";
strLoginBox +="<td class='bodytxt'><input name='txtpass' id='txtpass' size='16' onclick='javascript:clearText();' type='password' /></td>";
strLoginBox +="<td style='border: 0px none ;'><a href='javascript:void(0);' onclick='javascript:validateLogin();' onmouseover='MouseOver(6)' onmouseout='MouseOut(6);' style='border: 0px none ;'><img src='images/btnHome_go.gif' style='border: 0px none ; vertical-align: middle;' name='img6' id='img6' alt='' /></a></td>";
strLoginBox +="</tr>";
strLoginBox +="</table>";
                    
var tempClientX,tempClientY;
var tempShowDate;
var xmlHttpLogin
var width=1000;
var height=200;
var timer;
var tooltip="";
 var tempX;
 var tempY;
// Set Netscape up to run the "captureMousePosition" function whenever
// the mouse is moved. For Internet Explorer and Netscape 6, you can capture
// the movement a little easier.
if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
}
// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

function captureMousePosition(e) {
    if (document.layers) {
        // When the page scrolls in Netscape, the event's mouse position
        // reflects the absolute position on the screen. innerHight/Width
        // is the position from the top/left of the screen that the user is
        // looking at. pageX/YOffset is the amount that the user has 
        // scrolled into the page. So the values will be in relation to
        // each other as the total offsets into the page, no matter if
        // the user has scrolled or not.
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    } else if (document.all) {
        // When the page scrolls in IE, the event's mouse position 
        // reflects the position from the top/left of the screen the 
        // user is looking at. scrollLeft/Top is the amount the user
        // has scrolled into the page. clientWidth/Height is the height/
        // width of the current page the user is looking at. So, to be
        // consistent with Netscape (above), add the scroll offsets to
        // both so we end up with an absolute value on the page, no 
        // matter if the user has scrolled or not.
        xMousePos = window.event.x+document.documentElement.scrollLeft;
        yMousePos = window.event.y+document.documentElement.scrollTop;
        xMousePosMax = document.documentElement.clientWidth+document.documentElement.scrollLeft;
        yMousePosMax = document.documentElement.clientHeight+document.documentElement.scrollTop;        
        //xMousePosMax = document.body.clientWidth+document.documentElement.scrollLeft;
        //yMousePosMax = document.body.clientHeight+document.documentElement.scrollTop;
    } else if (document.getElementById) {
        // Netscape 6 behaves the same as Netscape 4 in this regard 
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    }
}

function GetXmlHttpObject()
{ 
    var objXMLHttp=null
    if (window.XMLHttpRequest)
    {
        objXMLHttp=new XMLHttpRequest()
    }
    else if (window.ActiveXObject)
    {
        objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
    }
    return objXMLHttp
} 
    

function hideLoginTip() {
 var url = window.location.href;
    var nohttp = url.split('//')[1];    
    var hostPort = nohttp.split('/')[1];
    var page =  hostPort.split('?')[0];  
    if (page != "buyTicket.aspx")
    {          
     ntipobj = document.getElementById( "LoginToolTip" );
     ntipobj.style.visibility="hidden";
    }
 else
 {
     //document.getElementById("ctl00_ContentPlaceHolder1_DivSynTooltip").className="displaynone";
 }
 ClearGenCRMPopUp();
 //clearTimeout(timer);
}
   
 function CheckLogin(e)
 {
     var XoffSet = 0;
    if (!e) 
    {
        e = window.event;
        XoffSet = 195;
    }
    else
    {
        XoffSet = 183;
    }
        
     xmlHttpLogin=GetXmlHttpObject()
    if (xmlHttpLogin==null)
    {
        alert ("Browser does not support HTTP Request")
        return
    } 
    ntipobj = document.getElementById( "LoginToolTip" );    
    var url = window.location.href;
    var nohttp = url.split('//')[1];    
    var hostPort = nohttp.split('/')[1];
    var page =  hostPort.split('?')[0];  
    if (page != "buyTicket.aspx")
    {          
        /*ntipobj.style.width= width;
        ntipobj.style.height= height;*/
        ntipobj.innerHTML=ttoltiploading;
        ntipobj.style.visibility="visible";
   }
    else
    {
       
      // document.getElementById("ctl00_ContentPlaceHolder1_DivSynTooltip").className="";
       //document.getElementById("ctl00_ContentPlaceHolder1_DivSynTooltip").innerHTML = ttoltiploading;
    }   
var w = screen.width; // Get the width of the screen
 var h = screen.height; // Get the height of the screen

 // The size of the Window
 var win_width = w/2; //- 700;
 var win_height = h/2 ;//- 450;

 // Where to place the Window
 var left = width/6;
 var top = height -60;
 

       /* ntipobj.style.left = (tempX-XoffSet) + "px";
        ntipobj.style.top = tempY + "px" ;
        tempClientX = (tempX-XoffSet) + "px";;
        tempClientY = (tempY+10) + "px" ;*/
       if(window.navigator.appName == "Microsoft Internet Explorer")
       {
            tempX = typeof(e.clientX) + document.documentElement.scrollLeft;
            tempY = typeof(e.clientY) + document.documentElement.scrollTop;
            ntipobj.style.posLeft = (win_width + document.documentElement.scrollLeft) - left;
            ntipobj.style.posTop = win_height + document.documentElement.scrollTop - top;
            ntipobj.style.left = (win_width + document.documentElement.scrollLeft) - left;
            ntipobj.style.top = (win_height + document.documentElement.scrollTop) - top;
       }
       else
       {
            ntipobj.style.posLeft = ((win_width + document.documentElement.scrollLeft) - left)+"px";
            ntipobj.style.posTop = ((win_height + document.documentElement.scrollTop) - top)+"px";
            ntipobj.style.left = ((win_width + document.documentElement.scrollLeft) - left)+ "px";
            ntipobj.style.top = ((win_height+ document.documentElement.scrollTop) - top)+"px" ;
       }
 
    /*Generate Date & time */
    var currentTime = new Date()
    var month = currentTime.getMonth() + 1
    var day = currentTime.getDate()
    var year = currentTime.getFullYear()
    var hours = currentTime.getHours()
    var minutes = currentTime.getMinutes()
    var seconds = currentTime.getSeconds()        
    var temp = month + "-" + day + "-" + year + "-" + hours + "-" + minutes + "-" + seconds;    
    /*End of Date Time*/
    
    var url ="Services/ITZService.asmx/CheckLogin?&rand="+temp;
 
    xmlHttpLogin.onreadystatechange=CheckLoginToolTip
    xmlHttpLogin.open("GET",url,true)
    xmlHttpLogin.send(null)  

    return false; 
 }
 
function CheckLoginToolTip() 
{
    if (xmlHttpLogin.readyState==4 || xmlHttpLogin.readyState=="complete")
    {
         if (xmlHttpLogin.status == 200)      
         {
            var str = new String(xmlHttpLogin.responseText);
            str= str.replace(/&gt;/g,'>');
            str= str.replace(/&lt;/g,'<');
            str= str.replace(/&amp;/g,'&');
            var url = window.location.href;
            var nohttp = url.split('//')[1];    
            var hostPort = nohttp.split('/')[1];
            var page =  hostPort.split('?')[0];    
            if (page != "searchByMovie.aspx")
            {                                
                
                tooltip=tooltipup+str+tooltipdown
                ntipobj = document.getElementById( "LoginToolTip" );
                ntipobj.innerHTML = tooltip;
                /*if(isLogin == 1)
                {
                    ntipobj.style.visibility="";
                }*/             
                //ntipobj.innerHTML = xmlHttp1.responseText;
            }
            else
            {   
                //document.getElementById("ctl00_ContentPlaceHolder1_DivSynTooltip").className="";
                //document.getElementById("ctl00_ContentPlaceHolder1_DivSynTooltip").innerHTML = tooltipup+xmlHttp1.responseText+tooltipdown;
            }
            ShowGenCRMPopUp();
           // timer=setTimeout("SetTipPostion()",250);
         } 
         
    }
}


function ShowGenCRMPopUp()
{

    GenCRMDarkenPage();
    //ShowGenCRMPopUpPanel();
    
   
}

function ClearGenCRMPopUp()
{
    var div_temp = document.getElementById('ntooltip');
    //div_temp.style.display = 'none';
    GenCRMLightenPage();
}


function ShowGenCRMPopUpPanel()
{
    var div_temp = document.getElementById('ntooltip');
    
    // w is a width of the newsletter panel
    w = 480;
    // h is a height of the newsletter panel
    h = 279;
    
    // get the x and y coordinates to center the newsletter panel
    xc = Math.round((document.body.clientWidth/2)-(w/2))
    //yc = Math.round((document.body.clientHeight/2)-(h/2))
 yc = Math.round((650/2)-(h/2))
    
    // show the newsletter panel
    //div_temp.style.left = xc + "px";
    //div_temp.style.top  = yc + "px";
    div_temp.style.display = 'block';
    
}


function GenCRMDarkenPage()
{
   var div_temp = document.getElementById('div_screen');
   div_temp.style.width = (parseInt(document.body.scrollWidth)) + 'px';
   div_temp.style.height = (parseInt(document.body.scrollHeight))+ 'px';//document.body.parentNode.scrollHeight + 'px';
   div_temp.style.display = 'block';
}

// this function removes the dark screen and the page is light again
function GenCRMLightenPage()
{
    var div_temp = document.getElementById('div_screen');
    div_temp.style.display = 'none';
}

function validateLogin()
{
    var UserID = document.getElementById("txtname").value;
    var PassWD = document.getElementById("txtpass").value;
    if(UserID == "")
    {
        alert("Please enter UserID");
        document.getElementById("txtname").focus();
        return false;   
    }
    if(PassWD == "")
    {
        alert("Please enter password");
        document.getElementById("txtpass").focus();
        return false;   
    }    
    xmlHttpLogin=GetXmlHttpObject()
    if (xmlHttpLogin==null)
    {
        alert ("Browser does not support HTTP Request")
        return
    } 
    var currentTime = new Date()
    var month = currentTime.getMonth() + 1
    var day = currentTime.getDate()
    var year = currentTime.getFullYear()
    var hours = currentTime.getHours()
    var minutes = currentTime.getMinutes()
    var seconds = currentTime.getSeconds()        
    var temp = month + "-" + day + "-" + year + "-" + hours + "-" + minutes + "-" + seconds;    
    /*End of Date Time*/
    
    var url ="Services/ITZService.asmx/validateLogin?login="+UserID+"&password="+PassWD+"&rand="+temp;
    xmlHttpLogin.onreadystatechange=validateLoginToolTip
    xmlHttpLogin.open("GET",url,true)
    xmlHttpLogin.send(null)  

    return false;     
}
function validateLoginToolTip() 
{
    if (xmlHttpLogin.readyState==4 || xmlHttpLogin.readyState=="complete")
    {
         if (xmlHttpLogin.status == 200)      
         {
                    switch(xmlHttpLogin.responseXML.getElementsByTagName("string")[0].childNodes[0].nodeValue)
                        {
                            case "0000" : 
                                        document.getElementById("tdValidate").innerHTML = "";                            
                                       document.getElementById("tdValidate").innerHTML="<font size='2' color='#D8141E'>&nbsp;<b>Invalid UserID/Password.</b></font>";
                                        /*document.getElementById("tdLoginLink").innerHTML="";
                                        document.getElementById("tdLoginLink").innerHTML=strLoginOnHome;*/
                                        break;
                            case "0001" : 
                                        document.getElementById("tdValidate").innerHTML = "";                            
                                       document.getElementById("tdValidate").innerHTML="<font size='2' color='#D8141E'>&nbsp;<b>Not Allowed to login.</b></font>";
                                       alert("Not Allowed to Login as you have booked 50 tickets in current week.\nTry to login in next week");
                                        /*document.getElementById("tdLoginLink").innerHTML="";
                                        document.getElementById("tdLoginLink").innerHTML=strLoginOnHome;*/
                                        break;                                        
                            default:
                                    isLogin =0;                            
                                    var url = window.location.href;
                                    var nohttp = url.split('//')[1];    
                                    var page = nohttp.split('/')[1].toLowerCase();
                                    
                                    var nohttp1 = url.split('//')[1];    
                                    var hostPort1 = nohttp1.split('/')[1].toLowerCase();
                                    var page1 =  hostPort1.split('?')[0];  
                                    if(page == null || page == "")
                                    {
                                        page = "home.aspx";
                                    }
                                    //var page = nohttp.split('/')[2].toLowerCase(); 
                                    if(page == "registeruser.aspx" || page == "registeragent.aspx" || page == "forgotpassword.aspx")
                                    {
                                        location.href = "home.aspx";
                                    }
                                    else if(page1 == "agentresponse.aspx")
                                    {
                                        location.href = "home.aspx";
                                    }
                                    else if (page == "home.aspx")
                                    { 
                                        document.getElementById("txtname").value="";
                                        document.getElementById("txtpass").value="";
                                        document.getElementById("tdLoginLink").innerHTML="";
                                        document.getElementById("divLoginText").innerHTML="";
                                        document.getElementById("divLoginText").innerHTML=strLoginOnHome;                                        
                                        /*document.getElementById("tdLoginLink").innerHTML="";
                                        document.getElementById("tdLoginLink").innerHTML=strLoginOnHome;*/
                                        var str = new String(xmlHttpLogin.responseText);
                                            str= str.replace(/&gt;/g,'>');
                                            str= str.replace(/&lt;/g,'<');
                                            str= str.replace(/&amp;/g,'&');
                                            if(document.getElementById("tdWelcome") != null && document.getElementById("tdwelName") != null)
                                            {
                                                var welText = document.getElementById("tdWelcome").value;
                                                document.getElementById("tdWelcome").value = "";
                                                document.getElementById("tdWelcome").value="<font color='#9ECEEB' size='2px'><b>"+welText+"</b></font>";
                                                var nameText = document.getElementById("tdwelName").value;
                                                document.getElementById("tdwelName").value = "";
                                                document.getElementById("tdwelName").value="<font color='#9ECEEB' size='2px'><b>"+nameText+"</b></font>";
                                            }       
                                            document.getElementById("tdValidate").innerHTML=str;   
                                                                            
                                            tempMoiveSessionID ="";
                                            tempMultiplexCode = "";
                                            tempCenterCode = "";
                                            tempITZMovieCode = "";
                                            tempHOMovieCode ="";
                                            tempMovieShowTime = "";
                                            tempMovieTitle = "";
                                            tempMovieShowDate ="";
                                            tempe = "";
                                    }
                                    else
                                    {
                                        var objUserName,objUserLogin;
                                        objUserName = document.getElementById("divUserName");
                                        objUserLogin = document.getElementById("divIsLogIn");
                                        if(objUserName == null)
                                        {
                                         objUserName = document.getElementById("ctl00_divUserName");
                                         objUserLogin = document.getElementById("ctl00_divIsLogIn");
                                        }
                                         
                                            hideLoginTip();
                                            var str = new String(xmlHttpLogin.responseText);
                                            str= str.replace(/&gt;/g,'>');
                                            str= str.replace(/&lt;/g,'<');
                                            str= str.replace(/&amp;/g,'&');
                                           
                                            if(document.getElementById("tdWelcome") != null && document.getElementById("tdwelName") != null)
                                            {
                                                var welText = document.getElementById("tdWelcome").value;
                                                document.getElementById("tdWelcome").value = "";
                                                document.getElementById("tdWelcome").value="<font color='#FFFFFF' size='2px'><b>"+welText+"</b></font>";
                                                var nameText = document.getElementById("tdwelName").value;
                                                document.getElementById("tdwelName").value = "";
                                                document.getElementById("tdwelName").value="<font color='#FFFFFF' size='2px'><b>"+nameText+"</b></font>";
                                            }
                                            objUserName.innerHTML=str;                                            
                                            objUserLogin.innerHTML=strLogin;
                                            if(tempMoiveSessionID != "")
                                            {
                                                showTip(tempCityID,tempMoiveSessionID, tempMultiplexCode, tempCenterCode, tempITZMovieCode, tempHOMovieCode, tempMovieShowTime, tempMovieTitle, tempMovieShowDate,1)
                                            }
                                            if(isPage == 1)
                                            {
                                                    MasterSearch(); // search of master page
                                            }
                                   }
                                    break;
                                 
                        }            
            
         } 
         
    }
}

function LogOut()
{      
    isLogin = 1; 
    tempMoiveSessionID ="";
    tempMultiplexCode = "";
    tempCenterCode = "";
    tempITZMovieCode = "";
    tempHOMovieCode ="";
    tempMovieShowTime = "";
    tempMovieTitle = "";
    tempMovieShowDate ="";
    tempe = "";
    xmlHttpLogin=GetXmlHttpObject()
    if (xmlHttpLogin==null)
    {
        alert ("Browser does not support HTTP Request")
        return
    }  
    
    /*Generate Date & time */
    var currentTime = new Date()
    var month = currentTime.getMonth() + 1
    var day = currentTime.getDate()
    var year = currentTime.getFullYear()
    var hours = currentTime.getHours()
    var minutes = currentTime.getMinutes()
    var seconds = currentTime.getSeconds()        
    var temp = month + "-" + day + "-" + year + "-" + hours + "-" + minutes + "-" + seconds;    
    /*End of Date Time*/
    
    var url="Logout.aspx?rand="+temp
    xmlHttpLogin.onreadystatechange=Logout_callBack
    xmlHttpLogin.open("GET",url,true)
    xmlHttpLogin.send(null)        
}

function Logout_callBack() 
{
    if (xmlHttpLogin.readyState==4 || xmlHttpLogin.readyState=="complete")
    {
     if (xmlHttpLogin.status == 200)      
         { 
            var url = window.location.href;
            var nohttp = url.split('//')[1];    
            var page = nohttp.split('/')[1].toLowerCase();
            //var page = nohttp.split('/')[2].toLowerCase(); 
 
            if(page == null || page == "")
            {
                page = "home.aspx";
            }
            if (page == "home.aspx")
            { 
                /*document.getElementById("txtname").value="";
                document.getElementById("txtpass").value="";*/
                document.getElementById("tdLoginLink").innerHTML="";
                document.getElementById("tdLoginLink").innerHTML=strLogoutOnHome;
                document.getElementById("tdValidate").innerHTML = "";
                document.getElementById("divLoginText").innerHTML="";
                document.getElementById("divLoginText").innerHTML=strLoginBox;                 
            }    
            else
            {   
                if(page == "editprofile.aspx" || page == "changepassword.aspx" || page == "bookinghistory.aspx" || page == "bookingstatus.aspx" || page == "editagentprofile.aspx" || page == "AgentResponse.aspx")
                {
                    location.href = "home.aspx";
                }
                else
                {
                    var objUserName,objUserLogin;
                    objUserName = document.getElementById("divUserName");
                    objUserLogin = document.getElementById("divIsLogIn");
                    if(objUserName == null)
                    {
                     objUserName = document.getElementById("ctl00_divUserName");
                     objUserLogin = document.getElementById("ctl00_divIsLogIn");
                    }
                    objUserLogin.innerHTML="";
                    objUserLogin.innerHTML = strLogout; 
                    objUserName.innerHTML = "";  
                    //location.href = "buyTickets.aspx";
                    if(page == "buytickets.aspx")
                    {
                        MasterSearch();
                    }
                }
            
 
                         
                 //location.reload(true);
                 //Redirect(window.parent.location.href);
             }
             
         } 
    }
}
 
function validateLoginBookingTip()
{
    var UserID = document.getElementById("txtname").value;
    var PassWD = document.getElementById("txtpass").value;
    if(UserID == "")
    {
        alert("Please enter UserID");
        document.getElementById("txtname").focus();
        return false;   
    }
    if(PassWD == "")
    {
        alert("Please enter password");
        document.getElementById("txtpass").focus();
        return false;   
    }    
    xmlHttpLogin=GetXmlHttpObject()
    if (xmlHttpLogin==null)
    {
        alert ("Browser does not support HTTP Request")
        return
    } 
    var currentTime = new Date()
    var month = currentTime.getMonth() + 1
    var day = currentTime.getDate()
    var year = currentTime.getFullYear()
    var hours = currentTime.getHours()
    var minutes = currentTime.getMinutes()
    var seconds = currentTime.getSeconds()        
    var temp = month + "-" + day + "-" + year + "-" + hours + "-" + minutes + "-" + seconds;    
    /*End of Date Time*/
    
    var url ="Services/ITZService.asmx/validateLogin?login="+UserID+"&password="+PassWD+"&rand="+temp;
    xmlHttpLogin.onreadystatechange=validateLoginBookingTip_callBack
    xmlHttpLogin.open("GET",url,true)
    xmlHttpLogin.send(null)  

    return false;     
}
function validateLoginBookingTip_callBack()
{
 if (xmlHttpLogin.readyState==4 || xmlHttpLogin.readyState=="complete")
    {
         if (xmlHttpLogin.status == 200)      
         {
                    switch(xmlHttpLogin.responseXML.getElementsByTagName("string")[0].childNodes[0].nodeValue)
                        {
                            case "0000" : 
                                        document.getElementById("tdValidate").innerHTML = "";                            
                                       document.getElementById("tdValidate").innerHTML="<font size='2' color='#D8141E'>&nbsp;<b>Invalid UserID/Password.</b></font>";
                                        break;
                            case "0001" : 
                                        document.getElementById("tdValidate").innerHTML = "";                            
                                       document.getElementById("tdValidate").innerHTML="<font size='2' color='#D8141E'>&nbsp;<b>Not Allowed to login.</b></font>";
                                       alert("Not Allowed to Login as you have booked 50 tickets in current week.\nTry to login in next week");
                                        break;                                        
                            default:
                                        var objUserName,objUserLogin;
                                        objUserName = document.getElementById("divUserName");
                                        objUserLogin = document.getElementById("divIsLogIn");
                                        if(objUserName == null)
                                        {
                                         objUserName = document.getElementById("ctl00_divUserName");
                                         objUserLogin = document.getElementById("ctl00_divIsLogIn");
                                        }
                                         
                                           var str = new String(xmlHttpLogin.responseText);
                                            str= str.replace(/&gt;/g,'>');
                                            str= str.replace(/&lt;/g,'<');
                                            str= str.replace(/&amp;/g,'&');
                                           
                                            if(document.getElementById("tdWelcome") != null && document.getElementById("tdwelName") != null)
                                            {
                                                var welText = document.getElementById("tdWelcome").value;
                                                document.getElementById("tdWelcome").value = "";
                                                document.getElementById("tdWelcome").value="<font color='#FFFFFF' size='2px'><b>"+welText+"</b></font>";
                                                var nameText = document.getElementById("tdwelName").value;
                                                document.getElementById("tdwelName").value = "";
                                                document.getElementById("tdwelName").value="<font color='#FFFFFF' size='2px'><b>"+nameText+"</b></font>";
                                            }
                                            objUserName.innerHTML=str;                                            
                                            objUserLogin.innerHTML=strLogin;
                                            if(tempMoiveSessionID != "")
                                            {
                                                showTip(tempCityID,tempMoiveSessionID, tempMultiplexCode, tempCenterCode, tempITZMovieCode, tempHOMovieCode, tempMovieShowTime, tempMovieTitle, tempMovieShowDate,1)
                                            }
                                            if(isPage == 1)
                                            {
                                                    MasterSearch(); // search of master page
                                            }                                            
                             break;
                                 
                    }            
         } 
    }
}

function clearText()
{
    document.getElementById("tdValidate").innerHTML = "";    
}
