function Register()
{
  System.Register(GetValue("Name"),GetValue("Surname"),GetValue("Email"),GetValue("Password"),GetValue("RetPassword"),GetValue("Gender"),function (result){
    if(result == "REG_OK")
    {
        location.href="?act=registration_ok";
    }
    else
    {
        document.getElementById("ErrorNotf").innerHTML = result;
    }
    });
}

function Login()
{
    System.CheckUser(GetValue("Email"),GetValue("Password"),function (result){
    if(result == "AUTH_OK")
    {
      var RQ = GetID("hRQ").value;
      if(RQ == "")
        location.href="?act=my_account";
      else
        location.href="?act="+RQ;
    }
    else
    {
        document.getElementById("ErrorNotf").innerHTML = result;
    }
    });
}


function ShowDiv(id,param)
{
  var obj = document.getElementById(id);
  obj.style.display = param;
}

function GetValue(ident)
{
	if(document.getElementById(ident).value!=false){
return document.getElementById(ident).value; }
return "";
}


function GetID(name)
{
  return document.getElementById(name);
}

function GetValue(name)
{
  return document.getElementById(name).value;
}

function UploadWebFile(SID,Domain)
{
  System.VerifyUploadVideoInfo(GetID("Title").value,GetID("cmbCategory").value,GetID("Hour").value,GetID("Minute").value,GetID("Second").value,function(result)
  {
    if(result != "VERIFY_OK")
    {
        GetID("ErrorNotf").innerHTML = result;
        return;
    }
    var obj = thisMovie("FlashUploader");
    obj.StartUpload();
  });

}

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}

function UploadComplete(Domain,SID)
{
  var PreviewTime = GetID("Hour").value + ";" + GetID("Minute").value + ";" + GetID("Second").value;
  System.WriteFile(GetID("Title").value,GetID("cmbCategory").value,SID,Domain,PreviewTime,1,GetID("cmbVideoAccess").value,function(result)
  {
    location.href="?act=add_video_ok";
    return;
  });
}

function InnerHtml(id,html)
{
  document.getElementById(id).innerHTML = html;
}

function AddToPlaylist(Code)
{
  System.AddToPlaylist(Code,function(result)
  {
     if(result[0] == 0)
     {
       ShowDiv("notfCntr","");
       InnerHtml("notfCntr",result[1]);
       return;
     }
     else if(result[0] == 2)
     {
       location.href="?act=login";
       return;
     }
     ShowDiv("notfCntr","");
     InnerHtml("notfCntr",result[1]);
  });
}

function CloseNotf()
{
  ShowDiv("notfCntr","none");
}

function ShowVideoLink(Code)
{
  System.ShowVideoLink(Code,function(result)
  {
     ShowDiv("notfCntr","");
     InnerHtml("notfCntr",result);
  });
}

function GetEmbedCode(Code)
{
  System.GetEmbedCode(Code,function(result)
  {
     ShowDiv("notfCntr","");
     InnerHtml("notfCntr",result);
  });
}

function DeleteFromPlaylist(ID)
{
  var notf = GetValue("hDeleteNotf");
  if(!confirm(notf)) return;
  System.DeleteFromPlaylist(ID,function(result)
  {
      if(result == "DELETE_OK")
        location.reload();
  });
}

function AddCommentForm()
{
  System.AddCommentForm(0,function(result)
  {
     ShowDiv("AddComment","");
     InnerHtml("AddComment",result[0]);
     if(result[1] != null)
        code=eval(result[1]); code;
  });
}

function AddComment()
{
  var Comment = GetValue("txtComment");
  if(Comment == "") return;
  System.AddComment(GetValue("hVID"),Comment,function(result)
  {
     ShowDiv("AddComment","none");
     LoadComments(0,result);
  });
}

function LoadCategory()
{
  location.href="?cid="+GetValue("cmbCategories");
}

function LoadComments(Start,ID)
{
   System.LoadComments(Start,ID,function (result){ InnerHtml(result[0],result[1]); });
}




