// JScript File

//AJAX
///getFormValues
///The AJAX calls go here 
///(this is the only AJAX method exposed to the interface)
function getFormValues(path){
    xmlhttp = createAJAXObject();
    xmlhttp.open("GET",path,true);
    xmlhttp.onreadystatechange = updatePage;
	xmlhttp.send(null);
}


function getFormValuesFillIn(path){

    xmlhttp = createAJAXObject();
    xmlhttp.open("GET",path,true);
    xmlhttp.onreadystatechange = updatePrice;
	xmlhttp.send(null);
}


function CookieCheck(path)
{
    xmlhttp = createAJAXObject();
    xmlhttp.open("GET",path,true);
    xmlhttp.onreadystatechange = SetSession;
	xmlhttp.send(null);
}


function updatePage(){
  if(xmlhttp.readyState==4)
  {
        var results = xmlhttp.responseText;

       if(results != ""){ 
            var groupID = splitStrings(results, 'group-ID');
            var groupName = splitStrings(results, 'group-name');
            var groupDescription = splitStrings(results, 'group-desc');

            document.getElementById('ctl00_contentMain_txtGroupName_Changed').value = groupName;
            document.getElementById('ctl00_contentMain_txtGroupDesc_Changed').value = groupDescription;

            var popUp = document.getElementById('ctl00_contentMain_pnlDetail');
            popUp.style.display = ''
        }else{
            //do nothing
        }
    }
}

function SetSession()
{

}



function splitStrings( result, splitBy){
    var values = result.split("<" + splitBy + ">");
    return values[1].split("</" + splitBy + ">")[0];
}

///createAJAXObject
///Creates the XMLHttp Request Object to be used in AJAX calls.
///Returns the XMLHttp Request Object
function createAJAXObject(){
//these checks are required because browsers support different
//methods of handling XMLHttp Request Objects (main support is IE 5+ and FF 1.0+)
    try{
        xmlhttp = new ActiveXObject( "Msxml2.XMLHTTP" );
    }catch(E){
        try{
            xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP" );
        }catch(E){
            xmlhttp = false;
        }
    }
    
    if( !xmlhttp && typeof XMLHttpRequest != 'undefined'){
        try{
            xmlhttp = new XMLHttpRequest();
        }catch(E){
            xmlhttp = false;
        }
    }
    
    if( !xmlhttp && window.createRequest){
        try{
            xmlhttp = window.createRequest();
        }catch(E){
            xmlhttp = false;
        }
    }
    
    if(!xmlhttp){
        alert( "Your browser does not support this script.\n  You will need to manually enter the data.");
    }
    
    return xmlhttp;
}


