var xmlHttp;
var RssxmlHttp;
var ldivid;
onerror=handleErr;
var txt="";
var myWindow;
var pdflink;
var passflag='N';
//window.onload=getrssfeed;
function handleErr(msg,url,l)
{
txt="There was an error on this page.\n\n";
txt+="Error: " + msg + "\n";
txt+="URL: " + url + "\n";
txt+="Line: " + l + "\n\n";
txt+="Click OK to continue.\n\n";
alert(txt);
return true;
}
function startpoint()
 { 
   
  /* var h1 = document.getElementById("r1").value;
   var h2 = document.getElementById("r2").value;
   var h3 =document.getElementById("dv5").style.height;
   var h4 =document.getElementById("dv6").style.height;
   */
   getrssfeed;
 }

function dispdiv(idno,rn)
{
 if (rn == 1)
  { 
     var idno1='rp1p' + idno;
     var idno2 = 'rp1d' + idno;
     var idno3 = 'lsdiv1' + idno;
  } 
  if (rn == 2)
  { 
     var idno1='rp2p' + idno;
     var idno2 = 'rp2d' + idno;
     var idno3 = 'lsdiv2' + idno;
  }
  var paraname = document.getElementById(idno1);
  var dvname = document.getElementById(idno2);
  var leftposition = paraname.style.left;
  //var pheight = rn*10 + 'px'
  dvname.style.left = '5px';
  dvname.style.paddingTop='15px';
  dvname.style.paddingBottom = '15px';
  //dvname.style.height = pheight;
  dvname.style.top = document.getElementById(idno3).style.top;
}  
function hidediv(idno,event)
{
  var browserName=navigator.appName;
  var dvname = document.getElementById(idno);
 if (browserName=="Microsoft Internet Explorer")
  {
      if (event.toElement != dvname && dvname.contains(event.toElement) == false)
          dvname.style.left = -1000;
     
   }
  else
    /*var node = event.target;
    while(node.nodeType != node.ELEMENT_NODE)
	 node = node.parentNode;*/

    {
       if (event.relatedTarget != dvname) 
       //&& (event.relatedTarget != dvname.childNodes.name) 
       dvname.style.display = "none" ;
     } 
}
function contains(a, b)
{
	// we climb through b parents
	// till we find a
 	while(b && (a!=b) && (b!=null))
		b = b.parentNode;
	return a == b;
}

//Display Ministry
function dispministry(idno1,idno2)
{
  var paraname = document.getElementById(idno1);
  var dvname = document.getElementById(idno2);
  dvname.style.left = paraname.style.left;
  dvname.style.visibility = "visible";
  //dvname.style.top = paraname.style.top;
  dvname.style.paddingTop='15px';
  dvname.style.paddingBottom = '15px';
}  
// Display Feedback date
function getfeedmenu(idno1,idno2)
{
  var paraname = document.getElementById(idno1);
  var dvname = document.getElementById(idno2);
  //dvname.style.left = paraname.style.left;
  //dvname.style.top =paraname.style.top;
  dvname.style.visibility = "visible";
  //dvname.style.top = paraname.style.top;
  dvname.style.paddingTop='15px';
  dvname.style.paddingBottom = '15px';
}  
function feedpass(flname,clipping)
 {
   if (clipping == 'N')
   { 
      alert ("Sorry You are not authorized for feedback");
    }
  else
  {
    var  myWindow=window.open(flname,'', 'left=0, width=650,height=800, scrollbars=yes,menubar=no,status=0,titlebar=1,toolbar=0,resizable=yes');
  }  
}

// Display Release
function disprel(trelid)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="getrelease.asp";
url=url+"?relid="+trelid;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged() 
{ 
 if (xmlHttp.readyState==4)
 { 
  var divhide = document.getElementById("dvhide");
  divhide.style.left = '32%';
  divhide.style.width = '65%';
  divhide.style.top = '0px';
  //divhide.style.height = '100%';
  divhide.innerHTML=xmlHttp.responseText;
 }
}
//*********** Get more Photo
function morephoto(clickside)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 

var url="morephoto.asp";
url=url+"?clickside="+clickside;
url=url+"&sid="+Math.random();
if (clickside != 'N')
  {
     var firstphid=document.getElementById("firstphid").value;
     var lastphid=document.getElementById("lastphid").value;
     url=url+"&firstphid="+firstphid;
     url=url+"&lastphid="+lastphid;
  }
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
//*********** Get more Video
function morevideo(clickside)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="morevideo.asp";
url=url+"?clickside="+clickside;
url=url+"&sid="+Math.random();
if (clickside != 'N')
  {
     var firstphid=document.getElementById("firstphid").value;
     var lastphid=document.getElementById("lastphid").value;
     url=url+"&firstphid="+firstphid;
     url=url+"&lastphid="+lastphid;
  }
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
//*********** Get more Infographic
function moregraphic(clickside)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="moregraphic.asp";
url=url+"?clickside="+clickside;
url=url+"&sid="+Math.random();
if (clickside != 'N')
  {
     var firstphid=document.getElementById("firstphid").value;
     var lastphid=document.getElementById("lastphid").value;
     url=url+"&firstphid="+firstphid;
     url=url+"&lastphid="+lastphid;
  }
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
//********************* Get Release
function getrelease(dvid)
{ 
ldivid = dvid;
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="morerelease.asp";
url=url+"?dvid="+ldivid;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=writerelease;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function writerelease() 
{ 
 if (xmlHttp.readyState==4)
 { 
  var divid=ldivid.substr(0,3);
  var divname=document.getElementById(divid).innerHTML=xmlHttp.responseText;
  
// divname.innerHTML=xmlHttp.responseText;
 }
 
}
// *************** Create XmlHttp
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

// ********* Get RSS Feed *************************
function getrssfeed(dvid)
{ 
ldivid = dvid;
var mincode = document.getElementById("mincode").value;
RssxmlHttp=GetXmlHttpObjectRss();
if (RssxmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="rss2html.asp";
url=url+"?mincode="+mincode;
url=url+"&sid="+Math.random();
RssxmlHttp.onreadystatechange=writerssfeed;
RssxmlHttp.open("GET",url,true);
RssxmlHttp.send(null);
}
function writerssfeed()
{
   if (RssxmlHttp.readyState==4)
   var divname=document.getElementById('rssfeed').innerHTML=RssxmlHttp.responseText;
}
// *************Create xmlHttp for Rss Feed********
function GetXmlHttpObjectRss()
{
var RssxmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  RssxmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    RssxmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    RssxmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return RssxmlHttp;
}
//****************** Hide Function ************

function hidebox()
 {
     var dvname = document.getElementById("dvhide");
  //    if (event.toElement != dvname &&  dvname.contains(event.toElement) == false)
  // {
      dvname.innerHTML="";
	  dvname.style.left = -1000;
    //  menuToHide.style.top = -1000; 
  // }
	  
 }

function playlink(slink)
 {	   
  var  myWindow=window.open(slink,'', 'left=0, width=650,height=800, scrollbars=yes,menubar=no,status=0,titlebar=1,toolbar=0,resizable=yes');
  }	   
// This function will display a password box
function clippass(clipdate,clipping)
 {
   document.getElementById("hdpass").value = clipdate;
  // if (passflag == 'N')
    if (clipping == 'N')
   { 
      //document.getElementById("dvpass").style.left = '60%';
      alert ("Sorry You are not authorized for clipping");
    }
  else
  {
    document.getElementById("dvpaper").style.left = '75%'; // display paper size select box
  }  
}
// This function will check password
 function getclippass(mincode)
{
   var pd=document.getElementById("txtpass").value;
   document.getElementById("dvpass").style.left = '-1000px';
   xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
   {
      alert ("Your browser does not support AJAX!");
      return;
   } 
   var url="chkpass.asp"; // This page will check password of particular ministry from database
   url=url+"?pi="+pd;
   url=url+"&ministrycode="+mincode;
   url=url+"&sid="+Math.random();
   xmlHttp.onreadystatechange=checkresponse;
   xmlHttp.open("GET",url,true);
   xmlHttp.send(null);
  } 
  
 function checkresponse() 
 {
   if (xmlHttp.readyState==4)
   {
   var pd=xmlHttp.responseText;
   if (pd == "YES")
    { 
      passflag = 'Y'; 
      document.getElementById("dvpaper").style.left = '75%'; // display paper size select box
    }
   else
   {
    alert("Sorry wrong Password");
   }
  } 
} 
  
 // This function will display select paper box
  
function getclipping(papersize,clipcode)
 {	   
   document.getElementById("dvpaper").style.left = '-1000px';
   var clipdate =  document.getElementById("hdpass").value;
   // here we will call your page by passing three parameter (ministrycode,clipdate,papersize) to display pdf file
   var slink;
   if (papersize == 'A4')
     window.open('http://cp.pressmonitor.com/cp/?ank_m=dl&noshell=1&noob=1&o=1724&d=' + clipdate + '&file=' + clipcode + '.pdf&login=pib&password=pib');
   else
     window.open('http://cp.pressmonitor.com/cp/?ank_m=dl&noshell=1&noob=1&o=1724&d=' + clipdate + '&file=' + clipcode + 'a3.pdf&login=pib&password=pib');
  
 }
function submitform(i)
{
 if (i == 1)
  document.bform.submit();
 if (i == 2)  
  document.sform1.submit();
}
   

