/*----------- Close Window -----------*/
function close_window(win) 
{
	win.hide();	
	WindowUtilities.enableScreen();
	Windows.resetOverflow();
	for(var i=0;i<Windows.windows.length;++i)
	{
		var lwin = Windows.windows[i];		
		//alert('win: '+lwin.getId() + ' - ' + lwin.isVisible);
		if(lwin!= null && lwin.getId()!=win.getId())
		{
		   if(lwin.modal && lwin.isVisible())
			 {
			  WindowUtilities.disableScreen(lwin.options.className, 'overlay_modal', lwin.getId());
			  lwin.toFront();
			  return;
			 }
		}
	}
	//win.destroy();
}
var lshowMeInLoad=false;
/*--------  Build Window ------------*/
function buildWindow(url,id,title,w,h,showMeInLoad)
{
	var sitio='';
	if( url!= null )
	  sitio = url;
	var win=null;
	lshowMeInLoad = showMeInLoad;
	title = '<span style="color:blue"><b>'+title+'</b></span>';
	// Ajax Options
	var opt={
		method:'get',
		asynchronous:true,
		onSuccess:function(t)
		{  
		  try{		   
		  // Mostrar la ventana una vez que obtuvo la informacion via Ajax
		  window.setTimeout("var lwin = Windows.windows[Windows.windows.length-1];if(lwin.showMeInLoad) lwin.showCenter(true); ",70);
		  }catch(e){ alert(e.message);  }
		},
		//Mostrar el Error si ocurre ------
		onFailure:function(t)
		{
		var strErr=t.responseText;
		  try
		  { 	  
			strErr = strErr.substring(strErr.indexOf("<title>")+7,strErr.lastIndexOf("</title"));	   
			alert('Ocurrio error en la solicitud:\n'+	strErr);	  
		  }catch(exInt){}
		}	
	 } 
	if( !(win=Windows.getWindow(id)) )
	{ 
	   win = new Window(id, { className:"mac_os_x",title: title, top:0, right:20, width: w, height: h, 
			 		  draggable:false, closable:true, minimizable:false, url: sitio  ,maximizable: false, 
					  resizable:false,hideEffectOptions : {duration:0}, showEffectOptions: {duration:0}})
	  if(sitio!='');
	    win.setAjaxContent(sitio,opt,true,true);
	  win.setDelegate({ canClose: close_window	 });	  
	  win.showMeInLoad = showMeInLoad;
	}
	else
	{
	 showHideFlash('none')
	 win.showCenter(true);
	}
	return  win;  
}

function loadWindow()
{

}
function getRemData(fnOk,fnErr)
{
	$.ajax({
	type: "POST",
	url: urlGet,
	beforeSend: function(){ $("#pgbar").show();},
	success: fnOk ,
	error: fnErr });
}