﻿// JScript File
 var xmlHttp;
 var xmlHttp11; 
 var xmlHttp22;
 var is_ie = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0;
 var is_ie5 = (navigator.appVersion.indexOf("MSIE 5.5")!=-1) ? 1 : 0;
 var is_opera = ((navigator.userAgent.indexOf("Opera6")!=-1)||(navigator.userAgent.indexOf("Opera/6")!=-1)) ? 1 : 0;
 //netscape, safari, mozilla behave the same???
 var is_netscape = (navigator.userAgent.indexOf('Netscape') >= 0) ? 1 : 0;
 
 
 function xmlHttp_Get(xmlhttp, url) {
        xmlhttp.open('GET', url, true);
        xmlhttp.send(null);
    }

    function GetXmlHttpObject(handler) {
        var objXmlHttp = null;    //Holds the local xmlHTTP object instance

        //Depending on the browser, try to create the xmlHttp object
        if (is_ie){
            //The object to create depends on version of IE
            //If it isn't ie5, then default to the Msxml2.XMLHTTP object
            var strObjName = (is_ie5) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP';
            
            //Attempt to create the object
            try{
                objXmlHttp = new ActiveXObject(strObjName);
                objXmlHttp.onreadystatechange = handler;
            }
            catch(e){
            //Object creation errored
                alert('IE detected, but object could not be created. Verify that active scripting and activeX controls are enabled');
                return;
            }
        }
        else if (is_opera){
            //Opera has some issues with xmlHttp object functionality
            alert('Opera detected. The page may not behave as expected.');
            return;
        }
        else{
            // Mozilla | Netscape | Safari
            objXmlHttp = new XMLHttpRequest();
            objXmlHttp.onload = handler;
            objXmlHttp.onerror = handler;
        }
        //Return the instantiated object
        return objXmlHttp;
        
    }
    
//cat wise member add rotate start here...
    function adInfo1()
    {
            var url = "ProfileListing.aspx?call=nxtAdd&Recid=" +  document.getElementById('hdncat1').value +"&cat=1";
            xmlHttp = GetXmlHttpObject(adHandler1);
            xmlHttp_Get(xmlHttp, url);
    }
    function adHandler1() 
    {   
        if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
        {
            var str = xmlHttp.responseText.split("#");
            if(str[0]=="1")// check login or not....
            {
                var rows = str[1].split("$");
                var data = "";
                for(var i=1; i < rows.length; i++)
                {
                    data = rows[i-1].split('|');
                    document.getElementById('img2'+i).src = "Admin/Photo/" + data[1];
                    document.getElementById('td2'+i).innerText = data[2];
                }
            }
            else
            {
                if(str[4]==0)
                {
                    swapfade(document.getElementById('img21'),document.getElementById('img21').src, "2", "Accessible Website Menu [blue]");
                }
                else
                {
                    swapfade(document.getElementById('img21'), "Admin/Photo/" + str[0], "2", "Accessible Website Menu [blue]");
                    //swapfadeText(document.getElementById("td21"),"Hello Sir how are you");
                    //document.getElementById('td21').innerText = str[1];
                    document.getElementById('hdndesc11').value = str[1];

                    if(str[4]==1)
                    {
                        document.getElementById('hdncat1').value = "0";
                    }
                    else
                    {
                        document.getElementById('hdncat1').value += "," + str[3];
                    }
                }
                xmlHttp=null;
                setTimeout('adInfo2()',20000);
            }
        }
    }
    function adInfo2()
    {
            var url = "ProfileListing.aspx?call=nxtAdd&Recid=" +  document.getElementById('hdncat2').value +"&cat=2";
            xmlHttp = GetXmlHttpObject(adHandler2);
            xmlHttp_Get(xmlHttp, url);
    }
    function adHandler2()
    {
        if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
        {
            var str = xmlHttp.responseText.split("#");
            if(str[4]==0)
            {
                swapfade(document.getElementById('img22'),document.getElementById('img22').src, "2", "Accessible Website Menu [blue]");
            }
            else
            {
                swapfade(document.getElementById('img22'), "Admin/Photo/" + str[0], "2", "Accessible Website Menu [blue]");
                //document.getElementById('td22').innerText = str[1];
                document.getElementById('hdndesc12').value = str[1];

                if(str[4]==1)
                {
                    document.getElementById('hdncat2').value = "0";
                }
                else
                {
                    document.getElementById('hdncat2').value += "," + str[3];
                }
            }
            xmlHttp=null;
            setTimeout('adInfo3()',20000);
        }
    }
    function adInfo3()
    {
               //var url = "Default.aspx?jsessionid=" + document.getElementById('sessid').value + "&stepId=" + step;                      
                var url = "ProfileListing.aspx?call=nxtAdd&Recid=" +  document.getElementById('hdncat3').value +"&cat=3";
                xmlHttp = GetXmlHttpObject(adHandler3);
                xmlHttp_Get(xmlHttp, url);
    }
    function adHandler3()
    {
        if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
        {
            var str = xmlHttp.responseText.split("#");
            if(str[4]==0)
            {
                swapfade(document.getElementById('img23'),document.getElementById('img23').src, "2", "Accessible Website Menu [blue]");
            }
            else
            {
                swapfade(document.getElementById('img23'), "Admin/Photo/" + str[0], "2", "Accessible Website Menu [blue]");
                //document.getElementById('td23').innerText = str[1];
                document.getElementById('hdndesc13').value = str[1];

                if(str[4]==1)
                {
                    document.getElementById('hdncat3').value = "0";
                }
                else
                {
                    document.getElementById('hdncat3').value += "," + str[3];
                }
            }
            xmlHttp=null;
            setTimeout('adInfo4()',20000);
        }
    }
    function adInfo4()
    {
            //var url = "Default.aspx?jsessionid=" + document.getElementById('sessid').value + "&stepId=" + step;
            var url = "ProfileListing.aspx?call=nxtAdd&Recid=" +  document.getElementById('hdncat4').value +"&cat=4";
            xmlHttp = GetXmlHttpObject(adHandler4);
            xmlHttp_Get(xmlHttp, url);
    }
    function adHandler4()
    {

        if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
        {
            var str = xmlHttp.responseText.split("#");

            if(str[4]==0)
            {
                swapfade(document.getElementById('img24'),document.getElementById('img24').src, "2", "Accessible Website Menu [blue]");
            }
            else
            {
                swapfade(document.getElementById('img24'), "Admin/Photo/" + str[0], "2", "Accessible Website Menu [blue]");
                //document.getElementById('td24').innerText = str[1];
                document.getElementById('hdndesc14').value = str[1];

                if(str[4]==1)
                {
                    document.getElementById('hdncat4').value = "0";
                }
                else
                {
                    document.getElementById('hdncat4').value += "," + str[3];
                }
            }
            xmlHttp=null;
            setTimeout('adInfo5()',20000);
        }
    }
    function adInfo5()
    {
             var url = "ProfileListing.aspx?call=nxtAdd&Recid=" +  document.getElementById('hdncat5').value +"&cat=5";
             xmlHttp = GetXmlHttpObject(adHandler5);
             xmlHttp_Get(xmlHttp, url);
    }
    function adHandler5()
    {
        if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
        {
            var str = xmlHttp.responseText.split("#");

            if(str[4]==0)
            {
                swapfade(document.getElementById('img25'),document.getElementById('img25').src, "2", "Accessible Website Menu [blue]");
            }
            else
            {
                swapfade(document.getElementById('img25'), "Admin/Photo/" + str[0], "2", "Accessible Website Menu [blue]");
                //document.getElementById('td25').innerText = str[1];
                document.getElementById('hdndesc15').value = str[1];
                
                if(str[4]==1)
                {
                    document.getElementById('hdncat5').value = "0";
                }
                else if(str[4] > 1)
                {
                    document.getElementById('hdncat5').value += "," + str[3];
                }
             }
            xmlHttp=null;
            setTimeout('adInfo6()',20000);
        }
    }
    function adInfo6()
    {
          var url = "ProfileListing.aspx?call=nxtAdd&Recid=" +  document.getElementById('hdncat6').value +"&cat=6";
          xmlHttp = GetXmlHttpObject(adHandler6);
          xmlHttp_Get(xmlHttp, url);
    }
    function adHandler6()
    {
        if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
        {
            var str = xmlHttp.responseText.split("#");
            if(str[4]==0)
            {
                swapfade(document.getElementById('img26'),document.getElementById('img26').src, "2", "Accessible Website Menu [blue]");
            }
            else
            {
                swapfade(document.getElementById('img26'), "Admin/Photo/" + str[0], "2", "Accessible Website Menu [blue]");
                //document.getElementById('td26').innerText = str[1];
                document.getElementById('hdndesc16').value = str[1];
                
                if(str[4]==1)
                {
                    document.getElementById('hdncat6').value = "0";
                }
                else
                {
                    document.getElementById('hdncat6').value += "," + str[3];
                }
            }
            xmlHttp=null;
            setTimeout('adInfo1()',20000);
        }
    }
//cat wise member funtions end....
      function rotateAdds()
      {
       xmlHttp=null;
       setTimeout('adInfo1()',5000);
       setTimeout('adInfoPlace1()',15000);
      }
 //places add rotate functions start.....
    function adInfoPlace1()
    {
            var url = "ProfileListing.aspx?call=nxtPlace&Recid=" +  document.getElementById('hdnplace1').value +"&category=placeToSee";
            xmlHttp22 = GetXmlHttpObject(adHandlers1);
            xmlHttp_Get(xmlHttp22, url);
    }
    function adHandlers1()
    {
        if (xmlHttp22.readyState == 4 || xmlHttp22.readyState == 'complete')
        {
            var str = xmlHttp22.responseText.split("#");
            if(str[3]==0)
            {
                document.getElementById('hdnplace1').value = "0";
                swapfade(document.getElementById('image1'),document.getElementById('image1').src, "2", "Accessible Website Menu [blue]");
            }
            else
            {
            
                swapfade(document.getElementById('image1'), "images/places/" + str[0], "2", "Accessible Website Menu [blue]");            
                document.getElementById('hdndesc1').value = str[1];
//                if(str[3]==1)
//                {
//                    document.getElementById('hdnplace1').value = "0";
//                }
//                else
//                {
                    document.getElementById('hdnplace1').value += "," + str[2];
//                }
            }
            xmlHttp22=null;
            setTimeout('adInfoPlace2()',20000);                     
        }
    }
    function adInfoPlace2()
    {
            var url = "ProfileListing.aspx?call=nxtPlace&Recid=" +  document.getElementById('hdnplace2').value +"&category=placeToStay";
            xmlHttp22 = GetXmlHttpObject(adHandlers2);
            xmlHttp_Get(xmlHttp22, url);
     
    }
    function adHandlers2() 
    { 
        
        if (xmlHttp22.readyState == 4 || xmlHttp22.readyState == 'complete')
        { 
            var str = xmlHttp22.responseText.split("#");              
            if(str[3]==0)
            {
                document.getElementById('hdnplace2').value = "0";
                swapfade(document.getElementById('image2'),document.getElementById('image2').src, "2", "Accessible Website Menu [blue]");
            }
            else
            {       
                swapfade(document.getElementById('image2'), "images/places/" + str[0], "2", "Accessible Website Menu [blue]");                
                document.getElementById('hdndesc2').value = str[1];
//                if(str[3]==1)
//                {
//                      document.getElementById('hdnplace2').value = "0";
//                }
//                else
//                {    
                    document.getElementById('hdnplace2').value += "," + str[2];
//                }
            }
            xmlHttp22=null;
            setTimeout('adInfoPlace3()',20000);                     
        }
    }
    function adInfoPlace3()
    {       
            var url = "ProfileListing.aspx?call=nxtPlace&Recid=" +  document.getElementById('hdnplace3').value +"&category=whereToEat";
            xmlHttp22 = GetXmlHttpObject(adHandlers3); 
            xmlHttp_Get(xmlHttp22, url);
    }
    function adHandlers3()
    {
        if (xmlHttp22.readyState == 4 || xmlHttp22.readyState == 'complete')
        {
            var str = xmlHttp22.responseText.split("#");
            if(str[3]==0)
            {
                document.getElementById('hdnplace3').value = "0";
                swapfade(document.getElementById('image3'),document.getElementById('image3').src, "2", "Accessible Website Menu [blue]");
            }
            else
            {
                swapfade(document.getElementById('image3'), "images/places/" + str[0], "2", "Accessible Website Menu [blue]");  
                document.getElementById('hdndesc3').value = str[1];
//                if(str[3]==1)
//                {
//                    document.getElementById('hdnplace3').value = "0";
//                }
//                else
//                {
                    document.getElementById('hdnplace3').value += "," + str[2];
//                }
            }
            xmlHttp22=null;
            setTimeout('adInfoPlace4()',20000);
        }
    }
    
    function adInfoPlace4()
    {       
            var url = "ProfileListing.aspx?call=nxtPlace&Recid=" +  document.getElementById('hdnplace4').value +"&category=thingsToDo";
            xmlHttp22 = GetXmlHttpObject(adHandlers4); 
            xmlHttp_Get(xmlHttp22, url);     
    }
    
    function adHandlers4()
    {        
        if (xmlHttp22.readyState == 4 || xmlHttp22.readyState == 'complete')
        {
            var str = xmlHttp22.responseText.split("#");
            if(str[3]==0)
            {
                document.getElementById('hdnplace4').value = "0";
                swapfade(document.getElementById('image4'),document.getElementById('image4').src, "2", "Accessible Website Menu [blue]");
            }
            else
            {
                swapfade(document.getElementById('image4'), "images/places/" + str[0], "2", "Accessible Website Menu [blue]");
                document.getElementById('hdndesc4').value = str[1];
                             
//                if(str[3]==1)
//                {
//                    document.getElementById('hdnplace4').value = "0";
//                }
//                else
//                {    
                    document.getElementById('hdnplace4').value += "," + str[2];
//                }
            }
            xmlHttp22=null;
            setTimeout('adInfoPlace5()',20000);
        }
    }
    
    function adInfoPlace5()
    {       
            var url = "ProfileListing.aspx?call=nxtPlace&Recid=" +  document.getElementById('hdnplace5').value +"&category=events";
            xmlHttp22 = GetXmlHttpObject(adHandlers5); 
            xmlHttp_Get(xmlHttp22, url);     
    }
    function adHandlers5()
    {
        if (xmlHttp22.readyState == 4 || xmlHttp22.readyState == 'complete')
        {
            var str = xmlHttp22.responseText.split("#");
            if(str[3]==0)
            {
                document.getElementById('hdnplace5').value = "0";
                swapfade(document.getElementById('image5'),document.getElementById('image5').src, "2", "Accessible Website Menu [blue]");
            }
            else
            {
                swapfade(document.getElementById('image5'), "images/places/" + str[0], "2", "Accessible Website Menu [blue]");     
                document.getElementById('hdndesc5').value = str[1];

//                if(str[3]==1)
//                {
//                  document.getElementById('hdnplace5').value = "0";
//                }
//                else
 //               {
                    document.getElementById('hdnplace5').value += "," + str[2];
   //             }
            }
            xmlHttp22=null;
            setTimeout('adInfoPlace1()',20000);
        }
    }
//add rotate places functions end...
    function memberInfo(pgno)
    {
        var url = "ProfileListing.aspx?call=memberInfo&pgno="+pgno+"";
        xmlHttp11 = GetXmlHttpObject(memberHandler);
        xmlHttp_Get(xmlHttp11, url);
    }
    
    function memberHandler()
    {
        if (xmlHttp11.readyState == 4 || xmlHttp11.readyState == 'complete')
        {
            var str = xmlHttp11.responseText;
            document.getElementById('divOutput').innerHTML = str;
        }
    }
    
    function ProfileInfo(ProfileId)
    {
        var url = "ProfileListing.aspx?call=ProfileInfo&ProfileId="+ProfileId+ "";
        xmlHttp11 = GetXmlHttpObject(ProfileHandler);
        xmlHttp_Get(xmlHttp11, url);
    }
    
    function ProfileHandler()
    {
        if (xmlHttp11.readyState == 4 || xmlHttp11.readyState == 'complete')
        {
            var str = xmlHttp11.responseText;
            document.getElementById('Profilediv').innerHTML = str;
        }
    }
    
    function mousestyle(obj)
    {
       obj.className="imageMouseOver";
    }
    
    function stylemouse(obj)
    {
        obj.className="MouseOverimage";
    }
    
    function rating(tblId)
    {
        var rate = "";
        var vardetl;
        if(tblId == "placesToSee")
        {
            rate =  document.getElementById('Rater1_Value').value;  
            vardetl = document.getElementById('hdnplace1').value;
            var ii = vardetl.split(',');
            vardetl = ii[ii.length-1];
        }else if(tblId == "placesToStay")
        {
            rate =  document.getElementById('Rater2_Value').value;
            //vardetl = document.getElementById('hdndesc2').value;
            vardetl = document.getElementById('hdnplace2').value;
            var ii = vardetl.split(',');
            vardetl = ii[ii.length-1];
        }else if(tblId == "WhereToEat")
        {
            rate =  document.getElementById('Rater3_Value').value;
            //vardetl = document.getElementById('hdndesc3').value;
            vardetl = document.getElementById('hdnplace3').value;
            var ii = vardetl.split(',');
            vardetl = ii[ii.length-1];
        }else if(tblId == "LocalEvent")
        {
            rate =  document.getElementById('Rater4_Value').value;
            //vardetl = document.getElementById('hdndesc4').value;
            vardetl = document.getElementById('hdnplace4').value;
            var ii = vardetl.split(',');
            vardetl = ii[ii.length-1];
        }else if(tblId == "ThingToDo")
        {
            rate =  document.getElementById('Rater5_Value').value;
            //vardetl = document.getElementById('hdndesc5').value;
            vardetl = document.getElementById('hdnplace5').value;
            var ii = vardetl.split(',');
            vardetl = ii[ii.length-1];
        }
        //var title = vardetl.split('#');
        //vardtl = title[2] +"#"+rate;
        vardetl = vardetl +"#"+ rate;
        var url = "ProfileListing.aspx?call=setRate&tblId="+tblId+ "&rate="+vardetl+"";
        xmlHttp11 = GetXmlHttpObject(RateHandler);
        xmlHttp_Get(xmlHttp11, url);
    }
    
    function RateHandler()
    {
        if (xmlHttp11.readyState == 4 || xmlHttp11.readyState == 'complete')
        {
            var str = xmlHttp11.responseText;
            alert(str);
            //document.getElementById('Rater1_Value').value = '2';
        }
    }
    
    function showComm(tblnm)
    {
        var myHTML ="";
        myHTML = "<table width='100%' align='center'><tr width='100%'><td width='100%'></td><td>";
        myHTML = myHTML +"<TABLE BORDER='0' CELLPADDING='0' CELLSPACING='0' width='100%' align='center' style='background-color:#FFF5E3'>";
        myHTML = myHTML +"<TR>";
        myHTML = myHTML +"<TD width='3' height='8'><img src='Images/table/box_01.gif' width='9' height='8' align='bottom'/></TD>";
        myHTML = myHTML +"<TD background='Images/table/box_02.gif' ><IMG SRC='Images/table/box_02.gif' HEIGHT=8 ALT=''></TD>";
        myHTML = myHTML +"<TD width=3><img src='Images/table/box_03.gif' width='9' height='8' /></TD>";
        myHTML = myHTML +"</TR>";
        myHTML = myHTML +"<TR>";
        myHTML = myHTML +"<TD background='Images/table/box_04.gif'><IMG SRC='Images/table/box_04.gif' WIDTH='9' HEIGHT='0' ALT=''>";
        myHTML = myHTML +"</TD>";
        myHTML = myHTML +"<TD align='left' valign='top' bgcolor='#FFF5E3'>";
        
        var titleId = "0";
        if(tblnm == "placesToSee")
        {
            titleId = document.getElementById('hdnplace1').value;
        }
        else if(tblnm=="placesToStay")
        {
            titleId = document.getElementById('hdnplace2').value;
        }
        else if(tblnm=="WhereToEat")
        {
            titleId = document.getElementById('hdnplace3').value;
        }
        else if(tblnm=="LocalEvent")
        {
            titleId = document.getElementById('hdnplace4').value;
        }
        else if(tblnm=="ThingToDo")
        {
            titleId = document.getElementById('hdnplace5').value;
        }               
        var temp = titleId.split(',');
        titleId = temp[temp.length-1];
        
        myHTML = myHTML +"<table>";
        myHTML = myHTML +"<tr>";
        myHTML = myHTML +"<td style='width: 100px' class='bmatter1'>";
        myHTML = myHTML +"Comment::</td>";
        myHTML = myHTML +"</tr>";
        myHTML = myHTML +"<tr>";
        myHTML = myHTML +"<td style='width: 300px'>";
        myHTML = myHTML +"<textarea id='txtcomment' ROWS='5' COLS='30'></textarea></td>";
        myHTML = myHTML +"</tr>";
        myHTML = myHTML +"<tr>";
        myHTML = myHTML +"<td align='center' style='width: 300px'>";
        myHTML = myHTML +"<a href='#' OnClick='postComment();'><img id='btnpost' src='Images/btnpost.gif' /></a></td>";
        myHTML = myHTML +"</tr>";
        myHTML = myHTML +"<tr>";
        myHTML = myHTML +"<td style='width: 100px'>";
        myHTML = myHTML +"<input id='hdntblnm' type='hidden' Value='"+ tblnm +"' />";
        myHTML = myHTML +"<input id='hdntitleid' type='hidden' Value='"+ titleId +"' />";
        myHTML = myHTML +"</td>";
        myHTML = myHTML +"</tr>";
        myHTML = myHTML +"</table>";
         
        myHTML = myHTML +"</TD>";
        myHTML = myHTML +"<TD background='Images/table/box_06.gif' ><IMG SRC='Images/table/box_06.gif' WIDTH='9' HEIGHT='0' ALT=''></TD>";
        myHTML = myHTML +"</TR>";
        myHTML = myHTML +"<TR>";
        myHTML = myHTML +"<TD width='9'><IMG SRC='Images/table/box_07.gif' WIDTH='9' HEIGHT='8' ALT=''></TD>";
        myHTML = myHTML +"<TD background='Images/table/box_08.gif'><IMG SRC='Images/table/box_08.gif' HEIGHT='8' ALT=''></TD>";
        myHTML = myHTML +"<TD width='9'>";
        myHTML = myHTML +"<IMG SRC='Images/table/box_09.gif' WIDTH='9' HEIGHT='8' ALT=''></TD>";
        myHTML = myHTML +"</TR><TR><TD style='height:10'></TD></TR>";
        myHTML = myHTML +"</TABLE>";
        myHTML = myHTML +"</td></tr></table>";

        showModalComm(myHTML);
    }

    function postComment()
    {
        if(document.getElementById('txtcomment').value == "")
        {
            alert('Please, write comment !!');
            document.getElementById('txtcomment').focus();
            return false;
        }
        else{
            var tblid = document.getElementById('hdntblnm').value;
            var titleid = document.getElementById('hdntitleid').value;
            var vardetl = titleid +"#"+ document.getElementById('txtcomment').value;
            var url = "ProfileListing.aspx?call=setComm&tblId="+tblid+ "&commDetl="+vardetl+"";
            xmlHttp11 = GetXmlHttpObject(CommHandler);
            xmlHttp_Get(xmlHttp11, url);
        }
    }
    function CommHandler()
    {
        if (xmlHttp11.readyState == 4 || xmlHttp11.readyState == 'complete')
        {
            var str = xmlHttp11.responseText;
            alert(str);
            HideAddForm2();
        }
        else
        {
            document.getElementById('btnpost').src='Images/Processing.gif';
        }
    }