﻿    //checks is the browser the IExplorer
    function IsIE()
       {
           if(typeof isIE== 'undefined')
           {
               var browser = navigator.appName;
               isIE = (browser == "Microsoft Internet Explorer");

           }
           return isIE;
       }

       // Creates and return the new object for request
       function CreateRequestObject()
       {
           var obj;
           if(IsIE())
           {
               obj = new ActiveXObject("Microsoft.XMLHTTP");
           }
           else
           {
               obj = new XMLHttpRequest();
           }
           return obj;
       }
       
       function Vote(text,username,tag)
       {
           SendToServerAsynch("CommentList.aspx?state=vote&msg="+text.toString()+"&tag="+tag.toString()+"&name="+username.toString(),cool);
       }
       
       function cool(text)
       {
           alert("Your vote is accepted.");
       }

       // Sends anisochronous request to server
       function SendToServerAsynch(url,callback_func,resp_control)
       {
           try
           {
               var http = CreateRequestObject();
               http.onreadystatechange =
                   function()
                   {
                       if(http.readyState==4)
                       {
                           if(callback_func!=null)
                               callback_func(http.responseText,resp_control);
                       }
                   }
               http.open("POST", url, true);
               http.send(null);
           }
           catch(ex)
           {
               alert("err " + ex.message)
           }
       }

       function TryActivate()
       {
           var code = document.getElementById("in_txt_code");
           var url = document.URL;
           var id = url.substring(url.indexOf("id=",0) + 3, url.length);
           SendToServerAsynch("Activation.ashx?id=" + id + "&code=" + code.value, ActivateResponse);
       }
       
       function ActivateResponse(response_text)
       {
           if(response_text.toString().indexOf("good",0) >= 0)
           document.location.href = "HomePage.aspx?state=log_in&name="+response_text.toString().substring(5,response_text.toString().indexOf("!",5)) + "&pass=" + response_text.toString().substring(response_text.toString().indexOf("!",5)+1,response_text.toString().length+1);
           else
           document.getElementById("in_txt_response").value = response_text;
       }
       
       function SendComment(text_name, tag_name)
       {
           var txt = document.getElementById(text_name.toString());
           if(txt.value != "")
           {
               var tag = document.getElementById(tag_name.toString());
               SendToServerAsynch("CommentList.aspx?state=send&msg="+txt.value+"&tag="+tag.value,send_test,tag_name);
               txt.value = "";
           }
       }
             
       function send_test(resp_text, resp_control)
       {
       }
           
       function Refresh(owner, control_name,resp_control)
       {
           control_in = document.getElementById(control_name.toString());
           SendToServerAsynch("CommentList.aspx?state=get&tag="+control_in.value+"&owner="+owner.toString(), RefreshComments,resp_control);
           window.setTimeout(function(){Refresh(owner,control_name,resp_control);},2000);
       }
              
       function RefreshComments(response_text,resp_control)
       {
           var control_out = document.getElementById(resp_control.toString());
           if(response_text.toString() != "no_comments")
           {
               control_out.innerHTML = response_text;
           }
           else
           control_out.innerHTML = "";
       }
       
       function ShowTop(owner, resp_pict)
       {
           SendToServerAsynch("CommentList.aspx?state=change_view&owner="+owner.toString(), ChangeImg, resp_pict);
       }
       
       function ChangeImg(show, resp_pict)
       {
           var img = document.getElementById(resp_pict.toString());
           if(show == 'y')
               img.src= "ShowGoodImg.png";
           else
               img.src= "DontShowImg.png";
       }
       
       function OpenDescription()
       {
           document.getElementById();

       }

       function SetPlayerName(player_name,control) 
       {

           document.getElementById("tb_tag_1").value = player_name;
       }

       function GetPlayerName() 
       {
           SendToServerAsynch("CommentList.aspx?state=get_player", SetPlayerName, "tb_tag_1");
       }
