﻿<!--
			function MM_openBrWindow(theURL,winName,features) {
  			window.open(theURL,winName,features);
			}

			var auctions = [];
			var myHttpRequest = false;
			var state = 'hidden';

			if(window.XMLHttpRequest)
    			 myHttpRequest = new XMLHttpRequest();
			else if(window.ActiveXObject)
    		 	myHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");


function printInitContent(source, content)
{
     if(myHttpRequest)
     {
          	var data = document.getElementById(content);
			data.innerHTML = data.innerHTML + "<br />" + source;
         	myHttpRequest.send(null);
     }
} 



function printTextContent(source, content)
{
     if(myHttpRequest)
     {
          	var data = document.getElementById(content);
			data.innerHTML = (source);
         	myHttpRequest.send(null);
     }
} 

function loadContent(source, content)
{
var MyHttpLoading = 'PODBITA!';
var ErrorMSG = '<p><br>ERROR!</p>';
var i = 0;

	myHttpRequest = GetHttpR()
  if(myHttpRequest)
  {
          	var data = document.getElementById(content);
          	var robo = document.getElementById('hidden');
			// document.getElementById(content).innerHTML = MyHttpLoading; 
          	myHttpRequest.open("GET",source, true);
         	myHttpRequest.onreadystatechange = function()

          {
          if(myHttpRequest.readyState==4)
          			{
          			
          			robo.innerHTML = myHttpRequest.responseText;
          			
          			if (robo.innerHTML == data.innerHTML) 
          					{ 
          					robo.innerHTML = myHttpRequest.responseText;      					
          					}
          			else 	{ 
          					data.innerHTML = myHttpRequest.responseText; 
          					}
					}
          else		{	
          			// document.getElementById(content).innerHTML = MyHttpLoading; 
          			}	// still working
          }
		if (i < 2) { myHttpRequest.send(null);	i++; }		
	}
  	else 
  	{ 
  	document.getElementById(content).innerHTML = ErrorMSG + source; 
  	}

}

function loadImage(source, content)
{
     if(myHttpRequest)
     {
          var data = document.getElementById(content);

          myHttpRequest.open("GET",source);

          myHttpRequest.onreadystatechange = function()
          {
               if(myHttpRequest.readyState==4)
                   data.innerHTML = myHttpRequest.responseText;
          }

          myHttpRequest.send(null);
     }
} 

function cmsload(source, content)
{
     if(myHttpRequest)
     {
          var data = document.getElementById(content);

          myHttpRequest.open("GET",source);

          myHttpRequest.onreadystatechange = function()
          {
               if(myHttpRequest.readyState==4)
                   data.innerHTML = myHttpRequest.responseText;
                   setup();
          }

          myHttpRequest.send(null);
     }
} 

function backload(source, content)
{
     if(myHttpRequest)
     {
          var data = document.getElementById(content);

          myHttpRequest.open("GET",source);

          myHttpRequest.onreadystatechange = function()
          {
               if(myHttpRequest.readyState==4)
                   data.innerHTML = myHttpRequest.responseText;
          }

          myHttpRequest.send(null);
     }
} 

function StartLoop()
{
	setTimeout("NewLoop()",10);
}

function NewLoop()
{
	var requestString = "forum_records.php?t_id=";
	requestString = requestString + auctions;
	setTimeout("loadContent('" + requestString + "','forum')",5000);
	setTimeout("NewLoop()",5000);
}

function GetStats()
{
		xmlHttp = GetHttpR()
		if (xmlHttp==false){return false;}
  		xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState==4)
      		{       
				if (xmlHttp.status == 200)
				{
        		ReadJSon(xmlHttp.responseText);
       			setTimeout("GetStats()",940);
       			}
      		}
		}

  		var requestString = "GetStats.php?a=";
		if (auctions.length > 0)
		{
	  		for (x in auctions)
			{
			requestString = requestString + auctions[x] + ",";
			}
			xmlHttp.open("GET",requestString,true);       
			xmlHttp.send(null);
			}
		}

function GetHttpR()
{

    var GetHttpR_ret = false;
    try
    {
        // Firefox, Opera 8.0+, Safari
        GetHttpR_ret=new XMLHttpRequest();
    }
    catch (e)
    {
        // Internet Explorer
        try
        {
            GetHttpR_ret=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                GetHttpR_ret=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
            {
                alert("Your browser does not support AJAX!");
                return false;
            }
        }
    }
    return GetHttpR_ret;
}

function ReadJSon(jsonString)
{
    var tab = jsonString.split(";");
    var id;
    var price;
    var timeLeft;
    var status;
   
    for(var i = 0; i < tab.length; i++)
    {
        if (tab[i] == "id")
        {
			i++;
            id = tab[i];
            i++;
        }
 
 	 	if (tab[i] == "st")
        {
            i++;
            status = tab[i];
            i++;
       	}
       	
        if (tab[i] =="wn")
        {
        	i++;
        	if (status == "fin")
            {
        	var winner = 'wygra?: ' + tab[i];
        	}
        	else 
        	{
        	var winner = 'prowadzi: ' + tab[i];
        	}
        	var winnerControlName = "leader_" + id;
        	var winnerControl = document.getElementById(winnerControlName);
        	if (winnerControl != null)
        	{
        		winnerControl.innerHTML = winner;
			}
				i++;
		}
		
		if (tab[i] == "v")
        {
            i++;
            price = tab[i];
            var priceControlName = "cena_" + id;
          
            var priceStara = document.getElementById(priceControlName);
            if (priceStara != null)
            {
            var priceAb = priceStara.innerHTML;
            var priceValue = priceAb.replace(/ PLN/, "");
            }
           
            var priceControl = document.getElementById(priceControlName)
            if (priceControl != null)
            {
                priceControl.innerHTML = price + ' PLN';
            }
            i++;
        }

        if (tab[i] == "tl")
        {
            i++;
            timeLeft = tab[i];
            
            if (price > priceValue) { status = "bid"; }
            
            
            if (status == "end")
            {
            timeLeft = "<span style='color: #ff6600;'>" + tab[i] + "</span>";
            }
            if (status == "bid")
            {
            timeLeft = "<span style='color: #ff0000; background-color: #ffddaa;'>" + tab[i] + "</span>";
            }
            if (status == "fin")
            {
            timeLeft = "<span style='color: #999999;'>" + tab[i] + "</span>";
            }
            
            var timeleftControlName = "time_" + id;
            var timeleftControl = document.getElementById(timeleftControlName)
            if (timeleftControl != null)
            {
                timeleftControl.innerHTML = timeLeft;
            }  
        }

    }
}
			//-->
