﻿myTinyMCE_MessagingMode = 1;
myTinyMCE_ModeratorMode = 2;

function myTinyMCE_Init(textAreaID, mode, maxLength, remainingDisplayID)
{
    var buttons;
    if (mode == myTinyMCE_ModeratorMode)
        buttons = "bold,italic,underline,undo,redo,forecolor,fontsizeselect"
    else 
        buttons = "bold,italic,underline,undo,redo,forecolor,separator,piemoticon_smile,piemoticon_wink,piemoticon_surprised,piemoticon_angry,piemoticon_confused,piemoticon_sad";
    
    var textArea = document.getElementById(textAreaID);
    textArea.myTinyMCE_MaxChars = maxLength;
    textArea.myTinyMCE_UndoBuffer = "";
    textArea.myTinyMCE_RemainingDisplayID = remainingDisplayID;
    textArea.myTinyMCE_Timer1 = null;
    
    tinyMCE.init({
        theme : "advanced",
        mode : "exact",
        elements: textAreaID,
        plugins : "pibbcode,piemoticon",
        theme_advanced_buttons1 : buttons,
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : "",
        theme_advanced_toolbar_location : "bottom",
        theme_advanced_toolbar_align : "center",
        theme_advanced_styles : "Code=codeStyle;Quote=quoteStyle",
        content_css : "css/pibbcode_editor.css",
        entity_encoding : "raw",
        add_unload_trigger : false,
        remove_linebreaks : false,
        inline_styles : false,
        convert_fonts_to_spans : false,
        handle_event_callback : "myTinyMCE_HandleEvent",
        onchange_callback : "myTinyMCE_CustomOnChangeHandler",
        oninit : "myTinyMCE_CustomOnInit"
    });
}

// init when unit TinyMCE editor is loaded
function myTinyMCE_CustomOnInit() {
    if (tinyMCE.selectedInstance)
        tinyMCE.selectedInstance.formElement.myTinyMCE_Timer1 = setTimeout("if (tinyMCE.selectedInstance) myTinyMCE_CheckLimit(tinyMCE.selectedInstance.editorId);", 1000); // wait a bit to avoid IE error
}

// event when something in TinyMCE changes (which is when an undo level is added. e.g. paste)
function myTinyMCE_CustomOnChangeHandler(inst) 
{
    if (tinyMCE.selectedInstance)
        tinyMCE.selectedInstance.formElement.myTinyMCE_Timer1 = setTimeout("if (tinyMCE.selectedInstance) myTinyMCE_CheckLimit(tinyMCE.selectedInstance.editorId)", 250); //slight delay before counting
}

// event such as key or mouse press
function myTinyMCE_HandleEvent(e) 
{
    if (e.type == "keyup") {
        clearTimeout(tinyMCE.selectedInstance.formElement.myTinyMCE_Timer1);
        myTinyMCE_CheckLimit(tinyMCE.selectedInstance.editorId)
    }
    return true;
}

function myTinyMCE_CheckLimit(editor_id) 
{
    var content = tinyMCE.getContent(editor_id);
    var currCount = content.length;
    var remainCount = tinyMCE.selectedInstance.formElement.myTinyMCE_MaxChars - currCount; 
    var displayObj= document.getElementById(tinyMCE.selectedInstance.formElement.myTinyMCE_RemainingDisplayID);
    if (displayObj)
        displayObj.innerHTML = eval(remainCount < 0 ? 0 : remainCount); 
    if (tinyMCE.selectedInstance.formElement.myTinyMCE_MaxChars != 0 && remainCount < 0) 
    { //typed too much
        var thisBuffer = tinyMCE.selectedInstance.formElement.myTinyMCE_UndoBuffer;
        if (thisBuffer.length > 0) {
            var myTinyMCE_timer2 = setTimeout("tinyMCE.setContent(thisBuffer)", 250);
        };
        if (displayObj)
            displayObj.innerHTML="0!"; 
    } 
    else {
        tinyMCE.selectedInstance.formElement.myTinyMCE_UndoBuffer = content;
        tinyMCE.selectedInstance.formElement.value = content;
    }
}

function NoIEActivate_CreateObjectWithSource(containerID, innerHTML)
{
    document.getElementById(containerID).innerHTML = innerHTML;
}

var ZoomWindowUniqueID;

function ZoomImage(imageURL, width, height)
{
    popImage(imageURL, "pafil")

/*
    if (!ZoomWindowUniqueID)
        ZoomWindowUniqueID = 0;

    if (!width)
      width = 800;
    if (!height)
      height = 600;

    ZoomWindowUniqueID++;
    var uploadWindow = window.open(imageURL, ZoomWindowUniqueID, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=' + 
        width + ', height=' + height);  */
}

/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" " + ((this.getAttribute("width")) ? ("width=\""+ this.getAttribute("width") + "\"") : "") + ((this.getAttribute("height")) ? (" height=\"" + this.getAttribute("height") + "\"") : "") + " style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" " + (this.getAttribute("width") != null ? "width=\""+ this.getAttribute("width") + "\"" : "") + (this.getAttribute("height") != null ? " height=\"" + this.getAttribute("height") + "\"" : "") + " style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

/**
 * Micox Word Wrap 2.0 
 * elmicoxcodes.blogspot.com - www.ievolutionweb.com - micoxjcg@yahoo.com.br
 * Creative Commons License - creativecommons.org
 * 
 * Description:
 * Wraps large words in Firefox and Opera.
 * Works just like the word-wrap: break-word; CSS property in Internet Explorer
 *
 * Usage:
 * 1) Include this JS file in your page. Example: <script type='text/javascript' src='micoxWordWrap.js'></script>
 * 2) Set 'word-wrap' as the classname of the elements that you want to word break. Example: <p class='word-wrap'>
 *
**/

function wrap(quem){
	var larg_total,larg_carac,quant_quebra,pos_quebra, over_orig;
	var elementos, pai, caracs, texto, pai_texto, display_orig, wid_orig;
    if(quem.nodeType==3){
		//elemento tipo texto. tenho que verificar se o pai dele tá quebrando
		if(quem.nodeValue.replace('\n','').replace('\t','').trim()==''){
			//se o textNode for vazio, não prossigo
			return true;
		}
		
		pai = quem.parentNode;		
		texto = quem.nodeValue;			
		
		//pegando a largura setada oficial
		display_orig = pai.style.display;
		over_orig = pai.style.overflow;
		wid_orig = pai.style.width;
			
		pai.style.display="block";
		pai.style.overflow="hidden";
		larg_oficial = pai.offsetWidth;
		
		//pegando a largura real total
		pai.style.display="table";
		pai.style.width = "auto"; //para o Opera
		pai.style.overflow = "visible";
		larg_total = pai.offsetWidth;
		//alert("texto: " + texto + " \r\n larg_oficial:" + larg_oficial + " \r\n larg_total:" + larg_total)
		pai.style.overflow = over_orig;
		
		if(larg_total>larg_oficial){ //se o pai do text tá extrapolando, quebro o text
			pos_quebra = 0;
			caracs = pai.textContent.length;
			//recalculando a largura real tirando os espaços pra poder calcular
			// direito a largura dos caracs e quando vou quebrar
			
			quem.nodeValue = pai.textContent.replace(/ /g,"Ø") + " ";
			larg_total = pai.offsetWidth;
			pai.style.display = display_orig;
			
			larg_carac = larg_total / caracs ;
			quant_quebra = parseInt(larg_oficial/larg_carac) - 2; 
			
			quem.nodeValue = '';
			
			while(pos_quebra<=caracs){
				quem.nodeValue += texto.substring(pos_quebra,pos_quebra + quant_quebra) + " "
				pos_quebra = pos_quebra + quant_quebra;
			}			
		}
		pai.style.display = display_orig;
		pai.style.display = over_orig;
		pai.style.width = wid_orig;
		
	}else if(quem.childNodes.length==1 && quem.childNodes[0].nodeType==3){

		//é o último do nível e o único filho é texto
		texto = String(quem.innerHTML); //salvando o original
		
		/*quem.innerHTML = " "		
		display_orig = quem.style.display;
		quem.style.display="block";
		larg_oficial = quem.offsetWidth;
				
		quem.style.display="table";
		quem.innerHTML = texto;
		larg_total = quem.offsetWidth;*/
		
		//pegando a largura setada oficial
		display_orig = quem.style.display;
		over_orig = quem.style.overflow;
		wid_orig = quem.style.width;
        
		quem.style.display="block";
		quem.style.overflow="hidden";
		larg_oficial = quem.offsetWidth;
		
		//pegando a largura real total
		quem.style.display="table";
		quem.style.width = "auto"; //para o Opera
		quem.style.overflow = "visible";
		larg_total = quem.offsetWidth;
		//alert("texto: " + texto + " \r\n larg_oficial:" + larg_oficial + " \r\n larg_total:" + larg_total)
		quem.style.overflow = over_orig;
		if(larg_total>larg_oficial){ //quebrando quem extrapolou
			pos_quebra = 0;
			caracs = texto.length;
			//recalculando a largura real tirando os espaços pra poder calcular
			// direito a largura dos caracs e quando vou quebrar
			quem.innerHTML = quem.innerHTML.replace(/ /g,"Ø");
			larg_total = quem.offsetWidth;
			larg_carac = larg_total / caracs ;
			
			quant_quebra = parseInt(larg_oficial/larg_carac) - 2; 
			quem.innerHTML = ""
			
			while(pos_quebra<=caracs){
				quem.innerHTML += texto.substring(pos_quebra,pos_quebra + quant_quebra) + " "
				pos_quebra = pos_quebra + quant_quebra;
			}
			
		}	
		quem.style.display = display_orig;
		quem.style.overflow = over_orig;
		quem.style.width = wid_orig;
		
	}else if(quem.childNodes.length>0){
		//se tiver mais que um filho, vou ter que executar de filho em filho nele
		for(var i=0;i<quem.childNodes.length;i++){
			wrap(quem.childNodes[i]);
		}
	}
}
function wordWrap(){  
    var elementos = document.body.getElementsByTagName("*") 
 
    if(navigator.appName.indexOf("Internet Explorer")>-1){
        for(var i=0; i<elementos.length;i++){
            if(elementos[i].className.indexOf("word-wrap")>-1){
                elementos[i].style.wordWrap = "break-word";
            }
        }
    }else{
        for(var i=0; i<elementos.length;i++){
            if(elementos[i].className.indexOf("word-wrap")>-1){
                wrap(elementos[i]);
            }
        }
    }
}
String.prototype.trim = function() { //Trim ambas direcciones
   return this.replace(/^[ ]+|[ ]+$/g,"");
}
function addEvent(obj, evType, fn){
    if (obj.addEventListener)
        obj.addEventListener(evType, fn, true)
    if (obj.attachEvent)
        obj.attachEvent("on"+evType, fn)
}
addEvent(window,'load',wordWrap);

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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 MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function changeHeadline(imgindex)
{
 var Image_headline = document.getElementById("img_headline");
 var Anchor_headline = document.getElementById("anc_headline");
 Image_headline.src = headimages[imgindex];
 Anchor_headline.href = headlinks[imgindex];
}

/*
==============================================================
Script:     Auto-Sizing Image Popup Window

Functions:  Use this script to launch a popup window that
            automatically loads an image and resizes itself
            to fit neatly around that image. The script also
            places a title you set in the titlebar of the 
            popup window. Any number of images can be launched
            from a single instance of the script.
            
Browsers:   NS6-7 & IE4 and later
            [Degrades functionally in NS4]

Author:     etLux
============================================================== */

// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this notice.

// SETUPS:
// ===============================

// Set the horizontal and vertical position for the popup

PositionX = 0;
PositionY = 0;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 500;
defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style type="text/css">body{margin:0px; overflow: scroll; background-color: #000000;}</style>');writeln('<sc'+'ript type="text/javascript">');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(300,300);');
writeln('width=300-(document.body.clientWidth-document.images[0].width);');
writeln('height=300-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript type="text/javascript">');
if (!AutoClose) writeln('</head><body onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body onload="reSizeToImage();doTitle();self.focus()">');
writeln('<div style="width: 100%; height: 100%; text-align: center;">');
writeln('<img name="George" src='+imageURL+' style="display:block; vertical-align: middle;"></div></body></html>');
close();		
}}
