cur_f  = 0;
next_f = 1;

function setCookie(c_name,value,expiredays) {
  var exdate = new Date();
  exdate.setDate(exdate.getDate()+expiredays);
  document.cookie=c_name+ "=" +escape(value)+
  ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name) {
  if (document.cookie.length>0) {
    c_start=document.cookie.indexOf(c_name + "=");
    if (c_start!=-1) {
      c_start=c_start + c_name.length+1;
      c_end=document.cookie.indexOf(";",c_start);
      if (c_end==-1) c_end=document.cookie.length;
      return unescape(document.cookie.substring(c_start,c_end));
    }
  }
  return "";
}


function f_animate() {
  f_cnt++;
  f_cnt++;
  if( f_cnt <= 80 ) {
    document.getElementById( "f"+cur_f ).style.opacity   = f_cnt/100;
    document.getElementById( "f"+next_f ).style.opacity  = (80-f_cnt)/100;

    document.getElementById( "f"+cur_f ).style.filter   = "alpha(opacity = "+f_cnt+" )";
    document.getElementById( "f"+next_f ).style.filter  = "alpha(opacity = "+(80-f_cnt)+" )";
    setTimeout( "f_animate()", 15 );
  } else {
    f_continue();
  }
}

function f_continue() {
  cur_f++;
  next_f++;
  if( next_f == 4 )
    next_f = 1;
  if( cur_f == 4 )
    cur_f = 1;
  f_cnt = 1;
  setTimeout( "f_animate()", 2000 );
}

if( document.getElementById( "f1" ) ) {
  f_continue();
}


function up( gotobj, lfaction ) {
  if( typeof( gotobj ) != "number" ) {
    id = ( gotobj.parentNode.id.replace( "cplace", "" ) );
  } else {
    id = gotobj;
  }

  if( document.getElementById( "cplace"+(id-1) ) ) {
    temp = document.getElementById( "cplace"+(id-1) ).innerHTML;
    document.getElementById( "cplace"+(id-1) ).innerHTML = document.getElementById( "cplace"+(id) ).innerHTML;
    document.getElementById( "cplace"+(id) ).innerHTML = temp;
  }
  save_order( lfaction );
  return false;
}

function down( gotobj, lfaction ) {
  id = gotobj.parentNode.id.replace( "cplace", "" );
  id = (parseFloat(id)+1);
  if( document.getElementById( "cplace"+(id) ) )
    up( id, lfaction );
  return false;
}

function save_order( lfaction ) {
  id = 1;
//sorder = "";
  if( typeof( order_top ) != "undefined" ) {
    order_field = "torder";
  } else {
    order_field = "order";
  }
  while( document.getElementById( "cplace"+id ) ) {
    rowid = document.getElementById( "cplace"+id ).innerHTML.split( "||" );
    rowid = rowid[1];

    ajax_call( "lfaction.php?lfaction="+lfaction+"&lfupdate=yes&lfupdate_id="+rowid+"&"+order_field+"="+id );
//sorder += "lfaction.php?lfaction="+lfaction+"&lfupdate=yes&lfupdate_id="+rowid+"&order="+id+"\n";
    id++;
  }
//alert( sorder);
}

function ajax_call( url ) {
  if(window.XMLHttpRequest) req = new XMLHttpRequest();
  if(window.ActiveXObject)  req = new ActiveXObject("Microsoft.XMLHTTP");
  req.open("GET", url, true);
  req.setRequestHeader("content-type","application/x-www-form-urlencoded");
  req.send(null);
}

function order_update_status( rid, sel_obj ) {
  document.getElementById( "order_update" ).lfupdate_id.value = rid;
  document.getElementById( "order_update" ).status.value = sel_obj.options[sel_obj.selectedIndex].text;
  document.getElementById( "order_update" ).submit();
}

news_pos = 0;
news_round = 0;

function news_scroll() {
  news_pos--;
  news_round++;
  if( news_round == 40 ) {
    news_round = 0;
    document.getElementById( "nws_in" ).innerHTML = document.getElementById( "nws_in" ).innerHTML+news_block;
  }
  document.getElementById( "nws_in" ).style.top = news_pos+"px";
  setTimeout( "news_scroll()", 180 );
}

if( document.getElementById( "nws_in" ) ) {
  news_block = document.getElementById( "nws_in" ).innerHTML;
  news_scroll();
}


function mc_check() {
  if( typeof( min_page_height ) == "undefined" ) {
    min_page_height = 745;
  }

  if( document.getElementById( "maincol" ) ) {
    if( document.getElementById( "maincol" ).offsetHeight < min_page_height ) {
      document.getElementById( "maincol" ).style.height = min_page_height+"px";
    }
  }
}

setTimeout( "mc_check()", 200 );
