﻿// JScript File

var dvopened = 0;
var clickedid ="";
var clickedbtn = "";
var rowQid;
var pid="";
        
    function preshow(idvid,whichdiv,rowno)
    {
        var lstatus = document.getElementById('hdnLstatus').value;
        if(lstatus != '0')
        {
            rowQid = rowno;
            whichdiv = whichdiv+rowno;
            if(dvopened == 0 && clickedid == "")
            {
                menulist(whichdiv);
                dvopened=1;
                clickedid=whichdiv;
                document.getElementById(idvid).style.display="none";
                clickedbtn = idvid;
            }
            else if(dvopened == 1 && clickedid == whichdiv)
            {
                hidelist(whichdiv);
                document.getElementById(idvid).style.display="block";
                dvopened=0;
                clickedid = "";
            }
            else if (dvopened == 1 && clickedid != whichdiv)
            {
                hidelist(clickedid);
                document.getElementById(clickedbtn).style.display="block";
                menulist(whichdiv);
                document.getElementById(idvid).style.display="none";
                clickedid = whichdiv;
                clickedbtn = idvid;
            }
            return false;
        }
        else
        {
            alert("Please login to send your request.");
            return false;
        }
    }
    function menulist(whichdiv)
    {
        animatedcollapse.show(whichdiv);
    }

    function hidelist(whichdiv)
    {
        animatedcollapse.hide(whichdiv);
    }
    
    function reqresponse(response)
    {
        var resQ=response.value;
        if(resQ == "0")
        {
            alert("Your message has been sent to the advertiser of this ad. \n\n Please wait for his response.");
            
            document.getElementById('msg'+parseInt(rowQid)).value = "";
            hidelist(clickedid);
            clickedid="";
            document.getElementById('btnSent'+parseInt(rowQid)).style.display = "block";
        }
        else if(resQ == "1")
        {
            alert("You need to login to send a request to the advertiser. \n\n If you are not a registered member yet, you can register with us to contact an advertiser or to post your own Ad. \n\n Its easy, free and secure and takes less than 60 seconds to register. TRY IT.");
        }
        else if(resQ == "2")
        {
            alert("An error occured while submitting your request. Please try again in a moment.");
        }
    }
    
    function reqresponseOnDetailPage(response)
    {
        var resQ=response.value;
        if(resQ == "0")
        {
            alert("Thank you! \n\n Your message has been sent to the advertiser of this ad. \n Please wait for his response.");
            
            document.getElementById('msg').value = "";
            document.getElementById('btnSendPvt').style.display = "none";
            document.getElementById('submitMsg').style.display = "none";
            document.getElementById('btnSent').style.display = "block";
        }
        else if(resQ == "1")
        {
            alert("You need to login to send a request to the advertiser. \n\n If you are not a registered member yet, you can register with us to contact an advertiser or to post your own Ad. \n\n Its easy, free and secure and takes less than 60 seconds to register. TRY IT.");
        }
        else if(resQ == "2")
        {
            alert("An error occured while submitting your request. Please try again in few moments.");
        }
    }
    
    function sentmsg()
    {
        alert("You already sent a request to the publisher of this carpool ad.");
    }
    
    function hideQdv()
    {
        document.getElementById('msg'+parseInt(rowQid)).value = "";
        hidelist(clickedid);
        clickedid="";
        document.getElementById('btnSendPvt'+parseInt(rowQid)).style.display = "block";
    }
    
    function changebg(cid)
    {
        document.getElementById(cid).style.backgroundColor='#fbfef4';
        if(pid != "")
            document.getElementById(pid).style.backgroundColor='#ffffff';
    }
