function supports_history_api() { return !!(window.history && history.pushState); } function swapPhoto(href) { var req = new XMLHttpRequest(); req.open("GET", href+'?call=ajax', false); req.send(null); if (req.status == 200) { document.getElementById("galWrapper").innerHTML = req.responseText; setupHistoryClicks(); hidead(); autoPlay(); //alert(href.indexOf("-related")); if(href.indexOf("-related")!=-1) {//alert('abc'); setTimeout(function(){ $('#next_timer').html('4 Secs');}, 1000); setTimeout(function(){ $('#next_timer').html('3 Secs');}, 2000); setTimeout(function(){ $('#next_timer').html('2 Secs');}, 3000); setTimeout(function(){ $('#next_timer').html('1 Secs');}, 4000); var element = Math.floor(Math.random()*8); $('.VideosRowphoto .storyImg').each( function(index) { var href = $(this).attr('href'); if(index==element){ var gal_id = href.replace(/.*?-(\d+)(-\d+|-related)*(\.html)/,"\$1"); $("#next_gallery_id").val(gal_id); $("#next_gallery").val(href); } }); var cname ='__autoplay_it_'+$("#next_gallery_id").val(); Set_Cookie(cname, 1, 1, '/'); setTimeout('loadNext()', 6000); } //eval($("#rhs_banner1").html()); var pageT = $("#pagetitle").val(); $(document).attr('title', pageT); var pagega=href.replace('http://'+document.domain,""); var pagega=pagega.replace('http://www.indiatimes.com',""); var pgcustom = window.location.pathname; var pgcustom=pgcustom.replace(/(.*?-\d+)(-\d+|-related)*(\.html)/,"\$1\$3"); var pgcustom =unescape(pgcustom); _gaq.push(['_setCustomVar', 1, 'Photogallery', pgcustom,3 ]); _gaq.push(['_trackPageview', pagega]); $.getJSON(ga_cnt_upt_req_url, function(data){}); //photoprevnext(); fblike(href); twlike(href); gpolike(href); // alert(slot1); alert(slot2); googletag.pubads().refresh([slot1,slot2]); var missindia =$('#AdFrame').attr('src'); $('#AdFrame').attr('src',missindia); return true; } return false; } function addClicker(link) { link.addEventListener("click", function(e) { if (swapPhoto(link.href)) { history.pushState(null, null, link.href); e.preventDefault(); } }, true); } function addClickerpic(link,nextlink) { link.addEventListener("click", function(e) { if (swapPhoto(nextlink.href)) { history.pushState(null, null, nextlink.href); e.preventDefault(); } }, true); } function setupHistoryClicks() { if(document.getElementById("nxt")) { addClickerpic(document.getElementById("arrnxt"),document.getElementById("nxt")); } if(document.getElementById("prvs")) { if(document.getElementById("galpics")) { addClickerpic(document.getElementById("arrprvs"),document.getElementById("prvs")); } } var pagenums = document.getElementsByClassName("numbers"); for(var i = 0, j=pagenums.length; i -1; if( is_chrome && !$('body').data('allow-popstate-action') ) { $('body').data('allow-popstate-action', true); return false; } swapPhoto('http://'+document.domain+location.pathname); }, false); }, 500); } document.addEventListener('keydown', function(e){ if (e.keyCode == 37 && $(document.activeElement).attr("type") != "textarea" && $(document.activeElement).attr("type") != "text") { if($('#prvs').attr('href')){ $('#prvs').fireEvent('click'); return false; } } if (e.keyCode == 39 && $(document.activeElement).attr("type") != "textarea" && $(document.activeElement).attr("type") != "text") { if($('#nxt').attr('href')){ $('#nxt').fireEvent('click'); return false; } } }, false); function fblike(href) { var fb = document.createElement('fb:like'); fb.setAttribute("data-href", href); fb.setAttribute("data-layout", "box_count"); fb.setAttribute("show_faces", "true"); fb.setAttribute("data-show-faces", "true"); fb.setAttribute("data-width", "100"); fb.setAttribute("font", "arial"); var fDiv = document.getElementById("widget-fb"); fDiv.removeChild(fDiv.childNodes[0]); document.getElementById("widget-fb").appendChild(fb); if (typeof FB !== 'undefined') { FB.XFBML.parse(document.getElementById('widget-fb')); } } function twlike(href) { if (typeof (twttr) !== 'undefined') { $('#widget-twt').empty(); $('#widget-twt').html('Tweet'); twttr.widgets.load(); } } function gpolike(href) { if (typeof (gapi) !== 'undefined') { $('#___plusone_0').empty(); var el = document.getElementById("___plusone_0"); gapi.plusone.render(el, { 'size': 'tall', 'href': href }); // $('#widget-gplus').css('overflow', 'hidden'); } } (function($, undefined) { $.fireEvent = function(el, eventName, opt) { if (el === undefined) return false; if('jquery' in el){ el = el[0]; } if(!evts[eventName]){ return false; } var evt; if (typeof(document.createEvent) != 'undefined') {//W3C way evt = document.createEvent(evts[eventName].w3c); evts[eventName].initEvt(evt, el, opt); el.dispatchEvent(evt); } else {//IE if (eventName == 'click') { // we use jquery to fire the click event because of a bug in IE7-8 $(el).click(); } else { el.fireEvent(evts[eventName].ie); } } }; $.fn.fireEvent = function(eventName, opt) { if (this.length == 0) return this; $.fireEvent.call({},this[0], eventName, opt); return this; }; /* -- Event cross-browser implementation -- */ var evts = { 'click': {//Tested/Work with Firefox 3.6 & Safari 5.0.1 & Chromium 6.0 ie: 'onclick', w3c: 'MouseEvents', initEvt: function(evt, target, opt) { var _def = $.extend({ type: 'click', canBubble: true, cancelable: true, view: window, detail: 1, screenX: 1, screenY: 1, clientX: 1, clientY: 1, ctrlKey: false, altKey: false, shiftKey: false, metaKey: false, button: 0, relatedTarget: target}, opt); evt.initMouseEvent(_def.type, _def.canBubble, _def.cancelable, _def.view, _def.detail, _def.screenX, _def.screenY, _def.clientX, _def.clientY, _def.ctrlKey, _def.altKey, _def.shiftKey, _def.metaKey, _def.button, _def.relatedTarget); } }, }; })(jQuery);