function calendarPicker(strField)
{

       window.open('../Calendar.aspx?field=' + strField, 'calendarPopup', 'width=250,height=170,resizable=no,left=420,top=255');
}   
   
var imgCalCtrl;
var lblSearchStr;

var lblSearchTitle;
var lblSearchText;
var lblSearchAuthor;
var lblSearchDate;

var inputDate;
var prevInd;
var labelPages;
var linkCal;
var labelNoMatch;
var lblErrMessage;
var lblErrTtl;
var lblErrTxt;
var lblErrAthr;
var lblErrDate;
var tdError;
var tdBefErr;
//Function called whenever page is being loaded
function init(lblSearch1, lblSearch2, lblSearch3, lblSearch4, imgCal, inputCal, dropdownList, txtboxSearch, lblPages, lblNoMatch, lnkCal, lblTtlRqd, lblTxtRqd, lblAthrRqd, lblDateRqd, tdErr, tdBeforeErr)
{
      
    //debugger;
    //lblSearchStr = $(lblSearch);
    
    lblSearchTitle = $(lblSearch1);
    lblSearchText = $(lblSearch2);
    lblSearchAuthor = $(lblSearch3);
    lblSearchDate = $(lblSearch4);
    
    imgCalCtrl = $(imgCal);
    inputDate = $(inputCal);
    dropdwnList = $(dropdownList);
    txtSearch = $(txtboxSearch);
    labelPages = $(lblPages);
    labelNoMatch = $(lblNoMatch);
    linkCal = $(lnkCal);
       
        //lblErrMessage = $(lblErr);
    lblErrTtl = $(lblTtlRqd);
    lblErrTxt = $(lblTxtRqd);
    lblErrAthr = $(lblAthrRqd);
    lblErrDate = $(lblDateRqd);
    
    tdError = $(tdErr);
    tdBefErr = $(tdBeforeErr);
    divall=$('divtxt');
    divDate=$('divdate');
    
    
        //lblErrMessage.style.visibility = 'Hidden';
    tdError.style.display = 'none';
    //tdError.style.visibility = 'Hidden';
    //labelNoMatch.style.visibility = 'visible';
    if(dropdwnList.selectedIndex != '3')    //Hide read-only textbox and calendar when other categories are selected.
    {
         divDate.style.display='none';
         divall.style.display='block';
    
        //imgCalCtrl.style.visibility = 'Hidden';
        //linkCal.style.visibility = 'Hidden';
        //inputDate.style.visibility = 'Hidden';
        if(dropdwnList.selectedIndex == '0')
        {
            //lblSearchStr.innerText = "Enter Title";
            //lblSearchStr.innerHTML = "Enter Title";
            lblSearchTitle.style.display = 'block';
            lblSearchText.style.display = 'none';
            lblSearchAuthor.style.display = 'none';
            lblSearchDate.style.display = 'none';
            prevInd = 0;
        }
        if(dropdwnList.selectedIndex == '1')
        {
            //lblSearchStr.innerText = "Enter Text";
            //lblSearchStr.innerHTML = "Enter Text";
            lblSearchTitle.style.display = 'none';
            lblSearchText.style.display = 'block';
            lblSearchAuthor.style.display = 'none';
            lblSearchDate.style.display = 'none';
            prevInd = 1;
        }
        if(dropdwnList.selectedIndex == '2')
        {
            //lblSearchStr.innerText = "Enter Author";
            //lblSearchStr.innerHTML = "Enter Author";
            lblSearchTitle.style.display = 'none';
            lblSearchText.style.display = 'none';
            lblSearchAuthor.style.display = 'block';
            lblSearchDate.style.display = 'none';
            prevInd = 2;
        }
    }
    else                                    //Hide the textbox when the 'Posted On' category is selected
    {
        divDate.style.display='block';
        divall.style.display='none';
        //txtSearch.style.display = 'none';
        //lblSearchStr.innerText = "Enter Date";
        //lblSearchStr.innerHTML = "Enter Date";
        lblSearchTitle.style.display = 'none';
        lblSearchText.style.display = 'none';
        lblSearchAuthor.style.display = 'none';
        lblSearchDate.style.display = 'block';
        prevInd = 3;
    } 
    //code for menu panel at left side
     var imgPar='find';
        for(i=0;i<7;i++)
        {
            var finalId=imgPar+i;
            if(document.getElementById(finalId))
            {
                var linkid='Img123'+i;
                var divid='Menu123'+i;
                toggleExceptOne(linkid,divid);
                break;
            }
        }  
        var checkStatus=get_cookie('ppkcookie2');
        if(checkStatus=='hide')
        {
            toggleOnLoad();
        }              
}

function $(d)
{ 
    return document.getElementById(d);
} 

function EnableDisable(dropdownList, txtboxSearch, gridView, reqSearch, reqDate, lblErr, tdErr)// reqSearch,(4th parameter)
{    
  
    txtSearch = $(txtboxSearch);
    dropdwnList = $(dropdownList);
    imgCalendar = imgCalCtrl;
    
    
    //lblSearchS = lblSearchStr;
    lblSearchTtl = lblSearchTitle;
    lblSearchTxt = lblSearchText;
    lblSearchAthr = lblSearchAuthor;
    lblSearchDt = lblSearchDate;
    
    txtDate = inputDate;
    grdView = $(gridView);
    lblPages1 = labelPages;
    lblNoResults = labelNoMatch;
    lblErrMsg = $(lblErr);
    tdataErr = $(tdErr);
    reqValSearch = $(reqSearch);
    reqValDate = $(reqDate);
    divall=$('divtxt');
    divDate=$('divdate');
    tdBeforeError = tdBefErr;
    
    if(dropdwnList.selectedIndex == '0')
    {
        divDate.style.display='none';
        divall.style.display='block';
        
        //lblSearchS.innerText = "Enter Title";
        //lblSearchS.innerHTML = "Enter Title";
        lblSearchTtl.style.display = 'block';
        lblSearchTxt.style.display = 'none';
        lblSearchAthr.style.display = 'none';
        lblSearchDt.style.display = 'none'; 
        
        //imgCalendar.style.visibility = 'Hidden';
        txtSearch.style.display= 'block';  
        txtDate.value = "24-09-2007";           //Put some value to the read-only textbox to avoid display of error message.
        txtDate.style.visibility = 'Hidden';
        if(prevInd != 0)     //Clear the textbox, when the category has been changed.
        {
            txtSearch.value = "";
            reqValSearch.style.visibility = 'Hidden';
            reqValDate.style.visibility = 'Hidden';
            
            if(grdView != null)
            {
                grdView.innerText = "";
            }
            if(lblNoResults != null)
            {
                lblNoResults.style.visibility = 'Hidden';
            }
            if(lblPages1 != null)
            {
                lblPages1.style.visibility = 'Hidden';
            }
            if(lblErrMsg != null)
            {
                lblErrMsg.style.visibility = 'Hidden';
            }    
            if(tdataErr != null)
            {
                //tdataErr.style.visibility = 'Hidden';
                tdataErr.style.display = 'none';
            }
        }
    }
    else if(dropdwnList.selectedIndex == '1')
    {
        divDate.style.display='none';
        divall.style.display='block';
            
        //lblSearchS.innerText = "Enter Text";
        //lblSearchS.innerHTML = "Enter Text";
        lblSearchTtl.style.display = 'none';
        lblSearchTxt.style.display = 'block';
        lblSearchAthr.style.display = 'none';
        lblSearchDt.style.display = 'none';
        
        //lblSearchS.outerText = "Search Text";
        //lblSearchS.outerHTML = "<SPAN class=normal_text_bold id=lblSearch style=\"LEFT: 0px; POSITION: relative; TOP: 0px\">Search Text</SPAN>"
        //imgCalendar.style.visibility = 'Hidden';
        txtSearch.style.display = 'block'; 
        txtDate.value = "24-09-2007";           //Put some value to the read-only textbox to avoid display of error message.
        txtDate.style.visibility = 'Hidden'; 
        if(prevInd != 1)     //Clear the textbox, when the category has been changed.
        {
            txtSearch.value = "";
            reqValSearch.style.visibility = 'Hidden';
            reqValDate.style.visibility = 'Hidden';
            
            if(grdView != null)
            {
                grdView.innerText = "";
            }
            if(lblNoResults != null)
            {
                lblNoResults.style.visibility = 'Hidden';
            }
            if(lblPages1 != null)
            {
                lblPages1.style.visibility = 'Hidden';
            }
            if(lblErrMsg != null)
            {
                lblErrMsg.style.visibility = 'Hidden';
            }
            if(tdataErr != null)
            {
                //tdataErr.style.visibility = 'Hidden';
                tdataErr.style.display = 'none';
            }
        }          
    }
    else if(dropdwnList.selectedIndex == '2')
    {
        divDate.style.display='none';
        divall.style.display='block';
    
        //lblSearchS.innerText = "Enter Author"; 
        //lblSearchS.innerHTML = "Enter Author";
        lblSearchTtl.style.display = 'none';
        lblSearchTxt.style.display = 'none';
        lblSearchAthr.style.display = 'block';
        lblSearchDt.style.display = 'none';
        
        //imgCalendar.style.visibility = 'Hidden'; 
        txtSearch.style.display = 'block'; ;
        txtDate.value = "24-09-2007";           //Put some value to the read-only textbox to avoid display of error message.
        txtDate.style.visibility = 'Hidden';
        if(prevInd != 2)     //Clear the textbox, when the category has been changed.
        {
            txtSearch.value = "";
            reqValSearch.style.visibility = 'Hidden';
            reqValDate.style.visibility = 'Hidden';
            
            if(grdView != null)
            {
                grdView.innerText = "";
            }
            if(lblNoResults != null)
            {
                lblNoResults.style.visibility = 'Hidden';
            }
            if(lblPages1 != null)
            {
                lblPages1.style.visibility = 'Hidden';
            }
            if(lblErrMsg != null)
            {
                lblErrMsg.style.visibility = 'Hidden';
            }
            if(tdataErr != null)
            {
                //tdataErr.style.visibility = 'Hidden';
                tdataErr.style.display = 'none';
            }
        }
    } 
    else if(dropdwnList.selectedIndex == '3')
    {
    
        divDate.style.display='block';
        divall.style.display='none';
        
        //lblSearchS.innerText = "Enter Date";
        //lblSearchS.innerHTML = "Enter Date";
        lblSearchTtl.style.display = 'none';
        lblSearchTxt.style.display = 'none';
        lblSearchAthr.style.display = 'none';
        lblSearchDt.style.display = 'block';
        //imgCalendar.style.visibility = 'visible';
        txtSearch.value = "the";               //Put some value to the textbox to avoid display of error message.
        txtSearch.style.display = 'none'; 
        txtDate.style.visibility = 'visible';
        if(prevInd != 3)     //Clear the textbox, when the category has been changed.
        {
            txtDate.value = "";
            reqValSearch.style.visibility = 'Hidden';
            reqValDate.style.visibility = 'Hidden';
            
            if(grdView != null)
            {
                grdView.innerText = "";
            }
            if(lblNoResults != null)
            {
                lblNoResults.style.visibility = 'Hidden';
            }
            if(lblPages1 != null)
            {
                lblPages1.style.visibility = 'Hidden';
            }
            if(lblErrMsg != null)
            {
                lblErrMsg.style.visibility = 'Hidden';
            }
            if(tdataErr != null)
            {
                //tdataErr.style.visibility = 'Hidden';
                tdataErr.style.display = 'none';
            }
        }
    }
    prevInd = dropdwnList.selectedIndex;
    
    //Code added to remove the extra space when error message is displayed
    //if(lblErrMessage.style.visibility == 'hidden')
    {
        tdBeforeError.style.display = 'block';//show the white strip if error message is not visible
        tdBeforeError.style.backgroundColor = "#ffffff";
    }
}
//function newfunction()
//{
// debugger;
//  
//}
function onChanged(gridView, dropdownList, lblErr, textBoxSearch, inputDate, tdErr)
{
   //debugger;
    grdView = $(gridView);
    dropdwnList = $(dropdownList);
    //lblErrMsg = $(lblErr);
        //lblErrMsg = lblErrMessage;
    txtSearch = $(textBoxSearch);
    txtDate = $(inputDate);
    tblErr = tdError;
    tdBErr = tdBefErr;
    if(txtSearch.value == "")   //If the textbox is blank 
    {
        //tblErr.style.visibility = 'visible';
        tblErr.style.display = 'block';
            //lblErrMsg.style.visibility = 'visible';     //make error lable visible 
        tdBErr.style.display = 'none';
    }
    if(dropdwnList.selectedIndex == '0')
    {
        lblErrTtl.style.display = 'block';
        lblErrTxt.style.display = 'none';
        lblErrAthr.style.display = 'none';
        lblErrDate.style.display = 'none';
            //lblErrMsg.innerHTML = "<br><LI>Title is required</LI>"; 
        //lblErrMsg.innerText = "Title is required";  //change the error label text depending on the selected category in drop down list
    }
    if(dropdwnList.selectedIndex == '1')
    {
        lblErrTxt.style.display = 'block';
        lblErrTtl.style.display = 'none';
        lblErrAthr.style.display = 'none';
        lblErrDate.style.display = 'none';
            //lblErrMsg.innerHTML = "<br><LI>Text is required</LI>"; 
        //lblErrMsg.innerText = "Text is required";   //change the error label text depending on the selected category in drop down list
    }
    if(dropdwnList.selectedIndex == '2')
    {
        lblErrAthr.style.display = 'block';
        lblErrTxt.style.display = 'none';
        lblErrTtl.style.display = 'none';
        lblErrDate.style.display = 'none';
            //lblErrMsg.innerHTML = "<br><LI>Author is required</LI>"; 
        //lblErrMsg.innerText = "Posted By is required";  //change the error label text depending on the selected category in drop down list
    }
    if(txtDate.value == "" && dropdwnList.selectedIndex == '3')
    {
        lblErrDate.style.display = 'block';
        lblErrTxt.style.display = 'none';
        lblErrTtl.style.display = 'none';
        lblErrAthr.style.display = 'none';
            //lblErrMsg.style.visibility = 'visible';
        tblErr.style.display = 'block';
        tdBErr.style.display = 'none';
        //tblErr.style.visibility = 'visible';
            //lblErrMsg.innerHTML = "<br><LI>Date is required</LI>"; 
        //lblErrMsg.innerText = "Date is required";   //change the error label text depending on the selected category in drop down list
    }
    
    if(labelPages != null)
    {
        labelPages.style.visibility = 'Hidden';
    }    
    if(labelNoMatch != null)
    {
        labelNoMatch.style.visibility = 'Hidden';      
    }
    if(grdView != null)
    {
        grdView.innerText = "";
        //grdView.innerHTML = "";
        //grdView.outerHTML = "";
    }
}


