var page = 0;
var start=0;
var size=0;
	function getWidgetArticle(pageNo){
	//alert("in getWidget()")
	page=parseInt(pageNo)+1;
	start = parseInt(pageNo);
		var url = "/electionWidget.do?choice=WidgetArticle&pageNo="+pageNo;
	
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}

	req.open("POST", url, true);
	req.onreadystatechange = getRecentArticles;
	req.send(null);	
	
	//currentStartPosition=start;
	//currentEndPosition=end;
	
	}
	
	 function getRecentArticles() {
	if (req.readyState == 4) {
		if (req.status == 200) {
	
			
			populateRecentArticles()
			
		}
	}
}

function populateRecentArticles() {
     
		 
     	 myTable = document.createElement("DIV");
    	 myTable.id="div1";	
     	
		var ReccentArticles =  req.responseXML.getElementsByTagName("articles")[0];
	     //var ReccentArticlesSizes =  req.responseXML.getElementsByTagName("sizes")[0];
	     i=0;
	     var temp="";
	      
	    temp +='<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#D6E3F2">';
  		temp +='<tr>';
	    temp +='<td align="center" valign="top">';
	    temp +='<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">';
    	temp +='<tr>';
        temp +='<td colspan="2" align="left" valign="top" bgcolor="#EEF5FB" style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#1B5790; text-decoration:underline">';
		temp +='<table width="100%" border="0" cellspacing="0" cellpadding="0">';
        temp +='<tr>';
        temp +='<td align="left" valign="middle"> <strong>Election Updates </strong></td>';
        temp +='<td align="right" valign="middle"><a href="#"><font face="Verdana, Arial, Helvetica, sans-serif" color="#333333" size="1"></font></a></td>';
        temp +='</tr>';
        temp +='</table>         </td>';
        temp +='</tr>';
    	temp +='<tr>';
        temp +='<td height="5" colspan="2" align="left" valign="middle"></td>';
	    temp +='</tr>';
        temp +='<tr>';
        temp +='<td colspan="2" align="left" valign="middle" style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#000000; text-decoration:none"><img src="http://www.merinews.com/images/logo_wgt.gif" width="130" height="38" /></td>';
      	temp +='</tr>';
	    temp +='<tr>';
        temp +='<td colspan="2" align="left" valign="middle> ';
	    temp +='<div id="bsttabs">';
		temp +='<ul id="tabmenu" > ';
		temp +='<li onclick="getWidgetJustIn(0)"><a href="#" class="" id="tab1" >Justin</a></li> ';
		temp +='<li onclick="getWidgetArticle(0)" style = "border-bottom-width: 3px; border-bottom-color: #EEF5FB; border-bottom-style: solid; background-color: #1B5790;"><a class="" id="tab2">Articles</a></li> ';
		temp +='<li onclick="getWidgetPhotos(0)"><a href="#" class="" id="tab1" >Photos</a></li> ';
		temp +='<li onclick="getWidgetDebateQuestion()"><a class="" id="tab2" >Debate</a></li>';
		temp +='</ul> </div></td>';
		temp +='</tr>';
      	temp +='<tr>';
        temp +='<td height="8" colspan="2"></td>';
      	temp +='</tr>';
      
	      
	     for (loop = 0;loop<ReccentArticles.childNodes.length;  loop++,i++)
	     {
	     var ReccentArticle = ReccentArticles.childNodes[loop];
	     var imageName=(ReccentArticle.getElementsByTagName("imageName")[0]).firstChild.nodeValue;
	     var title = (ReccentArticle.getElementsByTagName("title")[0]).firstChild.nodeValue;
	     var articleID = (ReccentArticle.getElementsByTagName("articleId")[0]).firstChild.nodeValue;
	     var briefSummary=(ReccentArticle.getElementsByTagName("briefSummary")[0]).firstChild.nodeValue;
	     size = (ReccentArticle.getElementsByTagName("size")[0]).firstChild.nodeValue;
	    
	    if(loop%2 == 1)
	    {
	    //alert('Yes');
		    temp +='<td align="left" valign="top" bgcolor="#F6F9FF">';
		    temp +='<a href="/catFull.jsp?articleID='+articleID+'" target="_blank"><img src="http://business.merinews.com/upload/thumbimage/'+imageName+'" width="58" height="47" hspace="0" vspace="0" border="0"/></a></td>';
	        temp +='<td align="left" valign="top" bgcolor="#F6F9FF"><a href="/catFull.jsp?articleID='+articleID+'" target="_blank" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#FF6600; text-decoration:none"><strong>'+title+'<br />';
	        temp +='</strong></a><span style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#666666; text-decoration:none">'+briefSummary+'</span></td>';
		    temp +='</tr>';
		    temp +='<tr>';
        	temp +='<td height="4" colspan="2"></td>';
      		temp +='</tr>';
      		temp +='<tr>';
        	temp +='<td height="1" colspan="2"bgcolor="#D6E3F2"></td>';
      		temp +='</tr>';
      		temp +='<tr>';
        	temp +='<td height="4" colspan="2"></td>';
      		temp +='</tr>';
	    }else{
	    
        	temp +='<tr>';
        	temp +='<td  width="16%" align="left" valign="top"><a href="/catFull.jsp?articleID='+articleID+'" target="_blank"><img src="http://business.merinews.com/upload/thumbimage/'+imageName+'" width="58" height="47" hspace="0" vspace="0" border="0"/></a></td>';
        	temp +='<td  width="84%" align="left" valign="top"><a href="/catFull.jsp?articleID='+articleID+'" target="_blank" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#FF6600; text-decoration:none"><strong>'+title+'<br />';
        	temp +='</strong></a><span style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#666666; text-decoration:none">'+briefSummary+'</span></td>';
      		temp +='</tr>';
      		temp +='<tr>';
        	temp +='<td height="4" colspan="2"></td>';
      		temp +='</tr>';
      		temp +='<tr>';
        	temp +='<td height="1" colspan="2"bgcolor="#D6E3F2"></td>';
      		temp +='</tr>';
      		temp +='<tr>';
        	temp +='<td height="4" colspan="2"></td>';
      		temp +='</tr>';
      		temp +='<tr>';
	  }  
   }
	  
	  if(start==0){
		   temp +='<tr>';
    	   temp +='<td align="left" valign="top">&nbsp;</td>';
           temp +='<td align="right" valign="middle" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#FF6600; text-decoration:none" ><a href="JavaScript:getWidgetArticle('+page+');" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#FF6600; text-decoration:none">next &rsaquo;&rsaquo;</a></td>';
	       temp +='</tr>';
	 
	  }else if(page*3 > size){
	  	temp +='<tr>';
        temp +='<td align="left" valign="top"><a href="JavaScript:getWidgetArticle('+(start-1)+');" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#FF6600; text-decoration:none">&lt;&lt;previous</a>&nbsp;</td>';
        temp +='<td align="right" valign="middle" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#FF6600; text-decoration:none" ></td>';
      	temp +='</tr>';
	  }
	  else{
	 	temp +='<tr>';
        temp +='<td align="left" valign="top"><a href="JavaScript:getWidgetArticle('+(start-1)+');" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#FF6600; text-decoration:none">&lt;&lt;previous</a>&nbsp;</td>';
        temp +='<td align="right" valign="middle" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#FF6600; text-decoration:none" ><a href="JavaScript:getWidgetArticle('+page+');" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#FF6600; text-decoration:none">next &rsaquo;&rsaquo;</a></td>';
      	temp +='</tr>';
	  }
	  	
        temp +='</table></td>';
		temp +='</tr>';
		temp +='</table>';
	  	
	  myTable.innerHTML =temp;
	  
	  var test1 = document.getElementById("div1");
	  //alert(test1);
	  if(test1 != null){
	  	document.body.removeChild(test1);
	  }
	   
      document.body.appendChild(myTable);
      
 }
	


function getWidgetPhotos(pageNo){
	//alert("in getWidget()")
	page=parseInt(pageNo)+1;
	start = parseInt(pageNo);
		var url = "/electionWidget.do?choice=WidgetPhotos&pageNo="+pageNo;
	
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}

	req.open("POST", url, true);
	req.onreadystatechange = getRecentPhotos;
	req.send(null);	
	
	//currentStartPosition=start;
	//currentEndPosition=end;
	
	}
	
	 function getRecentPhotos() {
	if (req.readyState == 4) {
		if (req.status == 200) {
	
			
			populateRecentPhotos()
			
		}
	}
}

function populateRecentPhotos() {
     
		 
     	 myTable = document.createElement("DIV");
    	 myTable.id="div1";	
     	
		var ReccentPhotos =  req.responseXML.getElementsByTagName("images")[0];
	     //var ReccentArticlesSizes =  req.responseXML.getElementsByTagName("sizes")[0];
	     i=0;
	     var temp="";
      	temp +='<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#D6E3F2">';
  		temp +='<tr>';
	    temp +='<td align="center" valign="top">';
	    temp +='<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">';
    	temp +='<tr>';
        temp +='<td colspan="2" align="left" valign="top" bgcolor="#EEF5FB" style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#1B5790; text-decoration:underline">';
		temp +='<table width="100%" border="0" cellspacing="0" cellpadding="0">';
        temp +='<tr>';
        temp +='<td align="left" valign="middle"> <strong>Election Updates </strong></td>';
        temp +='<td align="right" valign="middle"><a href="#"><font face="Verdana, Arial, Helvetica, sans-serif" color="#333333" size="1"></font></a></td>';
        temp +='</tr>';
        temp +='</table>         </td>';
        temp +='</tr>';
    	temp +='<tr>';
        temp +='<td height="5" colspan="2" align="left" valign="middle"></td>';
	    temp +='</tr>';
        temp +='<tr>';
        temp +='<td colspan="2" align="left" valign="middle" style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#000000; text-decoration:none"><img src="http://www.merinews.com/images/logo_wgt.gif" width="130" height="38" /></td>';
      	temp +='</tr>';
	    temp +='<tr>';
        temp +='<td colspan="2" align="left" valign="middle> ';
	    temp +='<div id="bsttabs">';
		temp +='<ul id="tabmenu" > ';
		temp +='<li onclick="getWidgetJustIn(0)"><a href="#" class="" id="tab1">Justin</a></li> ';
		temp +='<li onclick="getWidgetArticle(0)"><a class="" id="tab2">Articles</a></li> ';
		temp +='<li onclick="getWidgetPhotos(0)" style = "border-bottom-width: 3px; border-bottom-color: #EEF5FB; border-bottom-style: solid; background-color: #1B5790;"><a href="#" class="" id="tab1" >Photos</a></li> ';
		temp +='<li onclick="getWidgetDebateQuestion()"><a class="" id="tab2">Debate</a></li>';
		temp +='</ul> </div></td>';
		temp +='</tr>';
      	temp +='<tr>';
        temp +='<td height="8" colspan="2"></td>';
      	temp +='</tr>';
	    
	     for (loop = 0;loop<ReccentPhotos.childNodes.length;  loop++,i++)
	     {
	     
	     var ReccentArticle = ReccentPhotos.childNodes[loop];
	    // alert(ReccentArticle);
	     var imageId=(ReccentArticle.getElementsByTagName("imageId")[0]).firstChild.nodeValue;
	     var imageName = (ReccentArticle.getElementsByTagName("imageName")[0]).firstChild.nodeValue;
	     var title = (ReccentArticle.getElementsByTagName("title")[0]).firstChild.nodeValue;
	     
	     var caption=(ReccentArticle.getElementsByTagName("caption")[0]).firstChild.nodeValue;
	     
	     size = (ReccentArticle.getElementsByTagName("size")[0]).firstChild.nodeValue;
	    
	    
	    if(loop%2 == 1)
	    {
	    //alert('Yes');
		    temp +='<td align="left" valign="top" bgcolor="#F6F9FF"><a href="/newPhotoLanding.jsp?imageID='+imageId+'" target="_blank"><img src="http://www.merinews.com/upload/imageGallery/thumbImage/'+imageName+'" width="58" height="47" hspace="0" vspace="0" border="0"/></a></td>';
	        temp +='<td align="left" valign="top" bgcolor="#F6F9FF"><a href="/newPhotoLanding.jsp?imageID='+imageId+'" target="_blank" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#FF6600; text-decoration:none"><strong>'+title+'<br />';
	        temp +='</strong></a><span style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#666666; text-decoration:none">'+caption+'</span></td>';
		    temp +='</tr>';
		    temp +='<tr>';
        	temp +='<td height="4" colspan="2"></td>';
      		temp +='</tr>';
      		temp +='<tr>';
        	temp +='<td height="1" colspan="2"bgcolor="#D6E3F2"></td>';
      		temp +='</tr>';
      		temp +='<tr>';
        	temp +='<td height="4" colspan="2"></td>';
      		temp +='</tr>';
	    }else{
	    
        	temp +='<tr>';
        	temp +='<td width="16%" align="left" valign="top"><a href="/newPhotoLanding.jsp?imageID='+imageId+'" target="_blank"><img src="http://www.merinews.com/upload/imageGallery/thumbImage/'+imageName+'" width="58" height="47" hspace="0" vspace="0" border="0"/></a></td>';
        	temp +='<td width="84%" align="left" valign="top"><a href="/newPhotoLanding.jsp?imageID='+imageId+'" target="_blank" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#FF6600; text-decoration:none"><strong>'+title+'<br />';
        	temp +='</strong></a><span style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#666666; text-decoration:none">'+caption+'</span></td>';
      		temp +='</tr>';
      		temp +='<tr>';
        	temp +='<td height="4" colspan="2"></td>';
      		temp +='</tr>';
      		temp +='<tr>';
        	temp +='<td height="1" colspan="2"bgcolor="#D6E3F2"></td>';
      		temp +='</tr>';
      		temp +='<tr>';
        	temp +='<td height="4" colspan="2"></td>';
      		temp +='</tr>';
      		temp +='<tr>';
	  }
	    
	    
	    
       
	    
         }
	if(start==0){
		   temp +='<tr>';
    	   temp +='<td align="left" valign="top">&nbsp;</td>';
           temp +='<td align="right" valign="middle" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#FF6600; text-decoration:none" ><a href="JavaScript:getWidgetPhotos('+page+');" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#FF6600; text-decoration:none">next &rsaquo;&rsaquo;</a></td>';
	       temp +='</tr>';
	 
	  }else if(page*3 > size){
	  	temp +='<tr>';
        temp +='<td align="left" valign="top"><a href="JavaScript:getWidgetPhotos('+(start-1)+');" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#FF6600; text-decoration:none">&lt;&lt;previous</a>&nbsp;</td>';
        temp +='<td align="right" valign="middle" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#FF6600; text-decoration:none" ></td>';
      	temp +='</tr>';
	  }
	  else{
	 	temp +='<tr>';
        temp +='<td align="left" valign="top"><a href="JavaScript:getWidgetPhotos('+(start-1)+');" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#FF6600; text-decoration:none">&lt;&lt;previous</a>&nbsp;</td>';
        temp +='<td align="right" valign="middle" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#FF6600; text-decoration:none" ><a href="JavaScript:getWidgetPhotos('+page+');" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#FF6600; text-decoration:none">next &rsaquo;&rsaquo;</a></td>';
      	temp +='</tr>';
	  }
	  	
        temp +='</table></td>';
		temp +='</tr>';
		temp +='</table>';  
	
	  myTable.innerHTML =temp;
	  
	  var test1 = document.getElementById("div1");
	  //alert(test1);
	  if(test1 != null){
	  	document.body.removeChild(test1);
	  }
	  
      document.body.appendChild(myTable);
      
 }


function getWidgetJustIn(pageNo){
	//alert("in getWidget()")
	page=parseInt(pageNo)+1;
	start = parseInt(pageNo);
		var url = "/electionWidget.do?choice=WidgetJustIn&pageNo="+pageNo;
	
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}

	req.open("POST", url, true);
	req.onreadystatechange = getRecentJustIn;
	req.send(null);	
	
	//currentStartPosition=start;
	//currentEndPosition=end;
	
	}
	
	 function getRecentJustIn() {
	if (req.readyState == 4) {
		if (req.status == 200) {
	
			
			populateRecentJustIn()
			
		}
	}
}

function populateRecentJustIn() {
     
		 
     	 myTable = document.createElement("DIV");
    	 myTable.id="div1";	
     	
		var ReccentArticles =  req.responseXML.getElementsByTagName("comments")[0];
	     //var ReccentArticlesSizes =  req.responseXML.getElementsByTagName("sizes")[0];
	     i=0;
	     var temp="";
      	temp +='<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#D6E3F2">';
  		temp +='<tr>';
	    temp +='<td align="center" valign="top">';
	    temp +='<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">';
    	temp +='<tr>';
        temp +='<td colspan="2" align="left" valign="top" bgcolor="#EEF5FB" style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#1B5790; text-decoration:underline">';
		temp +='<table width="100%" border="0" cellspacing="0" cellpadding="0">';
        temp +='<tr>';
        temp +='<td align="left" valign="middle"> <strong>Election Updates </strong></td>';
        temp +='<td align="right" valign="middle"><a href="#"><font face="Verdana, Arial, Helvetica, sans-serif" color="#333333" size="1"></font></a></td>';
        temp +='</tr>';
        temp +='</table>         </td>';
        temp +='</tr>';
    	temp +='<tr>';
        temp +='<td height="5" colspan="2" align="left" valign="middle"></td>';
	    temp +='</tr>';
        temp +='<tr>';
        temp +='<td colspan="2" align="left" valign="middle" style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#000000; text-decoration:none"><img src="http://www.merinews.com/images/logo_wgt.gif" width="130" height="38" /></td>';
      	temp +='</tr>';
	    temp +='<tr>';
        temp +='<td colspan="2" align="left" valign="middle> ';
	    temp +='<div id="bsttabs">';
		temp +='<ul id="tabmenu" > ';
		temp +='<li onclick="getWidgetJustIn(0)" style = "border-bottom-width: 3px; border-bottom-color: #EEF5FB; border-bottom-style: solid; background-color: #1B5790;"><a href="#" class="" id="tab1">Justin</a></li> ';
		temp +='<li onclick="getWidgetArticle(0)"><a class="" id="tab2">Articles</a></li> ';
		temp +='<li onclick="getWidgetPhotos(0)"><a href="#" class="" id="tab1">Photos</a></li> ';
		temp +='<li onclick="getWidgetDebateQuestion()"><a class="" id="tab2">Debate</a></li>';
		temp +='</ul> </div></td>';
		temp +='</tr>';
      	temp +='<tr>';
        temp +='<td height="8" colspan="2"></td>';
      	temp +='</tr>';
	    
	     for (loop = 0;loop<ReccentArticles.childNodes.length;  loop++,i++)
	     {
	     
	     var ReccentArticle = ReccentArticles.childNodes[loop];
	    // alert(ReccentArticle);
	     var commentId=(ReccentArticle.getElementsByTagName("commentId")[0]).firstChild.nodeValue;
	     var title = (ReccentArticle.getElementsByTagName("title")[0]).firstChild.nodeValue;
	     //var articleID = (ReccentArticle.getElementsByTagName("size")[0]).firstChild.nodeValue;
	     
	     //var listSize=(ReccentArticle.getElementsByTagName("size")[0]).firstChild.nodeValue;
	     
	     size = (ReccentArticle.getElementsByTagName("size")[0]).firstChild.nodeValue;
	    if(loop%2 == 1)
	    {
	    //alert('Yes');
		    //temp +='<td align="left" valign="top" bgcolor="#F6F9FF"><img src="http://www.merinews.com/upload/imageGallery/thumbImage/'+imageName+'" width="58" height="47" hspace="0" vspace="0" border="0"/></td>';
	        //temp +='<td align="left" valign="top" bgcolor="#F6F9FF"><a href="/newPhotoLanding.jsp?imageID='+imageId+'" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#FF6600; text-decoration:none"><strong>'+title+'<br />';
	        //temp +='</strong></a><span style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#666666; text-decoration:none">'+caption+'</span></td>';
		    //temp +='</tr>';
		    
		    
		   temp +='<tr>';
        	temp +='<td align="left" valign="top" bgcolor="#F6F9FF">&nbsp;</td>';
        	temp +='<td align="left" valign="top" bgcolor="#F6F9FF"><a href="/justin" target="_blank" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#FF6600; text-decoration:none"><strong>'+title+'<br />';
        	temp +='</strong></a></td>';
      		temp +='</tr>';
		    
		    
		    temp +='<tr>';
        	temp +='<td height="4" colspan="2"></td>';
      		temp +='</tr>';
      		temp +='<tr>';
        	temp +='<td height="1" colspan="2"bgcolor="#D6E3F2"></td>';
      		temp +='</tr>';
      		temp +='<tr>';
        	temp +='<td height="4" colspan="2"></td>';
      		temp +='</tr>';
	    }else{
	    
        	
      		//bgcolor="#F6F9FF"
      		 temp +='<tr>';
        	temp +='<td width="3%" align="left" valign="top">&nbsp;</td>';
        	temp +='<td width="97%" align="left" valign="top"><a href="/justin" target="_blank" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#FF6600; text-decoration:none"><strong>'+title+'<br />';
        	temp +='</strong></a></td>';
      		temp +='</tr>';
      		
  
      		
      		temp +='<tr>';
        	temp +='<td height="4" colspan="2"></td>';
      		temp +='</tr>';
      		temp +='<tr>';
        	temp +='<td height="1" colspan="2"bgcolor="#D6E3F2"></td>';
      		temp +='</tr>';
      		temp +='<tr>';
        	temp +='<td height="4" colspan="2"></td>';
      		temp +='</tr>';
      		temp +='<tr>';
	  }
	    
         }
	  
	  	if(start==0){
		   temp +='<tr>';
    	   temp +='<td align="left" valign="top">&nbsp;</td>';
           temp +='<td align="right" valign="middle" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#FF6600; text-decoration:none" ><a href="JavaScript: getWidgetJustIn('+page+');" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#FF6600; text-decoration:none">next &rsaquo;&rsaquo;</a></td>';
	       temp +='</tr>';
	 
	  }else if(page*3 > size){
	  	temp +='<tr>';
        temp +='<td align="left" valign="top"><a href="JavaScript: getWidgetJustIn('+(start-1)+');" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#FF6600; text-decoration:none">&lt;&lt;previous</a>&nbsp;</td>';
        temp +='<td align="right" valign="middle" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#FF6600; text-decoration:none" ></td>';
      	temp +='</tr>';
	  }
	  else{
	 	temp +='<tr>';
        temp +='<td align="left" valign="top"><a href="JavaScript: getWidgetJustIn('+(start-1)+');" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#FF6600; text-decoration:none">&lt;&lt;previous</a>&nbsp;</td>';
        temp +='<td align="right" valign="middle" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#FF6600; text-decoration:none" ><a href="JavaScript: getWidgetJustIn('+page+');" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#FF6600; text-decoration:none">next &rsaquo;&rsaquo;</a></td>';
      	temp +='</tr>';
	  }
	  	
        temp +='</table></td>';
		temp +='</tr>';
		temp +='</table>';
	  	
	  
	  myTable.innerHTML =temp;
	  
	  var test1 = document.getElementById("div1");
	  //alert(test1);
	  if(test1 != null){
	  	document.body.removeChild(test1);
	  }
	   
      document.body.appendChild(myTable);
}


function getWidgetDebateQuestion(){
	//alert("in getWidget()")
	
		var url = "/electionWidget.do?choice=WidgetDebateQuestion";
	
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}

	req.open("POST", url, true);
	req.onreadystatechange = getDebateQuestion;
	req.send(null);	
	
	//currentStartPosition=start;
	//currentEndPosition=end;
	
	}
	
	 function getDebateQuestion() {
	if (req.readyState == 4) {
		if (req.status == 200) {
	
			
			populateDebateQuestion()
			
		}
	}
}

function populateDebateQuestion() {
     
		 
     	 myTable = document.createElement("DIV");
    	 myTable.id="div1";	
     	
		var ReccentDebateQuestions=  req.responseXML.getElementsByTagName("debateQuestions")[0];
	     //var ReccentArticlesSizes =  req.responseXML.getElementsByTagName("sizes")[0];
	     i=0;
	     var temp="";
      	temp +='<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#D6E3F2">';
  		temp +='<tr>';
	    temp +='<td align="center" valign="top">';
	    temp +='<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">';
    	temp +='<tr>';
        temp +='<td colspan="2" align="left" valign="top" bgcolor="#EEF5FB" style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#1B5790; text-decoration:underline">';
		temp +='<table width="100%" border="0" cellspacing="0" cellpadding="0">';
        temp +='<tr>';
        temp +='<td align="left" valign="middle"> <strong>Election Updates </strong></td>';
        temp +='<td align="right" valign="middle"><a href="#"><font face="Verdana, Arial, Helvetica, sans-serif" color="#333333" size="1"></font></a></td>';
        temp +='</tr>';
        temp +='</table>         </td>';
        temp +='</tr>';
    	temp +='<tr>';
        temp +='<td height="5" colspan="2" align="left" valign="middle"></td>';
	    temp +='</tr>';
        temp +='<tr>';
        temp +='<td colspan="2" align="left" valign="middle" style="font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#000000; text-decoration:none"><img src="http://www.merinews.com/images/logo_wgt.gif" width="130" height="38" /></td>';
      	temp +='</tr>';
	    temp +='<tr>';
        temp +='<td colspan="2" align="left" valign="middle> ';
	    temp +='<div id="bsttabs">';
		temp +='<ul id="tabmenu" > ';
		temp +='<li onclick="getWidgetJustIn(0)"><a href="#" class="" id="tab1">Justin</a></li> ';
		temp +='<li onclick="getWidgetArticle(0)"><a href="#" class="" id="tab2">Articles</a></li> ';
		temp +='<li onclick="getWidgetPhotos(0)"><a href="#" class="" id="tab1">Photos</a></li> ';
		temp +='<li onclick="getWidgetDebateQuestion()" style = "border-bottom-width: 3px; border-bottom-color: #EEF5FB; border-bottom-style: solid; background-color: #1B5790;"><a class="" id="tab2">Debate</a></li>';
		temp +='</ul> </div></td>';
		temp +='</tr>';
      	temp +='<tr>';
        temp +='<td height="8" colspan="2"></td>';
      	temp +='</tr>';
	    
	     for (loop = 0;loop<ReccentDebateQuestions.childNodes.length;  loop++,i++)
	     {
	     
	     var ReccentDebateQuestion = ReccentDebateQuestions.childNodes[loop];
	    // alert(ReccentArticle);
	     var questionId=(ReccentDebateQuestion.getElementsByTagName("questionId")[0]).firstChild.nodeValue;
	     var description = (ReccentDebateQuestion.getElementsByTagName("description")[0]).firstChild.nodeValue;
	     //var articleID = (ReccentArticle.getElementsByTagName("size")[0]).firstChild.nodeValue;
	     
	     //var listSize=(ReccentArticle.getElementsByTagName("size")[0]).firstChild.nodeValue;
	     
	     //size = (ReccentArticle.getElementsByTagName("size")[0]).firstChild.nodeValue;
	         	
      		//bgcolor="#F6F9FF"
      		
      		 temp +='<tr>';
        	temp +='<td align="left" valign="top" bgcolor="#F6F9FF">&nbsp;</td>';
        	temp +='<td align="left" valign="top" bgcolor="#F6F9FF"><a href="/debate?debateId='+questionId+'" target="_blank" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#FF6600; text-decoration:none"><strong>'+description+'<br />';
        	temp +='</strong></a></td>';
      		temp +='</tr>';
      		
      		temp +='<tr>';
        	temp +='<td height="4" colspan="2"></td>';
      		temp +='</tr>';
      		temp +='<tr>';
        	temp +='<td height="1" colspan="2"bgcolor="#D6E3F2"></td>';
      		temp +='</tr>';
   
         }
	  
	  	
	  	
        temp +='</table></td>';
		temp +='</tr>';
		temp +='</table>';
	  	
	  
	  myTable.innerHTML =temp;
	  
	  var test1 = document.getElementById("div1");
	  //alert(test1);
	  if(test1 != null){
	  	document.body.removeChild(test1);
	  }
	   
      document.body.appendChild(myTable);
}