
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,IsExternal)
{
	if(!PageURL || typeof(PageURL)=='undefined' || PageURL=="" ) return;	
	switch (Section)
	{
	    case "Chintoo" :
	    	if (!CurrentChintooEdition ) return;
	        PageURL = CurrentChintooEdition +"/" + PageURL;
	    break;
	    case "Graffiti" :
	    	if (!CurrentGraffitiEdition ) return;
	        PageURL = CurrentGraffitiEdition +"/" + 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);
		
		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);
}

function BotInitialize ()
{
	try
	{
		var ObjIframe = document.createElement('IFRAME');ObjIframe.id ="frmLogger";document.body.appendChild(ObjIframe);ObjIframe.style.display="none";
		TrackFirstAudit ();
	}
	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 BookmarkEsakal()
{
	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 ShowTemplateLoginPopup ()
{
    try
    {   
        MVJS.ShowPopup('divLoginPopup');
    }
    catch(e)
    {   
        alert(e);
    }    
}
function Logout(Depth)
{
    try
    {   
    	var strDepth = "";
    	if (Depth && Depth==1) strDepth = "../";
        var ObjLoginWin = document.getElementById('frmLogin');
        if (ObjLoginWin)
        {
            ObjLoginWin.src =strDepth+"Login.aspx?logout=1";
        }
    }
    catch(e)
    {
        alert(e);
    }
        
}
