﻿// JScript File

var RecsPerPage=20;///4//16;//8
var CurrentPage=1;
var imgPath="uploadedDocs/"

var NoLoginBoxPages="signup.aspx|login.aspx"

function OpenWindow(path)
 {
  
  window.open(path,"_self",'',true);
       return
 }
 
function alphaOver(obj)
{
    if(obj.className!="articleCatInactive")
        obj.className="articleCatOver";
}
function alphaOut(obj)
{
    if(obj.className!="articleCatInactive")
        obj.className="articleCatActive";
}
function alphaSet()
{
    loc=(location.href).indexOf("alpha=");
    if(loc<0)
        return;
    curAlpha=(location.href).slice(loc+6,loc+7);
    //alert(curAlpha.length+":"+curAlpha)
   alphaObj=document.getElementById("alpha"+curAlpha)
   //alphaObj=document.getElementById("alphaE")
    //alert(  alphaObj)  
    if(alphaObj==null)
        return;
   
    alphaObj.className="articleCatInactive"
}

function ShowNoRecordMsg(TableObj)
{
     RowsObj=TableObj.insertRow(0)                
     CellsObj=RowsObj.insertCell(0)  
	CellsObj.innerHTML="Sorry No Records Found";
	
}


function PrevPage()
{
    if(CurrentPage<2)
       return;    
    CurrentPage--;     
    SetPage(CurrentPage);
}

function NextPage()
{
    var RowValues = DataRecords.split(Delimeter);	
    var TotalPages=Math.floor((RowValues.length-1)/RecsPerPage)
	TotalPages++;
	
    if(CurrentPage>=TotalPages)
       return;    
    CurrentPage++;     
    SetPage(CurrentPage);
}
function SetPages(isPrev,isNext,curPage,totalPage)
{
    var cms="";
    cms+=" <div ><table   border=\"0\" cellspacing=\"2\" cellpadding=\"0\"><tr>"
    cms+=" <td  valign=\"middle\" >Pages&nbsp;</td>"
    if(isPrev)
    {   
        cms+=" <td onclick=\"PrevPage(this)\"width=\"70\" align=\"center\" valign=\"middle\" class=\"inactivepagging\"><a class=\"pagginglinks\" >Previous</a></td>"
       
    }
    for(pagei=1;pagei<=totalPage;pagei++)
    {
        if(pagei==curPage)
            cms+=" <td width=\"13\" align=\"center\" valign=\"top\" id=\"Page"+pagei+"\" class=\"activepagging\">"+pagei+"</td>"
        else
            cms+=" <td onclick=\"SetPage("+pagei+")\" width=\"13\" align=\"center\" valign=\"middle\" id=\"Page"+pagei+"\" class=\"inactivepagging\"><a  class=\"pagginglinks\" >"+pagei+"</a></td>"
    }
    if(isNext)
    {
        cms+="<td onclick=\"NextPage(this)\" width=\"70\" align=\"center\" valign=\"middle\" class=\"inactivepagging\"><a class=\"pagginglinks\" >Next</a></td>"
       
    }
    cms+="  </tr> </table>  </div>";
    return cms;
}

function alpha(letter)
{
   // alert(letter)
    var curLoc=location.href
    var path="";
    if(curLoc.indexOf("?")<0)    
        path=curLoc+"?alpha="+letter
    else if(curLoc.indexOf("?alpha")<0)  
    {
        curLocs=curLoc.split("&")    
        path=curLocs[0]+"&alpha="+letter
    }
    else 
    {
        curLocs=curLoc.split("?")    
        path=curLocs[0]+"?alpha="+letter
    }
    
    
    OpenWindow(path)    
}

function DelTable(tblObj)
 {
    i=0;
    while(tblObj.rows.length>0)  
        tblObj.deleteRow(i)
 } 
function OpenWindow(path)
 {
   
  window.open(path,"_self",'',true);
       return
 }
 
function SetSession()
{//return;
    
    var curlocPage=(location.href).split('/');
    if(NoLoginBoxPages.indexOf(curlocPage[curlocPage.length-1])>0)
    {
   // alert(curlocPage[curlocPage.length-1]);
      document.getElementById("tblLogin").style.display='none';
       document.getElementById("tblLogout").style.display='none';
       if( document.getElementById("trQuestion")!=null)
        document.getElementById("trQuestion").style.display='none';
    }
    else if(sSession!="0")
    {
    //alert(document.getElementById("trQuestion"));
      document.getElementById("tblLogin").style.display='none';
       document.getElementById("tblLogout").style.display='inline';
       if( document.getElementById("trQuestion")!=null)
        document.getElementById("trQuestion").style.display='none';
    }
   
    else
    {
        //alert(1);
       
        document.getElementById("tblLogin").style.display='inline';
       document.getElementById("tblLogout").style.display='none';
       if( document.getElementById("trQuestion")!=null)
        document.getElementById("trQuestion").style.display='';
    }
}

function SetSide()
{
 var colCount=0
 var rowCount=0
 var recCount=0; 
  var RowValues = SideDataRecords.split(Delimeter);
    
    TableObj=document.getElementById("tblSideRecords")
    DelTable(TableObj);
  
	var TotalRows

	TotalRows=RowValues.length-1;
    
	//alert(DataRecords)
	var designRow=0;
	
    while(rowCount<TotalRows)
    {
        RowsObj=TableObj.insertRow(designRow)                
      
		ColValues=RowValues[recCount].split(InnerDelimeter)
		
		CellsObj=RowsObj.insertCell(0)  
		CellsObj.innerHTML=CreateSideCell(RowValues[recCount++])    
        
        rowCount++
		++designRow
        
    } 
    return;
}

function CreateSideCell(cellRecs)
 {
	CellValues=cellRecs.split(InnerDelimeter);	
	var cms="";
	cms+="<div style=\"cursor:pointer;width:170px;\" onclick=\"OpenWindow('"+GlobalRef+"?RecordId="+CellValues[0]+"')\"  >" ;
	cms+="<table width=\"170px\" height=\"20\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
    cms+="<tr> <td width=\"20\" height=\"20\" align=\"center\" valign=\"middle\">"
    cms+="<img src=\"images/bullet.jpg\" width=\"5\" height=\"5\" /></td>"
    cms+="<td height=\"20\" align=\"left\" valign=\"middle\" class=\"PDCText\">"
    cms+=CellValues[1]
    cms+="</td> </tr>"
    cms+=" </table></div>";
    
    return cms;
 }
 
 
