/* KaBox v 1.0.0 */
/* Jun 2009 Kahiloa Solutions et Communication */
/* Nikon Europe Project */

// FadeIn Effect


function fadeIn(objId,opacity) {
	if(document.getElementById(objId)){
		//obj = document.getElementById(objId);
		//alert(obj);
		if (opacity <= 100) {
			setOpacity(objId, opacity);
			if (document.all) {
				opacity += 20;
			}			
			else {
				opacity += 10;
			}
			window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 50);
		}
	}
}

function setOpacity(obj, opacity) {
	if (document.all) {
		opacity = ((opacity == 100)?99.999:opacity) - 25;
	}
	else {
		opacity = ((opacity == 100)?99.999:opacity) - 60;
	}	

	// IE 
	document.getElementById(obj).style.filter = "alpha(opacity="+opacity+")";
	// Older Safari, Konqueror
	document.getElementById(obj).style.KHTMLOpacity = opacity/50;
	// Older Firefox
	document.getElementById(obj).style.MozOpacity = opacity/50;
	// Safari, newer Firefox, CSS3
	document.getElementById(obj).style.opacity = opacity/50;
 
}

function View3dController(JavaSrc, elWidth, elHeight, elColor) {
	var KaBoxPosition = window.pageYOffset;

	// Global container
	var appletContainer = document.createElement('div');
	appletContainer.setAttribute('id', 'ContainerJava');
	
	if (document.all) {
		appletContainer.style.cssText = 'background-color:'+ elColor + '; top:'+ KaBoxPosition +'px';
	}
	
	else {
		appletContainer.setAttribute('style', 'background-color:'+ elColor + '; top:'+ KaBoxPosition +'px');
	}
	
	// Create Appelet
	var applet = document.createElement('applet');
	if (document.all) {
		applet.style.cssText = 'margin-left:-'+ elWidth/2 +'px ; margin-top:-'+ elHeight/2 +'px';
	}
	
	else {
		applet.setAttribute('style', 'margin-left:-'+ elWidth/2 +'px ; margin-top:-'+ elHeight/2 +'px');
	}	
	
	applet.setAttribute('width', elWidth);
	applet.setAttribute('height', elHeight);
	applet.setAttribute('code', 'blaze3d.class');
	applet.setAttribute('archive', '/resources/styles/global/applet/holomatix.jar');
	
	// Create params
	var paraMovie = document.createElement('param');
	paraMovie.setAttribute('value', JavaSrc);
	paraMovie.setAttribute('name', 'movie');
	
	var paraScale = document.createElement('param');
	paraScale.setAttribute('value', 'showall');
	paraScale.setAttribute('name', 'Scale');
	
	var paraFlashVars = document.createElement('param');
	paraFlashVars.setAttribute('value', 'bg=w');
	paraFlashVars.setAttribute('name', 'FlashVars');
	
	// Including elements
	applet.appendChild(paraScale);
	applet.appendChild(paraMovie);
	applet.appendChild(paraFlashVars);
	appletContainer.appendChild(applet);
	document.body.appendChild(appletContainer);
	fadeIn('ContainerJava', 0); setOpacity('ContainerJava', 0);
	
	// Hiding body scroll bars
	document.body.style.overflow='hidden';
	
	// Removing box
	function removeBox() {
		document.body.style.overflow='visible';
		document.body.removeChild(appletContainer);
	}
	
	appletContainer.onclick = removeBox;
	
}
