﻿/*
function QueryListEx(listGuid, fields, where, orderBy, extractRows)
{
	var a = new ActiveXObject("Microsoft.XMLHTTP");

	if(a == null) return null;

	a.Open("POST", GetRootUrl() + "/_vti_bin/DspSts.asmx", false);
	a.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
	a.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/sharepoint/dsp/queryRequest");

	var d = '<?xml version=\"1.0\" encoding=\"utf-8\"?>'
	+ "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
	+ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
	+ "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope\/\">"
	+" <soap:Header xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope\/\">"
	+" <dsp:versions xmlns:dsp=\"http://schemas.microsoft.com/sharepoint/dsp\">"
	+" <dsp:version>1.0</dsp:version>"
	+" </dsp:versions>"
	+" <dsp:request xmlns:dsp=\"http://schemas.microsoft.com/sharepoint/dsp\""
	+" service=\"DspSts\" document=\"content\" method=\"query\">"
	+" </dsp:request>"
	+" </soap:Header>"
	+ "<soap:Body>"
	+ "<queryRequest "
	+" xmlns=\"http://schemas.microsoft.com/sharepoint/dsp\">"
	+" <dsQuery select=\"/list[@id='" + listGuid + "']\""
	+" resultContent=\"dataOnly\""
	+" columnMapping=\"attribute\" resultRoot=\"Rows\" resultRow=\"Row\">"
	+" <Query>"
	+" <Fields>" + fields + "</Fields>"
	+" <Where>"+ where +"</Where>"
	+" <OrderBy>"+ orderBy + "</OrderBy>"
	+" </Query>"
	+" </dsQuery>"
	+" </queryRequest>"
	+ "</soap:Body>"
	+ "</soap:Envelope>";



	a.Send(d);

	if (a.status != 200)
	{
		return null;
	}
	else
	{
		if (extractRows)
			return a.responseXML.selectNodes('//Row');
		else
			return a.responseXML;
	}
}

//*/

/*
function InciQueryWebService(listGuid, query)
{
	var a = new ActiveXObject("Microsoft.XMLHTTP");

	if(a == null) return null;


	a.Open("POST", GetRootUrl() + "/_layouts/inci_dspsts.asmx", false);
	a.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
	a.setRequestHeader("SOAPAction", "http://www.inciholding.com.tr/dsp/GetListQueryItems");



	var d = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
	+ "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
	+ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
	+ "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope\/\">"
	+ "<soap:Body>"
	+ "<GetListQueryItems xmlns=\"http://www.inciholding.com.tr/dsp\">"
	+ "<list_id>"+ listGuid +"</list_id>"
	+ "<query_xml>![CDATA["+query+"]]</query_xml>"	
	+" </GetListQueryItems>"
	+ "</soap:Body>"
	+ "</soap:Envelope>";



	a.Send(d);
	if (a.status != 200)
	{
		alert(a.statustext);
		return null;
	}
	else
	{
		var node = a.responseXML.documentElement.selectNodes('//exception');
		if(node.length!=0)
			return null;

		node = a.responseXML.documentElement.selectNodes('//z:row');
		return node;
	}

}
//*/
function InciQueryWebService(url, query, fields)
{

	var a = new ActiveXObject("Microsoft.XMLHTTP");

	if(a == null) return null;



	a.Open("POST", GetRootUrl() + url, false);

	a.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

	var d = "";
	d += "query="+query+"\n";
	d += "fields="+fields+"\n";



	a.Send(d);
	if (a.status != 200)
	{
		alert(a.statustext);
		return null;
	}
	else
	{
		node = a.responseXML.documentElement.selectNodes('//z:row');
		return node;
	}

}


function GetRootUrl()
{
	var pathparts = document.location.pathname.split("/");
	var url;
	url = "https://" + document.location.hostname;
	if(document.location.port != "")
	{
		url += ":" + document.location.port
	}

	return url;
}

