﻿// Ajax.js Javascript File for displaying experience & education in resume

var xmlHttp

//function showPoems(str)
//{
//    xmlHttp=GetXmlHttpObject()
//    if (xmlHttp==null)
//    {
//        alert ("Browser does not support HTTP Request")
//        return
//    }
//    var url="ShowPoems.aspx"
//    url=url+"?q="+str
//    url=url+"&sid="+Math.random()
//    xmlHttp.onreadystatechange=poemsStateChanged
//    xmlHttp.open("GET",url,true)
//    xmlHttp.send(null)
//}

function showFunnies(str)
{
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
        alert ("Browser does not support HTTP Request")
        return
    }
    var url="ShowFunnies.aspx"
    url=url+"?q="+str
    url=url+"&sid="+Math.random()
    xmlHttp.onreadystatechange=poemsStateChanged
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
}

function showCommentary(str)
{
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
        alert ("Browser does not support HTTP Request")
        return
    }
    var url="ShowCommentary.aspx"
    url=url+"?q="+str
    url=url+"&sid="+Math.random()
    xmlHttp.onreadystatechange=commentaryStateChanged
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
}

function showOtherCommentary(str)
{
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
        alert ("Browser does not support HTTP Request")
        return
    }
    var url="ShowCommentary.aspx"
    url=url+"?q="+str
    url=url+"&sid="+Math.random()
    xmlHttp.onreadystatechange=otherCommentaryStateChanged
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
}


function showEducation(str)
{ 
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
        alert ("Browser does not support HTTP Request")
        return
    } 
    var url="ShowEducation.aspx"
    url=url+"?q="+str
    url=url+"&sid="+Math.random()
    xmlHttp.onreadystatechange=eduStateChanged 
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
}

function showExperience(str)
{ 
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
        alert ("Browser does not support HTTP Request")
        return
    } 
    var url="ShowExperience.aspx"
    url=url+"?q="+str
    url=url+"&sid="+Math.random()
    xmlHttp.onreadystatechange=expStateChanged
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
}

function poemsStateChanged()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
       document.getElementById("txtPoems").innerHTML=xmlHttp.responseText 
    }   
}

function commentaryStateChanged()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
       document.getElementById("txtCommentary").innerHTML=xmlHttp.responseText 
    }   
}

function otherCommentaryStateChanged()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
       document.getElementById("txtOtherCommentary").innerHTML=xmlHttp.responseText 
    }   
}

function eduStateChanged() 
{ 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    { 
       document.getElementById("txtEducation").innerHTML=xmlHttp.responseText
    } 
} 

function changeTextColor(str)
{
    if(str == 'TESTOUT')
    {
    document.getElementById("testout").style.color='red'
    }
    else
    {
     document.getElementById("testout").style.color='black'   
    }
    
    if(str == 'NOVL')
    {
    document.getElementById("novell").style.color='red'
    }
    else
    {
    document.getElementById("novell").style.color='black'   
    }
    
    if(str == 'NETSCH')
    {
    document.getElementById("netschools").style.color='red'
    }  
    else
    {
     document.getElementById("netschools").style.color='black'  
    }      
}

function expStateChanged() 
{ 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    { 
        document.getElementById("txtExperience").innerHTML=xmlHttp.responseText 
    } 
}

function GetXmlHttpObject()
{ 
    var objXMLHttp = null
    
    try
    {    // Firefox, Opera 8.0+, Safari (seems to work for MS IE as well)
        objXMLHttp = new XMLHttpRequest();
    }
    catch (e)
    {    // Internet Explorer
        if (window.ActiveXObject)
        {
            try
            {
                objXMLHttp = new ActiveXObject("Msxml2.XMLHTTP")
            }
            catch(e)
            { 
                objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP")
            }
        }
        else if (window.XMLHttpRequest)
        {
             objXMLHttp=new XMLHttpRequest()
        }
    }
    
    return objXMLHttp
}
