/*
Javascript Document BilderBox (Plaktate und Flickr)

Spezifikation: 		Scroller
Code:				Martin Heyde
letzte Aenderung:	30.Jan. 2009

*/

//Variablen zum Aendern

var PB_time_btw_scroll = 4500;			//Zeit in ms die ein Bild angezeigt bleiben soll
var PB_time_scroll_picture = 2000;		//Zeit min ms, die der Scroll an sich dauert
var PB_picture_width = 690;				//Breite des Bildesin px
var PB_gesamtBreite_pictureBTW = 700;	//BUGFIX AUF DIE SCHNELLE		
var PB_margin_right = 1;				//Abstand zwischen den Bildern in px
var PB_show_description = true;			//Beschreibung anhand des Title-Tags des Bildes zuschaltbar (true,false)
var PB_show_Navigation = true;			//Navigation anzeigen oder ausblenden (true,false)
var PB_Navigator_max_Size = 10;			//Anzahl der anzuzeigenden Navigationselementen > 0



//Quellcode - hier nix Aendern
var zaehler = 1;
var zaehlerBTW = 1;
var PB_gesamtBreite_picture = PB_picture_width + PB_margin_right;
var myInterval = window.setInterval("Slideshow()", PB_time_btw_scroll);
var myIntervalBTW = window.setInterval("SlideshowBTW()", PB_time_btw_scroll);

  $(document).ready(function(){
  
  //Flickr WidgetLeistenPlugin
  
  if(document.getElementById("FDPSommerTour09_Pics")) { 
   	$("#FDPSommerTour09_Pics").flickr2();
  	$("#FDPSommerTour09_Pics ul").css('cursor','pointer').click(function(){
  		location.href = DBName + '/Inhalt/Sommertour2009';
  	});
  }
  
  if(document.getElementById("FDPMotorradTour09_Pics")) { 
   	$("#FDPMotorradTour09_Pics").flickr3();
  	$("#FDPMotorradTour09_Pics ul").css('cursor','pointer').click(function(){
  		location.href = DBName + '/Inhalt/Motorradtour';
  	});
  }
  
  //Breite der Scrollbox festlegen PLAKATE LANDTAGSWAHL
	if(document.getElementById("FDP_PlakatViewer_Scrollbereich")){
		var bildbereich = document.getElementById("FDP_PlakatViewer_Scrollbereich");
		var x = bildbereich.getElementsByTagName("img").length+1;
		bildbereich.style.width = (PB_gesamtBreite_picture * x) + "px";
		bildbereich.style.left = "-" + PB_gesamtBreite_picture + "px";
		
		//Descriptionfeld hinzuf\u00FCgen
	  	if(PB_show_description == true){
			  var inhalt = bildbereich.getElementsByTagName("img")[0].getAttribute("title");
			  document.getElementById("FDP_PlakatViewer_Information").innerHtml=inhalt;
	  	}
	  		  	
	  	//ausblenden, wenn gew\u00FCnscht
	  	else {document.getElementById("FDP_PlakatViewer_Information").style.display = "none";}
	
		//Navigation ausblenden, wenn gew\u00FCnscht
		if(PB_show_Navigation == false){
			document.getElementById("FDP_PlakatViewer_Navigator").style.display = "none";
		}
	
	
	
		//ID f\u00FCr Bilder anlegen
		for (var i=0; i < bildbereich.getElementsByTagName("img").length; i++)
		{
			var zahl = parseInt(i)+1;
			bildbereich.getElementsByTagName("img")[i].setAttribute("id", "b" + zahl);
		}
	
		//Bild am Anfang einf\u00FCgen -- f\u00FCr natlosen \u00C3\u0153bergang
		 var doppelBild = document.getElementById("b" + zahl).cloneNode(true);
		 bildbereich.insertBefore(doppelBild, document.getElementById("b1"));
		 //und noch die ID \u00C3\u00A4ndern
		 bildbereich.getElementsByTagName("img")[0].setAttribute("id","b0");
	
		//Bildern den Abstand zuweisen
		for(var marginZahl = 0; marginZahl < x-1; marginZahl++){
			bildbereich.getElementsByTagName("img")[marginZahl].style.marginRight = PB_margin_right + "px";
		}
	
	//Links f\u00C3\u00BCr die Bilder generieren
	for(var lnr = 1; lnr < x; lnr++){
		//Link anlegen
		var PBlink = document.createElement("a");
		var PBlinktext = lnr -1;
		//Text im Link anlegen
		var zahlKnoten = document.createTextNode(lnr);
		//Link einh\u00C3\u00A4gen
		var navi = document.getElementById("FDP_PlakatViewer_Navigator");
		navi.appendChild(PBlink);
  		//Attribute an Link anh\u00C3\u00A4ngen
		navi.getElementsByTagName("a")[PBlinktext].setAttribute("id", "n"+ lnr);
		navi.getElementsByTagName("a")[PBlinktext].setAttribute("href", "#");
		navi.getElementsByTagName("a")[PBlinktext].onclick = new Function("F","linkKlick('"+ PBlinktext +"'); return false;");
		//Textknoten an Link anh\u00C3\u00A4ngen
		navi.getElementsByTagName("a")[PBlinktext].appendChild(zahlKnoten);
		} 
	
	//Navigatorelemente die gr\u00C3\u00B6\u00C3\u0178er als PB_Navigator_max_Size sind ausblenden
	if(navi.getElementsByTagName("a").length > PB_Navigator_max_Size) {
	for(var ab = PB_Navigator_max_Size; ab < navi.getElementsByTagName("a").length; ab++){
		navi.getElementsByTagName("a")[ab].style.display = "none";
		}
	}
	
	
	//AN-AUS-Button einrichten
	if(bildbereich.getElementsByTagName("img").length > 1){
		//Link anlegen
		var SSBTN = document.createElement("a");
		//Text im Link anlegen
		
		//Link einh\u00C3\u00A4gen
		navi.appendChild(SSBTN);
  		//Attribute an Link anh\u00C3\u00A4ngen
		var y = navi.getElementsByTagName("a").length -1;
		navi.getElementsByTagName("a")[y].setAttribute("id", "FDP_PlakatViewer_SSBTN");
		var btn = document.getElementById("FDP_PlakatViewer_SSBTN")
		btn.setAttribute("href", "#");
		btn.onclick = new Function("F","onoffSwitch('0'); return false;");
		
		//Textknoten an Link anh\u00C3\u00A4ngen
		btn.className = "stop";
				
		}
	
	//ersten Link aktiv setzen
	var navigation = document.getElementById("FDP_PlakatViewer_Navigator");
	navigation.getElementsByTagName("a")[0].className = "aktiv";
	
	}
	else {
		window.clearInterval(myInterval);}
		
		
		
	//Breite der Scrollbox festlegen PLAKATE BUNDESTAGSWAHL
	if(document.getElementById("FDP_PlakatViewer_ScrollbereichBTW")){
		var bildbereich = document.getElementById("FDP_PlakatViewer_ScrollbereichBTW");
		var x = bildbereich.getElementsByTagName("img").length+1;
		bildbereich.style.width = (PB_gesamtBreite_pictureBTW * x) + "px";
		bildbereich.style.left = "-" + PB_gesamtBreite_picture + "px";
		
		//Descriptionfeld hinzuf\u00FCgen
	  	if(PB_show_description == true){
			  var inhalt = bildbereich.getElementsByTagName("img")[0].getAttribute("title");
			  document.getElementById("FDP_PlakatViewer_InformationBTW").innerHtml=inhalt;
	  	}
	  		  	
	  	//ausblenden, wenn gew\u00FCnscht
	  	else {document.getElementById("FDP_PlakatViewer_InformationBTW").style.display = "none";}
	
		//Navigation ausblenden, wenn gew\u00FCnscht
		if(PB_show_Navigation == false){
			document.getElementById("FDP_PlakatViewer_NavigatorBTW").style.display = "none";
		}
	
	
	
		//ID f\u00FCr Bilder anlegen
		for (var i=0; i < bildbereich.getElementsByTagName("img").length; i++)
		{
			var zahl = parseInt(i)+1;
			bildbereich.getElementsByTagName("img")[i].setAttribute("id", "btw" + zahl);
		}
	
		//Bild am Anfang einf\u00FCgen -- f\u00FCr natlosen \u00C3\u0153bergang
		 var doppelBild = document.getElementById("btw" + zahl).cloneNode(true);
		 bildbereich.insertBefore(doppelBild, document.getElementById("btw1"));
		 //und noch die ID \u00C3\u00A4ndern
		 bildbereich.getElementsByTagName("img")[0].setAttribute("id","btw0");
	
		//Bildern den Abstand zuweisen
		for(var marginZahl = 0; marginZahl < x-1; marginZahl++){
			bildbereich.getElementsByTagName("img")[marginZahl].style.marginRight = PB_margin_right + "px";
		}
	
	//Links f\u00C3\u00BCr die Bilder generieren
	for(var lnr = 1; lnr < x; lnr++){
		//Link anlegen
		var PBlink = document.createElement("a");
		var PBlinktext = lnr -1;
		//Text im Link anlegen
		var zahlKnoten = document.createTextNode(lnr);
		//Link einh\u00C3\u00A4gen
		var navi = document.getElementById("FDP_PlakatViewer_NavigatorBTW");
		navi.appendChild(PBlink);
  		//Attribute an Link anh\u00C3\u00A4ngen
		navi.getElementsByTagName("a")[PBlinktext].setAttribute("id", "nbtw"+ lnr);
		navi.getElementsByTagName("a")[PBlinktext].setAttribute("href", "#");
		navi.getElementsByTagName("a")[PBlinktext].onclick = new Function("F","linkKlickBTW('"+ PBlinktext +"'); return false;");
		//Textknoten an Link anh\u00C3\u00A4ngen
		navi.getElementsByTagName("a")[PBlinktext].appendChild(zahlKnoten);
		} 
	
	//Navigatorelemente die gr\u00C3\u00B6\u00C3\u0178er als PB_Navigator_max_Size sind ausblenden
	if(navi.getElementsByTagName("a").length > PB_Navigator_max_Size) {
	for(var ab = PB_Navigator_max_Size; ab < navi.getElementsByTagName("a").length; ab++){
		navi.getElementsByTagName("a")[ab].style.display = "none";
		}
	}
	
	
	//AN-AUS-Button einrichten
	if(bildbereich.getElementsByTagName("img").length > 1){
		//Link anlegen
		var SSBTN = document.createElement("a");
		//Text im Link anlegen
		
		//Link einh\u00C3\u00A4gen
		navi.appendChild(SSBTN);
  		//Attribute an Link anh\u00C3\u00A4ngen
		var y = navi.getElementsByTagName("a").length -1;
		navi.getElementsByTagName("a")[y].setAttribute("id", "FDP_PlakatViewer_SSBTNBTW");
		var btn = document.getElementById("FDP_PlakatViewer_SSBTNBTW")
		btn.setAttribute("href", "#");
		btn.onclick = new Function("F","onoffSwitchBTW('0'); return false;");
		
		//Textknoten an Link anh\u00C3\u00A4ngen
		btn.className = "stop";
				
		}
	
	//ersten Link aktiv setzen
	var navigation = document.getElementById("FDP_PlakatViewer_NavigatorBTW");
	navigation.getElementsByTagName("a")[0].className = "aktiv";
	
	}
	else {
		window.clearInterval(myIntervalBTW);}
	
  });
  
//LTW	
function gotoBild(zaehler){
	  var linksscroll = zaehler * PB_gesamtBreite_picture + PB_gesamtBreite_picture;
	  var zaehlerx = parseInt(zaehler) + 1;
	  var navigation = document.getElementById("FDP_PlakatViewer_Navigator");
	  //Navigator anpassen
		if(parseInt(zaehler) > parseInt(PB_Navigator_max_Size)-1 && (parseInt(zaehler)) % PB_Navigator_max_Size == 0 ) {
			for (var ss = 0; ss < parseInt(PB_Navigator_max_Size); ss++){
				var navipunkt_hide2 = parseInt(zaehler) - parseInt(ss) -1;
				var navipunkt_show2 = parseInt(zaehler) + ss;
				navigation.getElementsByTagName("a")[navipunkt_hide2].style.display = "none";
				if(navipunkt_show2 < navigation.getElementsByTagName("a").length)
				{
				navigation.getElementsByTagName("a")[navipunkt_show2].style.display = "block";
				}
			}
		 }	
	  
	  $("#FDP_PlakatViewer_Scrollbereich").animate( { left: "-" +linksscroll + "px"}, {duration : PB_time_scroll_picture, easing: "easeInOutBack"});
	  var bildbereich = document.getElementById("FDP_PlakatViewer_Scrollbereich");
	  
	  //Descriptionfeld hinzuf\u00C3\u00BCgen und f\u00C3\u00BCllen
	  if(PB_show_description == true){
	  var inhalt = bildbereich.getElementsByTagName("img")[zaehlerx].getAttribute("title");
	  document.getElementById("FDP_PlakatViewer_Information").innerHtml=inhalt;
	  }
	  else {document.getElementById("FDP_PlakatViewer_Information").style.display = "none";}
	
	}

	
function linkKlick(zaehler1){
	onoffSwitch(0); 
	zaehler = zaehler1;
	Slideshow();
	
	}
	
function Slideshow() {
	if(document.getElementById("FDP_PlakatViewer_Scrollbereich")){
		var navigation = document.getElementById("FDP_PlakatViewer_Navigator");
		  for (var i=0; i < navigation.getElementsByTagName("a").length-1; i++)
			{
				navigation.getElementsByTagName("a")[i].className = "";
			}
		  //aktiven Links einf\u00C3\u00A4rben
		  if( zaehler < navigation.getElementsByTagName("a").length -1){
		  navigation.getElementsByTagName("a")[zaehler].className = "aktiv";
		  //Bilderscroll ausf\u00C3\u00BChren
		  gotoBild(zaehler);
		  zaehler ++;
		}
		else {
			zaehler = 0;
			document.getElementById("FDP_PlakatViewer_Scrollbereich").style.left="1px";
			navigation.getElementsByTagName("a")[zaehler].className = "aktiv";
			gotoBild(zaehler);
			if(navigation.getElementsByTagName("a").length > PB_Navigator_max_Size) {
					for(var ab = PB_Navigator_max_Size; ab < navigation.getElementsByTagName("a").length -1; ab++){
						navigation.getElementsByTagName("a")[ab].style.display = "none";
					}
					for(var ac = 0; ac < PB_Navigator_max_Size; ac++) {
						navigation.getElementsByTagName("a")[ac].style.display = "block";
					}
				}
			zaehler = 1;
		}
	}
}

function onoffSwitch(a) {
	var cngBTN = document.getElementById("FDP_PlakatViewer_SSBTN");
	
	if(a == 0)
	{
		//Ausmachen
		window.clearInterval(myInterval);
		cngBTN.onclick = new Function("F","onoffSwitch('1'); return false;");
		cngBTN.className = "play";
	}
	else 
	{
		//Anmachen
		myInterval = window.setInterval("Slideshow()", PB_time_btw_scroll);
		cngBTN.onclick = new Function("F","onoffSwitch('0'); return false;");
		cngBTN.className = "stop";
	}
	}
	
	

//BTW	
function gotoBildBTW(zaehlerBTW){
	  var linksscroll = zaehlerBTW * PB_gesamtBreite_picture + PB_gesamtBreite_picture;
	  var zaehlerx = parseInt(zaehlerBTW) + 1;
	  var navigation = document.getElementById("FDP_PlakatViewer_NavigatorBTW");
	  //Navigator anpassen
		if(parseInt(zaehlerBTW) > parseInt(PB_Navigator_max_Size)-1 && (parseInt(zaehlerBTW)) % PB_Navigator_max_Size == 0 ) {
			for (var ss = 0; ss < parseInt(PB_Navigator_max_Size); ss++){
				var navipunkt_hide2 = parseInt(zaehlerBTW) - parseInt(ss) -1;
				var navipunkt_show2 = parseInt(zaehlerBTW) + ss;
				navigation.getElementsByTagName("a")[navipunkt_hide2].style.display = "none";
				if(navipunkt_show2 < navigation.getElementsByTagName("a").length)
				{
				navigation.getElementsByTagName("a")[navipunkt_show2].style.display = "block";
				}
			}
		 }	
	  
	  $("#FDP_PlakatViewer_ScrollbereichBTW").animate( { left: "-" +linksscroll + "px"}, {duration : PB_time_scroll_picture, easing: "easeInOutBack"});
	  var bildbereich = document.getElementById("FDP_PlakatViewer_ScrollbereichBTW");
	  
	  //Descriptionfeld hinzuf\u00C3\u00BCgen und f\u00C3\u00BCllen
	  if(PB_show_description == true){
	  var inhalt = bildbereich.getElementsByTagName("img")[zaehlerx].getAttribute("title");
	  document.getElementById("FDP_PlakatViewer_InformationBTW").innerHtml=inhalt;
	  }
	  else {document.getElementById("FDP_PlakatViewer_InformationBTW").style.display = "none";}
	
	}

	
function linkKlickBTW(zaehler1){
	onoffSwitchBTW(0); 
	zaehlerBTW = zaehler1;
	SlideshowBTW();
	}
	
function SlideshowBTW() {
	if(document.getElementById("FDP_PlakatViewer_ScrollbereichBTW")){
		var navigation = document.getElementById("FDP_PlakatViewer_NavigatorBTW");
		  for (var i=0; i < navigation.getElementsByTagName("a").length-1; i++)
			{
				navigation.getElementsByTagName("a")[i].className = "";
			}
		  //aktiven Links einf\u00C3\u00A4rben
		  if( zaehlerBTW < navigation.getElementsByTagName("a").length -1){
		  navigation.getElementsByTagName("a")[zaehlerBTW].className = "aktiv";
		  //Bilderscroll ausf\u00C3\u00BChren
		  gotoBildBTW(zaehlerBTW);
		  zaehlerBTW ++;
		}
		else {
			zaehlerBTW = 0;
			document.getElementById("FDP_PlakatViewer_ScrollbereichBTW").style.left="1px";
			navigation.getElementsByTagName("a")[zaehlerBTW].className = "aktiv";
			gotoBildBTW(zaehlerBTW);
			if(navigation.getElementsByTagName("a").length > PB_Navigator_max_Size) {
					for(var ab = PB_Navigator_max_Size; ab < navigation.getElementsByTagName("a").length -1; ab++){
						navigation.getElementsByTagName("a")[ab].style.display = "none";
					}
					for(var ac = 0; ac < PB_Navigator_max_Size; ac++) {
						navigation.getElementsByTagName("a")[ac].style.display = "block";
					}
				}
			zaehlerBTW = 1;
		}
	}
}

function onoffSwitchBTW(a) {
	var cngBTN = document.getElementById("FDP_PlakatViewer_SSBTNBTW");
	
	if(a == 0)
	{
		//Ausmachen
		window.clearInterval(myIntervalBTW);
		cngBTN.onclick = new Function("F","onoffSwitchBTW('1'); return false;");
		cngBTN.className = "play";
	}
	else 
	{
		//Anmachen
		myIntervalBTW = window.setInterval("SlideshowBTW()", PB_time_btw_scroll);
		cngBTN.onclick = new Function("F","onoffSwitchBTW('0'); return false;");
		cngBTN.className = "stop";
	}
	}


















//FLICKR PLUGIN

/*
 * jQuery Flickr - jQuery plug-in
 * Version 1.0, Released 2008.04.17
 *
 * Copyright (c) 2008 Daniel MacDonald (www.projectatomic.com)
 * Dual licensed GPL http://www.gnu.org/licenses/gpl.html 
 * and MIT http://www.opensource.org/licenses/mit-license.php
 */
(function($) {
$.fn.flickr = function(o){
var s = {
    api_key: '53794fe4e3e2a58357541a8dd4730e81',              // [string]    required, see http://www.flickr.com/services/api/misc.api_keys.html
    type: 'photoset',                 // [string]    allowed values: 'photoset', 'search', default: 'flickr.photos.getRecent'
    photoset_id: '72157621333885191',          // [string]    required, for type=='photoset'  
    text: null,			            // [string]    for type=='search' free text search
    user_id: '34630936@N08',              // [string]    for type=='search' search by user id
    group_id: null,             // [string]    for type=='search' search by group id
    tags: null,                 // [string]    for type=='search' comma separated list
    tag_mode: 'any',            // [string]    for type=='search' allowed values: 'any' (OR), 'all' (AND)
    sort: 'date-posted-desc',    // [string]    for type=='search' allowed values: 'date-posted-asc', 'date-posted-desc', 'date-taken-asc', 'date-taken-desc', 'interestingness-desc', 'interestingness-asc', 'relevance'
    thumb_size: 't',            // [string]    allowed values: 's' (75x75), 't' (100x?), 'm' (240x?)
    size: '',                 // [string]    allowed values: 'm' (240x?), 'b' (1024x?), 'o' (original), default: (500x?)
    per_page: 100,              // [integer]   allowed values: max of 500
    page: 1,     	              // [integer]   see paging notes
    attr: '',                   // [string]    optional, attributes applied to thumbnail <a> tag
    api_url: null,              // [string]    optional, custom url that returns flickr JSON or JSON-P 'photos' or 'photoset'
    params: '',                 // [string]    optional, custom arguments, see http://www.flickr.com/services/api/flickr.photos.search.html
    api_callback: '?',          // [string]    optional, custom callback in flickr JSON-P response
    callback: null              // [function]  optional, callback function applied to entire <ul>

    // PAGING NOTES: jQuery Flickr plug-in does not provide paging functionality, but does provide hooks for a custom paging routine
    // within the <ul> created by the plug-in, there are two hidden <input> tags, 
    // input:eq(0): current page, input:eq(1): total number of pages, input:eq(2): images per page, input:eq(3): total number of images
    
    // SEARCH NOTES: when setting type to 'search' at least one search parameter  must also be passed text, user_id, group_id, or tags
    
    // SIZE NOTES: photos must allow viewing original size for size 'o' to function, if not, default size is shown
  };
  if(o) $.extend(s, o);
  return this.each(function(){
    
	$("#flickrPage").css("width", parseInt(s.per_page * 122) +"px");
		
	// create unordered list to contain flickr images
		var list = $('<ul>').appendTo(this);
    var url = $.flickr.format(s);
		$.getJSON(url, function(r){
      if (r.stat != "ok"){
        for (i in r){
	        $('<li>').text(i+': '+ r[i]).appendTo(list);
        };
      } else {
        if (s.type == 'photoset') r.photos = r.photoset;
        // add hooks to access paging data
        for (var i=0; i<r.photos.photo.length; i++){
		  	  
		  var photo = r.photos.photo[i];
          // format thumbnail url
          var t = 'http://farm'+photo['farm']+'.static.flickr.com/'+photo['server']+'/'+photo['id']+'_'+photo['secret']+'_'+s.thumb_size+'.jpg';
          //format image url
          var h = 'http://farm'+photo['farm']+'.static.flickr.com/'+photo['server']+'/'+photo['id']+'_';
        switch (s.size){
            case 'm':
              h += photo['secret'] + '_m.jpg';
              break;
            case 'b':
              h += photo['secret'] + '_b.jpg';
              break;
            case 'o':
              if (photo['originalsecret'] && photo['originalformat']) {
                h += photo['originalsecret'] + '_o.' + photo['originalformat'];
              } else {
                h += photo['secret'] + '_b.jpg';
              };
              break;
            default:
              h += photo['secret'] + '.jpg';
          
		  };
		  		 			
		  //Bild eins laden
		  if(i==0) {
				showFlickrPic(h,photo['id']);
			}
		  
		  var mylink = "<li><a onclick=\"showFlickrPic('" + h + "','"+ photo['id'] +"'); return false;\" href=\"#\" "+s.attr+" title=\""+photo['title']+"\" alt="+ h +"><span>"+photo['title']+"</span><img src=\""+t+"\" alt=\"" +photo['title']+ "\" /></a></li>";
          list.append(mylink);
         
        };
        if(i<5) $("div.FlickrSrcollRight").css("display","none");
        if (s.callback) s.callback(list);
      };
		});
  });
};


$.fn.flickr4 = function(o){

var s = {
    api_key: '53794fe4e3e2a58357541a8dd4730e81',              // [string]    required, see http://www.flickr.com/services/api/misc.api_keys.html
    type: 'photoset',                 // [string]    allowed values: 'photoset', 'search', default: 'flickr.photos.getRecent'
    photoset_id: '72157621670980671',          // [string]    required, for type=='photoset'  
    text: null,			            // [string]    for type=='search' free text search
    user_id: '34630936@N08',              // [string]    for type=='search' search by user id
    group_id: null,             // [string]    for type=='search' search by group id
    tags: null,                 // [string]    for type=='search' comma separated list
    tag_mode: 'any',            // [string]    for type=='search' allowed values: 'any' (OR), 'all' (AND)
    sort: 'date-posted-desc',    // [string]    for type=='search' allowed values: 'date-posted-asc', 'date-posted-desc', 'date-taken-asc', 'date-taken-desc', 'interestingness-desc', 'interestingness-asc', 'relevance'
    thumb_size: 't',            // [string]    allowed values: 's' (75x75), 't' (100x?), 'm' (240x?)
    size: '',                 // [string]    allowed values: 'm' (240x?), 'b' (1024x?), 'o' (original), default: (500x?)
    per_page: 100,              // [integer]   allowed values: max of 500
    page: 1,     	              // [integer]   see paging notes
    attr: '',                   // [string]    optional, attributes applied to thumbnail <a> tag
    api_url: null,              // [string]    optional, custom url that returns flickr JSON or JSON-P 'photos' or 'photoset'
    params: '',                 // [string]    optional, custom arguments, see http://www.flickr.com/services/api/flickr.photos.search.html
    api_callback: '?',          // [string]    optional, custom callback in flickr JSON-P response
    callback: null              // [function]  optional, callback function applied to entire <ul>

    // PAGING NOTES: jQuery Flickr plug-in does not provide paging functionality, but does provide hooks for a custom paging routine
    // within the <ul> created by the plug-in, there are two hidden <input> tags, 
    // input:eq(0): current page, input:eq(1): total number of pages, input:eq(2): images per page, input:eq(3): total number of images
    
    // SEARCH NOTES: when setting type to 'search' at least one search parameter  must also be passed text, user_id, group_id, or tags
    
    // SIZE NOTES: photos must allow viewing original size for size 'o' to function, if not, default size is shown
  };
  if(o) $.extend(s, o);
  return this.each(function(){
    
	$("#flickrPage").css("width", parseInt(s.per_page * 122) +"px");
	
	
	
	// create unordered list to contain flickr images
		var list = $('<ul>').appendTo(this);
    var url = $.flickr.format(s);
		$.getJSON(url, function(r){
      if (r.stat != "ok"){
        for (i in r){
	        $('<li>').text(i+': '+ r[i]).appendTo(list);
        };
      } else {
        if (s.type == 'photoset') r.photos = r.photoset;
        // add hooks to access paging data
        for (var i=0; i<r.photos.photo.length; i++){
		  	  
		  var photo = r.photos.photo[i];
          // format thumbnail url
          var t = 'http://farm'+photo['farm']+'.static.flickr.com/'+photo['server']+'/'+photo['id']+'_'+photo['secret']+'_'+s.thumb_size+'.jpg';
          //format image url
          var h = 'http://farm'+photo['farm']+'.static.flickr.com/'+photo['server']+'/'+photo['id']+'_';
        switch (s.size){
            case 'm':
              h += photo['secret'] + '_m.jpg';
              break;
            case 'b':
              h += photo['secret'] + '_b.jpg';
              break;
            case 'o':
              if (photo['originalsecret'] && photo['originalformat']) {
                h += photo['originalsecret'] + '_o.' + photo['originalformat'];
              } else {
                h += photo['secret'] + '_b.jpg';
              };
              break;
            default:
              h += photo['secret'] + '.jpg';
          
		  };
		  //Bild eins laden
		  if(i==0) {
				showFlickrPic(h,photo['id']);
			}
		  
		  var mylink = "<li><a onclick=\"showFlickrPic('" + h + "','"+ photo['id'] +"'); return false;\" href=\"#\" "+s.attr+" title=\""+photo['title']+"\" alt="+ h +"><span>"+photo['title']+"</span><img src=\""+t+"\" alt=\"" +photo['title']+ "\" /></a></li>";
          list.append(mylink);
        };
        if(i<5) $("div.FlickrSrcollRight").css("display","none");
        if (s.callback) s.callback(list);
      };
		});
  });
};

$.fn.flickr5 = function(o){

var s = {
    api_key: '53794fe4e3e2a58357541a8dd4730e81',              // [string]    required, see http://www.flickr.com/services/api/misc.api_keys.html
    type: 'photoset',                 // [string]    allowed values: 'photoset', 'search', default: 'flickr.photos.getRecent'
    photoset_id: '72157621866478925',          // [string]    required, for type=='photoset'  
    text: null,			            // [string]    for type=='search' free text search
    user_id: '34630936@N08',              // [string]    for type=='search' search by user id
    group_id: null,             // [string]    for type=='search' search by group id
    tags: null,                 // [string]    for type=='search' comma separated list
    tag_mode: 'any',            // [string]    for type=='search' allowed values: 'any' (OR), 'all' (AND)
    sort: 'date-posted-desc',    // [string]    for type=='search' allowed values: 'date-posted-asc', 'date-posted-desc', 'date-taken-asc', 'date-taken-desc', 'interestingness-desc', 'interestingness-asc', 'relevance'
    thumb_size: 't',            // [string]    allowed values: 's' (75x75), 't' (100x?), 'm' (240x?)
    size: '',                 // [string]    allowed values: 'm' (240x?), 'b' (1024x?), 'o' (original), default: (500x?)
    per_page: 50,              // [integer]   allowed values: max of 500
    page: 1,     	              // [integer]   see paging notes
    attr: '',                   // [string]    optional, attributes applied to thumbnail <a> tag
    api_url: null,              // [string]    optional, custom url that returns flickr JSON or JSON-P 'photos' or 'photoset'
    params: '',                 // [string]    optional, custom arguments, see http://www.flickr.com/services/api/flickr.photos.search.html
    api_callback: '?',          // [string]    optional, custom callback in flickr JSON-P response
    callback: null              // [function]  optional, callback function applied to entire <ul>

    // PAGING NOTES: jQuery Flickr plug-in does not provide paging functionality, but does provide hooks for a custom paging routine
    // within the <ul> created by the plug-in, there are two hidden <input> tags, 
    // input:eq(0): current page, input:eq(1): total number of pages, input:eq(2): images per page, input:eq(3): total number of images
    
    // SEARCH NOTES: when setting type to 'search' at least one search parameter  must also be passed text, user_id, group_id, or tags
    
    // SIZE NOTES: photos must allow viewing original size for size 'o' to function, if not, default size is shown
  };
  if(o) $.extend(s, o);
  return this.each(function(){
    
	$("#flickrPage").css("width", parseInt(s.per_page * 122) +"px");
	
	
	
	// create unordered list to contain flickr images
		var list = $('<ul>').appendTo(this);
    var url = $.flickr.format(s);
		$.getJSON(url, function(r){
      if (r.stat != "ok"){
        for (i in r){
	        $('<li>').text(i+': '+ r[i]).appendTo(list);
        };
      } else {
        if (s.type == 'photoset') r.photos = r.photoset;
        // add hooks to access paging data
        for (var i=0; i<r.photos.photo.length; i++){
		  	  
		  var photo = r.photos.photo[i];
          // format thumbnail url
          var t = 'http://farm'+photo['farm']+'.static.flickr.com/'+photo['server']+'/'+photo['id']+'_'+photo['secret']+'_'+s.thumb_size+'.jpg';
          //format image url
          var h = 'http://farm'+photo['farm']+'.static.flickr.com/'+photo['server']+'/'+photo['id']+'_';
        switch (s.size){
            case 'm':
              h += photo['secret'] + '_m.jpg';
              break;
            case 'b':
              h += photo['secret'] + '_b.jpg';
              break;
            case 'o':
              if (photo['originalsecret'] && photo['originalformat']) {
                h += photo['originalsecret'] + '_o.' + photo['originalformat'];
              } else {
                h += photo['secret'] + '_b.jpg';
              };
              break;
            default:
              h += photo['secret'] + '.jpg';
          
		  };
		  //Bild eins laden
		  if(i==0) {
				showFlickrPic(h,photo['id']);
			}
		  
		  var mylink = "<li><a onclick=\"showFlickrPic('" + h + "','"+ photo['id'] +"'); return false;\" href=\"#\" "+s.attr+" title=\""+photo['title']+"\" alt="+ h +"><span>"+photo['title']+"</span><img src=\""+t+"\" alt=\"" +photo['title']+ "\" /></a></li>";
          list.append(mylink);
        };
        if(i<5) $("div.FlickrSrcollRight").css("display","none");
        if (s.callback) s.callback(list);
      };
		});
  });
};


$.fn.flickr6 = function(o){

var s = {
    api_key: '53794fe4e3e2a58357541a8dd4730e81',              // [string]    required, see http://www.flickr.com/services/api/misc.api_keys.html
    type: 'photoset',                 // [string]    allowed values: 'photoset', 'search', default: 'flickr.photos.getRecent'
    photoset_id: '72157622239734664',          // [string]    required, for type=='photoset'  
    text: null,			            // [string]    for type=='search' free text search
    user_id: '34630936@N08',              // [string]    for type=='search' search by user id
    group_id: null,             // [string]    for type=='search' search by group id
    tags: null,                 // [string]    for type=='search' comma separated list
    tag_mode: 'any',            // [string]    for type=='search' allowed values: 'any' (OR), 'all' (AND)
    sort: 'date-posted-desc',    // [string]    for type=='search' allowed values: 'date-posted-asc', 'date-posted-desc', 'date-taken-asc', 'date-taken-desc', 'interestingness-desc', 'interestingness-asc', 'relevance'
    thumb_size: 't',            // [string]    allowed values: 's' (75x75), 't' (100x?), 'm' (240x?)
    size: '',                 // [string]    allowed values: 'm' (240x?), 'b' (1024x?), 'o' (original), default: (500x?)
    per_page: 50,              // [integer]   allowed values: max of 500
    page: 1,     	              // [integer]   see paging notes
    attr: '',                   // [string]    optional, attributes applied to thumbnail <a> tag
    api_url: null,              // [string]    optional, custom url that returns flickr JSON or JSON-P 'photos' or 'photoset'
    params: '',                 // [string]    optional, custom arguments, see http://www.flickr.com/services/api/flickr.photos.search.html
    api_callback: '?',          // [string]    optional, custom callback in flickr JSON-P response
    callback: null              // [function]  optional, callback function applied to entire <ul>

    // PAGING NOTES: jQuery Flickr plug-in does not provide paging functionality, but does provide hooks for a custom paging routine
    // within the <ul> created by the plug-in, there are two hidden <input> tags, 
    // input:eq(0): current page, input:eq(1): total number of pages, input:eq(2): images per page, input:eq(3): total number of images
    
    // SEARCH NOTES: when setting type to 'search' at least one search parameter  must also be passed text, user_id, group_id, or tags
    
    // SIZE NOTES: photos must allow viewing original size for size 'o' to function, if not, default size is shown
  };
  if(o) $.extend(s, o);
  return this.each(function(){
    
	$("#flickrPage").css("width", parseInt(s.per_page * 122) +"px");
	
	
	
	// create unordered list to contain flickr images
		var list = $('<ul>').appendTo(this);
    var url = $.flickr.format(s);
		$.getJSON(url, function(r){
      if (r.stat != "ok"){
        for (i in r){
	        $('<li>').text(i+': '+ r[i]).appendTo(list);
        };
      } else {
        if (s.type == 'photoset') r.photos = r.photoset;
        // add hooks to access paging data
        for (var i=0; i<r.photos.photo.length; i++){
		  	  
		  var photo = r.photos.photo[i];
          // format thumbnail url
          var t = 'http://farm'+photo['farm']+'.static.flickr.com/'+photo['server']+'/'+photo['id']+'_'+photo['secret']+'_'+s.thumb_size+'.jpg';
          //format image url
          var h = 'http://farm'+photo['farm']+'.static.flickr.com/'+photo['server']+'/'+photo['id']+'_';
        switch (s.size){
            case 'm':
              h += photo['secret'] + '_m.jpg';
              break;
            case 'b':
              h += photo['secret'] + '_b.jpg';
              break;
            case 'o':
              if (photo['originalsecret'] && photo['originalformat']) {
                h += photo['originalsecret'] + '_o.' + photo['originalformat'];
              } else {
                h += photo['secret'] + '_b.jpg';
              };
              break;
            default:
              h += photo['secret'] + '.jpg';
          
		  };
		  //Bild eins laden
		  if(i==0) {
				showFlickrPic(h,photo['id']);
			}
		  
		  var mylink = "<li><a onclick=\"showFlickrPic('" + h + "','"+ photo['id'] +"'); return false;\" href=\"#\" "+s.attr+" title=\""+photo['title']+"\" alt="+ h +"><span>"+photo['title']+"</span><img src=\""+t+"\" alt=\"" +photo['title']+ "\" /></a></li>";
          list.append(mylink);
        };
        if(i<5) $("div.FlickrSrcollRight").css("display","none");
        if (s.callback) s.callback(list);
      };
		});
  });
};
// static function to format the flickr API url according to the plug-in settings 
$.flickr = {
    format: function(s){
        if (s.url) return s.url;
        var url = 'http://api.flickr.com/services/rest/?format=json&jsoncallback='+s.api_callback+'&api_key='+s.api_key;
        switch (s.type){
            case 'photoset':
                url += '&method=flickr.photosets.getPhotos&photoset_id=' + s.photoset_id;
                break;
            case 'search':
                url += '&method=flickr.photos.search&sort=' + s.sort;
                if (s.user_id) url += '&user_id=' + s.user_id;
                if (s.group_id) url += '&group_id=' + s.group_id;
                if (s.tags) url += '&tags=' + s.tags;
                if (s.tag_mode) url += '&tag_mode=' + s.tag_mode;
                if (s.text) url += '&text=' + s.text;
                break;
            default:
                url += '&method=flickr.photos.getRecent';
        };
        if (s.size == 'o') url += '&extras=original_format';
        url += '&per_page=' + s.per_page + '&page=' + s.page + s.params;
        return url;
    }
};
})(jQuery);


function showFlickrPic(pic, picid){		
		var test = $("#pic").attr("src");
		if(test != pic)
		{
			$("#loader, #blackBG").css("display","block");
			$("#pic").attr({
				src: pic
			}).load(function(){
					$("#loader, #blackBG").css("display","none");
					//Falls HochkantBild
					
					if($("#pic").innerHeight() > $("#pic").innerWidth() | $("#pic").innerHeight()> 330){
						$("#pic").css({
						"height": "330px",
						"width":"auto"
						});
					}
					else {
						if($("#pic").innerWidth()> 470)
						{
						$("#pic").css({
						"width": "470px",
						"height":"auto"
						});
						}
					}
					var br = $("#pic").innerWidth();
					var AbstandLeft = 345 - br/2;
					
				$("#pic").css({
					"display":"block",
					"left": AbstandLeft +"px"
				});
			});
			
				url="http://api.flickr.com/services/rest/?format=json&jsoncallback=?&api_key=53794fe4e3e2a58357541a8dd4730e81&method=flickr.photos.getInfo&photo_id=" + picid;
		  		$.getJSON(url, function(rr){
      			if (rr.stat != "ok"){
        			for (ii in rr){
	        			$('<li>').text(ii+': '+ rr[i]).appendTo(list);
        			};
      			} else {
        			var discphoto = rr.photo['description'];
        			discphoto=discphoto['_content']
        			if(discphoto.length>90) {
        				discphoto=discphoto.substring(0, 90);
        				n=discphoto.lastIndexOf(" ");
        				discphoto=discphoto.substring(0, n);
        			}
        			$("#picDisc").html(discphoto);
        		}
        		});  
        	
				 	
				
			}
	
}
		
	
(function($) {
$.fn.flickr2 = function(o){
var s = {
    api_key: '53794fe4e3e2a58357541a8dd4730e81',              // [string]    required, see http://www.flickr.com/services/api/misc.api_keys.html
    type: 'photoset',                 // [string]    allowed values: 'photoset', 'search', default: 'flickr.photos.getRecent'
    photoset_id: '72157621333885191',          // [string]    required, for type=='photoset'  
    text: null,			            // [string]    for type=='search' free text search
    user_id: '34630936@N08',              // [string]    for type=='search' search by user id
    group_id: null,             // [string]    for type=='search' search by group id
    tags: null,                 // [string]    for type=='search' comma separated list
    tag_mode: 'any',            // [string]    for type=='search' allowed values: 'any' (OR), 'all' (AND)
    sort: 'date-posted-desc',    // [string]    for type=='search' allowed values: 'date-posted-asc', 'date-posted-desc', 'date-taken-asc', 'date-taken-desc', 'interestingness-desc', 'interestingness-asc', 'relevance'
    thumb_size: 's',            // [string]    allowed values: 's' (75x75), 't' (100x?), 'm' (240x?)
    size: 'o',                 // [string]    allowed values: 'm' (240x?), 'b' (1024x?), 'o' (original), default: (500x?)
    per_page: 6,              // [integer]   allowed values: max of 500
    page: 1,     	              // [integer]   see paging notes
    attr: '',                   // [string]    optional, attributes applied to thumbnail <a> tag
    api_url: null,              // [string]    optional, custom url that returns flickr JSON or JSON-P 'photos' or 'photoset'
    params: '',                 // [string]    optional, custom arguments, see http://www.flickr.com/services/api/flickr.photos.search.html
    api_callback: '?',          // [string]    optional, custom callback in flickr JSON-P response
    callback: null              // [function]  optional, callback function applied to entire <ul>

    // PAGING NOTES: jQuery Flickr plug-in does not provide paging functionality, but does provide hooks for a custom paging routine
    // within the <ul> created by the plug-in, there are two hidden <input> tags, 
    // input:eq(0): current page, input:eq(1): total number of pages, input:eq(2): images per page, input:eq(3): total number of images
    
    // SEARCH NOTES: when setting type to 'search' at least one search parameter  must also be passed text, user_id, group_id, or tags
    
    // SIZE NOTES: photos must allow viewing original size for size 'o' to function, if not, default size is shown
  };
  if(o) $.extend(s, o);
  return this.each(function(){
    // create unordered list to contain flickr images
		var list = $('<ul>').appendTo(this);
    var url = $.flickr.format(s);
		$.getJSON(url, function(r){
      if (r.stat != "ok"){
        for (i in r){
	        $('<li>').text(i+': '+ r[i]).appendTo(list);
        };
      } else {
        if (s.type == 'photoset') r.photos = r.photoset;
        // add hooks to access paging data
        for (var i=0; i<r.photos.photo.length; i++){
		  	  
		  var photo = r.photos.photo[i];
          // format thumbnail url
          var t = 'http://farm'+photo['farm']+'.static.flickr.com/'+photo['server']+'/'+photo['id']+'_'+photo['secret']+'_'+s.thumb_size+'.jpg';
          //format image url
          var h = 'http://farm'+photo['farm']+'.static.flickr.com/'+photo['server']+'/'+photo['id']+'_';
        switch (s.size){
            case 'm':
              h += photo['secret'] + '_m.jpg';
              break;
            case 'b':
              h += photo['secret'] + '_b.jpg';
              break;
            case 'o':
              if (photo['originalsecret'] && photo['originalformat']) {
                h += photo['originalsecret'] + '_o.' + photo['originalformat'];
              } else {
                h += photo['secret'] + '_b.jpg';
              };
              break;
            default:
              h += photo['secret'] + '.jpg';
          
		  };
		  
		  
		  var mylink = "<li><img src=\""+t+"\" alt=\""+photo['title']+"\" /></li>";
          list.append(mylink);
        };
        if (s.callback) s.callback(list);
      };
		});
  });
};

/*#################################################################################################*/

		
$.fn.flickr_K = function(o){
var s = {
    api_key: '53794fe4e3e2a58357541a8dd4730e81',              // [string]    required, see http://www.flickr.com/services/api/misc.api_keys.html
    type: 'photoset',                 // [string]    allowed values: 'photoset', 'search', default: 'flickr.photos.getRecent'
   
   
   
   
    /*			#####
    			#####
    			#####
    			#####
    			####
    			
    			#####
    			#####
    			#####
    			
    */
    
    photoset_id: '72157623588300979',          // [string]    required, for type=='photoset 72157622168007820'  
    text: null,			            // [string]    for type=='search' free text search
    user_id: '34630936@N08',              // [string]    for type=='search' search by user id
    group_id: null,             // [string]    for type=='search' search by group id
    tags: null,                 // [string]    for type=='search' comma separated list
    tag_mode: 'any',            // [string]    for type=='search' allowed values: 'any' (OR), 'all' (AND)
    sort: 'date-posted-desc',    // [string]    for type=='search' allowed values: 'date-posted-asc', 'date-posted-desc', 'date-taken-asc', 'date-taken-desc', 'interestingness-desc', 'interestingness-asc', 'relevance'
    thumb_size: 't',            // [string]    allowed values: 's' (75x75), 't' (100x?), 'm' (240x?)
    size: '',                 // [string]    allowed values: 'm' (240x?), 'b' (1024x?), 'o' (original), default: (500x?)
    per_page: 10,              // [integer]   allowed values: max of 500
    page: 1,     	              // [integer]   see paging notes
    attr: '',                   // [string]    optional, attributes applied to thumbnail <a> tag
    api_url: null,              // [string]    optional, custom url that returns flickr JSON or JSON-P 'photos' or 'photoset'
    params: '',                 // [string]    optional, custom arguments, see http://www.flickr.com/services/api/flickr.photos.search.html
    api_callback: '?',          // [string]    optional, custom callback in flickr JSON-P response
    callback: null              // [function]  optional, callback function applied to entire <ul>

    // PAGING NOTES: jQuery Flickr plug-in does not provide paging functionality, but does provide hooks for a custom paging routine
    // within the <ul> created by the plug-in, there are two hidden <input> tags, 
    // input:eq(0): current page, input:eq(1): total number of pages, input:eq(2): images per page, input:eq(3): total number of images
    
    // SEARCH NOTES: when setting type to 'search' at least one search parameter  must also be passed text, user_id, group_id, or tags
    
    // SIZE NOTES: photos must allow viewing original size for size 'o' to function, if not, default size is shown
  };
  if(o) $.extend(s, o);
  return this.each(function(){
    
	$("#flickrPage").css("width", parseInt(s.per_page * 122) +"px");
	
	
	
	// create unordered list to contain flickr images
		var list = $('<ul>').appendTo(this);
    var url = $.flickr.format(s);
		$.getJSON(url, function(r){
      if (r.stat != "ok"){
        for (i in r){
	        $('<li>').text(i+': '+ r[i]).appendTo(list);
        };
      } else {
        if (s.type == 'photoset') r.photos = r.photoset;
        // add hooks to access paging data
        for (var i=0; i<r.photos.photo.length; i++){
		  	  
		  var photo = r.photos.photo[i];
          // format thumbnail url
          var t = 'http://farm'+photo['farm']+'.static.flickr.com/'+photo['server']+'/'+photo['id']+'_'+photo['secret']+'_'+s.thumb_size+'.jpg';
          //format image url
          var h = 'http://farm'+photo['farm']+'.static.flickr.com/'+photo['server']+'/'+photo['id']+'_';
        switch (s.size){
            case 'm':
              h += photo['secret'] + '_m.jpg';
              break;
            case 'b':
              h += photo['secret'] + '_b.jpg';
              break;
            case 'o':
              if (photo['originalsecret'] && photo['originalformat']) {
                h += photo['originalsecret'] + '_o.' + photo['originalformat'];
              } else {
                h += photo['secret'] + '_b.jpg';
              };
              break;
            default:
              h += photo['secret'] + '.jpg';
          
		  };
		  //Bild eins laden
		  if(i==0) {
				showFlickrPicKLEIN(h,photo['id']);
			}
		  
		  var mylink = "<li><a onclick=\"showFlickrPicKLEIN('" + h + "','"+ photo['id'] +"'); return false;\" href=\"#\" "+s.attr+" title=\""+photo['title']+"\" alt="+ h +"><span>"+photo['title']+"</span><img src=\""+t+"\" alt=\"" +photo['title']+ "\" /></a></li>";
          list.append(mylink);
        };
        if(i<5) $("div.FlickrSrcollRight").css("display","none");
        if (s.callback) s.callback(list);
      };
		});
  });
};
// static function to format the flickr API url according to the plug-in settings 
$.flickr = {
    format: function(s){
        if (s.url) return s.url;
        var url = 'http://api.flickr.com/services/rest/?format=json&jsoncallback='+s.api_callback+'&api_key='+s.api_key;
        switch (s.type){
            case 'photoset':
                url += '&method=flickr.photosets.getPhotos&photoset_id=' + s.photoset_id;
                break;
            case 'search':
                url += '&method=flickr.photos.search&sort=' + s.sort;
                if (s.user_id) url += '&user_id=' + s.user_id;
                if (s.group_id) url += '&group_id=' + s.group_id;
                if (s.tags) url += '&tags=' + s.tags;
                if (s.tag_mode) url += '&tag_mode=' + s.tag_mode;
                if (s.text) url += '&text=' + s.text;
                break;
            default:
                url += '&method=flickr.photos.getRecent';
        };
        if (s.size == 'o') url += '&extras=original_format';
        url += '&per_page=' + s.per_page + '&page=' + s.page + s.params;
        return url;
    }
};

/*###################################################################################*/





$.fn.flickr3 = function(o){
var s = {
    api_key: '53794fe4e3e2a58357541a8dd4730e81',              // [string]    required, see http://www.flickr.com/services/api/misc.api_keys.html
    type: 'photoset',                 // [string]    allowed values: 'photoset', 'search', default: 'flickr.photos.getRecent'
    photoset_id: '72157621670980671',          // [string]    required, for type=='photoset'  
    text: null,			            // [string]    for type=='search' free text search
    user_id: '34630936@N08',              // [string]    for type=='search' search by user id
    group_id: null,             // [string]    for type=='search' search by group id
    tags: null,                 // [string]    for type=='search' comma separated list
    tag_mode: 'any',            // [string]    for type=='search' allowed values: 'any' (OR), 'all' (AND)
    sort: 'date-posted-desc',    // [string]    for type=='search' allowed values: 'date-posted-asc', 'date-posted-desc', 'date-taken-asc', 'date-taken-desc', 'interestingness-desc', 'interestingness-asc', 'relevance'
    thumb_size: 's',            // [string]    allowed values: 's' (75x75), 't' (100x?), 'm' (240x?)
    size: 'o',                 // [string]    allowed values: 'm' (240x?), 'b' (1024x?), 'o' (original), default: (500x?)
    per_page: 6,              // [integer]   allowed values: max of 500
    page: 1,     	              // [integer]   see paging notes
    attr: '',                   // [string]    optional, attributes applied to thumbnail <a> tag
    api_url: null,              // [string]    optional, custom url that returns flickr JSON or JSON-P 'photos' or 'photoset'
    params: '',                 // [string]    optional, custom arguments, see http://www.flickr.com/services/api/flickr.photos.search.html
    api_callback: '?',          // [string]    optional, custom callback in flickr JSON-P response
    callback: null              // [function]  optional, callback function applied to entire <ul>

    // PAGING NOTES: jQuery Flickr plug-in does not provide paging functionality, but does provide hooks for a custom paging routine
    // within the <ul> created by the plug-in, there are two hidden <input> tags, 
    // input:eq(0): current page, input:eq(1): total number of pages, input:eq(2): images per page, input:eq(3): total number of images
    
    // SEARCH NOTES: when setting type to 'search' at least one search parameter  must also be passed text, user_id, group_id, or tags
    
    // SIZE NOTES: photos must allow viewing original size for size 'o' to function, if not, default size is shown
  };
  if(o) $.extend(s, o);
  return this.each(function(){
    // create unordered list to contain flickr images
		var list = $('<ul>').appendTo(this);
    var url = $.flickr.format(s);
		$.getJSON(url, function(r){
      if (r.stat != "ok"){
        for (i in r){
	        $('<li>').text(i+': '+ r[i]).appendTo(list);
        };
      } else {
        if (s.type == 'photoset') r.photos = r.photoset;
        // add hooks to access paging data
        for (var i=0; i<r.photos.photo.length; i++){
		  	  
		  var photo = r.photos.photo[i];
          // format thumbnail url
          var t = 'http://farm'+photo['farm']+'.static.flickr.com/'+photo['server']+'/'+photo['id']+'_'+photo['secret']+'_'+s.thumb_size+'.jpg';
          //format image url
          var h = 'http://farm'+photo['farm']+'.static.flickr.com/'+photo['server']+'/'+photo['id']+'_';
        switch (s.size){
            case 'm':
              h += photo['secret'] + '_m.jpg';
              break;
            case 'b':
              h += photo['secret'] + '_b.jpg';
              break;
            case 'o':
              if (photo['originalsecret'] && photo['originalformat']) {
                h += photo['originalsecret'] + '_o.' + photo['originalformat'];
              } else {
                h += photo['secret'] + '_b.jpg';
              };
              break;
            default:
              h += photo['secret'] + '.jpg';
          
		  };
		  
		  
		  var mylink = "<li><img src=\""+t+"\" alt=\""+photo['title']+"\" /></li>";
          list.append(mylink);
        };
        if (s.callback) s.callback(list);
      };
		});
  });
};
})(jQuery);


function showFlickrPicKLEIN(pic, picid){
		var test = $("#pic").attr("src");
		
		if(test != pic)
		{
			$("#loader, #blackBG").css("display","block");
			$("#pic").attr({
				src: pic
			}).load(function(){
					$("#loader, #blackBG").css("display","none");
					//Falls HochkantBild
					
					if($("#pic").innerWidth()> 300)
						{
						$("#pic").css({
						"width": "300px",
						"height":"auto"
						});
						}
					else {
					if($("#pic").innerHeight() > $("#pic").innerWidth() | $("#pic").innerHeight()> 280){
						$("#pic").css({
						"height": "280px",
						"width":"auto"
						});
					}
					}
					var br = $("#pic").innerWidth();
					var AbstandLeft = 170 - br/2;
					
				$("#pic").css({
					"display":"block",
					"left": AbstandLeft +"px"
				});
			});
			
				url="http://api.flickr.com/services/rest/?format=json&jsoncallback=?&api_key=53794fe4e3e2a58357541a8dd4730e81&method=flickr.photos.getInfo&photo_id=" + picid;
		  		$.getJSON(url, function(rr){
      			if (rr.stat != "ok"){
        			for (ii in rr){
	        			$('<li>').text(ii+': '+ rr[i]).appendTo(list);
        			};
      			} else {
        			var discphoto = rr.photo['description'];
        			discphoto=discphoto['_content']
        			if(discphoto.length>90) {
        				discphoto=discphoto.substring(0, 90);
        				n=discphoto.lastIndexOf(" ");
        				discphoto=discphoto.substring(0, n);
        			}
        			$("#picDisc").html(discphoto);
        		}
        		});  
        	
				 	
				
			}
	
}


