YAHOO.namespace("kittelberger.yuibox");
//YuiBox Standards:
YBheight = ['250px','500px','498px'];
YBwidth = ['366px','580px','600px'];

//function showYuiBox(iframeSrc, globalWidth, globalHeight, closeIt, printIt){
function showYuiBox(elid){

var tbId = "";	
	
if(elid.length > 0){
    YBel = document.getElementById(elid);
    thickboxSource = elid;
}else{
    YBel = this;
    thickboxSource = YBel.id.split('_')[1];
    tbId = YBel.id;
}

  if(YAHOO.util.Dom.hasClass(YBel,'small')){
     globalHeight = YBheight[0];
     globalWidth  = YBwidth[0];
  }else if(YAHOO.util.Dom.hasClass(YBel,'medium')){
     globalHeight = YBheight[1];
     globalWidth  = YBwidth[1];
 }else if(YAHOO.util.Dom.hasClass(YBel,'big')){
     globalHeight = YBheight[2];
     globalWidth  = YBwidth[2];
  }


 
 // Initialize the temporary Panel to display while waiting for external content to load param height must not be used!
	 if (navigator.appName=="Microsoft Internet Explorer")
	 {
		 var suche = globalHeight.indexOf("px");
		 globalHeight=globalHeight.substring(0, suche);
		 z=Number(globalHeight);
		 z+=4;//iefix
		 globalHeight=""+z+"px";
	 }
	
	 YAHOO.kittelberger.yuibox.box = new YAHOO.widget.Panel("yuiBox",
		 {
		 width: globalWidth,
		 fixedcenter: true,
		 close: false,
		 draggable: false,
		 zindex:999,
		 modal: true,
		 visible: false
		 }
	 );
	 

	 //alert(tbId);
	 if (tbId.indexOf("YB_asynchronThickboxMember") >= 0) {

	    profileId = tbId.substring("YB_asynchronThickboxMember".length+1,tbId.length);
		 
		var setBodyWithThickboxContent  = {
				success: function(o) {
						YAHOO.kittelberger.yuibox.box.setBody(o.responseText);
						renderThickbox();
					},
				failure: function(o) {
				}
	    }
		var transaction = YAHOO.util.Connect.asyncRequest('GET', encodeURI(communityPath) + 'memberThickbox.html?profileId=' + encodeURI(profileId) + '&ts=' + (new Date()).getTime(), setBodyWithThickboxContent, null);

	 }
	 else {
		SourceBox = document.getElementById(thickboxSource);
		newBox = SourceBox.cloneNode(true);
	    YAHOO.util.Dom.setStyle(newBox, 'display', 'block');
		 
		//if(printIt){
		//YAHOO.kittelberger.yuibox.box.setBody("<iframe name='IframeYuiBox' marginwidth='0' marginheight='0' frameborder='0' framespacing='0' scrolling='no' style='border:0px none;margin:0;padding:0' src='"+iframeSrc+"' width='"+globalWidth+"' height='"+globalHeight+"'></iframe><div id='footer'><a href='javascript:parent.frames.IframeYuiBox.focus();parent.frames.IframeYuiBox.print();' class='blue print'> "+printIt+"</a><a href='javascript:closeYB();' class='blue close'> "+closeIt+"</a></div>");
	    YAHOO.kittelberger.yuibox.box.setBody(newBox);
		//}else{
		//YAHOO.kittelberger.yuibox.box.setBody("<iframe marginwidth='0' marginheight='0' frameborder='0' framespacing='0' scrolling='no' style='border:0px none;margin:0;padding:0' src='"+iframeSrc+"' width='"+globalWidth+"' height='"+globalHeight+"'></iframe><div id='footer'><a href='javascript:closeYB();' class='blue close'> "+closeIt+"</a></div>");
		//	}
	    
	    renderThickbox();
	 }
	 
		YAHOO.util.Event.addListener('yuiBox_mask', 'click', closeYB);
		var kl = new YAHOO.util.KeyListener(document, { keys:27 },  							
													  { fn:closeYB,
														scope:YAHOO.kittelberger.yuibox.box,
														correctScope:true } );
		
		kl.enable();  
}

function renderThickbox() {
	
	YAHOO.util.Dom.addClass(YAHOO.kittelberger.yuibox.box.element, "yui-skin-sam");
	YAHOO.kittelberger.yuibox.box.render(document.body);
	
 	// Show the Panel
	document.getElementsByTagName("body")[0].style.overflowY = 'hidden';
	if(document.all) document.getElementsByTagName("html")[0].style.overflowY = 'hidden';	
	
	YAHOO.kittelberger.yuibox.box.show();
	
	//Ausnahme f�r den (Bosch)IE6, damit die Thickboxen die richtige Gr��e haben und mittig angeordnet werden.
	if(document.all){
		yuiMask = YAHOO.util.Dom.getNextSibling('yuiBox_mask');
		underlay = YAHOO.util.Dom.getElementsByClassName('underlay');
		
		if(yuiMask.tagName == 'IFRAME'){
			YAHOO.util.Dom.setStyle(yuiMask,'visibility','hidden');
			YAHOO.util.Dom.setStyle(underlay,'height','auto');
		}
	}
}


function closeYB(el){
	
	if(el)
	{	
		YAHOO.kittelberger.yuibox.box = parent.YAHOO.kittelberger.yuibox.box;
		YAHOO.kittelberger.yuibox.box.hide();
		
		//parent.window.location.reload();
		parent.document.getElementsByTagName("body")[0].style.overflowY = 'auto';
		if(document.all) parent.document.getElementsByTagName("html")[0].style.overflowY = 'auto';	
		if(document.all) parent.document.getElementsByTagName("body")[0].style.overflowY = 'hidden';

		if(document.all) parent.document.getElementsByTagName('html')[0].style.overflowX = "hidden";
		parent.document.getElementsByTagName('body')[0].style.overflowX = "hidden";		
	}
	else
	{
		// Simply hide the Panel 
		YAHOO.kittelberger.yuibox.box.hide();
		document.getElementsByTagName("body")[0].style.overflowY = 'auto';
		if(document.all) document.getElementsByTagName("html")[0].style.overflowY = 'auto';
		if(document.all) document.getElementsByTagName("body")[0].style.overflowY = 'hidden';		
		
		if(document.all) document.getElementsByTagName('html')[0].style.overflowX = "hidden";
		document.getElementsByTagName('body')[0].style.overflowX = "hidden";		
		// Destroy the Panel -> clean up the DOM
		YAHOO.kittelberger.yuibox.box.destroy();
	}
}

function DisplayBlock(){
	YAHOO.util.Dom.setStyle('top', 'display', 'block');
	}

function printYB(el){
		el.print();
	}


