function $(id)
{
        return document.getElementById( id );
}
function cwebshop()
{
    this.log = function()
    {
        var ajax = new HTTPRequest('/_ajax.php');
        ajax.data = { command:'log' };
        ajax.onload = function()
        {
        }
        setInterval( function() { ajax.send() }, 30000 );
        ajax.send();
    }
    this.compareProd = function( pid, place)
    {
        var ajax = new HTTPRequest('/_ajax.php');
        ajax.data = { command:'compareProd', pid: pid, place: place };
        ajax.onload = function()
        {
        	var response = this.response();
        	if( response.ok == 'ok' )
        	{
        		var resp = response.ret;
        		for( zimi in resp )
        		{
        			if( $( zimi ) )
        			{
        				//alert( zimi+ ' ' + resp[zimi] );
        				$( zimi ).innerHTML = resp[ zimi ];
        				//$( i ).innerHTML = 'asd';
        			}
        		}
        	}
        }
        ajax.send();
    }
    this.recalculate = function( country, postcode, upstype )
    {
        var ajax = new HTTPRequest('/_ajax.php');
        ajax.data = { command:'recalculate', dcountry: country, dpostcode: postcode, upstype: upstype };
        ajax.onload = function()
        {
        	var response = this.response();
        	var resp = response.ret;
        	if( $('reccost') )
        	{
        		//alert( resp );
        		$('reccost').innerHTML = resp;
        	}
        }
        ajax.send();
    }   	
}
var cwebshop = new cwebshop();
