function Display(todo,code,lang) {

    oContent = document.getElementById('content');

    if (todo == "OBJECT_INFO") {
        if (! default_content) return;

        oContent.innerHTML = default_content;
        imageIndex = 0;
        ImgMove(0);

        try {  SetMinPageHeight(); } catch(e) {}

        return;
    }
    else if (todo == "PRICE") {

        //if (! default_content) return;
        if (default_content == null) default_content = oContent.innerHTML;

        oContent.innerHTML =
            document.getElementById('price_layer').innerHTML;

        try {  SetMinPageHeight(); } catch(e) {}
        //oContent.innerHTML = default_content;
        return;
    }

    ax = new AjaxRequest();
    ax.AddParam('lang',lang);
    ax.AddParam('doAction',todo);
    try { ax.AddParam('is_b2b',is_b2b); } catch(e) {}
    try { ax.AddParam('no_periods',no_periods); } catch(e) {}

    
    // samo za specijalen ponude no name brodova
    iPos = document.location.href.indexOf("&so=");
    if (iPos > -1) {
    	try {
    		sSO = document.location.href.substring(iPos + 4);
    		if (sSO.substring(sSO.length-1) == "#") sSO = sSO.substring(0,sSO.length-1);
    		
    		//alert("###---" +  sSO);
    		
    		ax.AddParam('so',sSO);
    	} catch(e) {alert(e.message);}
    }
    
    
    switch(todo) {

        case "TRIPS":
            ax.AddParam('code',region_id);
        break;

        case "RIVA_SELECT":
            ax.AddParam('id',object_id);
            ax.AddParam('code','S' + code);
        break;

        default:
            ax.AddParam('code',code);
            try { ax.AddParam('object_code',object_code) } catch(e) {};
            try { ax.AddParam('object_name',object_name) } catch(e) {};
            //ax.AddParam('ship_id',object_id);
        break;

    }
    
    //alert(ax.QueryString());
    
    ax.OnRequestDone = function(http) {
    	
    	//alert(http.responseText);

        document.getElementById('content').innerHTML = http.responseText;
        if (todo == 'ROUTE') {
            //alert(http.responseText);
            try {
            	
            	SetRouteGallery(code);
            } catch(e) {}
            $("a[rel='cb_route']").colorbox();
            //$("a[rel='lightbox[route]']").colorbox();
        }
    }

    if (default_content == null) default_content = oContent.innerHTML;
    ax.SendPostRequest("/JSON.aspx");

    //document.getElementById('content').innerHTML = ax.QueryString();
    //alert(ax.QueryString());

    try {  SetMinPageHeight(); } catch(e) { alert(e.message) ; }

}

function ImgMove(index) {

    if (! index) {
        index = 0;
        imageList = queryData.object_gallery;
    }

    if (typeof(index) != 'number') index = 0;

    if ((imageIndex + index) < 0 ) return;
    if ((imageIndex + index) >= imageList.length) return;

    imageIndex += index;
    try {
		oImgUrl  = document.getElementById('img_url');
		oImgText = document.getElementById('img_text');
		oImgCount = document.getElementById('img_count');
	
		oImgUrl.src = imageList[imageIndex].url;
		oImgCount.innerHTML = "[ " + (imageIndex+1)  + "/" + imageList.length +  " ]";
		oImgText.innerHTML = imageList[imageIndex].text;
	} catch(e) {}
}

function SetRouteGallery(code) {

    arrGellery = queryData.route_gallery;

    for(var i = 0;i < arrGellery.length;i++) {

        if (arrGellery[i].key == code) {
            imageList = eval(arrGellery[i].value);
            imageIndex = 0;
            ImgMove('ROUTE');
            return;
        }
    }

    imageList = new Array();
    imageIndex = 0;

    document.getElementById('sngImgGal').className = "nosingal";
}


