function fnOpenNewWindow(oLink) {
	oWin = window.open(oLink.href);
	if( oWin ){
		oWin.focus();
		return false;
	} else {
		return true;
	}
}

var g_setupOk = false;
function setup(){
	if( g_setupOk == false ){
		setupPictureShow();
		// alert(g_setupOk);
	}
	return true;
}

function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}

/*
	Markiert ein Feld wenn es den Focus hat.
*/
function markInput(formElement, status) {
	var MARK_ON  = "#F9F3A8";
	var MARK_OFF = "#FFFFFF";
	var MARK_ERR = "#FF6347";
	
	if( status == 1 ){
		formElement.style.backgroundColor = MARK_ON;
	} else if( status == 0 ){
		formElement.style.backgroundColor = MARK_OFF;
	} else if( status == -1 ){
		formElement.style.backgroundColor = MARK_ERR;
	} 
}


/*
	MAKZ Pictureshow
	----------------
	Funktion für Extension: 	makz_pictureshow
	Aufruf in Designtemplate: 	makz_pictureshow.html
	*/
var g_lastSlideID = 0; // ID des zuletzt gewählten Bildes. Default = 0 per setupPictureShow(). 


function setupPictureShow(){
	var key = '';
	if( document.getElementById ){								// DOM-Browser?
		for( i=0; i<100; i++ ){
			key = 'pictureshowPic'+i;
			//alert(key);
			if( document.getElementById(key) ){					// Vorhanden?
				//alert(key);
				g_lastSlideID = key;
				g_setupOk = true;
				return;
			}
		}
	}
}
/*
	Parameter:
		linkID	= ID des <a>-Elements;
		picID	= ID des aktuellen Bildes;
		picSrc	= Url des aktuellen Bildes;
		textID	= ID des HTML-Elementes, in dem der Bildtext ausgegeben wird;
		picTitle= Title des Bildes und
		picDescr= Bildbeschreibung.
		
	Hinweis: Title und Beschreibung wurden per 'urlencode' kodiert, um in den Parametern des
	JS-Aufrufes untergebracht werden zu können. 'htmlspecialchars' funktioniert NICHT(!), da
	z.B. '&quot;' als '"' interpretiert wird, was dann Fehler verursacht.
	*/
	
	var storeURL = "";
	
function showPictureshow(linkID, picID, picSrc, textID){
	if( document.getElementById ){								// DOM-Browser?
		
		// Bilderrahmen mit dem angeforderten Bild als Hintergrund versehen.
		document.getElementById(picID).style.backgroundImage = "url(" + picSrc + ")";
		
		if( g_lastSlideID != '' ){								// Keine Bild-Id übergeben?
			document.getElementById(g_lastSlideID).className = 'isDefault';
		}
		
		g_lastSlideID = linkID;
		$(".isActive").removeClass("isActive").addClass("isDefault");									// Aktuelle Bild-Id merken.
		document.getElementById(linkID).className = "isActive";	// Klasse des <a>-Elements ändern.
		document.getElementById(linkID).blur()					// Focus von Link entfernen (Nur Optik!).
		
		if( document.getElementById('makz_pictureshow_picture_zoom') ){
			document.getElementById('makz_pictureshow_picture_zoom').href = picSrc;
			$('#makz_pictureshow_picture_zoom').attr('rel', document.getElementById(linkID).rel);
			storeURL = picSrc;
		}
		return false;
	}
	return true;	
}
function showSinglePicture(picUrl, winWidth, winHeight){
	
	// CaricaFoto(picUrl);
	// return false;
	$(document).ready(function() {
	
		//picUrl = picUrl.replace(/preview/,"showcase");
		$("#fancyPicture").attr("src", $('#makz_pictureshow_picture_zoom').attr('rel'));
		$("#fancyPicture").load(function() {
			$.fancybox($('#fancyPictureFrame').html());
		});
		
		//$.fancybox('<img src="'+ picUrl + '" />');
		return false;
	});
	return false;
	
}




function CaricaFoto(img){
foto1= new Image();

img = img.replace(/preview/,"showcase");

foto1.src=(img);
Controlla(img);
}
function Controlla(img){
if((foto1.width!=0)&&(foto1.height!=0)){
viewFoto(img);
}
else{
funzione="Controlla('"+img+"')";
intervallo=setTimeout(funzione,20);
}
}
function viewFoto(img){
largh=foto1.width+20;
altez=foto1.height+20;
stringa="width="+largh+",height="+altez;
finestra=window.open(img,"",stringa);
}

