
function OpenPage(PageURL,PageName,Section,IsExternal)
{
	if(!PageURL || typeof(PageURL)=='undefined' || PageURL=="" ) return;	
	InsertAuditLog(PageURL,PageName,Section);
	var _PageURL = PageURL;
	setTimeout(function () { location.href= _PageURL; },1000);
}
function OpenCurrentEditionPage (PageURL,PageName,Section,Depth)
{
	if(!PageURL || typeof(PageURL)=='undefined' || PageURL=="" ) return;	
	var strDepth = "";
    if (Depth && Depth==1) strDepth = "../";
	switch (Section)
	{
	    case "bindhast" :
	    	if (!CurrentbindhastEdition ) return;
	        PageURL = strDepth + CurrentbindhastEdition +"/" + PageURL;
	    break;
	    
	}
	InsertAuditLog(PageURL,PageName,Section);
	var _PageURL = PageURL;
	setTimeout(function () { location.href= _PageURL; },1000);
}
function InsertAuditLog (PageURL,PageName,Section)
{
	if (typeof(ObjSettings)=='undefined' || !ObjSettings || typeof(ObjSettings.InsertAudit)=='undefined' || !ObjSettings.InsertAudit) return;
	if(!PageURL || typeof(PageURL)=='undefined' || PageURL=="" ) return;
	if(!PageName || typeof(PageName)=='undefined' || PageName=="" ) PageName = PageURL;
	if(!Section || typeof(Section)=='undefined' || Section=="" ) Section = PageName;
	if(Section.length >0) Section=Section.replace('.htm','');
	var ObjIframe = document.getElementById('frmLogger');
	if (!ObjIframe) return;
	ObjIframe.src=ObjSettings.LoggerURL+"&SectionName="+Section+"&EventId="+ObjSettings.PageVisitEventId+"&PublicationId="+ObjSettings.PublicationId+"&PageName="+ PageName;
}

function TrackFirstAudit()
{
	try
	{
		var SectionName = "External Referrer";
		
		var CurrentUrl=location.href;
		var CompStr1=CurrentUrl.substring(0,CurrentUrl.lastIndexOf("/")+1);		
		CompStr1=CompStr1.toLowerCase();		
		var PageName=CurrentUrl.substring(CurrentUrl.lastIndexOf("/")+1);
		
		/* Insert AdServer log entry for page */
		var PageTemplate =0;
		if (ObjPageInfo && ObjPageInfo !=null)
		{
			if (ObjPageInfo.NewsId && ObjPageInfo.NewsId >0)
			{
				PageTemplate =3;
			}
			else if (ObjPageInfo.SectionName == 'Index')
			{
				PageTemplate =1;
			}
			else
			{
				PageTemplate =2;
			}
			try
			{			
				(PageTemplate>0)? ObjIframe.src="AdServeLog.aspx?p="+PageTemplate:'';
			}catch (e) {alert(e);}
		}
		
		
		if (typeof(ObjPageInfo)=='undefined' || !ObjPageInfo || typeof(ObjPageInfo.SectionName)=='undefined' || ObjPageInfo.SectionName =="")
		{
			if (PageName.indexOf(".") != -1)
			{
				SectionName = PageName.substr(0,PageName.lastIndexOf("."));
				if (!isNaN(SectionName)) SectionName = "External Referrer";
			}			
		}
		else
		{
			SectionName = ObjPageInfo.SectionName;
		}
							
		InsertAuditLog(PageName,PageName,SectionName);
	}
	catch(e)
	{		
	}
}

if( window.addEventListener )
{
  window.addEventListener('load',BotInitialize,false);
}
else if( window.attachEvent)
{
  window.attachEvent('onload',BotInitialize);
}

var ObjIframe = null;
function BotInitialize ()
{
	try
	{
		ObjIframe = document.createElement('IFRAME');ObjIframe.id ="frmLogger";document.body.appendChild(ObjIframe);ObjIframe.style.display="none";		
		TrackFirstAudit ();
		if (MVJS.GetById('lnkMumbaiThumb') && CurrentEdition)
		{
		    MVJS.GetById('lnkMumbaiThumb').href="javascript:window.open('http://www.epapergallery.com/Saamana/"+ CurrentEdition +"/Normal/Mumbai/index.htm','epaperPopup'+(Math.round((Math.random()*9)+1)).toString(),'alwaysRaised=yes,menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no,width='+screen.width+',height='+screen.height+',top=0,left=0,centerscreen=yes');void(0)";
		    MVJS.GetById ('imgMumbaiThumb').src="http://www.epapergallery.com/Saamana/"+ CurrentEdition +"/PageThumbs/Mumbai/index.jpg";
		    MVJS.Show('divPuneThumbContainer');
		    MVJS.Show('divSambhajinagarThumbContainer');
		    MVJS.GetById('lnkPuneThumb').href="javascript:window.open('http://www.epapergallery.com/Saamana/"+ CurrentEdition +"/Normal/Pune/index.htm','epaperPopup'+(Math.round((Math.random()*9)+1)).toString(),'alwaysRaised=yes,menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no,width='+screen.width+',height='+screen.height+',top=0,left=0,centerscreen=yes');void(0)";
		    MVJS.GetById ('imgPuneThumb').src="http://www.epapergallery.com/Saamana/"+ CurrentEdition +"/PageThumbs/Mumbai/index.jpg";
		    MVJS.GetById('lnkSambhajinagarThumb').href="javascript:window.open('http://www.epapergallery.com/Saamana/"+ CurrentEdition +"/Normal/Sambhajinagar/index.htm','epaperPopup'+(Math.round((Math.random()*9)+1)).toString(),'alwaysRaised=yes,menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no,width='+screen.width+',height='+screen.height+',top=0,left=0,centerscreen=yes');void(0)";
		    MVJS.GetById ('imgSambhajinagarThumb').src="http://www.epapergallery.com/Saamana/"+ CurrentEdition +"/PageThumbs/Sambhajinagar/index.jpg";
		    
		}
	}
	catch (e)
	{
		alert(e);
	}
}


/* Update Page Date Start */
	try
	{
		if (typeof (SiteUpdateDate) != 'undefined' && SiteUpdateDate!= null && SiteUpdateDate!="")
		{
			if(document.getElementById('spnCurrentDateTime'))
			{
				document.getElementById('spnCurrentDateTime').innerHTML = SiteUpdateDate;
			}
		}
	}
	catch (e) {}

/* Update Page Date End */

function BookmarkSaamana()
{
	Bookmark(ObjSettings.BookMarkTitle,ObjSettings.BookMarkUrl);
}
function Bookmark(title,url)
{
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url,'');
	else if(window.opera && window.print)
	{ // opera
		var elem=document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	}
else if(document.all)// ie
window.external.AddFavorite(url, title);
}

var CurrentFontSize =0;
SwitchFontSize (3);
function SwitchFontSize (SwitchTo)
{
	try
	{
		var PostFix ="";
		if (CurrentFontSize!=0){ (CurrentFontSize >0)?PostFix=CurrentFontSize: PostFix="_"+ Math.abs(CurrentFontSize);}		
		var ObjTargetDiv = document.getElementById('NewsContainer'+PostFix);
		if(!ObjTargetDiv) return;
		
		switch (SwitchTo)
		{
			case 0:
				CurrentFontSize =SwitchTo;
				break;
			case 1:
				(CurrentFontSize <4)? CurrentFontSize++:'';
				break;
			case 2:
				(CurrentFontSize > -2)? CurrentFontSize--:'';
				break;	
			case 3:				
				var nameEQ = "fs_newcontainer=";
				var ca = document.cookie.split(';');
				for(var i=0;i < ca.length;i++) {
					var c = ca[i];
					while (c.charAt(0)==' ') c = c.substring(1,c.length);
					if (c.indexOf(nameEQ) === 0){ CurrentFontSize= c.substring(nameEQ.length,c.length); break; }
				}
				if (CurrentFontSize ==0) return;
				break;
		}
		
		PostFix ="";
		if (CurrentFontSize!=0){ (CurrentFontSize >0)?PostFix=CurrentFontSize: PostFix="_"+ Math.abs(CurrentFontSize);}		
		ObjTargetDiv.id = 'NewsContainer'+PostFix;		
		var date = new Date();
		date.setTime(date.getTime()+(15*24*60*60*1000));
		document.cookie = "fs_newcontainer="+CurrentFontSize+"; expires="+date.toGMTString()+"; path=/";
		
	}
	catch (e) {}
}

function ShowSectionDiv()
{
    try
    {
       if (ObjPageInfo && ObjPageInfo !=null)
       {
            if (ObjPageInfo.SectionName=='agralekh' || ObjPageInfo.SectionName=='stambhalekh' || ObjPageInfo.SectionName=='Dakhal' || ObjPageInfo.SectionName=='loknyayalay')
            {
                MVJS.Show('SampadakiyaSectionContainer');
            }
            if(ObjPageInfo.SectionName=='padsad' || ObjPageInfo.SectionName=='samashti' || ObjPageInfo.SectionName=='padadyaaadun' || ObjPageInfo.SectionName=='chitradarbar' || ObjPageInfo.SectionName=='PoliceDiary')
            {
                MVJS.Show('SadareSectionContainer');
            }
       }
       
   }
   catch(e)
   {   }
}

ShowSectionDiv();

function SearchNews(Tag,PageLevel)
{
  try
  { 
    if(!PageLevel){var PageLevel='';}
    location.href= PageLevel + 'SearchNews.aspx?tag='+Tag ;        
  }
  catch(e)
  {
        alert(e);
  }   
}