$(document).ready(function(){ if($(".entry_preview").attr("class")){ $("body").prepend("<div class=\"switch_source\" style=\"visibility: hidden;\"><a id=\"source\"" + (!read_cookie("switch_source") || read_cookie("switch_source") == "source" ? " class=\"switch_source_selected\"" : "") + ">Quelle</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a id=\"cache\"" + (read_cookie("switch_source") == "cache" ? " class=\"switch_source_selected\"" : "") + ">Cache</a>"); $(".switch_source a").click(function(){ if((!read_cookie("switch_source") && $(this).attr("id") == "cache") || (read_cookie("switch_source") && $(this).attr("id") != read_cookie("switch_source"))){ $(".switch_source a").attr("class",""); $(".switch_source a[id=" + $(this).attr("id") + "]").attr("class","switch_source_selected"); document.cookie = "switch_source=" + $(this).attr("id"); if($(this).attr("id") == "cache") var new_url = "http://www.acsearch.info/ext_record.html?url=" + encodeURIComponent($(".entry_preview").attr("src")); else var new_url = decodeURIComponent($(".entry_preview").attr("src").split("url=")[1]); $(".entry_preview").attr("src",new_url); } }); fix_elements(); $(window).resize(function(){ fix_elements(); }); $(".entry_list div[class!=page_numbers]").click(function(){ preview(this); }); var get_id = window.location.href.split("#"); preview($(".entry_list div[class!=page_numbers]:eq(" + (get_id[1] ? get_id[1] : "0") + ")")); if(get_id[1]) $(".entry_list").animate({scrollTop: $(".entry_list div:has(font[id!=]):eq(" + get_id[1] + ")").position().top-$(".entry_list").position().top}); } }); function fix_elements(){ var list_position_top = $(".entry_list").position().top; var list_height = $(window).height()-list_position_top-1; $(".entry_list").css("height",list_height+"px"); $(".entry_preview").css("height",list_height+"px"); $(".preview_search_table").css("width",$(window).width()+"px"); $(".switch_source").css({ "top" : list_position_top+"px", "right" : "50px" }); } function preview(objct){ $(".entry_list div[class!=page_numbers]").css({ "padding" : "2px 2px 2px 2px;", "background-color" : "transparent", "border-width" : "0px;" }); $(objct).css({ "padding" : "1px 1px 1px 1px;", "background-color" : "#E4E2D7", "border-width" : "1px;" }); var this_url = $(objct).find("font[id!=]").attr("id"); if(read_cookie("switch_source") && read_cookie("switch_source") == "cache") this_url = "http://www.acsearch.info/ext_record.html?url=" + encodeURIComponent(this_url); $(".entry_preview").attr("src",this_url); window.location.href = window.location.href.split("#")[0] + "#" + (($(".entry_list div:has(font[id!=])").length-1)-$(objct).nextAll("div:has(font[id!=])").length); } function read_cookie(c_name){ var c_value = document.cookie; var c_split = c_value.split(";"); for(i=0;i<c_split.length;i++){ var c_s_split = c_split[i].split("="); if(c_name == $.trim(c_s_split[0])) return c_s_split[1]; } return false; }