var PRURL = "/utils/cities-slideshow/index/"; var MAX_REFERENCES = 6; var TIMER_DELAY = 8000; $(document).ready(function() { initIdeveloper(); }); var IdeveloperRefs = { NUMREF_INACTIVE_CLASS: "dot", NUMREF_ACTIVE_CLASS: "active", init: function(url, maxrefs, timer_delay) { this.url = url; this.maxrefs = maxrefs; this.timer_delay = timer_delay; var context = this; $.get(this.url, "", function(data) { context.generateOnLoaded(data); }); }, generateWidget: function(projects) { var context = this; this.projects = projects; var container = this.refContainer(); var a; for(var i=0; i' + (i+1) + ""); container.append(a); a.data("project", i); a.click(function(event) { context.generateToggleProject(event, $(this).data("project")); }); } //select first project this.selectProject(0); //start timer to rotate selected projects this.startTimer(); }, startTimer: function() { var context = this; this.timer = setTimeout(function() {context.onTimer();}, context.timer_delay); }, stopTimer: function() { clearTimeout(this.timer); }, onTimer: function() { this.selectNextProject(); this.startTimer(); }, selectNextProject: function() { if (this.selectedProject<(this.projects.length-1)) this.selectProject(this.selectedProject+1); else this.selectProject(0); }, //container for project references refContainer: function() { return $(".nove-bydleni .set-right").eq(0); }, //selected project reference header projectHeaderContainer: function() { return $(".nove-bydleni h3.headerToReplace a").eq(0); }, //"detail" image button projectDetailContainer: function() { return $(".nove-bydleni .pruh-dole .set-right a").eq(0); }, //selected projet image projectImageContainer: function() { return $(".nove-bydleni").eq(0); }, generateToggleProject: function(event, projectIndex) { event.preventDefault(); this.stopTimer(); this.selectProject(projectIndex); }, selectProject: function(projectIndex) { var context = this; this.selectedProject = projectIndex; var as = this.refContainer().find("a"); as.each(function() { $(this).removeClass(context.NUMREF_ACTIVE_CLASS); $(this).addClass(context.NUMREF_INACTIVE_CLASS); }); //mark selected project as.eq(projectIndex).addClass(this.NUMREF_ACTIVE_CLASS); as.eq(projectIndex).removeClass(this.NUMREF_INACTIVE_CLASS); //change header + background image var header = this.projectHeaderContainer(); var project = this.projects[projectIndex]; var image = this.projectImageContainer(); var detail = this.projectDetailContainer(); header.attr("href", project.url); header.html(project.name); detail.attr("href", project.url); //image.css("background", "transparent url('/resizeimage.php?url=" + project.img + "&w=468&h=350') no-repeat scroll 0 0"); image.css("background", "transparent url('" + project.img + "') no-repeat scroll 0 0"); }, generateOnLoaded: function(data) { try{ projects = eval("(" + data + ")"); this.generateWidget(projects); }catch(err){ //invalid json return; } } }; function initIdeveloper() { IdeveloperRefs.init(PRURL, MAX_REFERENCES, TIMER_DELAY); } var pozice = new Array(); var vyska = new Array(); var nahledy = new Array(); var rekurze = new Array(); function posun_vlevo(container,neverstop) { var Obj = document.getElementById(container); var innerObj = document.getElementById(container + '-inner'); pozice[container] = (pozice[container]) ? pozice[container] : 0; vyska[container] = innerObj.clientWidth; nahledy[container] = Obj.offsetWidth; innerObj.style.left = pozice[container] + 3 + 'px'; pozice[container] += 3; if (pozice[container] <= 0) { rekurze[container] = setTimeout('posun_vlevo("' + container + '",' + neverstop + ')', 30); } else { if (rekurze[container]) { clearTimeout(rekurze[container]); } innerObj.style.left = 0 + 'px'; if( neverstop ) { posun_vpravo(container,neverstop); } } } function posun_vpravo(container,neverstop) { var Obj = document.getElementById(container); var innerObj = document.getElementById(container + '-inner'); pozice[container] = (pozice[container]) ? pozice[container] : 0; nahledy[container] = Obj.offsetWidth; vyska[container] = innerObj.clientWidth; // IE neni schopen zjistit vysku dynamicky nastaveneho divu, // ale nedela mu problem pevne nastaveni urcite vysky a posun na jinou vysku // nechapu proc, ale funguje to if (vyska[container] == 0) { innerObj.style.height = nahledy[container]; vyska[container] = nahledy[container]; } innerObj.style.left = pozice[container] - 3 + 'px'; pozice[container] -= 3; if (Math.abs(pozice[container]) <= (vyska[container] - nahledy[container] + 10)) { rekurze[container] = setTimeout('posun_vpravo("' + container + '",' + neverstop + ')', 30); } else { if (rekurze[container]) { clearTimeout(rekurze[container]); } innerObj.style.left = (vyska[container] - nahledy[container]) * (-1) - 10 + 'px'; if( neverstop ) { posun_vlevo(container,neverstop); } } } function zastav(container) { if (rekurze[container]) { clearTimeout(rekurze[container]); } } // Heatmap function initHeatmap() { var deferred = $.post( "/utils/price-maps-proxy/index/", // url "", // data function(data) { if(typeof data == "error") { targetNode.innerHTML = "An unexpected error occurred: " + data; } else { var div = document.createElement('div'); div.id = 'heatmap_container'; div.setAttribute("style", "height: 48px; width: 991px; margin-bottom: 19px;"); div.innerHTML = data; if (document.getElementById('mapa')) { var mapa = document.getElementById('mapa'); mapa.style.marginBottom = "0px"; mapa.style.borderBottom = "none"; mapa.parentNode.appendChild(div); } load_cm_config(); } }, // callback "text" // type ); }