function createRequestObject(){

var req;
var divID;
var totalNo;
var pageNo;

if(window.XMLHttpRequest){
//For Firefox, Safari, Opera
req = new XMLHttpRequest();
}
else if(window.ActiveXObject){
//For IE 5+
req = new ActiveXObject("Microsoft.XMLHTTP");
}
else{
//Error for an old browser
alert('Your browser is not IE 5 or higher, or Firefox or Safari or Opera');
}

return req;
}

//Make the XMLHttpRequest Object
var http = createRequestObject();

function sendRequest(method, url,id,total,pageCt){

divID=id;
totalNo=total;
pageNo=pageCt;
if(method == 'get' || method == 'GET'){
http.open(method,url);
http.onreadystatechange = handleResponse;
http.send(null);
}
}

function handleResponse(){
if(http.readyState == 4 && http.status == 200){
var response = http.responseText;

if(response){

document.getElementById(divID).innerHTML = response;

var hrefNextId=document.getElementById('nextImage');
var hrefPreId=document.getElementById('preImage');
	if(totalNo > (pageNo+1)*5)
	{
	    hrefNextId.innerHTML ='<a style="cursor: pointer;" id="nextImgId" onclick="calNext('+(pageNo+1)+','+totalNo+');" class="nw-debate-nw-head"><img src="images/arrow-r.gif" width="26" height="21"></a>';
	}else
	{
	    hrefNextId.innerHTML ='<a style="cursor: pointer;" id="nextImgId" class="nw-debate-nw-head"><img src="images/arrow-r.gif" width="26" height="21"></a>';
	}
	if((pageNo-1) >= 0 )
	{
	   hrefPreId.innerHTML ='<a style="cursor: pointer;" id="preImgId" onclick="calPre('+(pageNo-1)+','+totalNo+');" class="nw-debate-nw-head"><img src="images/arrow-l.gif" width="26" height="21"></a>';
	
	}

  }
 }     
}

function calNext(pageNo,total){

sendRequest('GET','/mericampaign.do?choice=SubCategoryWithPhotoFeature&catID=4&subCatID=56&photoPageNo='+pageNo+'&photoFeatureID=2361&noOfRecords=5&photoFeatureTitle=Vancouer 2010&forwardpath=/vancouver-olympics-2010/campPhoto.jsp','imageDiv',total,pageNo);

}



function calPre(pageNo,total){

sendRequest('GET','/mericampaign.do?choice=SubCategoryWithPhotoFeature&catID=4&subCatID=56&photoPageNo='+pageNo+'&photoFeatureID=2361&noOfRecords=5&photoFeatureTitle=Vancouer 2010&forwardpath=/vancouver-olympics-2010/campPhoto.jsp','imageDiv',total,pageNo);


}

function calPreVer(pageNo,total){

sendRequestVer('GET','/mericampaign.do?choice=SubCategoryWithPhotoFeature&catID=4&subCatID=56&photoPageNo='+pageNo+'&photoFeatureID=2361&noOfRecords=5&photoFeatureTitle=Vancouer 2010&forwardpath=/vancouver-olympics-2010/photoHead.jsp','imageDiv',total,pageNo);


}
function calNextVer(pageNo,total){

sendRequestVer('GET','/mericampaign.do?choice=SubCategoryWithPhotoFeature&catID=4&subCatID=56&photoPageNo='+pageNo+'&photoFeatureID=2361&noOfRecords=5&photoFeatureTitle=Vancouer 2010&forwardpath=/vancouver-olympics-2010/photoHead.jsp','imageDiv',total,pageNo);

}
function sendRequestVer(method, url,id,total,pageCt){

divID=id;
totalNo=total;
pageNo=pageCt;
if(method == 'get' || method == 'GET'){
http.open(method,url);
http.onreadystatechange = handleResponseVer;
http.send(null);
}
}

function handleResponseVer(){
if(http.readyState == 4 && http.status == 200){
var response = http.responseText;
//alert(response);
if(response){

document.getElementById(divID).innerHTML = response;
//alert(document.getElementById('nextImage'));
var hrefNextId=document.getElementById('nextImage');
var hrefPreId=document.getElementById('preImage');
	if(totalNo > (pageNo+1)*5)
	{
	    hrefNextId.innerHTML ='<a style="cursor: pointer;" id="nextImgId" onclick="calNextVer('+(pageNo+1)+','+totalNo+');" ><img src="images/arrow-r-h.gif" width="33" height="120"></a>';
	}else
	{
	    hrefNextId.innerHTML ='<a style="cursor: pointer;" id="nextImgId" ><img src="images/arrow-r-h.gif" width="33" height="120"></a>';
	}
	if((pageNo-1) >= 0 )
	{
	   hrefPreId.innerHTML ='<a style="cursor: pointer;" id="preImgId" onclick="calPreVer('+(pageNo-1)+','+totalNo+');" ><img src="images/arrow-l-h.gif" width="33" height="120"></a>';
	
	}

  }
 }     
}

function calPreVer2(pageNo,total,myPath,myimageDiv,ttt){
//alert(pageNo);
sendRequestVer2('GET','/special.do?choice=Special&record='+ttt+'&pageno='+pageNo+'&path='+myPath,myimageDiv,total,pageNo);


}

function calNextVer2(pageNo,total,myPath,myimageDiv,ttt){
//alert(pageNo);
sendRequestVer2('GET','/special.do?choice=Special&record='+ttt+'&pageno='+pageNo+'&path='+myPath,myimageDiv,total,pageNo);

}
function sendRequestVer2(method, url,id,total,pageCt){

divID=id;
totalNo=total;
pageNo=pageCt;
if(method == 'get' || method == 'GET'){
http.open(method,url);
http.onreadystatechange = handleResponseVer2;
http.send(null);
}
}

function handleResponseVer2(){
if(http.readyState == 4 && http.status == 200){
var response = http.responseText;
//alert(response);
if(response){

document.getElementById(divID).innerHTML = response;
/*
//alert(document.getElementById('nextImage'));
var hrefNextId=document.getElementById('nextImage');
var hrefPreId=document.getElementById('preImage');
	if(totalNo > (pageNo+1)*10)
	{
	    hrefNextId.innerHTML ='<a style="cursor: pointer;" id="nextImgId" onclick="calNextVer2('+(pageNo+1)+','+totalNo+');" ><img src="../images/arrow-r.png" width="18" height="15"></a>';
	}else
	{
	    hrefNextId.innerHTML ='<a style="cursor: pointer;" id="nextImgId" ><img src="../images/arrow-r.png" width="18" height="15"></a>';
	}
	if((pageNo-1)*10 >= 0 )
	{
	   hrefPreId.innerHTML ='<a style="cursor: pointer;" id="preImgId" onclick="calPreVer2('+(pageNo-1)+','+totalNo+');" ><img src="../images/arrow-l.png" width="18" height="15"></a>';
	
	}
	else
	{
	    hrefNextId.innerHTML ='<a style="cursor: pointer;" id="preImgId" ><img src="../images/arrow-l.png" width="18" height="15"></a>';
	}
*/
  }
 }     
}
function calPreVer3(pageNo,total,myPath,myimageDiv,ttt){
//alert(pageNo);
//sendRequestVer3('GET','/generalElection.do?news=IPLJustIn&state=-1&start='+pageNo+'&end='+ttt+'&strReturn='+myPath,myimageDiv,total,pageNo);
//'/generalElection.do?news=IPLJustIn&state=-1&start='+pageNo+'&end='+ttt+'&strReturn='+myPath
//window.location='/generalElection.do?news=IPLJustIn&state=-1&start='+pageNo+'&end='+ttt+'&strReturn='+myPath;
window.location="/iplupdates/index.jsp?state=-1&start="+pageNo;
}

function calNextVer3(pageNo,total,myPath,myimageDiv,ttt){
//alert(pageNo);
//sendRequestVer3('GET','/generalElection.do?news=IPLJustIn&state=-1&start='+pageNo+'&end='+ttt+'&strReturn='+myPath,myimageDiv,total,pageNo);
//window.location='/generalElection.do?news=IPLJustIn&state=-1&start='+pageNo+'&end='+ttt+'&strReturn='+myPath;
window.location="/iplupdates/index.jsp?state=-1&start="+pageNo;
}
function sendRequestVer3(method, url,id,total,pageCt){

divID=id;
totalNo=total;
pageNo=pageCt;
if(method == 'get' || method == 'GET'){
http.open(method,url);
//alert(url);
http.onreadystatechange = handleResponseVer3;
http.send(null);
}
}

function handleResponseVer3(){
if(http.readyState == 4 && http.status == 200){
var response = http.responseText;
//alert(response);
if(response){

document.getElementById(divID).innerHTML = response;
/*
//alert(document.getElementById('nextImage'));
var hrefNextId=document.getElementById('nextImage');
var hrefPreId=document.getElementById('preImage');
	if(totalNo > (pageNo+1)*10)
	{
	    hrefNextId.innerHTML ='<a style="cursor: pointer;" id="nextImgId" onclick="calNextVer2('+(pageNo+1)+','+totalNo+');" ><img src="../images/arrow-r.png" width="18" height="15"></a>';
	}else
	{
	    hrefNextId.innerHTML ='<a style="cursor: pointer;" id="nextImgId" ><img src="../images/arrow-r.png" width="18" height="15"></a>';
	}
	if((pageNo-1)*10 >= 0 )
	{
	   hrefPreId.innerHTML ='<a style="cursor: pointer;" id="preImgId" onclick="calPreVer2('+(pageNo-1)+','+totalNo+');" ><img src="../images/arrow-l.png" width="18" height="15"></a>';
	
	}
	else
	{
	    hrefNextId.innerHTML ='<a style="cursor: pointer;" id="preImgId" ><img src="../images/arrow-l.png" width="18" height="15"></a>';
	}
*/
  }
 }     
}
function calPreVer4(pageNo,total,myPath,myimageDiv,ttt){
//alert(pageNo);
//sendRequestVer3('GET','/generalElection.do?news=IPLJustIn&state=-1&start='+pageNo+'&end='+ttt+'&strReturn='+myPath,myimageDiv,total,pageNo);
//'/generalElection.do?news=IPLJustIn&state=-1&start='+pageNo+'&end='+ttt+'&strReturn='+myPath
//window.location='/generalElection.do?news=IPLJustIn&state=-1&start='+pageNo+'&end='+ttt+'&strReturn='+myPath;
window.location="/ipl/articles.jsp?cmpId=4&pagesize="+pageNo;
}

function calNextVer4(pageNo,total,myPath,myimageDiv,ttt){
//alert(pageNo);
//sendRequestVer3('GET','/generalElection.do?news=IPLJustIn&state=-1&start='+pageNo+'&end='+ttt+'&strReturn='+myPath,myimageDiv,total,pageNo);
//window.location='/generalElection.do?news=IPLJustIn&state=-1&start='+pageNo+'&end='+ttt+'&strReturn='+myPath;
window.location="/ipl/articles.jsp?cmpId=4&pagesize="+pageNo;
}
function sendRequestVer4(method, url,id,total,pageCt){

divID=id;
totalNo=total;
pageNo=pageCt;
if(method == 'get' || method == 'GET'){
http.open(method,url);
//alert(url);
http.onreadystatechange = handleResponseVer4;
http.send(null);
}
}

function handleResponseVer4(){
if(http.readyState == 4 && http.status == 200){
var response = http.responseText;
//alert(response);
if(response){

document.getElementById(divID).innerHTML = response;
/*
//alert(document.getElementById('nextImage'));
var hrefNextId=document.getElementById('nextImage');
var hrefPreId=document.getElementById('preImage');
	if(totalNo > (pageNo+1)*10)
	{
	    hrefNextId.innerHTML ='<a style="cursor: pointer;" id="nextImgId" onclick="calNextVer2('+(pageNo+1)+','+totalNo+');" ><img src="../images/arrow-r.png" width="18" height="15"></a>';
	}else
	{
	    hrefNextId.innerHTML ='<a style="cursor: pointer;" id="nextImgId" ><img src="../images/arrow-r.png" width="18" height="15"></a>';
	}
	if((pageNo-1)*10 >= 0 )
	{
	   hrefPreId.innerHTML ='<a style="cursor: pointer;" id="preImgId" onclick="calPreVer2('+(pageNo-1)+','+totalNo+');" ><img src="../images/arrow-l.png" width="18" height="15"></a>';
	
	}
	else
	{
	    hrefNextId.innerHTML ='<a style="cursor: pointer;" id="preImgId" ><img src="../images/arrow-l.png" width="18" height="15"></a>';
	}
*/
  }
 }     
}
function calPreVer5(pageNo,total,myPath,myimageDiv,ttt){
//alert(pageNo);
//sendRequestVer3('GET','/generalElection.do?news=IPLJustIn&state=-1&start='+pageNo+'&end='+ttt+'&strReturn='+myPath,myimageDiv,total,pageNo);
//'/generalElection.do?news=IPLJustIn&state=-1&start='+pageNo+'&end='+ttt+'&strReturn='+myPath
//window.location='/generalElection.do?news=IPLJustIn&state=-1&start='+pageNo+'&end='+ttt+'&strReturn='+myPath;
window.location="/campaign/railway-budget/citizen-reactions.jsp?state=-12&start="+pageNo;
}

function calNextVer5(pageNo,total,myPath,myimageDiv,ttt){
//alert(pageNo);
//sendRequestVer3('GET','/generalElection.do?news=IPLJustIn&state=-1&start='+pageNo+'&end='+ttt+'&strReturn='+myPath,myimageDiv,total,pageNo);
//window.location='/generalElection.do?news=IPLJustIn&state=-1&start='+pageNo+'&end='+ttt+'&strReturn='+myPath;
window.location="/campaign/railway-budget/citizen-reactions.jsp?state=-12&start="+pageNo;
}
function sendRequestVer5(method, url,id,total,pageCt){

divID=id;
totalNo=total;
pageNo=pageCt;
if(method == 'get' || method == 'GET'){
http.open(method,url);
//alert(url);
http.onreadystatechange = handleResponseVer5;
http.send(null);
}
}

function handleResponseVer5(){
if(http.readyState == 4 && http.status == 200){
var response = http.responseText;
//alert(response);
if(response){

document.getElementById(divID).innerHTML = response;
/*
//alert(document.getElementById('nextImage'));
var hrefNextId=document.getElementById('nextImage');
var hrefPreId=document.getElementById('preImage');
	if(totalNo > (pageNo+1)*10)
	{
	    hrefNextId.innerHTML ='<a style="cursor: pointer;" id="nextImgId" onclick="calNextVer2('+(pageNo+1)+','+totalNo+');" ><img src="../images/arrow-r.png" width="18" height="15"></a>';
	}else
	{
	    hrefNextId.innerHTML ='<a style="cursor: pointer;" id="nextImgId" ><img src="../images/arrow-r.png" width="18" height="15"></a>';
	}
	if((pageNo-1)*10 >= 0 )
	{
	   hrefPreId.innerHTML ='<a style="cursor: pointer;" id="preImgId" onclick="calPreVer2('+(pageNo-1)+','+totalNo+');" ><img src="../images/arrow-l.png" width="18" height="15"></a>';
	
	}
	else
	{
	    hrefNextId.innerHTML ='<a style="cursor: pointer;" id="preImgId" ><img src="../images/arrow-l.png" width="18" height="15"></a>';
	}
*/
  }
 }     
}
function calPreVer6(pageNo,total,myPath,myimageDiv,ttt){
//alert(pageNo);
//sendRequestVer3('GET','/generalElection.do?news=IPLJustIn&state=-1&start='+pageNo+'&end='+ttt+'&strReturn='+myPath,myimageDiv,total,pageNo);
//'/generalElection.do?news=IPLJustIn&state=-1&start='+pageNo+'&end='+ttt+'&strReturn='+myPath
//window.location='/generalElection.do?news=IPLJustIn&state=-1&start='+pageNo+'&end='+ttt+'&strReturn='+myPath;
window.location="/campaign/railway-budget/articles.jsp?&cmpId=20&pagesize="+pageNo;
}

function calNextVer6(pageNo,total,myPath,myimageDiv,ttt){
//alert(pageNo);
//sendRequestVer3('GET','/generalElection.do?news=IPLJustIn&state=-1&start='+pageNo+'&end='+ttt+'&strReturn='+myPath,myimageDiv,total,pageNo);
//window.location='/generalElection.do?news=IPLJustIn&state=-1&start='+pageNo+'&end='+ttt+'&strReturn='+myPath;
window.location="/campaign/railway-budget/articles.jsp?&cmpId=20&pagesize="+pageNo;
}
function sendRequestVer6(method, url,id,total,pageCt){

divID=id;
totalNo=total;
pageNo=pageCt;
if(method == 'get' || method == 'GET'){
http.open(method,url);
//alert(url);
http.onreadystatechange = handleResponseVer6;
http.send(null);
}
}

function handleResponseVer6(){
if(http.readyState == 4 && http.status == 200){
var response = http.responseText;
//alert(response);
if(response){

document.getElementById(divID).innerHTML = response;
/*
//alert(document.getElementById('nextImage'));
var hrefNextId=document.getElementById('nextImage');
var hrefPreId=document.getElementById('preImage');
	if(totalNo > (pageNo+1)*10)
	{
	    hrefNextId.innerHTML ='<a style="cursor: pointer;" id="nextImgId" onclick="calNextVer2('+(pageNo+1)+','+totalNo+');" ><img src="../images/arrow-r.png" width="18" height="15"></a>';
	}else
	{
	    hrefNextId.innerHTML ='<a style="cursor: pointer;" id="nextImgId" ><img src="../images/arrow-r.png" width="18" height="15"></a>';
	}
	if((pageNo-1)*10 >= 0 )
	{
	   hrefPreId.innerHTML ='<a style="cursor: pointer;" id="preImgId" onclick="calPreVer2('+(pageNo-1)+','+totalNo+');" ><img src="../images/arrow-l.png" width="18" height="15"></a>';
	
	}
	else
	{
	    hrefNextId.innerHTML ='<a style="cursor: pointer;" id="preImgId" ><img src="../images/arrow-l.png" width="18" height="15"></a>';
	}
*/
  }
 }     
}
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;
 }
 return true;
}

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  populateAllImagesLater(){

    populateImagesLater("merinewslogo","<a href='http://www.merinews.com'> <img src='/mnc/images/logo.gif'	width='180' height='77' border='0' /></a>","inline","visible");
     iframeAds();
}
function populateImagesLater(myid,textall,dis,visi){
     document.getElementById(myid).innerHTML=textall;
     document.getElementById(myid).style.display=dis;
     document.getElementById(myid).style.visibility=visi;

}
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;
}


