﻿$(document).ready(function serviceModules(){
	var soapEnv =
	"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
	<soapenv:Body> \
	     <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
	        <listName>Services_Modules</listName> \
	        <viewFields> \
	            <ViewFields> \
	               <FieldRef Name='Image' /> \
	               <FieldRef Name='Link' /> \
	               <FieldRef Name='Title' /> \
	               <FieldRef Name='Synopsis' /> \
	           </ViewFields> \
	        </viewFields> \
	    </GetListItems> \
	</soapenv:Body> \
	</soapenv:Envelope>";
	$.ajax({
	url: "../_vti_bin/lists.asmx",
	type: "POST",
	dataType: "xml",
	data: soapEnv,
	complete: processSResult,
	contentType: "text/xml; charset=\"utf-8\""
	});
	
});

function processSResult(xData, status) {
	var browser6=navigator.appName;
	if(browser6== "Microsoft Internet Explorer"){
		$(xData.responseXML).find("z\\:row").each(function() {
		var sName = $(this).attr("ows_Title");
		var sImages = $(this).attr("ows_Image");
		var sSummary = $(this).attr("ows_Synopsis");
        
        Position6 = sImages.indexOf(','); 
        function Left77(str, n){
	    	if (n <= 0)
	    		return "";
	        else if (n > String(str).length)
	            return str;
	        else
	            return String(str).substring(0,n);
		}		
		sImagesRC = Left77(sImages, Position6);
		
		var sLinker = $(this).attr("ows_Link");
		PositionA = sLinker.indexOf(',');        	
        sLinky = Left77(sLinker, PositionA);
    	
    	var sStuff = "<div><div class='security-box' style='background:url("+ sImagesRC +") no-repeat'><h4>"+ sName +"</h4><p>"+ sSummary +"</p><p class='more'><a href='"+ sLinky +"'>more</a></p></div></div>";
    	$("#s1").append(sStuff);	
		});
	}
	else{
		$(xData.responseText).find("z\\:row").each(function() {
		var sName = $(this).attr("ows_Title");
		var sImages = $(this).attr("ows_Image");
		var sSummary = $(this).attr("ows_Synopsis");
        
        Position6 = sImages.indexOf(','); 
        function Left77(str, n){
	    	if (n <= 0)
	    		return "";
	        else if (n > String(str).length)
	            return str;
	        else
	            return String(str).substring(0,n);
		}		
		sImagesRC = Left77(sImages, Position6);
		
		var sLinker = $(this).attr("ows_Link");
		PositionA = sLinker.indexOf(',');        	
        sLinky = Left77(sLinker, PositionA);
    	
    	var sStuff = "<div><div class='security-box' style='background:url("+ sImagesRC +") no-repeat'><h4>"+ sName +"</h4><p>"+ sSummary +"</p><p class='more'><a href='"+ sLinky +"'>more</a></p></div></div>";
    	$("#s1").append(sStuff);	
		});
		
		
	
	}
	
	$('#s1').cycle({ 
			fx:     'fade', 
		    speed:   800, 
		    timeout: 20000,
		    random: 1,
		    cleartype:  1 
		});
}      



      