function markTypes(elm) { type = $(elm).attr('tname'); selected = ($(elm).attr('chosen') == 'false'); doTypeMarking(type,selected); } function doTypeMarking(type,selected) { elm = document.getElementById('types_'+ type); if(selected) { $(elm).attr('src','/imgs/design/epg/markers/'+ type +'Selected.gif'); $(elm).attr('chosen','true'); $('img[pType='+type+']').show(); } else { $(elm).attr('src','/imgs/design/epg/markers/'+ type +'.gif'); $(elm).attr('chosen','false'); $('img[pType='+type+']').hide(); } //saves the mark for next pageload marked = readCookie('markTypes'); if(marked == null) marked = '1,1,1,1,1,1'; myTypeMarking = marked.split(','); switch(type) { case 'movie': i = 0; break; case 'serie': i = 1; break; case 'sport': i = 2; break; case 'documentary': i = 3; break; case 'news': i = 4; break; case 'kids': i = 5; break; } myTypeMarking[i] = selected?1:0; myTypeMarkingString = myTypeMarking.join(','); saveCookie('markTypes',myTypeMarking,356); } //do marking function initTypeMarking() { marked = readCookie('markTypes'); if(marked == null) marked = '1,1,1,1,1,1'; var myTypeMarking = marked.split(','); if((myTypeMarking[0]!=1)) doTypeMarking('movie',false); if((myTypeMarking[1]!=1)) doTypeMarking('serie',false); if((myTypeMarking[2]!=1)) doTypeMarking('sport',false); if((myTypeMarking[3]!=1)) doTypeMarking('documentary',false); if((myTypeMarking[4]!=1)) doTypeMarking('news',false); if((myTypeMarking[5]!=1)) doTypeMarking('kids',false); } initTypeMarking(); function saveCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { createCookie(name,"",-1); } /** * Counts a like (or dislike) for logged in user. * Must be called for a container that can have added the class ui-state-highlight if liked or removed the class ui-state-highlight if not like anymore * * @param int id of program to like (or dislike if user already likes it) **/ function like(id, buttonElm) { $(buttonElm).find('img').attr('src', '/imgs/icons/loading.gif'); $.post('/scripts/epg/like.php', {id:id}, function(res) { if(isNaN(res)) { alert(res); } else { if(res == -1) { $(buttonElm).find('img').attr('src', '/imgs/icons/like.png'); $(buttonElm).find('a').html("Recommend"); if(typeof(__ontv_summary) == 'object') { if(typeof(__ontv_summary.loaded[id]) == 'object') { __ontv_summary.loaded[id].like = "FALSE"; } } } else { $(buttonElm).find('img').attr('src', '/imgs/icons/likes.png'); $(buttonElm).find('a').html("Don't recommend"); if(typeof(__ontv_summary) == 'object') { if(typeof(__ontv_summary.loaded[id]) == 'object') { __ontv_summary.loaded[id].like = "TRUE"; } } } } }); }