/* 
   Biblionetz-Skripte Version 006
   aktiv ab 15.07.2011
   muss Google-Suche nicht mehr dynamisch updaten
   
   Neu ab 05:
   Cookie für Zustand der Ein- und Ausklappungen der Menus
   
   Neu ab 04:
   - CoverFlow
   - jQuery Plugin für h2-collapse
*/   


function fontsize2(obj, dim) {
    if (dim== 'aph') {daten = eval(obj +'_aph'); factor = 15;}
    if (dim== 'kb')  {daten = eval(obj +'_kb'); factor = 0.5;}
    if (dim== 'ib')  {daten = eval(obj +'_ib'); factor = 0.5;}    
    wCloud = document.getElementById(obj).getElementsByTagName('span');
    for (i = 0 ; i < wCloud.length   ; i++ ) {
       if (dim=='clear') {
           wCloud[i].style.fontSize="100%";
       } else {
           wCloud[i].style.fontSize = (50 + daten[i] * factor) + "%";
       }
    }
}


/*
 * Image preview script 
 * powered by jQuery 
 * 
 * written by Alen Grakalic 
 * http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 
this.imagePreview = function(){	
	/* CONFIG */
		
		xOffset = 10;
		yOffset = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.b,a.t,a.p").hover(function(e){
		var c = "j/" + this.href.match(/[bpt][0-9]{5}/) + ".jpg";
		var t = c.substring(4,5);
			$("body").append("<p id='preview' class='preview-" + t + "'><img src='" + c + "' onerror='previewweg()' alt='Cover' /></p>"); 
			$("#preview")
				.css("top",(e.pageY - xOffset) + "px")
				.css("left",(e.pageX + yOffset) + "px")
				.fadeIn("fast");
    },
	function(){
		$("#preview").remove();
    });	
	$("a.b,a.t,a.p").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};
function previewweg(){$("#preview").remove();};


 function showapplet(name)
 {
 document.getElementById(name).className = "invisible";
 document.getElementById(name + "-applet").className = "applet-visible";
 
 }
  function hideapplet(name)
 {
 document.getElementById(name + "-applet").className = "applet-invisible";
 document.getElementById(name).className = "visible";
 
 };


  



// starting the script on page load
$(document).ready(function(){
	imagePreview();
	
	// Alle Untertitel, welche nicht aktiv sind auf inaktiv setzen
	$("h2:not(.active)").addClass("inactive");
	
	// Vor den ersten Untertitel einen Knopf hinsetzen
	$("h2").first().prev().append ("<button  id=showall>Alle Abschnitte anzeigen</button>");

	// QR-Code einfügen 
	if ($("a[itemprop='url']").attr("href") != undefined) {
		$('body').append("<h2 class='" + $("h2").first().attr("class") + "'><img src='i/i95.png'>QR-Code</h2><div id='qrcode'></div>");
		$('#qrcode').qrcode($("a[itemprop='url']").attr("href"));
	};
	
	
	// Wenn der Aktivieren-Knopf-geklickt wird, dann alle nicht aktiven h2-Titel anklicken und den Text des Buttons anpassen
	$("#showall").click(function() {
		if ($('#showall:contains("anzeigen")').length > 0 ) {
			$("h2:not(.active)").click();
			$("#showall").text('Alle Abschnitte verbergen');
		} else  {
			$("h2:not(.inactive)").click();
			$("#showall").text('Alle Abschnitte anzeigen');
		}
	});		
	
	// Das collapse-Skript initialisieren
	$("body").collapse({cookieName: dateiname});
	


	
	// Bei allen nummerierten Aufzählungen nur die ersten 5 Einträge anzeigen, Rest verbergen
	$("ol").hideextra(); 
	
	$("img[src='i\\/comments.png']").parent().css('display', 'none');
	

  // Sortierknöpfe integrieren für Typ 12	
$(".grid12").parent().prepend ("<div class='sort'><button id='grid12_laenge'>Kürzeste</button><button id='grid12_neuheit'>Neuste</button><button id='grid12_alter'>Älteste</button><button id='grid12_quelle'>Im Biblionetz meistzitierte Quelle</button><button id='grid12_hits'>Im Biblionetz meistabgerufene Quelle</button> zuoberst.</div>");
$("#grid12_laenge").click(function() {$(".grid12 .zitbox").qsort({attr: "laenge", digits: true})});
$("#grid12_neuheit").click(function() {$(".grid12 .zitbox").qsort({attr: "datum", order: "desc"})});
$("#grid12_alter").click(function() {$(".grid12 .zitbox").qsort({attr: "datum"})});
$("#grid12_quelle").click(function() {$(".grid12 .zitbox").qsort({attr: "inbound", digits: true, order: "desc"})});
$("#grid12_hits").click(function() {$(".grid12 .zitbox").qsort({attr: "hits", digits: true, order: "desc"})});

  // Sortierknöpfe integrieren für Typ 15
$(".grid15").parent().prepend ("<div class='sort'><button id='grid15_laenge'>Kürzeste</button><button id='grid15_neuheit'>Neuste</button><button id='grid15_alter'>Älteste</button><button id='grid15_quelle'>Im Biblionetz meistzitierte Quelle</button><button id='grid15_hits'>Im Biblionetz meistabgerufene Quelle</button> zuoberst.</div>");
$("#grid15_laenge").click(function() {$(".grid15 .zitbox").qsort({attr: "laenge", digits: true})});
$("#grid15_neuheit").click(function() {$(".grid15 .zitbox").qsort({attr: "datum", order: "desc"})});
$("#grid15_alter").click(function() {$(".grid15 .zitbox").qsort({attr: "datum"})});
$("#grid15_quelle").click(function() {$(".grid15 .zitbox").qsort({attr: "inbound", digits: true, order: "desc"})});
$("#grid15_hits").click(function() {$(".grid15 .zitbox").qsort({attr: "hits", digits: true, order: "desc"})});

// Dynamische Untermenus
  $("#titelmenu li.p").hover(function() {$('#menubalken').replaceWith('<div class="o01" style="background-color:#ffccff;" id="menubalken"><a href="p_a.html">A</a> <a href="p_b.html">B</a> <a href="p_c.html">C</a> <a href="p_d.html">D</a> <a href="p_e.html">E</a> <a href="p_f.html">F</a> <a href="p_g.html">G</a> <a href="p_h.html">H</a> <a href="p_i.html">I</a> <a href="p_j.html">J</a> <a href="p_k.html">K</a> <a href="p_l.html">L</a> <a href="p_m.html">M</a> <a href="p_n.html">N</a> <a href="p_o.html">O</a> <a href="p_p.html">P</a> <a href="p_q.html">Q</a> <a href="p_r.html">R</a> <a href="p_s.html">S</a> <a href="p_t.html">T</a> <a href="p_u.html">U</a> <a href="p_v.html">V</a> <a href="p_w.html">W</a> <a href="p_x.html">X</a> <a href="p_y.html">Y</a> <a href="p_z.html">Z</a> <small><a href="p_all.html">Alle</a> <a href="p_linked.html">Meistvernetzte</a> <a href="p_visited.html">Meistgesuchte</a> <a href="p_mit.html">Mit Biblionetz-Seite</a></small> </div>')});
  $("#titelmenu li.b").hover(function() {$('#menubalken').replaceWith('<div class="o02" style="background-color:#ffcc99" id="menubalken"><a href="b_0.html">0-9</a> <a href="b_a.html">A</a> <a href="b_b.html">B</a> <a href="b_c.html">C</a> <a href="b_d.html">D</a> <a href="b_e.html">E</a> <a href="b_f.html">F</a> <a href="b_g.html">G</a> <a href="b_h.html">H</a> <a href="b_i.html">I</a> <a href="b_j.html">J</a> <a href="b_k.html">K</a> <a href="b_l.html">L</a> <a href="b_m.html">M</a> <a href="b_n.html">N</a> <a href="b_o.html">O</a> <a href="b_p.html">P</a> <a href="b_q.html">Q</a> <a href="b_r.html">R</a> <a href="b_s.html">S</a> <a href="b_t.html">T</a> <a href="b_u.html">U</a> <a href="b_v.html">V</a> <a href="b_w.html">W</a> <a href="b_x.html">X</a> <a href="b_y.html">Y</a> <a href="b_z.html">Z</a> <small><a href="b_all.html">Alle</a> <a href="b_linked.html">Meistvernetzte</a> <a href="b_visited.html">Meistgesuchte</a> <a href="b_owned.html">Physisch Neue</a> <a href="b_added.html">Virtuell Neue</a> <a href="b_matur.html">Matur</a> <a href="b_da.html">DA</a> <a href="b_phd.html">PhD</a> <a href="b_conf.html">Conf</a> <a href="b_film.html">Filme</a> <a href="b_zines.html">Zeitschriften</a> <a href="b_ausgeliehen.html">Ausgeliehene</a></small> </div>')});
  $("#titelmenu li.t").hover(function() {$('#menubalken').replaceWith('<div class="o03" style="background-color:#ffcc66;" id="menubalken">&nbsp; </div>')});
  $("#titelmenu li.f").hover(function() {$('#menubalken').replaceWith('<div class="o04" style="background-color:#CCFFCC;" id="menubalken">&nbsp; </div>')});
  $("#titelmenu li.a").hover(function() {$('#menubalken').replaceWith('<div class="o05" style="background-color:#99FFCC;" id="menubalken">&nbsp; </div>')});		
  $("#titelmenu li.w").hover(function() {$('#menubalken').replaceWith('<div class="o08" style="background-color:#ccffff" id="menubalken"><a href="w_abk.html">Abkürzungen</a> <a href="w_a.html">A</a> <a href="w_b.html">B</a> <a href="w_c.html">C</a> <a href="w_d.html">D</a> <a href="w_e.html">E</a> <a href="w_f.html">F</a> <a href="w_g.html">G</a> <a href="w_h.html">H</a> <a href="w_i.html">I</a> <a href="w_j.html">J</a> <a href="w_k.html">K</a> <a href="w_l.html">L</a> <a href="w_m.html">M</a> <a href="w_n.html">N</a> <a href="w_o.html">O</a> <a href="w_p.html">P</a> <a href="w_q.html">Q</a> <a href="w_r.html">R</a> <a href="w_s.html">S</a> <a href="w_t.html">T</a> <a href="w_u.html">U</a> <a href="w_v.html">V</a> <a href="w_w.html">W</a> <a href="w_x.html">X</a> <a href="w_y.html">Y</a> <a href="w_z.html">Z</a> <a href="w_all.html">Alle</a> <a href="w_lat.html">Lateinische</a> <a href="w_defined.html">Definierte</a> <a href="w_linked.html">Meistvernetzte</a> <a href="w_visited.html">Meistgesuchte</a></div>')});
  $("#titelmenu li.g").hover(function() {$('#menubalken').replaceWith('<div class="o17" style="background-color:#ffffaa;" id="menubalken">&nbsp; </div>')});		
  $("#titelmenu li.hit").hover(function() {$('#menubalken').replaceWith('<div class="o20" style="background-color:silver;" id="menubalken">&nbsp; </div>')});		
  $("#titelmenu li.news").hover(function() {$('#menubalken').replaceWith('<div class="o21" style="background-color:silver;" id="menubalken">&nbsp; </div>')});		
  
   if (window.location.protocol == 'http:') {
  	$('#titelmenu').before('<g:plusone></g:plusone>');
  	$.getScript("https://apis.google.com/js/plusone.js");
   }
   
   
});


