/*
 *
 * GoldenWindow
 * Desenvolvedor: Fernando Arroyo
 * GoldenLight [ fernando.arroyo@goldenlight.biz ]
 * 06.08.2009
 *
 */

	var GoldenWindow=function(Parametros){
		
		/*
		 * Parametros - GoldenWindow
		 * 
		 * Conteudo
		 * Largura
		 * Altura
		 * 
		 */
		
		this.Executar=function(){

			GoldenWindowTelaConfirmacao	=document.createElement("div");
			GoldenWindowConteudo		=document.createElement("div");
			GoldenWindowFechar		=document.createElement("div");
			GoldenWindowLinkFechar	=document.createElement("a");
			GoldenWindowCamadaFechar	=document.createElement("span");
			GoldenWindowTelaFundo	=document.createElement("span");
			
			GoldenWindowTelaFundo.setAttribute("id","__GoldenWindowTelaFundo__");
			GoldenWindowTelaFundo.style.zIndex="9999";
			GoldenWindowTelaFundo.style.display="block";
			GoldenWindowTelaFundo.style.position="fixed";
			GoldenWindowTelaFundo.style.top="0px";
			GoldenWindowTelaFundo.style.left="0px";
			GoldenWindowTelaFundo.style.backgroundColor="#000000";
			GoldenWindowTelaFundo.style.opacity="0.5";
			GoldenWindowTelaFundo.style.filter="alpha(opacity=50)";
			GoldenWindowTelaFundo.style.width=document.body.clientWidth+"px";
			GoldenWindowTelaFundo.style.height=document.body.clientHeight+"px";
			document.body.appendChild(GoldenWindowTelaFundo);

			GoldenWindowLinkFechar.setAttribute("href","javascript:void(0);");
			GoldenWindowLinkFechar.setAttribute("style","text-decoration:none;");
			GoldenWindowLinkFechar.onclick=function(){
//				document.body.removeChild(GoldenWindowTelaConfirmacao);
				if (document.getElementById("__GoldenWindow__")) {
				$('#__GoldenWindow__').animate({
					 left:(-(screen.width))
				}
				,600
				,"swing"
				,function(){
					$('#__GoldenWindowTelaFundo__').remove();
					$('#__GoldenWindow__').remove();
				})
			}
//				$('#__GoldenWindow__').remove();

			}



			GoldenWindowCamadaFechar.innerHTML="x";
			with(GoldenWindowCamadaFechar.style){
				display="block";
				backgroundColor="#d8d8d8";
				fontWeight="bolder";
				color="#FFFFFF";
				padding="5px";
				paddingTop="0px";
				paddingBottom="2px";
			}
			GoldenWindowLinkFechar.appendChild(GoldenWindowCamadaFechar);
			GoldenWindowFechar.appendChild(GoldenWindowLinkFechar);
			with(GoldenWindowFechar.style){
				position="absolute";
				top="10px";
				if (Parametros.Largura) {
					left = (Parametros.Largura-30)+"px";
				}
				else{
					left = "370px";
				}
			}
			GoldenWindowConteudo.innerHTML=Parametros.Conteudo;

			with(GoldenWindowTelaConfirmacao){
				id="__GoldenWindow__";
				style.zIndex=999999;
				style.display="block";
				style.position="fixed";
				if(Parametros.Altura){
					style.top=(($(window).height()-Parametros.Altura)/2)+"px";
					style.height=Parametros.Altura+"px";
				}
				else{
					style.top=((screen.height-300)/2)+"px";
//					style.height="300px";
				}
				if(Parametros.Largura){
					style.left=(screen.width*2)+"px";
					style.width=Parametros.Largura+"px";
				}
				else{
					style.left=((screen.width-400)/2)+"px";
					style.width=400+"px";
				}
				style.fontFamily="Verdana";
				style.backgroundColor="#f4f4f4";
				style.border= "1px solid #d8d8d8";
				style.paddingBottom="10px";
				style.zIndex=999999;
				appendChild(GoldenWindowConteudo);
				appendChild(GoldenWindowFechar);
			}
			GoldenWindowConteudo.id = "__GoldenWindowConteudo__";
			with(GoldenWindowConteudo.style){
				position="relative";
				float="left";
				padding="10px";
				fontSize="12px";
				marginTop="25px";
			}
			document.body.appendChild(GoldenWindowTelaConfirmacao);
			$('#__GoldenWindow__').animate({
				 left:((screen.width-400)/2)
			}
			,600
			,"swing"
			,function(){
			})

		}
		
		if (!document.getElementById('__GoldenWindow__')) {
			this.Executar();
		}
		
		this.Fechar=function(){
				$('#__GoldenWindow__').remove();
//				document.body.removeChild(GoldenWindowTelaConfirmacao);
		}
	}

