﻿// JScript File 
var newMode; 
var UserID; 
var commentID; 
var replyID;  
var Name;
YAHOO.namespace("example.container"); 
function GetXmlHttpObject()
{
	var xmlHttp=false; 
	try 
	{
        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e) 
        {
            try 
            {
                
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            } 
            catch (e2) 
            {
                xmlHttp = false; 
               
            } 
            if (!xmlHttp && typeof XMLHttpRequest != 'undefined') 
            {
                
                xmlHttp = new XMLHttpRequest();
            } 
            if (window.XMLHttpRequest)
            {// code for IE7+, Firefox, Chrome, Opera, Safari
                xmlHttp = new XMLHttpRequest(); 
            }
        }
     return xmlHttp;
}   

function DisplayAccount(x) 
{  
 
    xmlHttp=new GetXmlHttpObject();
    var Url = 'DisplayAccount.aspx';
    Url = Url+"?AccountID="+x;
    Url = Url+"&sid="+Math.random();  
    xmlHttp.open("GET",Url,true); 
    xmlHttp.onreadystatechange = HttpDisplayAccount; 
    xmlHttp.send(null);   
}
function HttpDisplayAccount()
{ 
    document.getElementById("Account").innerHTML ="<img src=\"ajax-indicator.gif\"/>"
    if(xmlHttp.readystate == 4)
    {   
        
        try
        { 
            
            if(xmlHttp.status == 200)
            {  
                    document.getElementById("Account").innerHTML=xmlHttp.responseText 
                    
            }
            else 
            {
                alert("Response Error"+xmlHttp.status);
            }
        }
        catch(e)
        {
            //alert("May error"+http.status);
        }
    }
}   
function Userlogin() 
{ 
     var Username = document.getElementById("txtusername").value; 
     var Password = document.getElementById("txtpassword").value;
     xmlHttp=new GetXmlHttpObject();  
     var Url = 'ValidateAttemp.aspx'; 
     Url = Url+"?Username="+Username;
     Url = Url+"&Password="+Password;
     Url = Url+"&sid="+Math.random(); 
     xmlHttp.open("GET",Url,true); 
     xmlHttp.onreadystatechange = HttpUserLogin; 
     xmlHttp.send(null); 
}
function HttpUserLogin()
{ 
                    //var content = document.getElementById("content");
                    //content.innerHTML = "";
                    //if (!YAHOO.example.container.wait) {
                    // Initialize the temporary Panel to display while waiting for external content to load
                    //YAHOO.example.container.wait = 
                     //       new YAHOO.widget.Panel("wait",  
                        //                                    { width: "240px", 
                      //                                        fixedcenter: true, 
                      //                                        close: false, 
                       //                                       draggable: false, 
                        //                                      zindex:4,
                        ///                                      modal: true,
                        //                                      visible: false
                        //                                    } 
                        //                                );
            
                          YAHOO.example.container.Login.setHeader("Loading, please wait..."); 
                          YAHOO.example.container.Login.setBody("<img src=\"ajax-loader.gif\"/>");
                          YAHOO.example.container.Login.render(document.body);

                 //     } 
                   //  YAHOO.example.container.wait.show();   
    if(xmlHttp.readystate == 4)
    {   
             
                
        try
        { 
            //document.getElementById("stat").innerHTML = "Loading your account please wait.."
            if(xmlHttp.status == 200)
            {   
                     UserID = xmlHttp.responseText;  
                     document.cookie = "UserID="+UserID; 
                     //YAHOO.example.container.wait.hide();
                     window.location = "LoadingAccount.aspx?UserID="+UserID;  
                   
            }
            else 
            {
                alert("Response Error:HttpUserLogin"+xmlHttp.status);
            }
        }
        catch(e)
        {
            //alert("May error"+http.status);
        }
    }
}  
function InsertLogAction(Action,Desc) 
{  
     
     xmlHttp=new GetXmlHttpObject();  
     var Url = 'InsertLogAction.aspx'; 
     Url = Url+"?Action="+Action;
     Url = Url+"&Desc="+Desc;
     Url = Url+"&sid="+Math.random();  
     xmlHttp.open("GET",Url,true); 
     xmlHttp.onreadystatechange = HttpInsertLogAction; 
     xmlHttp.send(null); 
     
}
function HttpInsertLogAction()
{
    if(xmlHttp.readystate == 4)
    {   
      
        try
        { 
            
            if(xmlHttp.status == 200)
            {   
                    document.getElementById("Share").innerHTML=xmlHttp.responseText 
                    
            }
            else 
            {
                alert("Response Error"+xmlHttp.status);
            }
        }
        catch(e)
        {
            //alert("May error"+http.status);
        }
    }
}    
function LoadInitial(x)
{  
    //To load all LogAction data located in the masterpage
    newMode = x; //1 means all 0 means for today 
    xmlHttp=new GetXmlHttpObject();
    var Url = 'LoadInitial.aspx';
    Url = Url+"?Mode="+x;
    Url = Url+"&sid="+Math.random();  
    xmlHttp.open("GET",Url,true); 
    xmlHttp.onreadystatechange = HttpLoadInitial; 
    xmlHttp.send(null);  
    
} 
function HttpLoadInitial()
{
    document.getElementById("LoadInitial").innerHTML ="<img src=\"ajax-loader.gif\"/>"
    if(xmlHttp.readystate == 4)
    {   
        
        try
        { 
            
            if(xmlHttp.status == 200)
            { 
                    
                    document.getElementById("LoadInitial").innerHTML=xmlHttp.responseText 
                     //load request  
                     //load the new candidates 
                     LoadNewRequest(newMode); //load the new request 
            }
            else 
            {
                alert("Response Error"+xmlHttp.status);
            }
        }
        catch(e)
        {
            //alert("May error"+http.status);
        }
    }
}  

function LoadNewRequest(Mode) 
{   
    newMode = Mode;
    xmlHttp=new GetXmlHttpObject();
    var Url = 'NewRequest.aspx';
    Url = Url+"?Mode="+Mode;
    Url = Url+"&sid="+Math.random();  
    xmlHttp.open("GET",Url,true); 
    xmlHttp.onreadystatechange = HttpLoadNewRequest; 
    xmlHttp.send(null); 
}
function HttpLoadNewRequest()
{
    if(xmlHttp.readystate == 4)
    {   
      
        try
        { 
            
            if(xmlHttp.status == 200)
            { 
                    document.getElementById("NewRequest").innerHTML=xmlHttp.responseText ;
                     
            }
            else 
            {
                    alert("Response Error"+xmlHttp.status);
            }
        }
        catch(e)
        {
            //alert("May error"+http.status);
        }
    }
}  
function LoadNewCanidtes(Mode) 
{   
    newMode = Mode;
    xmlHttp=new GetXmlHttpObject();
    var Url = 'newCandidates.aspx';
    Url = Url+"?Mode="+Mode;
    Url = Url+"&sid="+Math.random();  
    xmlHttp.open("GET",Url,true); 
    xmlHttp.onreadystatechange = HttpLoadNewCandidates; 
    xmlHttp.send(null); 
}
function HttpLoadNewCandidates()
{
    if(xmlHttp.readystate == 4)
    {   
      
        try
        { 
            
            if(xmlHttp.status == 200)
            {  
     
                    document.getElementById("NewCanidates").innerHTML=xmlHttp.responseText 
            }
            else 
            {
                    alert("Response Error"+xmlHttp.status);
            }
        }
        catch(e)
        {
            //alert("May error"+http.status);
        }
    }
}  

function ViewReply(ID)
{
    replyID=ID;  
    //xmlHttp=new GetXmlHttpObject();
    var Url = 'DisplayReply.aspx';
    Url = Url+"?str="+replyID;
    Url = Url+"&sid="+Math.random();  
    xmlHttp.open("GET",Url,true); 
    xmlHttp.onreadystatechange = HttpdisplayReply; 
    xmlHttp.send(null);   
}
function HttpdisplayReply()
{
    if(xmlHttp.readystate == 4)
    {   
      
        try
        { 
            
            if(xmlHttp.status == 200)
            {  
                    //alert(commentID); 
                    document.getElementById(replyID+5).innerHTML=xmlHttp.responseText 
            }
            else 
            {
                    alert("Response Error"+xmlHttp.status);
            }
        }
        catch(e)
        {
            //alert("May error"+http.status);
        }
    }
}  
function GetcommentID(ID) 
{
    commentID=ID;  
    //alert(commentID);
    //xmlHttp=new GetXmlHttpObject();
    var Url = 'ChildComment.aspx';
    Url = Url+"?ID="+ID;
    Url = Url+"&sid="+Math.random();  
    xmlHttp.open("GET",Url,true); 
    xmlHttp.onreadystatechange = HttpdisplayComment; 
    xmlHttp.send(null);  
} 
function HttpdisplayComment()
{
    if(xmlHttp.readystate == 4)
    {   
      
        try
        { 
            
            if(xmlHttp.status == 200)
            {  
                    //alert(commentID); 
                    document.getElementById(commentID+5).innerHTML=xmlHttp.responseText 
            }
            else 
            {
                    alert("Response Error"+xmlHttp.status);
            }
        }
        catch(e)
        {
            //alert("May error"+http.status);
        }
    }
}  
function InsertComment(Desc) 
{  
     
     //alert(Desc);
     xmlHttp=new GetXmlHttpObject();  
     var Url = 'InsertComment.aspx'; 
     Url = Url+"?LogID="+commentID; 
     Url = Url+"&Desc="+Desc;
     Url = Url+"&sid="+Math.random();  
     xmlHttp.open("GET",Url,true); 
     xmlHttp.onreadystatechange = HttpInsertComment; 
     xmlHttp.send(null); 
     
}
function HttpInsertComment()
{
    if(xmlHttp.readystate == 4)
    {   
      
        try
        { 
            
            if(xmlHttp.status == 200)
            {   
                    document.getElementById(commentID+5).innerHTML=xmlHttp.responseText 
                    
            }
            else 
            {
                alert("Response Error"+xmlHttp.status);
            }
        }
        catch(e)
        {
            //alert("May error"+http.status);
        }
    }
}    

function ViewPage(str) 
{  
     
     //alert(Desc); 
     Name =str;
     xmlHttp=new GetXmlHttpObject();  
     var Url = 'Profile.aspx'; 
     Url = Url+"?name="+str; 
     Url = Url+"&sid="+Math.random();  
     xmlHttp.open("GET",Url,true); 
     xmlHttp.onreadystatechange = httpViewProfile; 
     xmlHttp.send(null); 
     
}
function httpViewProfile()
{ 
     document.getElementById(Name).style.visibility = 'visible'; 
    if(xmlHttp.readystate == 4)
    {   
      
        try
        { 
            
            if(xmlHttp.status == 200)
            {   
                    document.getElementById(Name).innerHTML=xmlHttp.responseText 
                    
            }
            else 
            {
                alert("Response Error"+xmlHttp.status);
            }
        }
        catch(e)
        {
            //alert("May error"+http.status);
        }
    }
}    

function Hidediv(str)
{ 
    document.getElementById(str).style.visibility = 'hidden'; 

}





 //document.getElementById("txtclient").innerHTML=xmlHttp.responseXML.getElementsByTagName("Client")[0].childNodes[0].nodeValue; 
                    //document.getElementById("Daterequested").innerHTML=xmlHttp.responseXML.getElementsByTagName("DateRequest")[0].childNodes[0].nodeValue; 
                    //document.getElementById("accountname").innerHTML=xmlHttp.responseXML.getElementsByTagName("AccountName")[0].childNodes[0].nodeValue; 
                    //temp document.getElementById("Daterequested").innerHTML=xmlHttp.responseXML.getElementsByTagName("DateRequest")[0].childNodes[0].nodeValue; 
                    //document.getElementById("Position").innerHTML=xmlHttp.responseXML.getElementsByTagName("Position")[0].childNodes[0].nodeValue; 
                    //document.getElementById("Vessel").innerHTML=xmlHttp.responseXML.getElementsByTagName("VesselName")[0].childNodes[0].nodeValue; 
                    //document.getElementById("Vesseltype").innerHTML=xmlHttp.responseXML.getElementsByTagName("Type")[0].childNodes[0].nodeValue; 
                    //document.getElementById("PositionNotes").innerHTML=xmlHttp.responseXML.getElementsByTagName("Notes")[0].childNodes[0].nodeValue; 
                    //document.getElementById("QTY").innerHTML=xmlHttp.responseXML.getElementsByTagName("QTY")[0].childNodes[0].nodeValue; 
                 