function createRajdevicesXMLHttpRequest(){
	  var req;
	  if (window.XMLHttpRequest){ 
		req = new XMLHttpRequest(); 
	} else if (window.ActiveXObject){ 
		req = new ActiveXObject("Microsoft.XMLHTTP"); 
	} 
	return req;
  }
  function getRajdevicesAutonomyResponse(XMLHttpRec,title,query,conSize,relatedLink,recency,source) {
   // Abort any currently pending requests for this XMLHttpRequest Object
   XMLHttpRec.onreadystatechange = function () {}
   XMLHttpRec.abort();
   var urlMapping = "";
   // Get variables from form and build URL to call
   if(urlMapping ==""){
		urlMapping="";
	}else	{
		urlMapping="/" + urlMapping;
	}
	
	url = urlMapping + "/realtedautonomy?autnQuery="+query+"&contentSize="+conSize+"&isReltated="+relatedLink+"&recency="+recency;
		
	// Tell the XMLHttpRequest object what the url is and that 
   // you will use the "GET" response not "POST" to call the external url
   XMLHttpRec.open("GET", url, true);

   // Assign the name of the JavaScript function which will be called 
   // when the request completed then send the request
   XMLHttpRec.onreadystatechange = function () { 
                                    callback(XMLHttpRec,title,source);
                                    }
   XMLHttpRec.send(null);
   
 } 
 
 function callback(req,sectionDiv,source){
	
	  if (req.readyState==4){ 
	      if (req.status == 200){ 
			if (window.ActiveXObject)
			{
	          	populateData(req,sectionDiv,source);
			} 
	        else if (window.XMLHttpRequest)
			{ 
	            populateData(req,sectionDiv,source); 
	        } 
	      } 
    } 

 }
 
  function populateData(r,sectionDiv,source){
	
    var resp = r.responseText;
    var myJSONObject = eval('(' + resp + ')');
	displayRajdevicesData(myJSONObject,sectionDiv,source);
  }
  
  
  
  function displayRajdevicesData(rajdevicesInfoObj,sectionDiv,source)
{	

  	var i;
  	var flag = false;
      var responseHTML = "";
  	//var divID = infoObj.divID;
      var moreID = "more"+sectionDiv;
  	if (typeof(rajdevicesInfoObj.sectionData)=="undefined")
  	{
  		if(source == 'EVENT')
  		{
  		document.getElementById(sectionDiv).innerHTML = "<div class='rightCommon'><span class='headlineTitle'>No Data Available...</span></div>";
  		}else{
  		document.getElementById(sectionDiv).innerHTML = "<div class='headlineTxt'><br><i><strong>No Data Available...</strong></i></div>";
  		}
  		/*if (document.getElementById(moreID)!=null){
  			document.getElementById(moreID).style.display="none";
  		}*/
  		return;
  	}else if (rajdevicesInfoObj.sectionData.length == 0){
  		document.getElementById(sectionDiv).innerHTML = "<div class='headlineTxt'><br><i><strong>No Data Available...</strong></i></div";
  			/*if (document.getElementById(moreID)!=null){
  				document.getElementById(moreID).style.display="none";
  			}*/
  	}
  	
  	for (i = 0; i < rajdevicesInfoObj.sectionData.length; i++) 
  	{  
  		var rajdevicesData = rajdevicesInfoObj.sectionData[i];
  			
  						
  		/*	if (typeof(vid.imgSrc)!="undefined" && vid.imgSrc != null){
  				responseHTML +="<div class='sectionRightImg'><img src='"+vid.imgSrc+"' border='0'/></div>";
  				
  			}
  			responseHTML +="<div class='"+titleClass+"'><span class='"+spanClass+"'><a href='"+vid.articleUrl+"'>"+ vid.articleTitle +"</a></span><br/></div>";
  			responseHTML +="<div class='"+contentClass+"'><p>"+vid.bodyContent+"</p></div>";						
  				
  			//responseHTML +="</p>"; */
  			
  			if(source == "PEOPLE"){
  			if(rajdevicesInfoObj.sectionData.length == 2){
  			responseHTML +="<div class='peopleContainer'><span class='peopleTitle'><a href='"+rajdevicesData.articleUrl+"'>"+rajdevicesData.articleTitle+"</a></span>";
			responseHTML +="<span class='peopleTxt'>"+rajdevicesData.bodyContent+"</span></div>";
			}if(rajdevicesInfoObj.sectionData.length == 1){
			responseHTML +="<div class='middleCommon'><span class='headlineTitle'><a href='"+rajdevicesData.articleUrl+"'>"+rajdevicesData.articleTitle+"</a></span>";
			responseHTML +="<span class='newsContent'>"+rajdevicesData.bodyContent+"</span></div>";
			}
  			}else if(source == "INTERVIEW"){
  			responseHTML +="<div class='middleCommon'><span class='headlineTitle'><a href='"+rajdevicesData.articleUrl+"'>"+rajdevicesData.articleTitle+"</a></span></div>";
  			responseHTML +="<div class='middleCommon'><span class='italicText'>"+rajdevicesData.articleDate+"</span></div><br/>";
  			responseHTML +="<div class='middleCommon'><span class='italicText'><i>"+rajdevicesData.author+"</i></span></div><br/>";
			responseHTML +="<div class='middleCommon'><p>"+rajdevicesData.bodyContent+"</p></div>";
  			}else if(source == "Events"){
  			responseHTML +="<div class='rightCommon'><span class='headlineTitle'><a href='"+rajdevicesData.articleUrl+"'>"+rajdevicesData.articleTitle+"</a></span></div>";
			responseHTML +="<div class='rightCommon'><span class='italicText'>"+rajdevicesData.eventDate+"</span></div>";
			responseHTML +="<div class='rightCommon'><span class='newsContent'>"+rajdevicesData.eventLocation+"</span></div>";
  			}else if(source =="SECTOR NEWS"){
  			responseHTML +="<div class='leftHeading'><span class='headlineTitle'><a href='"+rajdevicesData.articleUrl+"'>"+rajdevicesData.articleTitle+"</a></span></div>";
			responseHTML +="<div class='leftHeading'><span class='italicText'>"+rajdevicesData.articleDate+"</span></div>";
			responseHTML +="<div class='leftHeading'><p>"+rajdevicesData.bodyContent+"</p></div>";
			if (typeof(rajdevicesData.relatedLink1)!="undefined"){
				responseHTML +="<div class='leftHeading'><span class='leftArrow'><img src='/template/ver1-0/images/arrowImg.gif' height='7' width='5' border='0'/></span>";
				responseHTML +="<span class='leftInnerTxt'> <a href='"+rajdevicesData.relatedUrl1+"'>"+rajdevicesData.relatedLink1.substring(0,60)+"...</a></span></div>";
				
			}
			if (typeof(rajdevicesData.relatedLink2)!="undefined"){
				responseHTML +="<div class='leftHeading'><span class='leftArrow'><img src='/template/ver1-0/images/arrowImg.gif' height='7' width='5' border='0'/></span>";
				responseHTML +="<span class='leftInnerTxt'> <a href='"+rajdevicesData.relatedUrl2+"'>"+rajdevicesData.relatedLink2.substring(0,60)+"...</a></span></div>";				
			}
  			}else if(source == "LATEST FEATURE"){
			responseHTML +="<div class='middleCommon'><span class='headlineTitle'><a href='"+rajdevicesData.articleUrl+"'>"+rajdevicesData.articleTitle+"</a></span></div>";
			responseHTML +="<div class='middleCommon'><span class='italicText'>"+rajdevicesData.articleDate+"</span></div>";
			responseHTML +="<div class='middleCommon'><span class='middleTxt'>"+rajdevicesData.bodyContent+"</span></div>";
  			}
  			else if(source == "TOP STORY"){	  			
			responseHTML +="<div class='leftHeading'><span class='headlineTitle'><a href='"+rajdevicesData.articleUrl+"'>"+rajdevicesData.articleTitle+"</a></span></div>";
			responseHTML +="<div class='leftHeading'><span class='italicText'>"+rajdevicesData.articleDate+"</span></div>";
			responseHTML +="<div class='leftHeading'><span class='middleTxt'>"+rajdevicesData.bodyContent+"</span></div>";			
			if (typeof(rajdevicesData.relatedLink1)!="undefined"){
				responseHTML +="<div class='leftHeading'><span class='leftArrow'><img src='/template/ver1-0/images/arrowImg.gif' height='7' width='5' border='0'/></span>";
				responseHTML +="<span class='leftInnerTxt'> <a href='"+rajdevicesData.relatedUrl1+"'>"+rajdevicesData.relatedLink1.substring(0,60)+"...</a></span></div>";
				
			}
			if (typeof(rajdevicesData.relatedLink2)!="undefined"){
				responseHTML +="<div class='leftHeading'><span class='leftArrow'><img src='/template/ver1-0/images/arrowImg.gif' height='7' width='5' border='0'/></span>";
				responseHTML +="<span class='leftInnerTxt'> <a href='"+rajdevicesData.relatedUrl2+"'>"+rajdevicesData.relatedLink2.substring(0,60)+"...</a></span></div>";				
			}			
		}
  			else{
  			if (typeof(rajdevicesData.imgSrc)!="undefined" && rajdevicesData.imgSrc != null){
				responseHTML +="<div class=leftHeading><div class=leftImage><img src='"+rajdevicesData.imgSrc+"' border='0'/></div>";
				responseHTML +="<div class='leftContent'><span class='headlineSubTitle'><a href='"+rajdevicesData.articleUrl+"'>"+rajdevicesData.articleTitle+"</a></span>";
				responseHTML +="<span class='italicTextAlt'>"+rajdevicesData.articleDate+"</span></div><div class='leftContentTxt marginTop10'>"+rajdevicesData.bodyContent+"</div></div>";
			}else {
				responseHTML +="<div class='leftHeading'><span class='headlineTitle'><a href='"+rajdevicesData.articleUrl+"'>"+rajdevicesData.articleTitle+"</a></span></div>";
				responseHTML +="<div class='leftHeading'><span class='italicText'>"+rajdevicesData.articleDate+"</span></div>";
				responseHTML +="<div class='leftHeading marginTop10'><p>"+rajdevicesData.bodyContent+"</p></div>";
			}			
			if (typeof(rajdevicesData.relatedLink1)!="undefined"){			 
				responseHTML +="<div class='leftHeading'><span class='leftArrow'><img src='/template/ver1-0/images/arrowImg.gif' height='7' width='5' border='0' /></span>";
				responseHTML +="<span class='leftInnerTxt'><a href='"+rajdevicesData.relatedUrl1+"'>"+rajdevicesData.relatedLink1.substring(0,60)+"...</a></span></div>";
			}
			if (typeof(rajdevicesData.relatedLink2)!="undefined"){
				responseHTML +="<div class='leftHeading'><span class='leftArrow'><img src='/template/ver1-0/images/arrowImg.gif' height='7' width='5' border='0' /></span>";
				responseHTML +="<span class='leftInnerTxt'><a href='"+rajdevicesData.relatedUrl2+"'>"+rajdevicesData.relatedLink2.substring(0,60)+"...</a></span></div>";
			}
			}
  		  				
  		
  	}
  	
  	document.getElementById(sectionDiv).innerHTML = responseHTML;


}
 
 
 
  function getRajdevicesEventsResponse(XMLHttpRec,source) {
		
		 var urlMapping = "";
	  
	   // Get variables from form and build URL to call
	   if(urlMapping ==""){
			urlMapping="";
		}else	{
			urlMapping="/" + urlMapping;
		}
		
	   // Abort any currently pending requests for this XMLHttpRequest Object
	   XMLHttpRec.onreadystatechange = function () {}
	   XMLHttpRec.abort();
	   // Get variables from form and build URL to call
	   var url = urlMapping+"/latestEvents";

	   // Tell the XMLHttpRequest object what the url is and that 
	   // you will use the "GET" response not "POST" to call the external url
	   XMLHttpRec.open("GET", url, true);

	   // Assign the name of the JavaScript function which will be called 
	   // when the request completed then send the request
	   XMLHttpRec.onreadystatechange = function () { 
	                                    callback(XMLHttpRec,source,source);
	                                    }
	   XMLHttpRec.send(null);
	   
	 }
 