//---------------------------------**************   Ajax call Begins   ****************////
var xmlHttpPhotos;
function createXmlHttpObjects(){
if (window.XMLHttpRequest){     // Object of the current windows
    xmlHttpPhotos=new XMLHttpRequest();
   } 
   else if (window.ActiveXObject){   // ActiveX version
    xmlHttpPhotos=new ActiveXObject("Microsoft.XMLHTTP");//features//footer
    } 
 }

createXmlHttpObjects();
//Recent      
var rall="";
//Google ads       
function callgoogleads(){
    document.getElementById("ad").style.visibility="visible";
    document.getElementById("ad").style.display="";
    //callPhotos();
}
function scmi(){
document.getElementById("marqueeid").scrollAmount=0;
}                                  
function scmo(){
document.getElementById("marqueeid").scrollAmount=6;
}                                  
//photos
function callPhotos(){
xmlHttpPhotos.open("POST", "/image.do?method=RandomHomeonLoadH",  true);
xmlHttpPhotos.onreadystatechange =processStateChangePhotos;
xmlHttpPhotos.setRequestHeader("Connection", "close");
xmlHttpPhotos.send(null); 
}
function processStateChangePhotos(){
  if(xmlHttpPhotos.readyState  == 4 && xmlHttpPhotos.status  == 200) {
    document.getElementById("photos").innerHTML=xmlHttpPhotos.responseText;
     iframeAds();
   }
}                                   
//photo end
//left navigate
function leftNavigate(){
var leftNavigate="";
leftNavigate=leftNavigate+"<div id='buttons' align='left'>";
leftNavigate=leftNavigate+"  <table width='100%' border='0' cellspacing='0' cellpadding='0'>";
leftNavigate=leftNavigate+"    <tr>";
leftNavigate=leftNavigate+"      <td width='50%' align='left' valign='top'>";
 leftNavigate=leftNavigate+"     <a href='/SignUp.jsp'>";
leftNavigate=leftNavigate+"      <img src='/mnc/images/becjbutt.gif' alt='CJ' width='129' height='30' border='0' /> ";
leftNavigate=leftNavigate+"      </a>";
leftNavigate=leftNavigate+"   </td>";
 leftNavigate=leftNavigate+"     <td width='50%' align='left' valign='top'><a href='/submitChoice.jsp' ><img src='/mnc/images/subbutt.gif' alt='submit news' width='130' height='30' border='0' /> </a> </td>";
leftNavigate=leftNavigate+"    </tr>";
leftNavigate=leftNavigate+"    <tr>";
leftNavigate=leftNavigate+"      <td align='left' valign='top'><a href='/mnc_rewards.jsp' target='_blank'><img src='/mnc/images/rewardsbutt.gif' alt='Rewards' width='129' height='30' border='0' /></a></td>";
leftNavigate=leftNavigate+"      <td align='left' valign='top'><a href ='clog' target='_blank'><img src='/mnc/images/clogbutt.gif' alt='cloghome.jsp' width='130' height='30' border='0' /> </a> </td>";
leftNavigate=leftNavigate+"    </tr>";
leftNavigate=leftNavigate+" </table>";
leftNavigate=leftNavigate+"</div>";
document.getElementById("leftNavigation").innerHTML=leftNavigate;
}
//skype
function getSkype(){


var skypevar="<div>";
skypevar=skypevar+"<a href='http://www.apnatiffin.com' target='_blank'> <img src='/mnc/images/apna-tiffin.jpg' width='259' height='65' border='0' /> </a>";
skypevar=skypevar+"</div>";
//skypevar=skypevar+"<div id='spacerb' />";
//skypevar=skypevar+"<div><a href='skype:merinews?add' onClick='return skypeCheck()'><img src='/mnc/images/skype_banner.gif' width='260' height='77' border='0' />";
//skypevar=skypevar+"</a></div><div id='spacerb'></div>";
document.getElementById("skypemnc").innerHTML=skypevar;
}
//skype end

function getRightAds00(){
 var rightAds00="<iframe src='/home/components/newhome/RightHomeAd1InFrame.jsp'";
 rightAds00=rightAds00+" align='middle' marginheight='0' marginwidth='0' width='250' height='90' frameborder='0' scrolling='no'>";
 rightAds00=rightAds00+"</iframe>";
document.getElementById("RightHomeAd1").innerHTML=rightAds00;
}
//---------------------------------**************   Ajax call ends   ****************////
<!--
// This method is used to remove Leading spaces.
// It takes argument of the string which Leading Spaces has to removed.
function removeLeadingSpaces(str)
{
   var whitespace = new String(" \\t\\n\\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(0)) != -1)
    {
      var j=0, i = s.length;
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)  j++;
      s = s.substring(j, i);
    }
   return s;
}
//######################################################################################################
// This method is used to remove Trailing spaces.
// It takes argument of the string which Trailing Spaces has to removed.
function removeTrailingSpaces(str)
{
   var whitespace = new String(" \\t\\n\\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(s.length-1)) != -1)
   {
      var i = s.length - 1;       // Get length of string
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1) i--;
      // Get the substring from the front of the string to
      // where the last non-whitespace character is...
      s = s.substring(0, i+1);
   }
   return s;
}
//######################################################################################################
// Removes both Leading and Trailing blanks.
//
function removeAllSpaces(str)
{
   str = removeLeadingSpaces(str); //Remove Leading Spaces
   str = removeTrailingSpaces(str); //Remove Trailing Spaces
   return str;
}
function frmreset(){
document.form1.reset();

return false;
}


function validate()
{
 if(removeAllSpaces(document.form1.userID.value)=="")
 {
  alert("Please enter your User Name");
  document.form1.userID.focus();
  return false;
 }
 if(removeAllSpaces(document.form1.password.value)=="")
 {
  alert("Please enter your password");
  document.form1.password.focus();
  return false;
 }
form1.submit();
 return true;
}
//Google ads 

function googleadds1(){
	  GS_googleAddAdSenseService("ca-pub-9372192619832074");
	  GS_googleEnableAllServices();

}
//Google ads end
////////////Debate start
var senderName;  
var senderEmail;
var urlNew="";

function showArticle(id){
//alert("HiiiiiiiiFFFFFFFFF");
  
   document.getElementById(id).style.display = 'none';
   
   alert( document.getElementById(id).style.display);
}

function toggleDisplay(id){

var me = document.getElementById(id);
if (me.style.display=="none"){

me.style.display="block";
me.focus();
}
else if (me.style.display=="block"){

document.getElementById(id).style.display='none';
//me.style.display="none";
}else{

me.style.display="block";
me.focus();

}
}
function show123(id, hide){
//alert("HiiiiiiiiFFFFFFFFF");
   document.getElementById(hide).style.display = 'none';
   document.getElementById(id).style.display = 'none';
   
}

function show(id, hide){
//alert("Hiiiiiiiiggggggiiiiiii");
	document.form1.senderName.value ="";
	document.form1.senderEmail.value ="";
	for(i=0; i<document.form1.recepientEmail.length ;i++)
	 {
 		document.form1.recepientEmail[i].value =""; 		
	 }
	 for(i=0; i<document.form1.recepientName.length ;i++)
	 { 		
 		document.form1.recepientName[i].value ="";
	 }
   document.getElementById(hide).style.display = 'none';
   document.getElementById(id).style.display = 'block';
 //  validateMail1();
   
  
}
function validateMail1(id, hide)
{
//alert("Validaie mail function");
 getTrimed();
 var flag=0;
 	if(document.form1.senderName.value ==""){
	        alert("Please enter your name");
			document.form1.senderName.focus();	      
	  return false;
	 } 
	
	 if(notValidEmail(form1.senderEmail)){
	        alert("Please enter your valid email");
			document.form1.senderEmail.focus();
	      
	  return false;
	 }
 for(i=0; i<document.form1.recepientName.length && document.form1.recepientName[i].value == "";i++);
	 if(i == document.form1.recepientName.length )
	 {
	   alert("Please enter any one recipient name");
	   document.form1.recepientName[0].focus();
	   return false;
	 }
 for(i=0; i<document.form1.recepientEmail.length ;i++)
 {
	   if(document.form1.recepientEmail[i].value != "")
	   {
	    if(notValidEmail(form1.recepientEmail[i])){
	        alert("Please enter valid email");
			document.form1.recepientEmail[i].focus();
	      
	      return false;
	     }else
	     {
	     if(document.form1.recepientName[i].value ==""){
	        alert("Please enter name");
			document.form1.recepientName[i].focus();
	      
	       return false;
	       } 
	     }
	   flag =1;
	   }
 }
		 if(flag ==0)
		 {
		   alert("Please enter any one email address");
		   document.form1.recepientEmail[0].focus();
		   return false;
		 } 
 senderName = document.form1.senderName.value;
 senderEmail = document.form1.senderEmail.value;
 //description=document.form2.description.value;
 urlNew="";
		  for(i=0; i<document.form1.recepientEmail.length && document.form1.recepientEmail[i].value!="" ;i++)
		  {
		 // alert(urlNew)		 ;
		  urlNew=urlNew+"&recepientName="+document.form1.recepientName[i].value+"&recepientEmail="+document.form1.recepientEmail[i].value;
		//  alert(urlNew)		 ;
		  }
 sendDebate();
 //if(flag ==1){
 //alert("guiuiyuiyiy8o");
 show123(id, hide);
//}
return false;
} 

function sendDebate() {
	//	alert("We r in send Debate Method");
		var url = "/mncDebateFor.do?method=SendDebate&senderName="+ senderName + "&senderEmail="+ senderEmail + urlNew;

        alert(url)		 ;
		if (window.XMLHttpRequest) {
		
			req = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		  // req.open("POST", url, true);
		  //req.send();
		}
		
		req.open("POST", url, true);
		//alert("11111111111111111111");
		req.onreadystatechange = getStatusHumour1;
		//alert("22222222222222222");
		req.send(null);	
		//alert("33333333333333333333");
	}

	function getStatusHumour1() {
	//alert("44444444444444444444");
		if (req.readyState == 4) {
	//alert("555555555555555555555");
			if (req.status == 200) {
			resetHumourForm();
		//alert("6666666666666666666666");
		  }
				
		}
	}
function resetHumourForm(){
		 //removeForm();
	}
	
function randomPhoto(){
//alert("random photo");
var url = "/image.do?method=RandomHome";
if (window.XMLHttpRequest) {

		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
	
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	req.open("POST", url, true);
	//alert("random photo444");
	req.onreadystatechange = getPhotos;
	req.send(null);	
 }
 
function getPhotos() {
///alert("random photogggggg");
	if (req.readyState == 4) {
		if (req.status == 200) {
			populatePhotos();
		}
	}
}

function populatePhotos() {	
//alert("random photopoppopopopop");
	 myTable = document.getElementById("randomphoto");	 
	// alert("random photopoppopopopop111"+myTable);
	 myTable.innerHTML="";	
	// alert("random photopoppopopopop2222");
	 var childDiv1 = document.createElement("DIV");
	// alert("random photopoppopopopop3333");
	 childDiv1.innerHTML="";	
	// alert("random photopoppopopopop44444");  
	  var photos =  req.responseXML.getElementsByTagName("photos")[0];	  
	//  alert(photos); 
		var i = 0;
	  for (loop = photos.childNodes.length-1; loop>=0; loop--)
	  {
	  var photo = photos.childNodes[loop];	
	   var title = (photo.getElementsByTagName("title")[0]).firstChild.nodeValue; 
	  var imageID = (photo.getElementsByTagName("imageID")[0]).firstChild.nodeValue;
	  var thumbImage = (photo.getElementsByTagName("thumbImage")[0]).firstChild.nodeValue;	
		thumbImage=  "<IMG SRC='/upload/imageGallery/thumbImage/"+thumbImage+"' width='100' height='80' border='0' title='"+title+"' >";	 
	 	childDiv1.innerHTML += "<a href=\"http://photos.merinews.com/newPhotoLanding.jsp?imageID=" + imageID + "\" target='_blank'>" + thumbImage + "</a>";
	     
	   //  myTable.appendChild(childDiv1);	
	    //  myTable.appendChild(childDiv2);	  
	  }	
	   myTable.appendChild(childDiv1);
	  childDiv1.innerHTML +=  "<a href='JavaScript:randomPhoto();'><img src='/mnc/images/arrow.gif' border='0' width='33' height='80'/></a>";
	
}	

function getNodeText(node){
	if(node.tagName){
		var txt = "<" + node.tagName;
		var attributes = node.attributes;
		for(var i = 0; i < attributes.length; i++){
			txt += " " + attributes[i].nodeName + "=\"" + node.attributes[i].nodeValue + "\"";
		}
		if(node.hasChildNodes()){
			txt += ">";
			for(var i = 0; i < node.childNodes.length; i++){
				txt += getNodeText(node.childNodes[i]);
			}
			txt += "</" + node.tagName + ">";
		}
		else {
			txt += "/>";
		}
		return txt;
	}
	if(node.data){
		return node.data;
	}
	return "";
}	
///////////////Debate End
//-->
// ******************************************recentArticle.js start 
var flag=0;
var scroll;

var currentStartPosition=0;
var currentEndPosition=10;	
var  start=0;
var end=0;
var size=60;
var noOfItems = 10;

function up()
{
	myTable1 = document.getElementById("recentImg");
	 myTable1.innerHTML="<img src='/mnc/images/recenthead.gif' width='138' height='16' /><a href='JavaScript:up();'  ><img src='/mnc/images/up.gif' width='57' height='16' border='0'/></a>";
	 myTable1.innerHTML+="<a href='JavaScript:down();' ><img src='/mnc/images/down.gif' width='57' height='16' border='0'/></a>";
	
	//if(currentStartPosition==0){
   //     myTable1.innerHTML="<img src='/mnc/images/recenthead.gif' width='138' height='16' /><img src='/mnc/images/up_fade.gif' width='57' height='16' border='0'/>";
 	//	myTable1.innerHTML+="<a href='JavaScript:down();'  ><img src='/mnc/images/down.gif' width='57' height='16' border='0'/></a>";

	//	}
	//	else{
			start=currentStartPosition-noOfItems;
			if(start<0)
				start=0;
			end=start+noOfItems;
			if(end>size)
				end=size;
		//}
		
		getRecent(start,end);
	}

function  down() {		

     myTable1 = document.getElementById("recentImg");
	 myTable1.innerHTML="<img src='/mnc/images/recenthead.gif' width='138' height='16' /><a href='JavaScript:up();'  ><img src='/mnc/images/up.gif' width='57' height='16' border='0'/></a>";
	 myTable1.innerHTML+="<a href='JavaScript:down();' ><img src='/mnc/images/down.gif' width='57' height='16' border='0'/></a>";
	
		//if(currentEndPosition==size){
		// myTable1.innerHTML="<img src='/mnc/images/recenthead.gif' width='138' height='16' /><a href='JavaScript:up();'  ><img src='/mnc/images/up.gif' width='57' height='16' border='0'/></a>";
		// myTable1.innerHTML+="<img src='/mnc/images/down_fade.gif' width='57' height='16' border='0'/>";
	//		}
		//else{
			if(currentEndPosition+noOfItems>size)
			{
				start =size-noOfItems;
				if(start<0)
					start=0;
				end =size;
			}
			else {
				start =currentEndPosition;
				end =currentEndPosition+noOfItems;
			}
		//}
	
		 getRecent(start,end);
		
	}


function getRecent(start,end) {

	var url = "/articleList.do?choice=RecentArticleByAjax&fromIndex="+start+"&toIndex="+end;
	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;
	if(currentStartPosition==0){
        myTable1.innerHTML="<img src='/mnc/images/recenthead.gif' width='138' height='16' /><img src='/mnc/images/up_fade.gif' width='57' height='16' border='0'/>";
 		myTable1.innerHTML+="<a href='JavaScript:down();'  ><img src='/mnc/images/down.gif' width='57' height='16' border='0'/></a>";

		}
	if(currentEndPosition==size){
		 myTable1.innerHTML="<img src='/mnc/images/recenthead.gif' width='138' height='16' /><a href='JavaScript:up();'  ><img src='/mnc/images/up.gif' width='57' height='16' border='0'/></a>";
		 myTable1.innerHTML+="<img src='/mnc/images/down_fade.gif' width='57' height='16' border='0'/>";
			}	
	

 }

function getRecentArticles() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			
			populateRecentArticles()
			
		}
	}
}
 function populateRecentArticles() {
 
	
	
	 myTable = document.getElementById("recentarticles1");
	 
	
	 
	 for(var i=0;i<10;i++)
	 {
	 var div1 = document.getElementById('div'+i);
	 myTable.removeChild(div1);
	 } 
	 myTable.removeChild(document.getElementById("morelinks"));
	  
	/* var childDiv1= document.createElement("DIV");
		
	 childDiv1.id='recentImg';
     childDiv1.innerHTML="<img src='/mnc/images/recenthead.gif' width='138' height='13' border='0' onclick='javascript:getRecent()'/>";
  
     var childDiv2= document.createElement("DIV");
	 childDiv2.id='spacer_b';
	 
 	  */
	  var ReccentArticles =  req.responseXML.getElementsByTagName("ReccentArticles")[0];
	
	  i=0;
	  
	  //myTable.appendChild(childDiv1);
	  //myTable.appendChild(childDiv2);
	  
	  for (loop = 0;loop<ReccentArticles.childNodes.length;  loop++,i++)
	  {
	  

	   var childDiv3 = document.createElement("div");
	
	  var ReccentArticle = ReccentArticles.childNodes[loop];
	
	  var title = (ReccentArticle.getElementsByTagName("title")[0]).firstChild.nodeValue;
	  
	 
	  var contributor = (ReccentArticle.getElementsByTagName("contributor")[0]).firstChild.nodeValue;
	  var time = (ReccentArticle.getElementsByTagName("postedTime")[0]).firstChild.nodeValue;
	  var articleID = (ReccentArticle.getElementsByTagName("articleID")[0]).firstChild.nodeValue;
	  size=(ReccentArticle.getElementsByTagName("size")[0]).firstChild.nodeValue;
	   childDiv3.id='div'+loop;
	    childDiv3.innerHTML = "<ul class='rc'><li><a href='/catFull.jsp?articleID="+articleID+"' class='text' >"+title+"</a><br/>&nbsp;<span class='cj'>CJ: "+contributor +" - "+time+"</span> </li></ul>" ;
//	    childDiv3.innerHTML += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class='cj'>CJ: "+contributor +" - "+time+"</span> </li></ul>" ;
	    
	  
	  
	    
	    myTable.appendChild(childDiv3);
	  
	  
	  }
	   var childDiv4 = document.createElement("div");
	   childDiv4.id='morelinks';
	   childDiv4.innerHTML="<div align='right' id='morelinks'><a href='/allArticles.do?choice=Recent&pageNo=1' class='grey'><strong>view all articles</strong><span class='red'>>></span></a></div>";
	   myTable.appendChild(childDiv4);
// setTimeout ( "getRecent()", 10000 );	  
}


// ******************************************recentArticle.js end
//*******************************************Common.js start
// function to set the div of comment
function displayComment(divId, title, label, target){
	
	var formTitle = "title" + divId;
	var formLabel = "label" + divId;
	
	if(document.getElementById(divId).style['display'] == 'block' && 
	document.getElementById(formTitle).innerHTML == title)
	{
		
		document.getElementById(divId).style['display'] = 'none';
	}
	else{
		
		document.getElementById(divId).style['display'] = 'block';
	}
	
	var formTitle = "title" + divId;
	var formLabel = "label" + divId;
	
	
	document.getElementById(formTitle).innerHTML = title;
	
	//document.getElementById(formLabel).innerHTML = label + ":";
	
	var formName = "form" + divId;
	
	
	
	var inputs = document.getElementById(formName).elements;
	
	var inputByName = inputs["method"];
	
	inputByName.value = target;
	
	//document.getElementById(formName).name = target;
	//document.getElementById(formName).onsubmit = "if(validateCommentForm(this,' + label + ',' + divId + ')){verify(this.form,divId);}";
	buttonName = 'button' + divId;
	document.getElementById(buttonName).name = label;	
}

// function to open new window
function openNewWindow(url, windowName){
	window.open(url,windowName,'status=yes,width=650,height=500,scrollbars=yes');
}

// function to open a new window to view results of poll
function popup(url, windowName){
	window.open(url, windowName, 'left=0,top=0,width=250,height=190,scrollbars=no');	
	return false;
}

// function for search articles by keword by contributor/content
function validateSearchArticleForm(form){
	var keyword = form.keyword.value;
	if(keyword == '' || keyWord == null){
		alert("Please enter Keyword");
		form.keyWord.focus();
		return false;
	}
	var searchOption = form.searchOption.value; 
	if(searchOption == 0){
		alert("Please select Search By option");
		form.searchOption.focus();
		return false;
	}  
	form.submit();
	return true;
}


function validateSearchForm(form){
	var keyword = form.keyword.value;
	if(keyword == '' || keyword == null){
		alert("Please enter Keyword");
		form.keyword.focus();
		return false;
	}
	var choice = form.choice.value; 
	if(choice == 0){
		alert("Please select Search By option");
		form.choice.focus();
		return false;
	}  
	form.submit();
	
	return true;
 

}



function callAction(form){
	var keyword = document.searchArticleForm.keyword.value;
	if(keyword == '' || keyword == null){
		alert("Please enter Keyword");
		document.searchArticleForm.keyword.focus();
		document.searchArticleForm.choice.value ="";
		return false;
	}
	var choice = document.searchArticleForm.choice.value; 
	if(choice == ""){
		alert("Please select Search By option");
		document.searchArticleForm.choice.focus();
		return false;
	}  
	var choice = document.searchArticleForm.choice.value; 
	var action="";
	if(document.searchArticleForm.choice.value  == 'sitesearch' ){
	//alert(document.searchArticleForm.keyword.value);
	//alert(document.searchArticleForm.q);
	document.searchArticleForm.q.value=document.searchArticleForm.keyword.value;
	document.searchArticleForm.action="/googlesearch.jsp"
	//return false;
	}
	else{
       document.searchArticleForm.action="/articleSearch"
	}
	  
	document.searchArticleForm.submit();
	return true;
}

// function for search articles by keword by contributor/content
function validateSearchNewArticle(form){
	var keyword = form.keyword.value;
	if(keyword == '' || keyword == null){
		alert("Please enter Keyword");
		form.keyword.focus();
		return false;
	}
	
	form.submit();
	return true;
}


// function to validate the entered email
function isValidEmail(email){
	mailRE = new RegExp( );
	mailRE.compile( '^[\._a-z0-9-]+@[\.a-z0-9-]+[\.]{1}[a-z]{2,4}$', 'gi' );
	return (mailRE.test(email));
}

// function to clear the text from email text box on focus
function removeEmail(form){
	form.email.value="";
}

// function used when clicked on go for subsribing to newsletter
function validateSubscribeForm(form) {
	email=form.email.value;
	if((email==''||email==null)) {
		alert("Please enter E-Mail");
		form.email.focus();
		return false;
	}
	else if(!isValidEmail(form.email.value)) {
		alert( "Please enter valid E-mail address");
		form.email.focus();
		return false;
	}
	else {
		popup("subscribe.jsp?eid="+email,'subscribe');
		return false;
	}
}
 
// function for voting a poll
function validateVoteForm(form, pollId){
	var vote="";
	var choice=false;
	for (i = 0; i < form.vote.length; i++) {
		if (form.vote[i].checked) {
			vote = form.vote[i].value;
			choice = true;
		}
	}
	if(!choice){
		alert("Please select a choice");
		return false;
	}
	else{
		popup("/pollQuestion.do?type=SetPollResults&vote=" + vote + "&pollID=" + pollId, 'ViewResults');
		return false;
	}
	
	return false;
}

function removeFieldValue(){
	
	 if(document.commentForm.commenterName.value=="Name"){
	 document.commentForm.commenterName.value='';
	
	return false;
	}
	
	if(document.commentForm.description.value=="Comments"){
	 document.commentForm.description.value='';
	
	return false;
	}
	
	if(document.commentForm.email.value=="Email"){
	 document.commentForm.email.value='';
	
	return false;
	}
	
	return false;
}




function getSelectedRadioValue(buttonGroup) {
   // returns the value of the selected radio button or "" if no button is selected
   var i = getSelectedRadio(buttonGroup);
   if (i == -1) {
      return "";
   } else {
      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
         return buttonGroup[i].value;
      } else { // The button group is just the one button, and it is checked
         return buttonGroup.value;
      }
   }
} // Ends the "getSelectedRadioValue" function




function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function

function imageTitleSearch(){
	var text = document.getElementById('image').title;
		if(text != ""){
		if(text.indexOf("&")>0){
			text = text.replace("&", "*");
		}
		window.open("/articleSearch?keyword="+text+"&q=&choice=Content");
		}
	}
//******************************************common.js end
function iframeAds(){
var iframeAds1="<iframe src='/home/components/ads/adDisplay.jsp' height='90' width='728' scrolling='no' frameborder='0' align='right' marginheight='0' marginwidth='0' ></iframe>"
document.getElementById("myhomeads").innerHTML=iframeAds1;
}
///for ads
//get articles js for viewer choice

var viewSort;

function setSort(viewsort) {
	viewSort = viewsort;
	var url = "/articleList.do?choice=ViewerChoice&viewSort=" + viewSort;
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	req.open("POST", url, true);
	req.onreadystatechange = getArticles;
	req.send(null);	
 }
 
function getArticles() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			populateArticles();
		}
	}
}
 
function populateArticles() {

	myTable     = document.getElementById("ViewerTable");
	noRows = myTable.rows.length;
	for(i = 0; i < noRows; i++){
		myTable.deleteRow(0);
	}
	//alert("req.getResponseHeader('content-type'):" + req.getResponseHeader('content-type'));
	//alert('req.responseText:' + req.responseText);
	//alert('req.responseXML.childNodes.length:' + req.responseXML.childNodes.length);
	var articles =  req.responseXML.getElementsByTagName("articles")[0];
	//alert('articles:' + articles);
	for (loop = articles.childNodes.length-1; loop>=0; loop--) {
		var article = articles.childNodes[loop];
		var articleId = (article.getElementsByTagName("articleId")[0]).firstChild.nodeValue;
		
		var title = "";
		if(article.getElementsByTagName("title")[0].hasChildNodes()){
			for(var i = 0; i < article.getElementsByTagName("title")[0].childNodes.length; i++){
				title += getNodeText(article.getElementsByTagName("title")[0].childNodes[i]);
			}
		}
		
		//var userName = (article.getElementsByTagName("userName")[0]).firstChild.nodeValue;
		var artLinks = (article.getElementsByTagName("artLink")[0]).firstChild.nodeValue;
		var cmpImageTag = "";
		if(article.getElementsByTagName("cmpImageTag")[0].hasChildNodes()){
			for(var i = 0; i < article.getElementsByTagName("cmpImageTag")[0].childNodes.length; i++){
				cmpImageTag += getNodeText(article.getElementsByTagName("cmpImageTag")[0].childNodes[i]);
			}
		}
		
		if(cmpImageTag == 'null')
			cmpImageTag = "";
	
		//var userName = (article.getElementsByTagName("userName")[0]).firstChild.nodeValue;
		var views = (article.getElementsByTagName("views")[0]).firstChild.nodeValue;
		var comments = (article.getElementsByTagName("comments")[0]).firstChild.nodeValue;

		var row = document.getElementById('ViewerTable').insertRow(0);
  		
  		var col1 = row.insertCell(0);
  		row.cells[0].width = "3%";
  		row.cells[0].align = "left";
  		row.cells[0].valign = "baseline";
  		
  		var col2 = row.insertCell(1);
  		row.cells[1].width = "97%";
		row.cells[1].align = "left";
		row.cells[1].valign = "middle";
		row.cells[1].className = "text";
		/*
		var col3 = row.insertCell(2);
		row.cells[2].width = "5%";
		row.cells[2].align = "right";
		row.cells[2].valign = "top";
		row.cells[2].className = "textblue";

		var col4 = row.insertCell(3);
		row.cells[3].width = "4";
		row.cells[3].align = "right";
		row.cells[3].valign = "top";

		var col5 = row.insertCell(4);
		row.cells[4].width = "5%";
		row.cells[4].align = "right";
		row.cells[4].valign = "top";

		var col6 = row.insertCell(5);
		row.cells[5].width = "5%";
		row.cells[5].align = "right";
		row.cells[5].valign = "top";
		row.cells[5].className = "textblue";

		var col7 = row.insertCell(6);
		row.cells[6].width = "2%";
		*/
  		col1.innerHTML = "<img src='/mnc/images/blue_bull.gif'/>";
  		col2.innerHTML = "<a href=\"http://www.merinews.com"+ artLinks + "\" class=\"text\" >" + title + "</a>" + cmpImageTag;
  		//col2.innerHTML = "<span class=\"textblue\">Views:</span>";
  		//col3.innerHTML = views;
  		//col4.innerHTML = "";
  		//col5.innerHTML = "<span class=\"textblue\">Comments:</span>";
  		//col6.innerHTML = comments;
  		//col7.innerHTML = "";
  		document.getElementById("changesortorder").innerHTML="<a href='/allArticles.do?choice=Viewer&pageNo=1&viewSort="+viewSort+"' class='grey'><strong>more</strong><span class='red'>>></span></a></div>";
	}
	
	// text
	var weekCol = document.getElementById("week");
	var monthCol = document.getElementById("month");
	var quarterCol = document.getElementById("quarter");
	
	// links
	var weekLink = document.getElementById("weekLink");
	var monthLink = document.getElementById("monthLink");
	var quarterLink = document.getElementById("quarterLink");

	if(viewSort == 7){
		weekCol.className = "#EFEFEF";
		weekLink.href = "JavaScript:";
		weekLink.className = "mahroon";
		
		monthCol.className = "#EFEFEF";
		monthLink.href = "JavaScript:setSort(30);";
		monthLink.className = "bs";
		
		quarterCol.className = "#EFEFEF";
		quarterLink.href = "JavaScript:setSort(90);";
		quarterLink.className = "bs";
	}
	
	if(viewSort == 30){
		weekCol.className = "#EFEFEF";
		weekLink.href = "JavaScript:setSort(7);";
		weekLink.className = "bs";

		monthCol.className = "#EFEFEF";
		monthLink.href = "JavaScript:";
		monthLink.className = "mahroon";

		quarterCol.className = "#EFEFEF";
		quarterLink.href = "JavaScript:setSort(90);";
		quarterLink.className = "bs";
	}
	
	if(viewSort == 90){
		weekCol.className = "#EFEFEF";
		weekLink.href = "JavaScript:setSort(7);";
		weekLink.className = "bs";
		
		monthCol.className = "#EFEFEF";
		monthLink.href = "JavaScript:setSort(30);";
		monthLink.className = "bs";
		
		quarterCol.className = "#EFEFEF";
		quarterLink.href = "JavaScript:";
		quarterLink.className = "mahroon";
	}
}

function getNodeText(node){
	if(node.tagName){
		var txt = "<" + node.tagName;
		var attributes = node.attributes;
		for(var i = 0; i < attributes.length; i++){
			txt += " " + attributes[i].nodeName + "=\"" + node.attributes[i].nodeValue + "\"";
		}
		if(node.hasChildNodes()){
			txt += ">";
			for(var i = 0; i < node.childNodes.length; i++){
				txt += getNodeText(node.childNodes[i]);
			}
			txt += "</" + node.tagName + ">";
		}
		else {
			txt += "/>";
		}
		return txt;
	}
	if(node.data){
		return node.data;
	}
	return "";
}
function getRandomTemplate() {
  var i = 4;
  var j = Math.floor( Math.random() * ( i + 1 ) );
  return j;
}
function populateImagesLater(myid,textall,dis,visi){
     document.getElementById(myid).innerHTML=textall;
     document.getElementById(myid).style.display=dis;
     document.getElementById(myid).style.visibility=visi;

}
function  populateAllImagesLater(){
    populateImagesLater("merinewslogo","<a href='http://www.merinews.com'> <img src='/mnc/images/logo.gif'	width='180' height='77' border='0' /></a>","inline","visible");
     populateImagesLater("recentImg","<img src='/mnc/images/recenthead.gif' width='138' height='16' /><img src='/mnc/images/up_fade.gif' width='60' height='16' border='0' /><a href='JavaScript:down();' class='bs'><img src='/mnc/images/down.gif' width='60' height='16' border='0' />","inline","visible");
     //populateImagesLater("electionbanner","<a href='/campaign/racism/racism.jsp' > <img src='/mnc/images/racimbannerupdate2.gif' border='0'/> </a>","inline","visible");
     //populateImagesLater("electionbanner","<a href='http://www.merinews.com/campaign/union-budget/index.jsp' title='Union Budget 2009-10' > <img src='/mnc/images/union-budget-2009.jpg' border='0'/> </a>","inline","visible");
     populateImagesLater("ctzbanner","<a href='/citizensmanifesto' target='_blank'> <img src='/mnc/images/ctzmanibanner.jpg' width='259' height='65' border='0' /> </a>","inline","visible");
    //populateImagesLater("visionbanner","<a href='http://www.worldvision.in/promo.php?site=432&page=one_child' target='_blank'> <img src='/mnc/images/world_vision.gif' width='259' height='65' border='0' /> </a>","inline","visible");
     populateImagesLater("beacjbanner","<a href='/submitChoice.jsp' ><img src='/mnc/images/subbutt.gif' alt='submit news' width='130' height='30' border='0' /> </a>","inline","visible");
     populateImagesLater("rewardbanner","<a href='/mnc_rewards.jsp' target='_blank'><img src='/mnc/images/rewardsbutt.gif' alt='Rewards' width='129' height='30' border='0' /></a>","inline","visible");
     populateImagesLater("clogbanner","<a href ='/cloghome.jsp' target='_blank'><img src='/mnc/images/clogbutt.gif' alt='cloghome.jsp' width='130' height='30' border='0' /> </a>","inline","visible");
     populateImagesLater("signupbanner","<a href='/SignUp.jsp'><img src='/mnc/images/becjbutt.gif' alt='CJ' width='129' height='30' border='0' /></a>","inline","visible");
    // populateImagesLater("packageOffer","<a href='/bestdealpackage.html' target='_blank'> <img src='/mnc/images/bestdeal.gif' width='259' height='65' border='0' /> </a>","inline","visible");
 
}

	
    var tempdis11=0;
    var idt;	
    var timetochange=5000;
	function changeDebJust1(){
	if (tempdis11==0){
	document.getElementById("j12121").innerHTML="<a href='http://www.merinews.com/mydebate'><img src='/mnc/images/deb.jpg'  border='0'></a>";
	clearTimeout(idt);
	changeDebJust();
	tempdis11=1;
	}else{
	tempdis11=0;
	document.getElementById("j12121").innerHTML="<a href='http://www.merinews.com/justin'><img src='/mnc/images/jin.jpg'  border='0'></a>";
	clearTimeout(idt);
	changeDebJust();
	 }
	}

	function changeDebJust(){
	idt=setTimeout ( "changeDebJust1()", timetochange ); 
	}
	function changeDebJust2(num1){
	tempdis11=num1;
	//alert(num1);
	//clearTimeout(idt);
	changeDebJust1();
	 
	}
	changeDebJust();
	
	

