// JavaScript Document
if( typeof( jsn ) == 'undefined' ) var jsn = new Array();
if( ! jsn[0] ) jsn[0] = 1;
// gd support
if( ! jsn[1] ) jsn[1] = 'Sender\'s name had not been declared';
// addslashes( _NEWS10 )
if( ! jsn[2] ) jsn[2] = 'Sender\'s email had not been declared';
// addslashes( _NEWS11 )
if( ! jsn[3] ) jsn[3] = 'Friend\'s email address had not been declared';
// addslashes( _NEWS12 )
if( ! jsn[4] ) jsn[4] = 'Friend\'s email address had not been declared';
// addslashes( _SECURITYCODEINCORRECT )
if( ! jsn[5] ) jsn[5] = 'The letter was sent. Thanks!';
// addslashes( _NEWS13 )
if( ! jsn[6] ) jsn[6] = 0;
// allowed_comm
if( ! jsn[7] ) jsn[7] = 'To comment on this article, you need to log in as user.\nPlease click OK to login';
// addslashes( _NEWS19 )
if( ! jsn[8] ) jsn[8] = 'You have not yet declared their behalf';
// addslashes( _COMMPOSTERROR1 )
if( ! jsn[9] ) jsn[9] = 'You have not yet announced an e-mail address';
// addslashes( _COMMPOSTERROR2 )
if( ! jsn[10] ) jsn[10] = 'You have not yet written content';
// addslashes( _COMMPOSTERROR3 )
if( ! jsn[11] ) jsn[11] = 'Your comment has been sent. Thanks';
// addslashes( _COMMPOSTED )

function nv_send_friend( sid )
{
   var leftposition = ( ( nv_getWinX() - 500 ) / 2 );
   var topposition = ( ( nv_getWinY() - 350 ) / 2 );
   if( IE || GK )
   {
      var wnd = window.showModalDialog( jsi[1] + jsi[0] + '/index.php?' + jsi[2] + '=News&op=sendst&id=' + sid, "SendMail", 'dialogHeight:350px; dialogWidth:500px; dialogTop:' + topposition + 'px;dialogLeft:' + leftposition + 'px;resizable:no;center:yes;help:no;status:no' );
      return wnd;
   }
   else
   {
      var wnd = window.open( jsi[1] + jsi[0] + '/index.php?' + jsi[2] + '=News&op=sendst&id=' + sid, "SendMail", 'menubar=no,toolbar=no,scrollbars=no,location=0, directories=0,copyhistory=0,status=no,modal=yes,dialog=yes,minimizable=no,resizable=no,dependent=yes,width=500,height=350,top=' + topposition + ',left=' + leftposition );
      wnd.focus();
      return wnd;
   }
}

//  ---------------------------------------

function nv_print( sid )
{
   var leftposition = ( ( nv_getWinX() - 700 ) / 2 );
   var topposition = ( ( nv_getWinY() - 500 ) / 2 );

   var wnd = window.open( jsi[1] + jsi[0] + '/index.php?' + jsi[2] + '=News&op=printst&id=' + sid, "Print", 'menubar=no,toolbar=no,scrollbars=yes,location=0, directories=0,copyhistory=0,status=no,modal=yes,dialog=yes,minimizable=no,resizable=no,dependent=yes,width=700,height=500,top=' + topposition + ',left=' + leftposition );
   wnd.focus();
   return wnd;
}

//  ---------------------------------------

function nv_stat( sid )
{
   var leftposition = ( ( nv_getWinX() - 500 ) / 2 );
   var topposition = ( ( nv_getWinY() - 500 ) / 2 );

   var wnd = window.open( jsi[1] + jsi[0] + '/index.php?' + jsi[2] + '=News&op=stat&id=' + sid, "Statistics", 'menubar=no,toolbar=no,scrollbars=yes,location=0, directories=0,copyhistory=0,status=no,modal=yes,dialog=yes,minimizable=no,resizable=no,dependent=yes,width=500,height=500,top=' + topposition + ',left=' + leftposition );
   wnd.focus();
   return wnd;
}

//  ---------------------------------------

function sendfriend_submit( sid )
{
   var sendername = document.getElementById( 'a' );
   var senderemail = document.getElementById( 'b' );
   var friendmail = document.getElementById( 'c' );
   if( sendername.value.length < 2 )
   {
      alert( jsn[1] );
      sendername.focus();
      return false;
   }
   if( ! mailfilter.test( senderemail.value ) )
   {
      alert( jsn[2] );
      senderemail.focus();
      return false;
   }
   if( ! mailfilter.test( friendmail.value ) )
   {
      alert( jsn[3] );
      friendmail.focus();
      return false;
   }
   var query = 'sendername=' + encodeURIComponent( sendername.value );
   query += '&senderemail=' + senderemail.value;
   query += '&friendmail=' + friendmail.value;

   if( jsn[0] )
   {
      var seccode = document.getElementById( 'd' );
      if( ( seccode.value.length != 6 || ! numcheck.test( seccode.value ) ) )
      {
         alert( jsn[4] );
         seccode.focus();
         return false;
      }
      query += '&seccode=' + seccode.value;
   }
   query += '&save=1';
   nv_ajax( 'post', jsi[1] + jsi[0] + '/index.php?' + jsi[2] + '=News&op=sendst&id=' + sid, query, '', 'sendfriend_result' );
   return false;
}

//  ---------------------------------------

function sendfriend_result( res )
{
   var sendername = document.getElementById( 'a' );
   var senderemail = document.getElementById( 'b' );
   var friendmail = document.getElementById( 'c' );
   if( res == 1 )
   {
      alert( jsn[5] );
      window.close();
      return false;
   }
   if( res == 2 )
   {
      alert( jsn[1] );
      sendername.focus();
      return false;
   }
   if( res == 3 )
   {
      alert( jsn[2] );
      senderemail.focus();
      return false;
   }
   if( res == 4 )
   {
      alert( jsn[3] );
      friendmail.focus();
      return false;
   }
   if( jsn[0] )
   {
      var seccode = document.getElementById( 'd' );
      if( res == 5 )
      {
         alert( jsn[4] );
         nv_change_captcha('vimg','d');
         seccode.focus();
         return false;
      }
   }
   return false;
}

//  ---------------------------------------

function nv_rating_submit( sid )
{
   var point = document.getElementById( 'rt_point' ).options[document.getElementById( 'rt_point' ).selectedIndex].value;
   document.getElementById( 'rt_point' ).value = 0;
   query = 'point=' + point;
   nv_ajax( 'post', jsi[1] + jsi[0] + '/index.php?' + jsi[2] + '=News&op=ratingst&id=' + sid, query, '', 'nv_rating_result' );
   return false;
}

//  ---------------------------------------

function nv_rating_result( res )
{
   if( res != 'No' )
   {
      var img_rating = document.getElementById( 'img_rating' );
      img_rating.innerHTML = decodeURIComponent( res );
   }
   return false;
}

//  ---------------------------------------

function nv_comm( sid )
{
   if( jsn[6] )
   {
      var leftposition = ( ( nv_getWinX() - 500 ) / 2 );
      var topposition = ( ( nv_getWinY() - 550 ) / 2 );
      if( IE || GK )
      {
         var wnd = window.showModalDialog( jsi[1] + jsi[0] + '/index.php?' + jsi[2] + '=News&op=commst&id=' + sid, "Add comment", 'dialogHeight:550px; dialogWidth:500px; dialogTop:' + topposition + 'px;dialogLeft:' + leftposition + 'px;resizable:no;center:yes;help:no;status:no' );
         return wnd;
      }
      else
      {
         var wnd = window.open( jsi[1] + jsi[0] + '/index.php?' + jsi[2] + '=News&op=commst&id=' + sid, "Add comment", 'menubar=no,toolbar=no,scrollbars=no,location=0, directories=0,copyhistory=0,status=no,modal=yes,dialog=yes,minimizable=no,resizable=no,dependent=yes,width=500,height=550,top=' + topposition + ',left=' + leftposition );
         wnd.focus();
         return wnd;
      }
   }
   else
   {
      if ( confirm( jsn[7] ) )
      {
         window.location.href = jsi[1] + jsi[0] + '/index.php?' + jsi[2] + '=Users&op=login';
      }
   }
   return false;
}

//  ---------------------------------------

function nv_postcomm_submit( sid )
{
   var postname = document.getElementById( 'a' );
   var postemail = document.getElementById( 'b' );
   var postsubject = document.getElementById( 'c' );
   var postcontent = document.getElementById( 'd' );
   if( postname.value.length < 2 )
   {
      alert( jsn[8] );
      postname.focus();
      return false;
   }
   if( ! mailfilter.test( postemail.value ) )
   {
      alert( jsn[9] );
      postemail.focus();
      return false;
   }
   if( postcontent.value.length < 2 )
   {
      alert( jsn[10] );
      postcontent.focus();
      return false;
   }
   var query = 'postname=' + encodeURIComponent( postname.value );
   query += '&postemail=' + postemail.value;
   query += '&subject=' + encodeURIComponent( postsubject.value );
   query += '&content=' + encodeURIComponent( postcontent.value );
   if( jsn[0] )
   {
      var seccode = document.getElementById( 'e' );
      if( ( seccode.value.length != 6 || ! numcheck.test( seccode.value ) ) )
      {
         alert( jsn[4] );
         seccode.focus();
         return false;
      }
      query += '&seccode=' + seccode.value;
   }
   query += '&save=1';
   nv_ajax( 'post', jsi[1] + jsi[0] + '/index.php?' + jsi[2] + '=News&op=commst&id=' + sid, query, '', 'nv_postcomm_result' );
   return false;
}

//  ---------------------------------------

function nv_postcomm_result( res )
{
   var postname = document.getElementById( 'a' );
   var postemail = document.getElementById( 'b' );
   var postsubject = document.getElementById( 'c' );
   var postcontent = document.getElementById( 'd' );
   if( res == 1 )
   {
      alert( jsn[11] );
      window.close();
      return false;
   }
   if( res == 2 )
   {
      alert( jsn[8] );
      postname.focus();
      return false;
   }
   if( res == 3 )
   {
      alert( jsn[9] );
      postemail.focus();
      return false;
   }
   if( res == 4 )
   {
      alert( jsn[10] );
      postcontent.focus();
      return false;
   }
   if( jsn[0] )
   {
      var seccode = document.getElementById( 'e' );
      if( res == 5 )
      {
         alert( jsn[4] );
         nv_change_captcha('vimg','e');
         seccode.focus();
         return false;
      }
   }
   return false;
}

//  ---------------------------------------

function nv_dgo(lk)
{
   var n_day = document.getElementById( 'nday' ).options[document.getElementById( 'nday' ).selectedIndex].value;
   var n_month = document.getElementById( 'nmonth' ).options[document.getElementById( 'nmonth' ).selectedIndex].value;
   var n_year = document.getElementById( 'nyear' ).options[document.getElementById( 'nyear' ).selectedIndex].value;
   n_date = nv_mktime( 23, 59, 59, n_month, n_day, n_year );
   lk = decodeURIComponent(lk);
   window.location.href = lk + '&tm=' + n_date;
   return false;
}
