function fix_external_links() { // assign external link popup warnings $("#content a[href^='http']").click( function() { if ($(this).attr('rel') == 'coupon') { load_facebox_page('leaving-coupons', $(this).attr('href'), $(this).attr('rel')); return false; } else if ($(this).attr('rel') != 'safe') { load_facebox_page('leaving', $(this).attr('href'), $(this).attr('rel')); return false; } else return true; }); } function assign_sub_nav_button_hovers() { // assign the hovers to non-active buttons $("#bottom-nav img[class!=active]").hover(function() { if ($(this).attr("class") != 'exclude') $(this).attr("src", $(this).attr("src").split(".").join("_on.")); }, function() { $(this).attr("src", $(this).attr("src").split("_on.").join(".")); }); // assign the active buttons $("#bottom-nav img[class=active]").each(function() { $(this).attr("src", $(this).attr("src").split(".").join("_on.")); }); } function assign_other_hovers() { // assign the hovers to non-active buttons $("#content img[class=hover], #header img[class=hover]").hover(function() { $(this).attr("src", $(this).attr("src").split(".").join("_on.")); }, function() { $(this).attr("src", $(this).attr("src").split("_on.").join(".")); }); } function fix_hr_in_ie() { $('hr').wrap('
'); } function urlencode( str ) { var histogram = {}, tmp_arr = []; var ret = str.toString(); var replacer = function(search, replace, str) { var tmp_arr = []; tmp_arr = str.split(search); return tmp_arr.join(replace); }; // The histogram is identical to the one in urldecode. histogram["'"] = '%27'; histogram['('] = '%28'; histogram[')'] = '%29'; histogram['*'] = '%2A'; histogram['~'] = '%7E'; histogram['!'] = '%21'; histogram['%20'] = '+'; // Begin with encodeURIComponent, which most resembles PHP's encoding functions ret = encodeURIComponent(ret); for (var search in histogram) { replace = histogram[search]; ret = replacer(search, replace, ret); // Custom replace. No regexing } // Uppercase for full PHP compatibility return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) { return "%"+m2.toUpperCase(); }); return ret; } function load_facebox_page(page, arg, rel) { var html = $.ajax({ url: "/popup/"+page+".jsp?arg="+urlencode(arg), async: false }).responseText; $.facebox(html, rel); } function alter_stylesheet(size) { setActiveStyleSheet(size); $('#sizer_image').attr('src', '/resources/images/font_'+size+'.gif'); } function setActiveStyleSheet(title) { var i, a, main; for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) { a.disabled = true; if(a.getAttribute("title") == title) {a.disabled = false; createCookie("style", title, 365)} } } } function getPreferredStyleSheet() { return null; } function getActiveStyleSheet() { var i, a; for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title"); } return null; } function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else 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 read_style() { var cookie = readCookie("style"); var title = cookie ? cookie : 'medium'; alter_stylesheet(title); } $(document).ready(function(){ fix_external_links(); assign_sub_nav_button_hovers(); assign_other_hovers(); fix_hr_in_ie(); read_style(); });