<!--
var tipsters_current=1; // precuation 

var side_xmlHttp;
var side_refresher;
var biglive_refresher;
var tippers_refresher;
var side_gambles = new Array();

var biglive_rate = 7000; // 10 seconds
var tippers_rate = 7000;
var menu_current;
var submenu_current;
var biglive_current=1;

function maximize() {
    window.moveTo(0,0)
    window.resizeTo(screen.availWidth, screen.availHeight)
}

function init()
{ 
  <!-- big live -->
  var biglive;
  var i=1;
  while ( biglive = document.getElementById('biglive' + i) ) 
  {
    if (i==1) {
      biglive.style.display='block';
    }
    biglive.style.zindex=100;
    i++;
  }


  <!-- Welcome -->
  var obj = document.getElementById('welcome_top');
  var curleft = curtop = 0;
   
  if (obj.offsetParent) {
    curleft = obj.offsetLeft
    curtop = obj.offsetTop 
    while (obj = obj.offsetParent) {
      curleft += obj.offsetLeft
      curtop += obj.offsetTop  
    }
  }  
   
  var welcome = document.getElementById('welcome');
  welcome.style.display='inline';
  welcome.style.position='absolute';
  welcome.style.left=curleft + 60;  
  welcome.style.top=curtop + 15;   
 
  <!-- Logout -->
  var obj = document.getElementById('logout_top');
  var curleft = curtop = 0;
  
  if (obj.offsetParent) {
    curleft = obj.offsetLeft
    curtop = obj.offsetTop    
    while (obj = obj.offsetParent) {
      curleft += obj.offsetLeft;
      curtop += obj.offsetTop  + 2;
    }
  }    
     
  var logout = document.getElementById('logout');
  logout.style.display='inline';
  logout.style.position='absolute';  
  logout.style.left=curleft + 12;
  logout.style.top=curtop + 10;
  
  // change biglive ticker //
  biglive_refresher = setInterval("doBiglive();",biglive_rate);
  tippers_refresher = setInterval("doTippers();",tippers_rate);
  side_load();
}

function doBiglive()
{
  clearInterval(biglive_refresher);
  biglive_next(0);
  biglive_refresher = setInterval("doBiglive();",biglive_rate);  
}

function doTippers()
{
  clearInterval(tippers_refresher);
  tippers_next();
  tippers_refresher = setInterval("doTippers();",tippers_rate);  
}

function IsNumeric(sText)
{
  var ValidChars = "0123456789.";
  var IsNumber=true;
  var Char;

  if (! sText) { return false; }

  for (i = 0; i < sText.length && IsNumber == true; i++)
  {
    Char = sText.charAt(i);
    if (ValidChars.indexOf(Char) == -1)
    {
      IsNumber = false;
    }
  }

  return IsNumber;
}


function biglive_next(type_bool)
{
  if (type_bool) { 
    clearInterval(biglive_refresher);
    biglive_refresher = setInterval("doBiglive();",biglive_rate); 
  }

  var biglive = document.getElementById('biglive' + biglive_current);
  if (biglive)
  {
    biglive.style.display='none';
    biglive_current++;
  }
  else { return true; }

  biglive = document.getElementById('biglive' + biglive_current);
  if (! biglive) {
    if (type_bool) { 
      // stay at the last ticket //
      biglive_current--;
      biglive = document.getElementById('biglive' + biglive_current);
      biglive.style.display='block'; 
      alert('אין יותר משחקים להריץ קדימה'); 
    } 
    else {
      // return to the start //
      biglive_current=1;
      biglive = document.getElementById('biglive' + biglive_current);
      biglive.style.display='block';
    }
  }
  else { biglive.style.display='block'; }
}

function biglive_previous(type_bool)
{    
  if (type_bool) {
    clearInterval(biglive_refresher);
    biglive_refresher = setInterval("doBiglive();",biglive_rate);
  }   

  var biglive = document.getElementById('biglive' + biglive_current-1);
  biglive = document.getElementById('biglive' + biglive_current);
  biglive.style.display='none';

  biglive_current--;
  biglive = document.getElementById('biglive' + biglive_current);
  if (! biglive) {   
    biglive_current++;
    biglive = document.getElementById('biglive' + biglive_current);
    biglive.style.display='block';
    if (type_bool) { alert('אין יותר משחקים להריץ אחורה'); }
  }
  else { biglive.style.display='block'; }
}   

function tippers_next()
{
  var tippers_table;
  tippers_table = document.getElementById('tipsters' + tipsters_current);
  tippers_table.style.display='none';
  tippers_table = document.getElementById('tippers_menu');
  tippers_table.style.display='none';

  if (! tipsters_current) { tipsters_current=0; }
  if (tipsters_current==4) { tipsters_current=0; }

  for(var i=1;i<5;i++)
  {
    if (i <= tipsters_current) { continue; }

    tippers_table = document.getElementById('tipsters' + i);
    if (tippers_table)
    {
      tippers_table.style.display='block';
      tipsters_current=i;
      return true;
    }
  }

  return true;
}


function side_GetXmlHttpObject()
{
  side_xmlHttp=null;
  try
  {
    // Firefox, Opera 8.0+, Safari
    side_xmlHttp=new XMLHttpRequest();
  }
  catch (e)
  {
    //Internet Explorer
    try
    {
      side_xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      side_xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }

  return side_xmlHttp;
}

function side_init()
{
  side_xmlHttp=side_GetXmlHttpObject();
  if (side_xmlHttp==null)
  {
    alert ("Browser does not support HTTP Request");
    return false;
  }
}

function side_connect()
{ 
  if (side_xmlHttp==null)
  {
    alert ("Browser does not support HTTP Request");
    return false;
  }

  var side_url='/side_ajax2.pl?date=' + new Date().getTime();
  side_xmlHttp.onreadystatechange=side_data;
  side_xmlHttp.open("GET",side_url,true);
  side_xmlHttp.send(null);
}

function side_connect_remove(gamble_id)
{
  if (side_xmlHttp==null)
  {
    alert ("Browser does not support HTTP Request");
    return false;
  }
  if (! gamble_id) { return false; }  

  //Send the proper header information along with the request
  //side_xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  //side_xmlHttp.setRequestHeader("Content-length", params.length);
  //side_xmlHttp.setRequestHeader("Connection", "close");

  var side_url='/side_ajax2.pl?remove_explicit=1&remove=' + gamble_id + '&date=' + new Date().getTime();
  //alert(side_url);
  side_xmlHttp.onreadystatechange=side_data;
  side_xmlHttp.open("GET",side_url,true);
  side_xmlHttp.send(null);
  
  if (typeof stan_xmlHttp=="object")
  {
    stan_init();
    stan_connect();
    stan_data();
  }

  if (typeof pshop_xmlHttp=="object")
  {
    pshop_init();
    pshop_connect();
    pshop_data();
  }  
}

function side_load()
{
  side_init();
  side_connect();
  side_data();
  side_refresher = window.setInterval("side_init();side_connect();side_data();",3000); // 3 seconds
}

function side_send()
{
  var params='';
  var gamble_id;
  
  if (side_xmlHttp==null)
  {
    alert ("Browser does not support HTTP Request");
    return false;
  }

  var games_count = side_gambles.length;
  params = 'send=1&games_count=' + games_count;
  
  for(var i=0;i<side_gambles.length;i++)  
  {
    gamble_id = side_gambles[i];
    params += '&gamble' + (i+1) + '=' + gamble_id;
    params += '&mark' + (i+1) + '=' + 1;
  }
  
  var side_url='/personal_shop_ajax.pl?' + params + '&date=' + new Date().getTime();
  side_xmlHttp.open("GET",side_url,true);
  side_xmlHttp.onreadystatechange=side_data_reciet;  
  side_xmlHttp.send(null);

  if (typeof pshop_xmlHttp=="object")
  {
    pshop_init();
    pshop_connect();
    pshop_data();
  }  

  if (typeof stan_xmlHttp=="object")
  {
    stan_init();
    stan_connect();
    stan_data();
  }
}

function side_data_reciet()
{
  var special,error,gamble_error,cell,cost,price;
  var str,output,name,value,reciet_div;
  var array = new Array();
  var backref = new Array();
  var thanks=0;

  clearInterval(side_refresher);  
  reciet_div = document.getElementById('side_div');
  price=0;
  output='';

  if (side_xmlHttp.readyState==4 || side_xmlHttp.readyState=="complete")
  { 
    str = side_xmlHttp.responseText;
    array = str.split("<INPUT");

    for(var i=1;i<array.length;i++)
    {
      backref = array[i].match("name=(.+?)\s*value=(.+?)\">");
      name = backref[1];
      value = backref[2];   
      
      name = name.replace(/"/g,"");
      value = value.replace(/"/g,"");
      if (name.match('special'))
      {
        special=value;
        if (special) { 
          output += '<TR><TD align="center"><U>מיוחד!</U></TD></TR>'
                  + '<TR><TD align="center">עלות מיוחדת לצוות.</TD></TR>'
                  + '<TR><TD>&nbsp;</TD></TR>';
        }
      }   
      else if (name.match('error'))
      {
        error=value;
      }        
      else if (name.match('gamble_error'))
      {
        gamble_error=value;
      }   
      else if (name.match('cellphone_num'))
      {
        cell=value;
      }   
      else if (name.match('cost'))
      {
        cost=value;
          
          if (error) { 
            output += '<TR><TD align="center"><U>שים לב!</U></TD></TR>'
                   + '<TR><TD align="center">' 
                   + 'אחת ההודעות שהזמנת<BR>'
                   + 'כבר נשלחה אליך בעבר.<BR>';
          }

          if (gamble_error) { 
            output += '<TR><TD align="center"><U>בעיה עם הסלולארי</U></TD></TR>'
                   + '<TR><TD align="center">' 
                   + gamble_error + '</TD></TR>';
          }

          if (cost) { 
            if (! thanks)
            {
              output += '<TR><TD align="center"><U>ההודעה נשלחה</U></TD></TR>';
              thanks=1;
            }

            output += '<TR><TD align="center">' + cost + '</TD></TR>';
          }
      }   
    }

    output += '<TR><TD>&nbsp;</TD></TR>';
    output += '<TR><TD>תודה מצוות ביג-טיפ</TD></TR>';                   
    output += '<TR><TD align="center" OnClick="side_data();" style="cursor:pointer;color:red;"><U>סגור</U></TD></TR>';
    
    reciet_div.innerHTML = '<TABLE  style="position:relative;left:-3px;background:url'
                         + '(/images/shop_reciet.png);" width="140px" height="249">'
                         + '<TR><TD height="45px"></TD></TR>'
                         + '<TR><TD valign="top" align="center"><TABLE>'
                         + output 
                         + '</TABLE></TD></TR>'
                         + '<TR><TD>&nbsp;</TD></TR></TABLE>';
  }

  delete(array);
  delete(backref);
}

function side_data() 
{ 
  var side_str;
  var name,value;
  var gamble_count,gamble_id,user_id,username,serial,gamble_index,disabled;
  var output;
  var array = new Array();
  var backref = new Array();
  var side_div = document.getElementById('side_div');
    
  side_gambles = new Array();
  
  if (side_xmlHttp.readyState==4 || side_xmlHttp.readyState=="complete")
  {   
    output = '<tr><td valign="top" style="position:relative;left:-3px;background:url(/images/shop_full_new.png);" width="140px" height="248px">'
     + '<table><tr><td height="47px" style="cursor:pointer;"'
     + 'OnClick="window.location.href=\'\/personal\/shop.html\'"></td></tr>'
     + '<tr><td><table><tr>'
     + '<td width="65px" style="font-size:11px;color:#961207;padding-right:14px;">'
     + 'שם טיפר</td><td style="font-size:11px;color:#961207;">מס סידורי</td>'
     + '</tr></table></td></tr><tr><td height="2px"></td></tr>';

    side_str = side_xmlHttp.responseText;
    //alert(side_str);
    array = side_str.split("<INPUT");
    gamble_index=1;
    for(var i=1;i<array.length;i++)
    {
      backref = array[i].match("name=(.+?)\s*value=(.+?)\">");
      name = backref[1];
      value = backref[2];   
      
      name = name.replace(/"/g,"");
      value = value.replace(/"/g,"");

      if (name.match("gamble" + gamble_index))
      {
        gamble_id=value;
      }   
      else if (name.match('serial' + gamble_index))
      {
        serial=value;
      }
      else if (name.match('username' + gamble_index))
      {
        username=value;
      }
      else if (name.match('user_id' + gamble_index))
      {
        user_id=value;
        side_gambles.push(gamble_id);
        output += '<TR><TD width="100%"><TABLE width="100%"><TR>'
               + '<TD style="font-size:7px;width:10px;padding-right:3px;cursor:pointer;" valign="top"'
               + 'OnClick="side_init();side_connect_remove(' + gamble_id + ');">X</TD>'
               + '<TD style="font-size:11px;line-height:17px;width:65px;">'
               + username + '</TD>'
               + '<TD style="font-size:11px;">משחק:' + serial + '</TD></TR></TABLE></TD></TR>';
        gamble_index++;
      }
      else if (name.match('gamble_count'))
      {
        gamble_count=value;
      }
      else if (name.match('disabled'))
      {
        disabled=value;
      }
    }

    if (gamble_count>0 && disabled==0)
    {
      if (gamble_count==1) { price=1.5 }
      if (gamble_count==2) { price=3 }
      if (gamble_count==3) { price=3 }
      if (gamble_count==4) { price=4.5 }
      if (gamble_count==5) { price=6 }
      if (gamble_count==6) { price=6 }

      height=(6-gamble_count)*17;
      height += 4;
      output += '<TR><TD height="' + height + 'px"></TD></TR>';
      output += '<TR><TD><TABLE><TR>'
             + '<TD width="65px" style="padding-right:20px;font-size:11px;line-height:17px;color:#961207">טיפים</TD>'
             + '<TD width="65px" style="padding-right:14px;font-size:11px;line-height:17px;color:#961207">עלות</TD>'
             + '</TR>'
             + '<TR>'
             + '<TD width="65px" style="padding-right:26px;line-height:17px;">' + gamble_count + '</TD>'
             + '<TD width="65px" style="padding-right:13px;line-height:17px;">' + price + ' ש"ח</TD>'
             + '</TR>'
             + '</TABLE></TD></TR>'
             + '<TR><TD height="13px"></TD></TR>';

      output += '<TR><TD align="center">'
             + '<INPUT style="cursor:pointer;position:relative;left:5px;" type="image" src="/images/shop_order.png"'
             + ' OnClick="side_send();">'
             + '</TD></TR></TABLE></td></tr>';          
    }
    else if (gamble_count>0 && disabled==1)
    {
      if (gamble_count==1) { price=1.5 }
      if (gamble_count==2) { price=3 }
      if (gamble_count==3) { price=3 }
      if (gamble_count==4) { price=4.5 }
      if (gamble_count==5) { price=6 }
      if (gamble_count==6) { price=6 }

      height=(6-gamble_count)*17;
      height += 4;
      output += '<TR><TD height="' + height + 'px"></TD></TR>';
      output += '<TR><TD><TABLE>'
             + '<TR><TD width="130px" style="padding-right:18px;line-height:17px;">מספר פלאפון נחסם</TD></TR>'
             + '<TR><TD width="130px" style="padding-right:20px;line-height:17px;">נסה שוב עוד שבוע</TD></TR>'
             + '</TABLE></TD></TR>'
             + '<TR><TD height="13px"></TD></TR>'
             + '<TR><TD align="center">'
             + '</TD></TR></TABLE></td></tr>';      
    }    
    else
    {
      output = '<tr><td valign="top" width="140px" height="223px"'
             + 'style="position:relative;left:-3px;cursor:pointer;'
             + 'background:url(\'/images/shop_empty.png\');background-repeat:no-repeat;"'
             + 'OnClick="window.location.href=\'/tipsters\/experts.html\';">&nbsp;</TD></TR>';
    }

    //alert(output);
    side_div.innerHTML = '<TABLE>' 
      + output
      + '</TABLE>';
  }

  delete(array);
  delete(backref);
  return true;
}

function menu_open(menu_str)
{
  var div,obj;
  var curtop,curleft;
  
  // find position and place submenu
  obj = document.getElementById(menu_str + '1');
  if (obj && obj.style.display=='none')
  {
    obj = document.getElementById(menu_str + '2');
  }

  curleft = curtop = 0;
   
  if (obj.offsetParent) {
    curleft = obj.offsetLeft;
    curtop = obj.offsetTop;
    while (obj = obj.offsetParent) {
      curleft += obj.offsetLeft;
      curtop += obj.offsetTop;
    }
  }   

 
  div = document.getElementById(menu_str);
  div.style.display='block';
  div.style.position='absolute';
  div.style.left=curleft - 2;
  div.style.top=curtop + 22;  
  
  // change to pressed button in top menu
  div = document.getElementById(menu_str + '1');
  div.style.display='none';
  
  div = document.getElementById(menu_str + '2');
  div.style.display='block'; 
  
  if (menu_current && menu_current!=menu_str)
  {
    // cloes menu
    div = document.getElementById(menu_current);
    if (div)
    {
      div.style.display='none';
    }

    // change the current open menu button to unpressed button in top menu    
    div = document.getElementById(menu_current + '1');
    if (div)
    {
      div.style.display='block'; 
    }
    div = document.getElementById(menu_current + '2');
    if (div)
    {
      div.style.display='none';
    }
  }
  
  menu_current=menu_str;
}

function menu_close(menu_str)
{
  var div;

  div = document.getElementById(menu_str);
  div.style.display='none';

  // change to unpressed button in top menu
  div = document.getElementById(menu_str + '2');
  div.style.display='none';

  div = document.getElementById(menu_str + '1');
  div.style.display='block'; 
}

function menu_close_explicit()
{
  var div;

  if (menu_current)
  {
    div = document.getElementById(menu_current);
    if (div) { div.style.display='none'; }

    // change to unpressed button in top menu
    div = document.getElementById(menu_current + '2');
    if (div) { div.style.display='none'; }

    div = document.getElementById(menu_current + '1');
    if (div) { div.style.display='block'; }
  }
}

function submenu_open(menu_str)
{
  var div,obj;
  var curtop,curleft;
  
  obj = document.getElementById('sub' + menu_str + '1');
  if (obj && obj.style.display=='none')
  {
    obj = document.getElementById('sub' + menu_str + '2');
  }

  curleft = curtop = 0;
   
  if (obj.offsetParent) {
    curleft = obj.offsetLeft;
    curtop = obj.offsetTop;
    while (obj = obj.offsetParent) {
      curleft += obj.offsetLeft;
      curtop += obj.offsetTop;
    }
  }   
    
  div = document.getElementById(menu_str);
  div.style.display='block';
  div.style.position='absolute';
  div.style.left=curleft - 90;
  div.style.top=curtop - 12;  
  div.zindex=100;  
  
  // change to pressed button in top submenu
  div = document.getElementById('sub' + menu_str + '2');
  div.style.display='block';

  div = document.getElementById('sub' + menu_str + '1');
  div.style.display='none'; 
}

function submenu_close(menu_str)
{
  var div;
  div = document.getElementById(menu_str);
  div.style.display='none';
  
  // change to unpressed button in top submenu
  div = document.getElementById('sub' + menu_str + '2');
  div.style.display='none';

  div = document.getElementById('sub' + menu_str + '1');
  div.style.display='block'; 
}

function submenu_open2(menu_str)
{
  var div;
  
  // change to pressed button in top submenu
  div = document.getElementById('sub' + menu_str + '2');
  div.style.display='block';

  div = document.getElementById('sub' + menu_str + '1');
  div.style.display='none'; 
}

function submenu_close2(menu_str)
{
  var div;
  
  // change to unpressed button in top submenu
  div = document.getElementById('sub' + menu_str + '2');
  div.style.display='none';

  div = document.getElementById('sub' + menu_str + '1');
  div.style.display='block'; 
}
function submenu_open3(menu_above,menu_str)
{
  var div;
  
  // change to pressed button in top submenu
  div = document.getElementById('inner' + menu_str + '2');
  div.style.display='block';

  div = document.getElementById('inner' + menu_str + '1');
  div.style.display='none'; 

  menu_open(menu_above);

}

function submenu_close3(menu_above,menu_str)
{
  var div;
  
  // change to unpressed button in top submenu
  div = document.getElementById('inner' + menu_str + '2');
  div.style.display='none';

  div = document.getElementById('inner' + menu_str + '1');
  div.style.display='block'; 

  menu_close(menu_above);
}

function menu_init()
{
  return true;
}

-->
