
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 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];
		
	}
	
	
	
	ds = xDocSize();
	$('body1').insert("<div id='DialogGreyElement' class='xModalDialogGreyElement'></div>");
	newObj=$('DialogGreyElement');
	xMoveTo(newObj, 0, 0);
	xResizeTo(newObj, ds.w, ds.h);
	$('body1').insert("<div id='dlgwait' class='xdlgwait'><h4>Bitte warten...</h4><img src='mischaSoft/pics/warten.gif'></div>");
	
	newObj=$('dlgwait');
	xResizeTo(newObj, 200, 200);
	xMoveTo(newObj, xScrollLeft()+(xClientWidth()-newObj.offsetWidth)/2,xScrollTop()+(xClientHeight()-newObj.offsetHeight)/2);
	
	
	
	var url = "xajaxFunc.php?contid="+contid+rettxt;  
	
	
	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 getT3Content(id)
{
	ds = xDocSize();
	$('body1').insert("<div id='DialogGreyElement' class='xModalDialogGreyElement'></div>");
	newObj=$('DialogGreyElement');
	xMoveTo(newObj, 0, 0);
	xResizeTo(newObj, ds.w, ds.h);
	$('body1').insert("<div id='dlgwait' class='xdlgwait'><h4>Bitte warten...</h4><img src='mischaSoft/pics/warten.gif'></div>");
	
	newObj=$('dlgwait');
	xResizeTo(newObj, 200, 200);
	xMoveTo(newObj, xScrollLeft()+(xClientWidth()-newObj.offsetWidth)/2,xScrollTop()+(xClientHeight()-newObj.offsetHeight)/2);
	
	
	
	var url = "index.php?type=101&id="+id;  
	
	
	var myAjax = new Ajax.Request(url,
			{method:'get',
			onSuccess: function(transport){ var response = transport.responseText || "no response text";  prozessRequest(response);},
			onFailure: function(){ alert('Ein Fehler ist aufgetreten, leider können die angeforderten Daten nicht angezeigt werden');
									$('dlgwait').remove();
									$('DialogGreyElement').remove(); }   }); 
	
	
	
}


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()-50, xClientHeight()-50);
	xResizeTo(contObj,750, xClientHeight()-100);
	//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("<div id='closeBtn' ><div class='txt'></div><img src='mischaSoft/pics/close.png'  onclick='xModalMultiBildRemove()'></div><div id='modalcont' class='cont'>"+xmltxt+"</div>");
	
	contObj=$('modalcont');
	xResizeTo(contObj,745, xClientHeight()-135);
	
	
	
}


function change_src(targetimg,newsrc,fullpic, pictxt, targettxt)
{
var imgname=targetimg;



document.images[targetimg].src=newsrc;

if(targettxt != "")
{
	//alert(pictxt+"  " + targettxt);
	$(targettxt).firstChild.nodeValue =pictxt;
}
}








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
}



