﻿
var idT,idd;   // stores temporory id of currently displaying div
var i=1; // index of currently active tab

/*------------ This function executes onlaod & initialise all values. --------------------------------
-------------- It hides all divs but leave the one. ---------------------------------------------------*/
function InitialHide()
{
    idT='tabD9';
    EnbDesbPrv();
    EnbDesbNxt();
}

//--------------------------- This method visible the div corrosponding to active tab --------------------


if (window.addEventListener)
window.addEventListener("load", InitialHide, false)
else if (window.attachEvent)
window.attachEvent("onload", InitialHide)

// ---------------- this method deactivate 'Prv' button if there is no previous page availaible for news ------
function EnbDesbPrv()
{
    var j=parseInt(i)-1;
    idd=idT+j;
    if(document.getElementById(idd))
    {
        document.getElementById('Int_Prv').style.display='';
    }
    else
    {
        document.getElementById('Int_Prv').style.display='none';
    }
}

// ---------------- this method deactivate 'Nxt' button if there is no Next page availaible for news --------
function EnbDesbNxt()
{
    var j=parseInt(i)+1;
    idd=idT+j;
    if(document.getElementById(idd))
    {
        
        document.getElementById('Int_Nxt').style.display='';
    }
    else
    {
         document.getElementById('Int_Nxt').style.display='none';
    }
}


//--------------------------- This methods provides effect as next & prev ro currently displaying news ---------
$(document).ready(function(){
    
    $("#Int_Nxt").click(function () 
    {
        var j=parseInt(i)+1;
        idd=idT+j;
        if(document.getElementById(idd))
        {
            idd='#'+idT+i;
            $(idd).fadeOut("slow",function(){
                    i=parseInt(i)+1;
                    idd='#'+idT+i;
                    $(idd).fadeIn("slow");
                    EnbDesbPrv();
                    EnbDesbNxt();  
            });
        }
    });
    
    $("#Int_Prv").click(function () 
    {
        var j=parseInt(i)-1;
        idd=idT+j;
        if(document.getElementById(idd))
        {
            idd='#'+idT+i;
            $(idd).fadeOut("slow",function(){
                i=parseInt(i)-1;
                idd='#'+idT+i;
                $(idd).fadeIn("slow"); 
                EnbDesbPrv();
                EnbDesbNxt();    
            });
        }
    });            
});

