//Copyright Square Solutions Ltd
//COMS Generic Ajax Support	
//Updates
//15 November 2010 - added show div by setting display='' when field received	

//Group of functions concerned with the option popup
var permissionGetSuccess = function(o) {
    if (o.responseText !== undefined) {
        if (o.status == 403) { alert('403-----error'); return; }
        if (o.status == 200) {
//            alert(o.responseText);
            var root1 = o.responseXML.documentElement;
            var nc = root1.getElementsByTagName("node");
            var nodecount = nc.length;
            //            alert("Number of rows(nodes)=" + nodecount);
            var xx = root1.childNodes;

            for (var i = 0; i < nodecount; i++) {
                var yy = xx[i];
                var zz = yy.childNodes;
                var nc1 = zz.length
                //                alert("Number of columns=" + nc1);

                for (var j = 0; j < nc1; j++) {
                    var uu = zz[j];
//                  alert(uu.tagName + '=' + uu.textContent);
                

		    try {
                        var IE = /*@cc_on!@*/false;
                        if (IE) {
			    if (uu.tagName == 'location') {
				alert('navigating to ' + uu.text);
				location.href=uu.text;
				return;	
			    }

                            document.getElementById(uu.tagName).innerHTML = uu.text;
                            document.getElementById(uu.tagName).style.display='';
				
                        } else {
			    if (uu.tagName == 'location') {
				alert('navigating to ' + uu.textContent);
				location.href=uu.textContent;
				return;	
			    }
                            document.getElementById(uu.tagName).innerHTML = uu.textContent;
                            document.getElementById(uu.tagName).style.display='';
                        }

                    }
                    catch (ex) {
//                        alert("Document element " + uu.tagName + " not found");
                    }




                }
            }





        }
    }
}
var permissionGetFailure = function(o)
	{
	if (o.status==403) {alert('403 error');	return;}	
	if(o.responseText !== undefined) {
	    alert(o.responseText);
		alert("fetch of data failed " + o.status);
		}
  }

var permissionGetCallBack =
	{
	 	success:	permissionGetSuccess,
   	failure:	permissionGetFailure,
   	argument: { foo:"foo", bar:"bar" }
	}

function getAjaxData(sqlcode)
	{
	var postURL = 'SQLXMLPublic.asp';
	var codestring=sqlcode.replace(/&amp;/g,"&")
	var postParam = encodeURI(codestring);

//	var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, permissionGetCallBack);
	var request = YAHOO.util.Connect.asyncRequest('POST', postURL, permissionGetCallBack, postParam);
	//// 	myLogWriter.log(sUrl);
	
  }

//------------------------------------------------------------------------------	
	
	
	

