// REQUIRES jQuery !!!!!!



var myAsJsInterface;



var AsJsInterface = function () {

    this.setTitle = function(title) {

        setTextFor('#myTitle', title);

    };

    

    this.setCaption = function(caption) {

        setTextFor('#myCaption', caption);

    };

    

    function setTextFor(id, text)

    {

	try

	{

	    $(id).html(text);

	} catch(error)

	{

	    alert('An error occoured');

	}

    }

    

    this.goConfigure = function(data)

    {

        var json = eval('('+data+')');

        var url = 'tappeto/configura?rug_id='+json.rug_id+'&rug_name='+json.rug_name;

        this.changeLocation(url);

    };

    

    

    this.goOrder = function()

    {

        var url = 'ordine_tappeto_step_3.php?rug_id='+rug_id+'&rug_name='+escape(rug_name)+'&rug_colors='+rug_colors+'&ID_prodotto='+ID_prodotto;

        this.changeLocation(url);

    };

    

    this.goCondividi = function()

    {

        var url = 'condividi_il_tuo_tappeto.php?rug_id='+rug_id+'&rug_name='+escape(rug_name)+'&rug_colors='+rug_colors+'&ID_prodotto='+ID_prodotto;

        this.changeLocation(url);

    };
	
    this.goCondividieng = function()

    {

        var url = 'send_your_carpet_to_a_friend.php?rug_id='+rug_id+'&rug_name='+escape(rug_name)+'&rug_colors='+rug_colors+'&ID_prodotto='+ID_prodotto;

        this.changeLocation(url);

    };	
	
	

    

    this.goBack = function(rug_id, rug_name, rug_colors, ID_prodotto)

    {

        var url = 'ordine_tappeto_step_2.php?rug_id='+rug_id+'&rug_name='+escape(rug_name)+'&rug_colors='+rug_colors+'&ID_prodotto='+ID_prodotto;

        this.changeLocation(url);

    }

    

    

    this.changeLocation = function(url)

    {

         if(window && window.location)

        {

            if(typeof(window.location.assign) != 'undefined')

	    {

		window.location.assign(url);

	    } else

	    {

		window.location.href = url;

	    }

        }

    }

    

    

    this.setConfigurationData = function(data)

    {

        var json = eval('('+data+')');

        

        rug_id = json.rug_id;

        rug_colors = json.rug_colors;

    }

};







myAsJsInterface = new AsJsInterface();
