﻿//Activate TRIM function for java script
String.prototype.trim = function(){ return this.replace(/^s+|s+$/g,'') }
var ie4 = false; if(document.all) { ie4 = true; }
if (typeof(Sys) !== "undefined") Sys.Application.notifyScriptLoaded();
function noCache(uri){return uri.concat(/\?/.test(uri)?"&":"?","noCache=",(new Date).getTime(),".",Math.random()*1234567)};
var playlistId;
/////////////////////////////////////////////////////
//Common functions
/////////////////////////////////////////////////////
function getobject(id) { 
  if (ie4) {     
    return document.all[id];
  }else {  
    return document.getElementById(id); 
  }logIn
}

function trim(cadena)
{
	for(i=0; i<cadena.length; )
	{
		if(cadena.charAt(i)==" ")
			cadena=cadena.substring(i+1, cadena.length);
		else
			break;
	}

	for(i=cadena.length-1; i>=0; i=cadena.length-1)
	{
		if(cadena.charAt(i)==" ")
			cadena=cadena.substring(0,i);
		else
			break;
	}
	
	return cadena;
}

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function putFileIdOnSession(fileId){  
  PageMethods.putFileIdOnSession(fileId, putFileIdOnSessionSuccess,putFileIdOnSessionFail);  
}

//when function putFileIdOnSession is completed correctly
function putFileIdOnSessionSuccess(result, userContext, methodName){ 
  var d = new Date();
  window.location ="playVideo.aspx?r=" + d.getMilliseconds() + d.getSeconds();
  //window.location ="player.aspx";
}

//when function putFileIdOnSession is not completed correctly
function putFileIdOnSessionFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function putFileIdOnSession1(fileId){  
  PageMethods.putFileIdOnSession(fileId, putFileIdOnSession1Success,putFileIdOnSession1Fail);  
}

//when function putFileIdOnSession is completed correctly
function putFileIdOnSession1Success(result, userContext, methodName){ 
  var d = new Date();
  window.location ="../playVideo.aspx?r=" + d.getMilliseconds() + d.getSeconds();
//  window.location ="../playVideo.aspx";
  //window.location ="player.aspx";
}

//when function putFileIdOnSession is not completed correctly
function putFileIdOnSession1Fail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function putPlaylistIdOnSession(fileId){  
  PageMethods.putPlaylistIdOnSession(fileId, putPlaylistIdOnSessionSuccess,putPlaylistIdOnSessionFail);  
}

//when function putPlaylistIdOnSession is completed correctly
function putPlaylistIdOnSessionSuccess(result, userContext, methodName){ 
  var d = new Date();
  window.location ="playVideo.aspx?r=" + d.getMilliseconds() + d.getSeconds();
  //window.location ="playVideo.aspx";
  //window.location ="player.aspx";
}

//when function putPlaylistIdOnSession is not completed correctly
function putPlaylistIdOnSessionFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function putPlaylistIdOnSession1(playlistId){  
  PageMethods.putPlaylistIdOnSession(playlistId, putPlaylistIdOnSession1Success,putPlaylistIdOnSession1Fail);  
}

//when function putPlaylistIdOnSession1 is completed correctly
function putPlaylistIdOnSession1Success(result, userContext, methodName){ 
  var d = new Date();
  window.location ="../playVideo.aspx?r=" + d.getMilliseconds() + d.getSeconds();
//  window.location ="../playVideo.aspx";
  //window.location ="player.aspx";
}

//when function putPlaylistIdOnSession1 is not completed correctly
function putPlaylistIdOnSession1Fail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function loadVideos1(start){ 
    var index = -1;
    var value = 1;
    try
    {
        index = document.forms[0]["ddlChannel"].selectedIndex;
        value= document.forms[0]["ddlChannel"].options[index].value;
    }catch (ex)
    {
        index=0;
        value=1;
    }
  PageMethods.loadVideos(value, start, loadVideos1Success,loadVideos1Fail);  
}

//when function loadVideos is completed correctly
function loadVideos1Success(result, userContext, methodName){ 
  var divVideos = getobject('divVideos');
  divVideos.innerHTML = result;
}

//when function loadVideos is not completed correctly
function loadVideos1Fail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// load list of videos when we are searching
function loadSearchVideos(strSearch, start){ 
  PageMethods.loadVideos(strSearch, start, loadSearchVideosSuccess,loadSearchVideosFail);  
}

//when function loadSearchVideos is completed correctly
function loadSearchVideosSuccess(result, userContext, methodName){ 
  var divVideos = getobject('divVideos');
  divVideos.innerHTML = result;
}

//when function loadSearchVideos is not completed correctly
function loadSearchVideosFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function loadHeaderVideos(){  
  PageMethods.loadHeaderVideos( loadHeaderVideosSuccess,loadHeaderVideosFail);  
}

//when function loadHeaderVideos is completed correctly
function loadHeaderVideosSuccess(result, userContext, methodName){ 
  var divHeaderVideos = getobject('divHeaderVideos');
  divHeaderVideos.innerHTML = result;
}

//when function loadHeaderVideos is not completed correctly
function loadHeaderVideosFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function loadHeaderPlaylist(playlistId){ 
  PageMethods.loadHeaderPlaylist(playlistId, loadHeaderPlaylistSuccess,loadHeaderPlaylistFail);  
}

//when function loadHeaderPlaylist is completed correctly
function loadHeaderPlaylistSuccess(result, userContext, methodName){ 
  var divHeaderPlaylist = getobject('divHeaderPlaylist');
  divHeaderPlaylist.innerHTML = result;
}

//when function loadHeaderPlaylist is not completed correctly
function loadHeaderPlaylistFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function playlistsaved(){  
  PageMethods.playlistsaved(playlistsavedSuccess,playlistsavedFail);  
}

//when function playlistsaved is completed correctly
function playlistsavedSuccess(result, userContext, methodName){ 
  if (result== 'true')
  {
    var divMessage =getobject('divMessage');
    divMessage.innerHTML ='';
    var index = document.forms[0]["ddlPlaylist"].selectedIndex;
    playlistId = document.forms[0]["ddlPlaylist"].options[index].value;
    loadPlaylistFile();
  }
  else
  {
    if (confirm('Your changes in this playlist will be ignored. Dou you want to continue?'))
    {
      var index = document.forms[0]["ddlPlaylist"].selectedIndex;
      playlistId = document.forms[0]["ddlPlaylist"].options[index].value;
      //savePlaylist();
      var divMessage =getobject('divMessage');
      divMessage.innerHTML ='';
      loadPlaylistFile();
    }
    else
    {
      loadHeaderPlaylist(playlistId);
    }
  }
}

//when function playlistsaved is not completed correctly
function playlistsavedFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function loadPlaylistFile(){  
  var index = document.forms[0]["ddlPlaylist"].selectedIndex;
  var txtPlaylistName = getobject('txtPlaylistName');
  txtPlaylistName.value = document.forms[0]["ddlPlaylist"].options[index].text;
  PageMethods.loadPlaylistFile(document.forms[0]["ddlPlaylist"].options[index].value, loadPlaylistFileSuccess,loadPlaylistFileFail);  
}

//when function loadPlaylistFile is completed correctly
function loadPlaylistFileSuccess(result, userContext, methodName){ 
  var divPlaylistVideos = getobject('divPlaylistVideos');
  divPlaylistVideos.innerHTML = result;
}

//when function loadPlaylistFile is not completed correctly
function loadPlaylistFileFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function savePlaylist(){ 
  var txtPlaylistName = getobject('txtPlaylistName');
  PageMethods.savePlaylist(txtPlaylistName.value, savePlaylistSuccess,savePlaylistFail);  
}

//when function savePlaylist is completed correctly
function savePlaylistSuccess(result, userContext, methodName){
  loadHeaderPlaylist();
  var index1=document.forms[0]["ddlPlaylist"].length -1;
  document.forms[0]["ddlPlaylist"].options[index1].selected=true;
  var index = document.forms[0]["ddlPlaylist"].selectedIndex;
  var txtPlaylistName = getobject('txtPlaylistName');
  txtPlaylistName.value = document.forms[0]["ddlPlaylist"].options[index].text;
  var divMessage = getobject('divMessage');
  divMessage='<b class="error">Playlist saved</b>';
  hideDivInvitation();
}

//when function savePlaylist is not completed correctly
function savePlaylistFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function viewArtistBiography(artistId){  
  PageMethods.viewArtistBiography(artistId, viewArtistBiographySuccess,viewArtistBiographyFail);  
}

//when function viewArtistBiography is completed correctly
function viewArtistBiographySuccess(result, userContext, methodName){ 
  if (result>0)
    window.location ="../artistBiography.aspx";
  else
    window.location ="artistBiography.aspx";
}

//when function viewArtistBiography is not completed correctly
function viewArtistBiographyFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function addPlaylistfile(fileId){  
  PageMethods.addPlaylistfile(fileId, addPlaylistfileSuccess,addPlaylistfileFail);  
}

//when function addPlaylistfile is completed correctly
function addPlaylistfileSuccess(result, userContext, methodName){ 
  var divPlaylistVideos = getobject('divPlaylistVideos');
  divPlaylistVideos.innerHTML = divPlaylistVideos.innerHTML + result
  var divMessage = getobject('divMessage');
  divMessage.innerHTML = '';
}

//when function addPlaylistfile is not completed correctly
function addPlaylistfileFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function removePlaylistfile(div){  
  PageMethods.removePlaylistfile(div, removePlaylistfileSuccess,removePlaylistfileFail);  
}

//when function removePlaylistfile is completed correctly
function removePlaylistfileSuccess(result, userContext, methodName){ 
var div = getobject(result);
  var divPlaylistVideos = getobject('divPlaylistVideos');
  divPlaylistVideos.removeChild(div)
}

//when function removePlaylistfile is not completed correctly
function removePlaylistfileFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function savePlaylist1(){  
  var index = document.forms[0]["ddlPlaylist"].selectedIndex;
  var txtPlaylistName = getobject('txtPlaylistName');
  if (txtPlaylistName.value != "")
    PageMethods.savePlaylist1(document.forms[0]["ddlPlaylist"].options[index].value, txtPlaylistName.value , savePlaylist1Success,savePlaylist1Fail);  
  else
   alert('you must to enter the name of the playlist');
}

//when function savePlaylist1 is completed correctly
function savePlaylist1Success(result, userContext, methodName){ 
//alert(result);
//alert(result.indexOf('asdf'));
  if (result.indexOf('Error') > -1)
    alert(result);
  else  
  {
    var values = result.split(':');
    loadHeaderPlaylist(values[0]);
    var divMessage =getobject('divMessage');
    divMessage.innerHTML ='<b class="error">' + values[1] + '</b>';
  }
}

//when function savePlaylist1 is not completed correctly
function savePlaylist1Fail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function loadVideos(channelId, start, srtFieldSort, sort){  
  PageMethods.loadVideos(channelId, start, srtFieldSort, sort, loadVideosSuccess,loadVideosFail);  
}

//when function savePloadVideoslaylist is completed correctly
function loadVideosSuccess(result, userContext, methodName){ 
  var divVideos = getobject('divVideos');
  divVideos.innerHTML = result;
}

//when function loadVideos is not completed correctly
function loadVideosFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function getChannelId(){  
  PageMethods.getChannelId(getChannelIdSuccess,getChannelIdFail);  
}

//when function savePloadVideoslaylist is completed correctly
function getChannelIdSuccess(result, userContext, methodName){ 
  var index = document.forms[0]["ddlFieldSort"].selectedIndex;
  var index1 = document.forms[0]["ddlSort"].selectedIndex;
  loadVideos(result,0, document.forms[0]["ddlFieldSort"].options[index].value, document.forms[0]["ddlSort"].options[index1].value);
}

//when function getChannelId is not completed correctly
function getChannelIdFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function getStrSearch(){  
  PageMethods.getStrSearch(getStrSearchSuccess,getStrSearchFail);  
}

//when function getStrSearch is completed correctly
function getStrSearchSuccess(result, userContext, methodName){ 
  if (result!="")
    loadSearchVideos(result, 0);
    //loadVideos(result,0);
}

//when function getStrSearch is not completed correctly
function getStrSearchFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function loadPlaylist(){ 
var num = new Date();
  PageMethods.loadPlaylist(num.getMilliseconds(), loadPlaylistSuccess,loadPlaylistFail);  
  //PageMethods.loadPlaylist(loadPlaylistSuccess,loadPlaylistFail);  
}

//when function loadPlaylist is completed correctly
function loadPlaylistSuccess(result, userContext, methodName){ 
  var divPlaylist = getobject('divPlaylist');
  divPlaylist.innerHTML = result;
}

//when function loadPlaylist is not completed correctly
function loadPlaylistFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function loadPlaylist1(){ 
var num = new Date();
  PageMethods.loadPlaylist(num.getMilliseconds(), loadPlaylist1Success,loadPlaylist1Fail);  
  //PageMethods.loadPlaylist(loadPlaylistSuccess,loadPlaylistFail);  
}

//when function loadPlaylist1 is completed correctly
function loadPlaylist1Success(result, userContext, methodName){ 
  var divPlaylist = getobject('divPlaylist');
  divPlaylist.innerHTML = result;
}

//when function loadPlaylist1 is not completed correctly
function loadPlaylist1Fail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function loadPlaylistFileView(playlistId){ 
  PageMethods.loadPlaylistFile(playlistId, loadPlaylistFileViewSuccess,loadPlaylistFileViewFail);  
}

//when function loadPlaylistFileView is completed correctly
function loadPlaylistFileViewSuccess(result, userContext, methodName){ 
  var divPlaylistVideos = getobject('divPlaylistVideos');
  divPlaylistVideos.innerHTML = result;
}

//when function loadPlaylistFileView is not completed correctly
function loadPlaylistFileViewFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************
//function openPlayer(fileId, playlistId)
//{
//  window.open ("player.aspx?fileId=" + fileId + "&playlistId=" + playlistId, "mywindow","location=no, menubar=no,status=yes,scrollbars=no, width=1072,height=660"); 
//}

//function openPlayer1(fileId, playlistId)
//{
//  window.open ("../player.aspx?fileId=" + fileId + "&playlistId=" + playlistId, "mywindow","location=no, menubar=no,status=yes,scrollbars=no, width=1072,height=660"); 
//}

function openPlayer(fileId, playlistId)
{
  window.location = "playVideo.aspx?fileId=" + fileId + "&playlistId=" + playlistId; 
}

function openPlayer1(fileId, playlistId)
{
  window.location = "../playVideo.aspx?fileId=" + fileId + "&playlistId=" + playlistId; 
}

//************************************************************
function loadFileInformation(fileId,random){ 
    var hFileId = getobject('hFileId');
    hFileId.value = fileId;
    //alert(hFileId.value);
    loadCommentsFile(fileId);
    loadRelatedVideos(fileId);
    loadPromotedVideos();
}
//************************************************************

//************************************************************
// get all information about the current menu
function loadRelatedVideos(fileId){  
  PageMethods.loadRelatedVideos(fileId, loadRelatedVideosSuccess,loadRelatedVideosFail);  
}

//when function loadRelatedVideos is completed correctly
function loadRelatedVideosSuccess(result, userContext, methodName){ 
//alert(result);
  if (result != ""){   
    var divRelatedVideos = getobject ("divRelatedVideos");
    divRelatedVideos.innerHTML = result;
  }      
}

//when function loadRelatedVideos is not completed correctly
function loadRelatedVideosFail(error, userContext, methodName){ 
//alert('related');
alert(error.getname);
}
//************************************************************

//************************************************************
// get all information about the current menu
function loadPromotedVideos(){  
  PageMethods.loadPromotedVideos(loadPromotedVideosSuccess,loadPromotedVideosFail);  
}

//when function loadPromotedVideos is completed correctly
function loadPromotedVideosSuccess(result, userContext, methodName){ 
  if (result != ""){   
    var divPromotedVideos = getobject ("divPromotedVideos");
    divPromotedVideos.innerHTML = result;
  }      
}

//when function loadPromotedVideos is not completed correctly
function loadPromotedVideosFail(error, userContext, methodName){ 
//alert('promoted');
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function loadRightColumn(){  
  PageMethods.loadRightColumn(loadRightColumnSuccess,loadRightColumnFail);  
}

//when function loadRightColumn is completed correctly
function loadRightColumnSuccess(result, userContext, methodName){ 
    var divRight = getobject('divRight');
    divRight.innerHTML = result;
}

//when function loadRightColumn is not completed correctly
function loadRightColumnFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function loadShorts(start, numberPage){  
  PageMethods.loadShorts(start, numberPage, loadShortsSuccess,loadShortsFail);  
}

//when function loadShorts is completed correctly
function loadShortsSuccess(result, userContext, methodName){ 
    var divShorts = getobject('divShorts');
    divShorts.innerHTML = result;
}

//when function loadShorts is not completed correctly
function loadShortsFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function removePlaylist(div){  
    if (confirm('Dou you want to remove this playlist?'))
      PageMethods.removePlaylist(div, removePlaylistSuccess,removePlaylistFail);  
}

//when function removePlaylist is completed correctly
function removePlaylistSuccess(result, userContext, methodName){ 
var div = getobject(result);
  var divPlaylist = getobject('divPlaylist');
  divPlaylist.removeChild(div)
}

//when function removePlaylist is not completed correctly
function removePlaylistFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function deletePlaylist(div){  
    var ddlPlaylist = getobject('ddlPlaylist');
    var index = document.forms[0]["ddlPlaylist"].selectedIndex;
    if (ddlPlaylist.options[index].value == 0)
        alert('You must to select a playlist to delete');
    else
    {
        if (confirm('Dou you want to remove this playlist?'))
            PageMethods.deletePlaylist(ddlPlaylist.options[index].value, deletePlaylistSuccess,deletePlaylistFail);  
    }
}

//when function deletePlaylist is completed correctly
function deletePlaylistSuccess(result, userContext, methodName){ 
  var divPlaylistVideos = getobject('divPlaylistVideos');
  divPlaylistVideos.innerHTML="";
  var txtPlaylistName = getobject('txtPlaylistName');
  txtPlaylistName.value="New Playlist";
  loadHeaderPlaylist(0);
}

//when function deletePlaylist is not completed correctly
function deletePlaylistFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function loadVMBMenu(){  
    PageMethods.loadVMBMenu(loadVMBMenuSuccess,loadVMBMenuFail);  
}

//when function loadVMBMenu is completed correctly
function loadVMBMenuSuccess(result, userContext, methodName){ 
//  var divVMB = getobject('divVMB');
//  divVMB.innerHTML=result;
}

//when function loadVMBMenu is not completed correctly
function loadVMBMenuFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

  function showDivShare(playlistId){        
    var hPlaylistId = getobject('hPlaylistId');
    hPlaylistId.value=playlistId;
    var divShare = getobject('divShare');
    var div_transparency = getobject('div_transparency');
    div_transparency.style["display"] = "block";
    divShare.style["display"]="block";
  }
  function hideDivShare(){        
    var hPlaylistId = getobject('hPlaylistId');
    hPlaylistId.value='';
    var txtRecipients = getobject('txtRecipients');
    txtRecipients.value='';
    var divShare = getobject('divShare');
    var div_transparency = getobject('div_transparency');
    div_transparency.style["display"] = "none";
    divShare.style["display"]="none";
  }

//************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function sharePlaylist(){  
    var txtRecipients = getobject('txtRecipients');
    var hPlaylistId = getobject('hPlaylistId');
    if (trim(txtRecipients.value) != "" )
        PageMethods.sharePlaylist(trim(txtRecipients.value), hPlaylistId.value, sharePlaylistSuccess,sharePlaylistFail);  
    else
        alert('You must to enter recipients before share this playlist');
}

//when function sharePlaylist is completed correctly
function sharePlaylistSuccess(result, userContext, methodName){ 
  hideDivShare();
}

//when function sharePlaylist is not completed correctly
function sharePlaylistFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************

  function showDivLogin(){        
    var divLogin = getobject('divLogin');
    var div_transparency = getobject('div_transparency');
    div_transparency.style["display"] = "block";
    divLogin.style["display"]="block";
  }
  function hideDivLogin(){        
    var divMessage = getobject('divMessage');
    divMessage.innerHTML = '';
    var txtUsername = getobject('txtUsername');
    var txtPassword = getobject('txtPassword');
    txtUsername.value='';
    txtPassword.value='';
    var divLogin = getobject('divLogin');
    var div_transparency = getobject('div_transparency');
    div_transparency.style["display"] = "none";
    divLogin.style["display"]="none";
  }
  
  //************************************************************
// Indicate if the member who is seen the profile is owner or visitor of the profile
function logIn(){  
    var txtUsername = getobject('txtUsername');
    var txtPassword = getobject('txtPassword');
    var hFileId = getobject('hFileId');
//    alert(trim(txtUsername.value));
//    alert(trim(txtPassword.value));
//    alert(hFileId.value);
    if (trim(txtUsername.value) != "" && trim(txtPassword.value) != "" )
        PageMethods.logIn(trim(txtUsername.value), trim(txtPassword.value), hFileId.value, logInSuccess,logInFail);  
    else
        alert('You must to enter username and password');
}

//when function logIn is completed correctly
function logInSuccess(result, userContext, methodName){ 
//alert('result' + result);
  var r = result.split('|');
  if (trim(r[0]) != "")
  {
    var divMessage = getobject('divMessage');
    divMessage.innerHTML = r[0];
  }
  else
  {
    //location.reload();
    loadCommentsFile(r[1]);
    hideDivLogin();
  }
}

//when function logIn is not completed correctly
function logInFail(error, userContext, methodName){ 
alert(error.getname);
}
//************************************************************


