
function buildAjaxContent(contid, targetdiv, senderdiv, cssClass, SelCssClass)
{
	//ds = xDocSize();
	height= $(targetdiv).getHeight();
	width=$(targetdiv).getWidth();
	
	$(targetdiv).setOpacity(0);
	
	//alert(targetdiv);
	
	
	var par_Node= $(senderdiv).parentNode;
	
	
	for(var i=0;i<par_Node.childNodes.length;i++) 
	{ 
		
		
		if(par_Node.childNodes[i].className ==SelCssClass)
		{
			
			par_Node.childNodes[i].className=cssClass;
		}
	} 
	
	
	$(senderdiv).className=SelCssClass; 
	


	
	
	
	
	$(targetdiv).update("<div id='dlgwait' class='xdlgwait'><h4>Bitte warten...</h4><img src='pics/warten.gif'></div>");
	
	newObj=$('dlgwait');
	xResizeTo(newObj, 200, 200);
	xMoveTo(newObj, (width-newObj.offsetWidth)/2,xScrollTop()+(height-newObj.offsetHeight)/2);
	$(targetdiv).setOpacity(1);
	
	var url = "phpincl/xajaxFunc.php?contid="+contid+"&contclass=cont";
	var myAjax = new Ajax.Request(url,
			{method:'get',
			onSuccess: function(transport){ var response = transport.responseText || "no response text";  buildAjaxContent_prozessRequest(response,targetdiv);},
			onFailure: function(){ alert('Something went wrong...') }   }); 
	
	
}
function buildAjaxContent_prozessRequest(xmltxt,targetdiv)
{
	
	$(targetdiv).setOpacity(0);
	$(targetdiv).update(xmltxt);	
	
	$(targetdiv).appear({ duration: 3.0 });
	//$('ajaxFrame_276').setOpacity(0);
	//$('ajaxFrame_276').appear({ duration: 3.0 });
}


function getPicSize(ww,wh,pic)
{
var picw=pic.width;
var pich=pic.height;
if(picw<ww && pich<wh)
{
pic.width=picw;
pic.height=pich;
}
else
{
		if((picw/ww)>(pich/wh))
		{
		
		pic.width=ww-100;		
		pic.height=(pich*((ww-100)/picw));
		}
		if((picw/ww)<(pich/wh))
		{
		
		pic.height=wh-100;		
		pic.width=(picw*((wh-100)/pich));
		}
	
}

return pic;
}

function vollbild(picfile)
{
ds = xDocSize();
$('body1').insert("<div id='DialogGreyElement' class='xModalDialogGreyElement'></div>");
newObj=$('DialogGreyElement');
xMoveTo(newObj, 0, 0);
xResizeTo(newObj, ds.w, ds.h);
newObj.style.zindex=1000;


filekat=picfile.substring(picfile.length-3,picfile.length);

if(filekat=="swf")
{

vollVideo(picfile);
}
else
{
	if(filekat=="flv")
	{
	
	vollVideo_flv(picfile);
	}
	else
	{
		
		$('body1').insert("<div id='dlgwait' class='xdlgwait'><h4>Bitte warten...</h4><img src='pics/warten.gif'></div>");
		newObj=$('dlgwait');
		xResizeTo(newObj, 200, 200);
		xMoveTo(newObj, xScrollLeft()+(xClientWidth()-newObj.offsetWidth)/2,xScrollTop()+(xClientHeight()-newObj.offsetHeight)/2);

		newObj.style.zindex=1001;
		var bild = new Image();
		bild.onload=function(){weiter(picfile);};
		bild.src=picfile;
	}
}
}


function xxxvollMultiBild(contid)
{
	
	ds = xDocSize();
	$('body1').insert("<div id='DialogGreyElement' class='xModalDialogGreyElement'></div>");
	newObj=$('DialogGreyElement');
	xMoveTo(newObj, 0, 0);
	xResizeTo(newObj, ds.w, ds.h);
	newObj.style.zindex=1000;
	
	
	var newtxt=xajax_ax_getContentbyContId (contid,'body1')
	alert(newtxt);
	$('body1').insert(newtxt);
	
	
	
	
}

function slideOut()
{
	//alert("slideIn");
	var e, x, y, uTime;
	e=$('SlideInMenu');
	x=xLeft(e);
	y=xTop(e)+xHeight(e)-40;
	
	document.images['SlidePic'].onclick=function(){slideIn();};
	xSlideTo(e, x, y, xHeight(e)*5.5);
	document.images['SlidePic'].src="pics/slideinPic.png";
	//xSlideTo(e, 330, 300, 10000);
	
	
	
	
	
}
function slideIn()
{
	//alert("slideIn");
	var e, x, y, uTime;
	e=$('SlideInMenu');
	x=xLeft(e);
	y=39-xHeight(e);
	
	document.images['SlidePic'].onclick=function(){slideOut();};
	//alert(document.images['SlidePic'].src);
	xSlideTo(e, x, y, xHeight(e)*5.5);
	document.images['SlidePic'].src="pics/slideoutPic.png";
	//xSlideTo(e, 330, 300, 10000);
	
	

	
	
}




function vollMultiBild(contid, fields, vals)
{
	
	var f= fields.split(",");
	var v=vals.split(",");
	var rettxt="";
	for (var i = 0; i < f.length; i++)
	{
		rettxt=rettxt+"&"+f[i]+"="+v[i];
		
	}

	//alert(rettxt);
	
	
	
	
	ds = xDocSize();
	$('body1').insert("<div id='DialogGreyElement' class='xModalDialogGreyElement'></div>");
	newObj=$('DialogGreyElement');
	xMoveTo(newObj, 0, 0);
	xResizeTo(newObj, ds.w-5, ds.h-5);
	$('body1').insert("<div id='dlgwait' class='xdlgwait'><h4>Bitte warten...</h4><img src='pics/warten.gif'></div>");
	
	newObj=$('dlgwait');
	xResizeTo(newObj, 200, 200);
	xMoveTo(newObj, xScrollLeft()+(xClientWidth()-newObj.offsetWidth)/2,xScrollTop()+(xClientHeight()-newObj.offsetHeight)/2);
	
	
	
	var url = "phpincl/xajaxFunc.php?contid="+contid+rettxt; 
	//alert(url);
	var myAjax = new Ajax.Request(url,
			{method:'get',
			onSuccess: function(transport){ var response = transport.responseText || "no response text";  prozessRequest(response);},
			onFailure: function(){ alert('Something went wrong...') }   }); 
	
	
	
	
	
}

function prozessRequest(xmltxt)
{
	
	
	$('dlgwait').remove();
	
	//alert("Success! \n\n" + xmltxt); 
	ds = xDocSize();
	
	
	
	//alert(xClientHeight() + "   " + ds.h);
	
	
	$('body1').insert("<div id='modalContainer' class='xModalContainer'></div>")
	contObj=$('modalContainer');
	xResizeTo(contObj, xClientWidth()-60, xClientHeight()-60);
	//xMoveTo(contObj, 0, 0);
	//xMoveTo(contObj, xScrollLeft()+(xClientWidth()-contObj.offsetWidth)/2,xScrollTop()+(xClientHeight()-contObj.offsetHeight)/2);
	xMoveTo(contObj,xScrollLeft()+ (xClientWidth()-contObj.offsetWidth)/2,xScrollTop()+(xClientHeight()-contObj.offsetHeight)/2);
	//contObj.style.zindex=1100;
	
	
	contObj.insert(xmltxt+"<div id='mdlFooter'><div id='closeBtn' onclick='xModalMultiBildRemove()'>Schlie&szlig;en</div></div>");
	
	
	
	
}











function vollVideo(Videofile){
	var flashvars={};
	$('body1').insert("<div id='ModalPictureDiv' class='xModalPictureDiv'><div id='closeBtn' onclick='xModalDialogremove()'>Schlie&szlig;en</div><object id='flashfilm'></object></div>");
	newObj=$('ModalPictureDiv');
	newObj.style.zindex=1002;
	swfobject.embedSWF(Videofile, "flashfilm", "600", "400", "9.0.0", "expressInstall.swf",flashvars);
	xMoveTo(newObj, xScrollLeft()+(xClientWidth()-newObj.offsetWidth)/2,xScrollTop()+(xClientHeight()-newObj.offsetHeight)/2);
	
	newObj.style.zindex=1002;
}

function vollVideo_flv(Videofile){
	var flashvars={};
	flashvars.flvurl=Videofile;
	alert(flashvars.flvurl);
	$('body1').insert("<div id='ModalPictureDiv' class='xModalPictureDiv'><div id='closeBtn' onclick='xModalDialogremove()'>Schlie&szlig;en</div><object id='flashfilm'></object></div>");
	newObj=$('ModalPictureDiv');
	newObj.style.zindex=1002;
	swfobject.embedSWF("videoPlayer.swf", "flashfilm", "600", "400", "9.0.0", "expressInstall.swf",flashvars);
	xMoveTo(newObj, xScrollLeft()+(xClientWidth()-newObj.offsetWidth)/2,xScrollTop()+(xClientHeight()-newObj.offsetHeight)/2);
	newObj.style.zindex=1002;
}










function weiter(picfile)
{
//alert("Hier"+picfile);
$('dlgwait').remove();
ds = xDocSize();
var bild = new Image();
bild.src=picfile;
var cw=xClientWidth();
var ch=xClientHeight();
bild=getPicSize(cw,ch,bild);

var imgtxt = "<img src='"+picfile+"'  width='"+bild.width+"' height='"+bild.height+"'>"



//alert(imgtxt);

$('body1').insert("<div id='ModalPictureDiv' class='xModalPictureDiv'><div id='closeBtn' onclick='xModalDialogremove()'>Schlie&szlig;en</div>"+imgtxt+"</div>");
newObj=$('ModalPictureDiv');


xMoveTo(newObj, xScrollLeft()+(xClientWidth()-newObj.offsetWidth)/2,xScrollTop()+(xClientHeight()-newObj.offsetHeight)/2);
newObj.style.zindex=1002;


}











function xModalDialogremove()
{
$('closeBtn').remove();
$('DialogGreyElement').remove();
$('ModalPictureDiv').remove();


}

function xModalMultiBildRemove()
{
	$('closeBtn').remove();
	$('DialogGreyElement').remove();
	$('modalContainer').remove();
	//modalContainer
}



