/*
     TITLE: GUESTPIXEL FUNCTIONS
   VERSION: 1.0.5
      TYPE: Object Definition
    AUTHOR: Dimitre Lima
 COPYRIGHT: 1999-2001 Sereia Corporation, Inc. All Rights Reserved
 
functions criadas por Dimitre Lima (dmtr@terra.com.br) 
*/

function toHex(dec){
 	var result= (parseInt(dec).toString(16));
 	if(result.length ==1) result= ("0" +result);
 	return result.toUpperCase();
}

function manda()
{if (form1.nome.value!='nome')
 {form1.submit()}
 else if (form1.nome.value=='nome')
 {form1.nome.style.backgroundColor='#bbbbbb';form1.nome.focus()}
}

function foto(endereco)
{
	sobraX = 12;
	sobraY = (screen.height - screen.availHeight);
	if (navigator.appName != "Microsoft Internet Explorer")
	{sobraX = 0;	sobraY = 0;	}
	if ((navigator.platform == 'MacPPC' ) && (navigator.appName == "Microsoft Internet Explorer"))
	{sobraX = 0;	sobraY = 0;}
	nova = window.open('', 'foto', 'fullscreen=0,location=0,directories=0,menubar=0,toolbar=0,status=1,resizable=1,scrollbars=0,width=75,height=20,top=20,left=10')
	nova.document.open('text/html', 'replace');
	nova.document.writeln('<HTML><HEAD><TITLE>'+endereco+'</TITLE></HEAD>');
	nova.document.writeln('<BODY bgcolor=black background="load2.gif" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="self.resizeTo(document.pic.width + ' + sobraX.toString() + ', document.pic.height + ' + sobraY.toString() + ');">'); 
	nova.document.writeln('<a href="javascript:close(\'foto\')"><IMG SRC="' + endereco + '" BORDER=0 name="pic" alt="clique para fechar"></a></BODY></HTML>');
	nova.document.close();
	nova.focus();
}










function shortCuts() {
	if (event.ctrlKey != true) return;
	strSelection = document.selection.createRange().text;
	if (event.keyCode == 1) ahrefThis();
	if (event.keyCode == 2) boldThis(2);
	if (event.keyCode == 20) italicThis(2);
//	if (event.keyCode == 19) post(1);
//	if (event.keyCode == 10) post(0);
//	if (event.keyCode == 17) deleteMe();
}

function ahrefThis() {
	strSelection = document.selection.createRange().text
	if (strSelection == "") document.posta.mensagem.focus()
	strHref = prompt("Entre a URL:","http://")
	if (strHref == null) return;
	document.selection.createRange().text = "<a href=\"" + strHref + "\" target=_blank>" + strSelection + "</a>"
	return;
}

function boldThis(from) {
	strSelection = document.selection.createRange().text
	if (strSelection == "") {
		document.posta.mensagem.focus()
		if (from == 2) document.posta.mensagem.select()
		strSelection = document.selection.createRange().text
		document.selection.createRange().text = strSelection + "<b></b>"
	}	
	else document.selection.createRange().text = "<b>" + strSelection + "</b>"
	return;
}

function italicThis(from) {
	strSelection = document.selection.createRange().text
	if (strSelection == "") {
		document.posta.mensagem.focus()
		if (from == 2) document.posta.mensagem.select()
		strSelection = document.selection.createRange().text
		document.selection.createRange().text = strSelection + "<i></i>"
	}
	else document.selection.createRange().text = "<i>" + strSelection + "</i>"
	return;
}

function underThis(from) {
	strSelection = document.selection.createRange().text
	if (strSelection == "") {
		document.posta.mensagem.focus()
		if (from == 2) document.posta.mensagem.select()
		strSelection = document.selection.createRange().text
		document.selection.createRange().text = strSelection + "<u></u>"
	}
	else document.selection.createRange().text = "<u>" + strSelection + "</u>"
	return;
}

function colorThis(color) {
	strSelection = document.selection.createRange().text
	if (strSelection == "") {
		document.posta.mensagem.focus()
		if (from == 2) document.posta.mensagem.select()
		strSelection = document.selection.createRange().text
		document.selection.createRange().text = strSelection + ""
	}
	else document.selection.createRange().text = "<font color='" + color + "'>" + strSelection + "</font>"
	return;
}

function upperThis(from) {
	strSelection = document.selection.createRange().text
	if (strSelection == "") {
		document.posta.mensagem.focus()
		if (from == 2) document.posta.mensagem.select()
		strSelection = document.selection.createRange().text
		document.selection.createRange().text = strSelection + ""
	}
	else document.selection.createRange().text = strSelection.toUpperCase();
	return;
}

function lowerThis(from) {
	strSelection = document.selection.createRange().text
	if (strSelection == "") {
		document.posta.mensagem.focus()
		if (from == 2) document.posta.mensagem.select()
		strSelection = document.selection.createRange().text
		document.selection.createRange().text = strSelection + ""
	}
	else document.selection.createRange().text = strSelection.toLowerCase();
	return;
}
/*
function preview()
{
	nova = window.open('', 'foto', 'fullscreen=0,location=0,directories=0,menubar=0,toolbar=0,status=1,resizable=1,scrollbars=0,width=75,height=20,top=20,left=10')
	nova.document.open('text/html', 'replace');
	nova.document.writeln('<HTML><HEAD><TITLE></TITLE><link rel="STYLESHEET" type="text/css" href="blog.css"></HEAD>');
	nova.document.writeln('<BODY leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
	nova.document.writeln(document.posta.mensagem.value);
	nova.document.close();
	nova.focus();
}
*/

function atualiza()
{
	var re = new RegExp (String.fromCharCode(13) , 'gi') ;
	var newstr = document.posta.mensagem.value.replace(re, '<br>') ;
	document.all['divBlog'].innerHTML=newstr;
//	document.all['divBlog'].innerHTML=document.posta.mensagem.value
}