<!--

var NewsStorage = {
    
    Domain: function ()
    {
        return 'http://ikupiec.pl';
    },
    SetLangId: function (_i)
    {
        this.langId = _i;
    },
    LangId: function ()
    {
        return this.langId;
    }
}

function MyNewsCollection(_langId)
{
        NewsStorage.SetLangId(_langId);
        var _url = NewsStorage.Domain() + '/mvc.php?x=' ;
	var _action = 'news/latest/|/'  + NewsStorage.LangId();
	var _json = '';
	var _list = '';
	objectDestId = '';
	this.inject = inject;
	this.MakeSuccess = MakeSuccess;
	
	function inject (obj)
	{
		this.objectDestId = obj.id;
		var url = _url + _action;
		YAHOO.util.Connect.asyncRequest('GET', url, _callback, "");
	}
	
	var _callback = 
	{
		success: MakeSuccess, 
		failure: MakeFailure, 
		scope: this,
		cache: true
	};
	
	function MakeSuccess(o){		
		var json =o.responseText;
		_setJson(json);
		_setList();
		_display(this.objectDestId);
		};

	function MakeFailure(o){
		//alert(2);
	};

	var _setJson = function(j)
	{
		_json = j;
	}

	var _setList = function()
	{
		_list = eval('(' + _json + ')');
	}
	
	var _display = function(id)
	{
            // alert(this.langId);
		var el = document.getElementById(id);
		var tmp = "<ul>";
                var x;
                var list;
                var isint = false;
		for (i in _list){
                    list = _list[i];
                    for (x in list){
                        isint = parseInt(x);
                        if (isNaN(isint)) {
                            // containsValue info sometimes was shown
                            continue;
                        }
                        News = list[x];
                        //tmp += x + ' ; ' + ob[x];
                        tmp += '<li><span style="cursor: pointer" onclick="js:DisplayNews(' + i + ', '+NewsStorage.LangId()+');">&raquo; '+News['name']+'</span>';}
                        tmp +="</li>";
		}
		tmp +="</ul>";
		el.innerHTML  = tmp;
	}	
}

function DisplayNews(id)
{
	obj = new MyNews(id);
	obj.Display();
}

function MyNews(id)
{
        var _url = NewsStorage.Domain() + '/mvc.php?x=' ;
	var _action = 'news/get/|/'+NewsStorage.LangId()+'/id/';
	var _html = '';
	
	this.id = id;
	this.MakeSuccess = MakeSuccess;
	this.MakeFailure = MakeFailure;
	this.Display = Display;
	
	var _callback = 
	{
		success: MakeSuccess, 
		failure: MakeFailure, 
		scope: this,
		cache: true
	};
	
	var _setData = function (id)
	{
		url = _url + _action + id;
		YAHOO.util.Connect.asyncRequest('GET', url, _callback, "");
	}
	
	function MakeSuccess(o) {
		_html =o.responseText;
		YAHOO.mySimpleDialog.setBody(_html);
	};

	function MakeFailure(o){
		alert('New error: ' + o.statusText);
	};
	
	var _setSimpleDialog = function()
	{
			YAHOO.mySimpleDialog = new YAHOO.widget.SimpleDialog("centerWindow", { 
			width: '900px', 
			height: '450px',
			fixedcenter:true,
			modal: false,
			preventcontextoverlap: true,
			visible:false,
			draggable:false,
			zindex: 10
			});
			YAHOO.mySimpleDialog.render(document.body);
	}
	
	function Display()
	{
		if (YAHOO.mySimpleDialog==null) {
			_setSimpleDialog();
		}
		YAHOO.mySimpleDialog.setHeader('--- header ---');
		//YAHOO.mySimpleDialog.setBody();
		YAHOO.mySimpleDialog.show();
	};
		_setData(this.id);
}

function computePage() {
  myWidth = 0, myHeight = 0;
  myBrowser = 0;
  middleHeight = 0, middleWidth =0;
  
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
    myBrowser = 1;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
    myBrowser = 2;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight/1;
    myBrowser = 2;
  }
}

-->
