// shrink all images
var ws = 0
function sai() {
	ws = window.innerWidth ? window.innerWidth : document.body && document.body.offsetWidth ? document.body.offsetWidth : screen.width;
	if (document.images.length) {
		var i = document.images;
		for (var x = 0; x < i.length; x++) {
			if (i[x].width > ws) {
				if (typeof i[x].ow == 'undefined') {
					i[x].ow = i[x].width;
					i[x].oh = i[x].height;
				}
				i[x].width = i[x].ow / (i[x].ow / (ws / 2));
				if (i[x].height == i[x].oh) {
					i[x].height = i[x].height / (i[x].ow / (ws / 2));
				}
				if (i[x].parentNode.nodeName != 'A') {
					i[x].onclick = ri;
					i[x].title = i[x].src;
					i[x].className = 'resized';
				}
			}
		}
	}
};
// restore image (element)
function ri(e) {
	var o = window.event ? window.event.srcElement : e.target;
	o.width = o.ow;
	if (o.height != o.oh) {
		o.height = o.oh;
	}
	o.onclick = si;
};
// shrink image (element)
function si(e) {
	var o = window.event ? window.event.srcElement : e.target;
	o.width = o.width / (o.width / (ws / 2));
	if (o.height == o.oh) {
		o.height = o.height / (o.ow / (ws / 2));
	}
	o.onclick = ri;
};

/* ALTES SCRIPT -------------------------------------------------

function resizeImages() 
{ 
          if (document.images.length > 0)          
          { 
 
		var maxWidth = window.innerWidth/2;
               	var imgHeight; 
               	var imgWidth; 
               	for (var loop = 0; loop < document.images.length; loop++) 
               { 
                         imgWidth = document.images[loop].width; 
                         imgHeight = document.images[loop].height; 
 
if (imgWidth>window.innerWidth/2){
				image = new Image();
                              	image = document.images[loop]; 
 
				newImage = image.cloneNode( true )	;
 
				// Originalgröße speichern 
                              newImage.origHeight = image.height;
                            	newImage.origWidth = image.width
 
 
                             	newImage.width = maxWidth ; 
 
                              //Höhe proportionalisieren 
                              	imgHeight = imgHeight / (imgWidth/ maxWidth ); 
                              	newImage.height = imgHeight; 
				
				newImage.style.cursor = 'pointer';
 
 
				if( image.outerHTML )
				{ 
                	              	newImage.onclick = "var altHeight; var altWidth;	altHeight = this.height ; altWidth = this.width; this.width = this.origWidth; 	this.height = this.origHeight; this.origWidth = altWidth; this.origHeight = altHeight; 	"; 
				} else {
                	              	newImage.onclick = function () { 
						var altHeight;
						var altWidth;
						
						// Dimensionen in vars speichern
						altHeight = this.height ;
						altWidth = this.width;
 
	
						// alternative Dimensionen erstellen
						this.width = this.origWidth; 
						this.height = this.origHeight; 
 
						// speichern 
						this.origWidth = altWidth; 
						this.origHeight = altHeight; 
					}; 
				}
 
 
				// parent node
				// & in eine tabelle mit Texthinweis speichern
				if( parentNode = image.parentNode )
				{
					textMessage = document.createTextNode(text_note_global);
 
					elem = document.createElement("td");
					elem.setAttribute( "align", "center");
					elem.style.backgroundColor = 'black';
					elem.style.color = 'white';
					elem.style.fontWeight = '900';
					elem.style.fontSize = '8pt';
 
					elem.appendChild( textMessage );
					elem.appendChild( document.createElement("br"));
					elem.appendChild( newImage );
						
					
					tableRow = document.createElement("tr");
					tableRow.appendChild(elem);
					
					TableElem = document.createElement("table");
					TableElem.setAttribute( "border", "1");
					TableElem.appendChild( tableRow );
 
					frag = document.createElement("div");
					frag.appendChild( TableElem );
 
					if( image.outerHTML )
					{
						image.outerHTML = frag.innerHTML;
					} else {
						parentNode.replaceChild( TableElem, image );
					}
				}}
 
               } 
          } 
     } 
window.onload = resizeImages;*/
