/*
CHROMELESS WINDOWS v.30.5
(c) Gabriel Suchowolski power[z]one / www.microbians.com / powerz@microbians.com
Distributed under the terms of the GNU Library General Public License (www.gnu.org)
*/
function openchromeless(theURL,wname,W,H,X,Y,NONEgrf,CLOSEdwn,CLOSEup,CLOSEovr,MINIdwn,MINIup,MINIovr,CLOCKgrf,titHTML,titWIN,winBORDERCOLOR,winBORDERCOLORsel,winBGCOLOR,winBGCOLORsel) {
var isie=false
var isv55=false
var iswin=false
if ( navigator.appName=="Microsoft Internet Explorer" && parseInt(navigator.appVersion)>=4 ) {
isie=true
if ( navigator.appVersion.substring(navigator.appVersion.indexOf("MSIE ")+5,navigator.appVersion.indexOf("MSIE ")+8) >=5.5 ) isv55=true
}
if ( navigator.userAgent.toLowerCase().indexOf("win")!=-1 ) iswin=true
if (X==null) X=Math.ceil( (window.screen.width-W) / 2 )
if (Y==null) Y=Math.ceil( (window.screen.height-H) / 2 )
if (isie) { H=H+20+3;W=W+2;}
var s=",width="+ W +",height="+ H ;
if (isie && iswin) {
var chromeTIThtml=''+
'<html>\n'+
'<head>\n'+
'<style type="text/css">\n'+
'#crtMOVE {position:absolute;left:0px;top:0px;z-index:2;}\n'+
'#txtTITLE {position:absolute;left:0px;top:0px;width:100%;height:20px;z-index:1;clip:rect(0,100%,20,0);}\n'+
'#btnCLOSE {position:absolute;left:-20px;top:4px;width:11px;height:11px;z-index:3;clip:rect(0,11,11,0);}\n'+
'#btnMINI {position:absolute;left:-20px;top:4px;width:11px;height:11px;z-index:3;clip:rect(0,11,11,0);}\n'+
'#grfCLOCK {position:absolute;left:-20px;top:4px;width:11px;height:11px;z-index:3;clip:rect(0,11,11,0);}\n'+
'</style>\n'+
'<script language="javascript">\n'+
'var imgCLOSEdwn=new Image();imgCLOSEdwn.src="'+ CLOSEdwn +'"\n'+
'var imgCLOSEup=new Image();imgCLOSEup.src="'+ CLOSEup +'"\n'+
'var imgCLOSEovr=new Image();imgCLOSEovr.src="'+ CLOSEovr +'"\n'+
'var imgMINIdwn=new Image();imgMINIdwn.src="'+ MINIdwn +'"\n'+
'var imgMINIup=new Image();imgMINIup.src="'+ MINIup +'"\n'+
'var imgMINIovr=new Image();imgMINIovr.src="'+ MINIovr +'"\n'+
'var CLOCKgrfImg=new Image();CLOCKgrfImg.src="'+ CLOCKgrf +'"\n'+
'document.onselectstart=new Function("return false;")\n'+
'document.ondragstart=new Function("moveWIN();return false;")\n'+
'document.oncontextmenu=new Function("return false;")\n'+
'document.onmousemove=moveWIN\n'+
'winSTATUS="up"\n'+
'function setLAYOUT() {\n'+
'document.all["btnCLOSE"].style.pixelLeft=document.body.clientWidth-18\n'+
'if ( top.mainloaded ) {\n'+
'document.all["grfCLOCK"].style.visibility="hidden"\n'
if (isv55) {
chromeTIThtml +=''+
'document.all["btnMINI"].style.visibility="visible"\n'+
'document.all["btnMINI"].style.pixelLeft=document.body.clientWidth-38\n'
}
chromeTIThtml +=''+
'}\n'+
'else {\n'+
'document.all["btnMINI"].style.visibility="hidden"\n'+
'document.all["grfCLOCK"].style.pixelLeft=document.body.clientWidth-38\n'+
'setTimeout("setLAYOUT()",500)\n'+
'}\n'+
'}\n'+
'function minimizeWIN() {\n'+
'top.window.moveTo(0,-4000)\n'+
'if ( (top.opener) && (!top.opener.closed) ) { top.opener.window.focus();}\n'+
'top.window.blur()\n'+
'}\n'+
'function moveWIN() {\n'+
'if ( winSTATUS=="down") {\n'+
'document.body.bgColor="'+winBGCOLORsel+'"\n'+
'parent.bordeM.document.body.bgColor="'+winBORDERCOLORsel+'"\n'+
'parent.bordeT.document.body.bgColor="'+winBORDERCOLORsel+'"\n'+
'parent.bordeB.document.body.bgColor="'+winBORDERCOLORsel+'"\n'+
'parent.bordeL.document.body.bgColor="'+winBORDERCOLORsel+'"\n'+
'parent.bordeR.document.body.bgColor="'+winBORDERCOLORsel+'"\n'+
'ofx=event.x\n'+
'ofy=event.y\n'+
'winSTATUS="drag"\n'+
'}\n'+
'else if ( winSTATUS=="drag") {\n'+
'px=event.screenX-ofx-1\n'+
'py=event.screenY-ofy-1\n'+
'top.window.x=px\n'+
'top.window.y=py\n'+
'top.window.moveTo(px,py)\n'+
'} else {\n'+
'document.body.bgColor="'+winBGCOLOR+'"\n'+
'parent.bordeM.document.body.bgColor="'+winBORDERCOLOR+'"\n'+
'parent.bordeT.document.body.bgColor="'+winBORDERCOLOR+'"\n'+
'parent.bordeB.document.body.bgColor="'+winBORDERCOLOR+'"\n'+
'parent.bordeL.document.body.bgColor="'+winBORDERCOLOR+'"\n'+
'parent.bordeR.document.body.bgColor="'+winBORDERCOLOR+'"\n'+
'winStatus="up"\n'+
'}\n'+
'}\n'+
'</script>\n'+
'</head>\n'+
'<body onresize="setLAYOUT()" bgcolor='+winBGCOLOR+'>\n'+
'<div id=crtMOVE><img onmousedown="winSTATUS=\'down\';moveWIN()" onmouseup="winSTATUS=\'up\';moveWIN()" border=0 src="'+NONEgrf+'" width=110% height=500></div>\n'+
'<div id=txtTITLE>'+ '<table width=100% height=20 border=0 cellpadding=0 cellspacing=0><tr><td valign=middle align=left>'+titHTML+'</td></tr></table>' +'</div>\n'+
'<div id=btnCLOSE><img name=imgCLOSE src="'+ CLOSEup +'" border=0 width=11 height=11 onmouseover="this.src=imgCLOSEovr.src" onmouseout="btnSTATUS=false;this.src=imgCLOSEup.src" onmouseup="this.src=imgCLOSEup.src" onmousedown="this.src=imgCLOSEdwn.src" onclick="top.window.close()"></div>\n'+
'<div id=btnMINI><img name=imgMINI src="'+ MINIup+'" border=0 width=11 height=11 onmouseover="this.src=imgMINIovr.src" onmouseout="btnSTATUS=false;this.src=imgMINIup.src" onmouseup="this.src=imgMINIup.src" onmousedown="this.src=imgMINIdwn.src" onclick="minimizeWIN()"></div>\n'+
'<div id=grfCLOCK><img name=imgCLOCK src="'+ CLOCKgrf +'" border=0 width=11 height=11></div>\n'+
'<script>setLAYOUT()</script>\n'+
'</body>\n'+
'</html>\n'
var chromeFRMhtml='' +
'<HTML>\n'+
'<HEAD>\n'+
'<TITLE>'+ titWIN +'</TITLE>\n'+
'</HEAD>\n'+
'<script>\n'+
'top.mainloaded=false\n'+
'function generatetitle() {\n'+
'if( window.frames["frmTIT"] && window.frames["bordeL"] && window.frames["bordeB"] && window.frames["bordeR"] && window.frames["bordeM"] ) {\n'+
'frmTIT.document.bgColor="'+ winBGCOLOR +'"\n'+
'frmTIT.document.open()\n'+
'frmTIT.document.write( "'+ quitasaltolinea(chromeTIThtml) +'" )\n'+
'frmTIT.document.close()\n'+
'bordeM.document.bgColor="'+ winBORDERCOLOR +'"\n'+
'bordeL.document.bgColor="'+ winBORDERCOLOR +'"\n'+
'bordeR.document.bgColor="'+ winBORDERCOLOR +'"\n'+
'bordeB.document.bgColor="'+ winBORDERCOLOR +'"\n'+
'bordeT.document.bgColor="'+ winBORDERCOLOR +'"\n'+
'} else {\n'+
'setTimeout("generatetitle()",20)\n'+
'}\n'+
'}\n'+
'top.window.h='+H+'\n'+
'top.window.w='+W+'\n'+
'top.window.x='+X+'\n'+
'top.window.y='+Y+'\n'+
'generatetitle()\n'+
'</script>\n'+
'<frameset onload="top.mainloaded=true" onfocus="top.window.moveTo(top.window.x,top.window.y)" border=0 framespacing=0 frameborder=0 cols="1,100%,1">\n'+
'<frame name=bordeL src="about:blank" scrolling=no noresize>\n'+
'<frameset border=0 framespacing=0 frameborder=0 rows="1,20,1,100%,1">\n'+
'<frame name=bordeT src="about:blank" scrolling=no noresize>\n'+
'<frame name=frmTIT src="about:blank" scrolling=no noresize>\n'+
'<frame name=bordeM src="about:blank" scrolling=no noresize>\n'+
'<frame name=main src="'+theURL+'">\n'+
'<frame name=bordeB src="about:blank" scrolling=no noresize>\n'+
'</frameset>\n'+
'<frame name=bordeR src="about:blank" scrolling=no noresize>\n'+
'</frameset>\n'+
'</HTML>'
var CWIN=window.open( "",wname,"fullscreen=1"+s)
CWIN.resizeTo(Math.ceil(W),Math.ceil(H))
CWIN.moveTo(Math.ceil(X),Math.ceil(Y))
CWIN.document.open()
CWIN.document.write( chromeFRMhtml )
CWIN.document.close()
}else{
var CWIN=window.open(theURL,wname,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1"+s,true)
}
CWIN.focus()
return CWIN
}

function quitasaltolinea(txt) {
var salida=txt.toString()
var re=/\\/g;var salida=salida.replace(re,"\\\\");
re=/\//g;var salida=salida.replace(re,"\\\/");
re=/\"/g;var salida=salida.replace(re,"\\\"");
re=/\'/g;var salida=salida.replace(re,"\\\'");
re=/\n/g;var salida=salida.replace(re,"\\n");
return salida
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function adicionaraofavoritos(vUrl,vDescricao, vRetorno)
{
  window.external.AddFavorite(vUrl,vDescricao);
  if (vRetorno==null)
  {
    //não retorna nada
  }
  else
  {
    //retorna qualquer coisa que você definir em vRetorno 
    //obs.: aplicavel ao caso de querer retornar uma outra função ou o valor de outra função
    return vRetorno;
  };
};

function definircomopaginainicial(vId, vUrl, vRetorno)
{
  var ns = (navigator.appName == "Netscape");
  var ie = (navigator.appName == "Microsoft Internet Explorer");
  if(ie)
  {
    vId.style.behavior='url(#default#homepage)';
    vId.setHomePage(vUrl);
  } 
  else if(ns)
  {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesWrite");
    navigator.preference("browser.startup.homepage", vUrl);
  };

  if (vRetorno==null)
  {
    //não retorna nada
  }
  else
  {
    //retorna qualquer coisa que você definir em vRetorno 
    //obs.: aplicavel ao caso de querer retornar uma outra função ou o valor de outra função
    return vRetorno;
  };
};
// ------------------------------------------

/**
  * This file contains functions to allow adding items from inside the weblog.
  * Also contains code to avoid submitting form data twice.
  *
  * (C) Wouter Demuynck (wouter@demuynck.org)
  */

var nucleusConvertBreaks = true;
var nucleusMediaPopupURL = '';
var nucleusMediaURL = 'media/';
var nucleusAuthorId = 0;

function setConvertBreaks(newval) {	nucleusConvertBreaks = newval; }
function setMediaUrl(url) { nucleusMediaURL = url; }
function setAuthorId(id) { nucleusAuthorId = id; }

function preview(id, value) {
	elem = document.getElementById(id);
	if (!elem) return;
	
	var preview = nucleusConvertBreaks ? str_replace("\n","<br />",value)+"&nbsp;" : value+"&nbsp;";
	
	// expand the media commands
	preview = preview.replace(/\<\%image\(([^\|]*)\|([^\|]*)\|([^\|]*)\|([^)]*)\)\%\>/g,"<img src='"+nucleusMediaURL+nucleusAuthorId+"/$1' width='$2' height='$3' alt=\"$4\" />");
	preview = preview.replace(/\<\%popup\(([^\|]*)\|([^\|]*)\|([^\|]*)\|([^)]*)\)\%\>/g,"<a href='' onclick='if (event &amp;&amp; event.preventDefault) event.preventDefault(); alert(\"popup image\"); return false;' title='popup'>$4</a>");
	preview = preview.replace(/\<\%media\(([^\|]*)\|([^)]*)\)\%\>/g,"<a href='' title='media link'>$2</a>");
	
	elem.innerHTML = preview;
}

function showedit() {
	prevval = document.getElementById('edit').style.display;
	if (prevval == "block")
		newval = "none";
	else
		newval = "block";
	document.getElementById('edit').style.display = newval;

	if (newval == "block")
		updAllPreviews();	
}

function updAllPreviews() {
	updPreview('title');
	updPreview('body');
	updPreview('more');
}

function isEditVisible() {
	var editform = document.getElementById('edit');
	if (!editform) return true;
	var prevval = editform.style.display;
	return (prevval == "none") ? false : true;
}

function updPreview(id) {
	// don't update when preview is hidden
	if (!isEditVisible()) return;
	
	var inputField = document.getElementById('input' + id);
	if (!inputField) return;
	preview('prev' + id, inputField.value);
}

// replace a in s by b (taken from milov.nl)
function str_replace(a, b, s)
{
	if (a == b || !s.length || !a.length) return s;
	if ((p=s.indexOf(a)) == -1) { return s; }
	else { ns = s.substring(0,p) + b + s.substring(p+a.length,s.length); }
	return (s.indexOf(a) != -1) ? str_replace(a, b, ns) : ns;
}

function shortCuts() {
	if (!event || (event.ctrlKey != true)) return;
	
	switch (event.keyCode) {
		case 1:
			ahrefThis(); break; // ctrl-shift-a
		case 2:
			boldThis(); break; // ctrl-shift-b
		case 9:
			italicThis(); break; // ctrl-shift-i
		case 13:
			addMedia(); break; // ctrl-shift-m
		default: 
			return;
	}
	return;
}

function cutThis() { execAndUpdate('cut'); }
function copyThis() { execAndUpdate('copy'); }
function pasteThis() { execAndUpdate('paste'); }
function boldThis() { insertAroundCaret('<b>','</b>'); }
function italicThis() { insertAroundCaret('<i>','</i>'); }
function leftThis() { insertAroundCaret('<div class="leftbox">','</div>'); }
function rightThis() { insertAroundCaret('<div class="rightbox">','</div>'); }

function ahrefThis() {
	if (document.selection)
		strSelection = document.selection.createRange().text;
	else
		strSelection = '';
		
	strHref = prompt("Create a link to:","http://");
	if (strHref == null) return;
	
	var textpre = "<a href=\"" + strHref + "\">";
	insertAroundCaret(textpre, "</a>");
}

function execAndUpdate(action) {
	lastSelected.caretPos.execCommand(action);
	updAllPreviews();	
}


var nonie_FormType = 'body';

// Add media to new item
function addMedia(type) {
	
	nonie_FormType = type;	// form type (for non-ie browsers)
	
	var mediapopup = window.open(nucleusMediaPopupURL + 'media.php?destid=' + nucleusAuthorId,'name',
		'status=yes,toolbar=no,scrollbars=yes,resizable=yes,width=500,height=400,top=0,left=0');

	return;
} 


function setMediaPopupURL(url) {
	nucleusMediaPopupURL = url;
}

function includeImage(filename, type, width, height) {

	if (isCaretEmpty()) {
		text = prompt("Text to display ?","");
	} else {
		text = getCaretText();
	}
	
	var replaceBy;
	switch(type) {
		case 'popup':
			replaceBy = '<%popup(' +  filename + '|'+width+'|'+height+'|' + text +')%>';
			break;
		case 'inline':
		default:
			replaceBy = '<%image(' +  filename + '|'+width+'|'+height+'|' + text +')%>';
	}
	
	insertAtCaret(replaceBy);
	updAllPreviews();	

}


function includeOtherMedia(filename) {
	if (isCaretEmpty()) {
		text = prompt("Text to display ?","");
	} else {
		text = getCaretText();
	}
	
	var replaceBy = '<%media(' +  filename + '|' + text +')%>';
	
	insertAtCaret(replaceBy);
	updAllPreviews();	
}



// function to prevent submitting form data twice
var submitcount=0;
function checkSubmit() {
	if (submitcount == 0) {
		submitcount++;
		return true;
	} else {
		return false;
	}
}


// code to store the caret (cursor) position of a text field/text area
// taken from javascript.faqts and modified
// http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130

// stores the caret
function storeCaret (textEl) {
	// store caret
	if (textEl.createTextRange) 
		textEl.caretPos = document.selection.createRange().duplicate();

	// also store lastselectedelement
	lastSelected = textEl;
}

var lastSelected;

// inserts text at caret (overwriting selection)
function insertAtCaret (text) {
	var textEl = lastSelected;
	if (textEl && textEl.createTextRange && textEl.caretPos) {
		var caretPos = textEl.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
	} else if (textEl) {
		textEl.value  = text;
	} else {
		document.getElementById('input' + nonie_FormType).value += text;		
	}
	updAllPreviews();
}

// inserts a tag around the selected text
function insertAroundCaret (textpre, textpost) {
	var textEl = lastSelected;
	if (textEl && textEl.createTextRange && textEl.caretPos) {
		var caretPos = textEl.caretPos;
		caretPos.text = textpre + caretPos.text + textpost;
	} else {
		document.getElementById('input' + nonie_FormType).value += textpre + textpost;
	}
	updAllPreviews();
}

function getCaretText() {
	return lastSelected.caretPos.text;
}

function isCaretEmpty() {
	if (lastSelected && lastSelected.createTextRange && lastSelected.caretPos)
		return (lastSelected.caretPos.text == '')
	else
		return true;
}

function BtnHighlight(el) {
	with(el.style){
		borderLeft="1px solid gray";
		borderRight="1px solid #e9e9e9";
		borderTop="1px solid gray";
		borderBottom="1px solid #e9e9e9";
	}
}

function BtnNormal(el) {
	with(el.style){
		padding="3px";
		border="1px solid #dddddd";
	}
}

<!--
//POPUP

function popup(page,nome,w,h,s,m) {

var winl = (screen.width - w) / 2;
//var wint = (screen.height - h) / 2;

var props = 'left='+winl+',top=0,width='+w+',height='+h+',scrollbars='+s+',alwaysLowered=0,alwaysRaised=0,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar='+m+',resizable=0,status=0,titlebar=1,toolbar=0' ;

window.open(page, nome, props);
}

function PrintContents()
{
	window.print();
}

End -->
