/****************************************************************************************************************************************************
*WriteSWF*/


function writeswfhtml(nome, width, height, html) {
	document.writeln('<object type="application/x-shockwave-flash" data="'+ nome +'.swf" width="'+ width +'" height="'+ height +'">');
	document.writeln('<param name="movie" value="'+ nome +'.swf" />');
	document.writeln('<param name="quality" value="high" />');
	document.writeln('<param name="wmode" value="transparent">');	
	document.writeln(html);
	document.writeln('</object>');
	
}
/*
function writeswfhtml2(nome, width, height, html, paramextra) {
	document.writeln('<object type="application/x-shockwave-flash" data="includes/swf/'+ nome +'.swf" width="'+ width +'" height="'+ height +'">');
	document.writeln('<param name="movie" value="includes/swf/'+ nome +'.swf" />');
	document.writeln('<param name="quality" value="high" />');
	document.writeln(paramextra);
	document.writeln(html);
	document.writeln('</object>');
}

function writemapa(nome, width, height) {
	document.writeln('<object type="application/x-shockwave-flash" data="includes/swf/'+ nome +'" width="'+ width +'" height="'+ height +'">');
	document.writeln('<param name="movie" value="includes/swf/'+ nome +'" />');
	document.writeln('<param name="quality" value="high" />');
	document.writeln('<param name="wmode" value="transparent">');	
	document.writeln('</object>');
}


function uf(estado) {
	document.location.href = 'representantes?uf='+estado;
}


function insertFlash( arquivo, tam_x, tam_y ){
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+tam_x+'" height="'+tam_y+'">');
	document.writeln('<param name="movie" value="'+arquivo+'" />');
	document.writeln('<param name="wmode" value="transparent" />');
	document.writeln('<param name="quality" value="high" />');
	document.writeln('<embed src="'+arquivo+'" wmode="transparent"  quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+tam_x+'" height="'+tam_y+'"></embed>');
	document.writeln('</object>');
}

*/

/****************************************************************************************************************************************************
	Event load
****************************************************************************************************************************************************/

function addEvent(obj, evType, fn){
    if(obj.addEventListener){
        obj.addEventListener(evType, fn, false);

        return true;

    } else if (obj.attachEvent){
        var r = obj.attachEvent('on'+evType, fn);

        return r;

    } else {
        return false;

    }
}//end function







/****************************************************************************************************************************************************
	External Link
*****************************************************************************************************************************************************/

function init() {
	createExternalLinks();
}//end function


function createExternalLinks() {
    if(document.getElementsByTagName) {
        var anchors = document.getElementsByTagName('a');
        for(var i=0; i<anchors.length; i++) {
            var anchor = anchors[i];
            if(anchor.getAttribute("href") && anchor.getAttribute('rel')=='blank') { 
                anchor.target = '_blank';
             
            }
        }
    }
}//end function




addEvent(window, "load", init);





/****************************************************************************************************************************************************
	Pop-up
****************************************************************************************************************************************************

function openWin( url, page ){

	var w = 360;
	var h = 380;
	
	var cW=(screen.width - largura)/2;
	var cY=(screen.height - altura)/2;

	pp = window.open('local'+url+'.php?k='+page,'window','top='+cY+',left='+cW+',width='+w+',height='+h+',scrollbars=0, status=1');
	if (window.focus) {
		pp.focus()
	}//end if
}//end function

*/


/****************************************************************************************************************************************************
*Lightbox
****************************************************************************************************************************************************
$(function() {
					$('a[@rel*=lightbox]').lightBox(); 
});

function doOpen() {
	var elBody = Ext.get(document.body);
	var el = Ext.get('lightbox');
	elBody.mask();
	elBody.appendChild(el);
	el.center(elBody);
	el.dom.style.visibility = 'visible';
	el.fadeIn({
		endOpacity: 1,
		easing: 'easeIn',
		duration: .8,
		callback: function() {
			//el.frame("ffffff", 2, { duration: 0.8 });
		}
	});
}

function doClose() {
	var el = Ext.get('lightbox');
	el.ghost('b', {
		endOpacity: 0,
		easing: 'easeOut',
		duration: .8,
		callback: function() {
			Ext.get(document.body).unmask();
		}
	});
}

*/






/****************************************************************************************************************************************************
*Toogle
****************************************************************************************************************************************************

 * jQuery Plugin Toggle Fade v1.0
 * Requires jQuery 1.2.3 (Not tested with earlier versions).
 * Copyright (c) 2008 Gregorio Magini [gmagini at gmail dot com] 
 * 
 *	@param: Object Array. Arguments need to be in object notation.
 *	Returns: jQuery.
 *	Options:	
 *		speedIn: Sets the speed of the fadeIn effect. Default: "normal".
 *    speedOut: Sets the speed of the fadeOut effect. Default: same as speedIn.
 *
 *	Examples: 
 *    
 *    speedIn and speedOut both "normal":
 *		$("#toggle-link").toggleFade();
 *
 *    speedIn and speedOut both "fast":
 *		$("#toggle-link").toggleFade({ speedIn : "fast");
 *
 *    different settings for speedIn and speedOut:
 *		$("#toggle-link").toggleFade({ speedIn : 800, speedOut : 150 });
 *
 
 
 function tooTab(obj) {
		$('.item').each(function(i,el){
			if(el.id!=obj.attr('id')){
				$('#'+el.id).hide();
			}else{
				obj.toggle();
			}
	});		

		CSBfleXcroll('cro')
	};
	

(function($) {
  $.fn.toggleFade = function(settings)
  {
  	settings = jQuery.extend(
  		{
        speedIn: "normal",
        speedOut: settings.speedIn
  		}, settings
  	);
  	return this.each(function()
  	{
	  
  	  var isHidden = jQuery(this).is(":hidden");
      jQuery(this)[ isHidden ? "fadeIn" : "fadeOut" ]( isHidden ? settings.speedIn : settings.speedOut);
	  window.alert("teste")
    });
  };
})(jQuery);

*/
 



/****************************************************************************************************************************************************
	Custom Radio, Check e Select
****************************************************************************************************************************************************

Created by Ryan Fait
www.ryanfait.com

The only thing you need to change in this file is the following
variables: checkboxHeight, radioHeight and selectWidth.

Replace the first two numbers with the height of the checkbox and
radio button. The actual height of both the checkbox and radio
images should be 4 times the height of these two variables. The
selectWidth value should be the width of your select list image.

You may need to adjust your images a bit if there is a slight
vertical movement during the different stages of the button
activation.

Visit http://ryanfait.com/ for more information.

*

var checkboxHeight = "25";
var radioHeight = "25";
var selectWidth = "170";

// No need to change anything after this

document.write('<style type="text/css">input.styled { display: none; } select.styled { position: relative; width: ' + selectWidth + 'px; opacity: 0; filter: alpha(opacity=0); z-index: 5; }</style>');

var Custom = {
	init: function() {
		var inputs = document.getElementsByTagName("input"), span = Array(), textnode, option, active;
		for(a = 0; a < inputs.length; a++) {
			if((inputs[a].type == "checkbox" || inputs[a].type == "radio") && inputs[a].className == "styled") {
				span[a] = document.createElement("span");
				span[a].className = inputs[a].type;

				if(inputs[a].checked == true) {
					if(inputs[a].type == "checkbox") {
						position = "0 -" + (checkboxHeight*2) + "px";
						span[a].style.backgroundPosition = position;
					} else {
						position = "0 -" + (radioHeight*2) + "px";
						span[a].style.backgroundPosition = position;
					}
				}
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = Custom.clear;
				span[a].onmousedown = Custom.pushed;
				span[a].onmouseup = Custom.check;
				document.onmouseup = Custom.clear;
			}
		}
		
		inputs = document.getElementsByTagName("select");
		for(a = 0; a < inputs.length; a++) {
			if(inputs[a].className == "styled") {
				option = inputs[a].getElementsByTagName("option");
				active = option[0].childNodes[0].nodeValue;
				textnode = document.createTextNode(active);
				for(b = 0; b < option.length; b++) {
					if(option[b].selected == true) {
						textnode = document.createTextNode(option[b].childNodes[0].nodeValue);
					}
				}
				span[a] = document.createElement("span");
				span[a].className = "select";
				span[a].id = "select" + inputs[a].name;
				span[a].appendChild(textnode);
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = Custom.choose;
			}
		}
	},
	pushed: function() {
		element = this.nextSibling;
		if(element.checked == true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 -" + checkboxHeight*3 + "px";
		} else if(element.checked == true && element.type == "radio") {
			this.style.backgroundPosition = "0 -" + radioHeight*3 + "px";
		} else if(element.checked != true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 -" + checkboxHeight + "px";
		} else {
			this.style.backgroundPosition = "0 -" + radioHeight + "px";
		}
	},
	check: function() {
		element = this.nextSibling;
		if(element.checked == true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 0";
			element.checked = false;
		} else {
			if(element.type == "checkbox") {
				this.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
			} else {
				this.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
				group = this.nextSibling.name;
				inputs = document.getElementsByTagName("input");
				for(a = 0; a < inputs.length; a++) {
					if(inputs[a].name == group && inputs[a] != this.nextSibling) {
						inputs[a].previousSibling.style.backgroundPosition = "0 0";
					}
				}
			}
			element.checked = true;
		}
	},
	clear: function() {
		inputs = document.getElementsByTagName("input");
		for(var b = 0; b < inputs.length; b++) {
			if(inputs[b].type == "checkbox" && inputs[b].checked == true && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
			} else if(inputs[b].type == "checkbox" && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 0";
			} else if(inputs[b].type == "radio" && inputs[b].checked == true && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
			} else if(inputs[b].type == "radio" && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 0";
			}
		}
	},
	choose: function() {
		option = this.getElementsByTagName("option");
		for(d = 0; d < option.length; d++) {
			if(option[d].selected == true) {
				document.getElementById("select" + this.name).childNodes[0].nodeValue = option[d].childNodes[0].nodeValue;
			}
		}
	}
}
//window.onload = Custom.init;


*/




/****************************************************************************************************************************************************
	Hover menu
****************************************************************************************************************************************************

startList = function() {
		  var navRoot = document.getElementById('menu');
		  for (i=0; i<navRoot.childNodes.length; i++) {
			  node = navRoot.childNodes[i];
			  node.onmouseover=function() {
				  this.className+='over';
			  }//end over
			  node.onmouseout=function() {
				  this.className=this.className.replace('over', '');
			  }//end out
		  }//end loop
	  }//end function
//window.onload = startList;

**/







/****************************************************************************************************************************************************
 * jQuery custom selectboxes
 * 
 * Copyright (c) 2008 Krzysztof Suszynski (suszynski.org)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * @version 0.6.1
 * @category visual
 * @package jquery
 * @subpakage ui.selectbox
 * @author Krzysztof Suszynski <k.suszynski@wit.edu.pl>
*/


jQuery.fn.selectbox = function(options){
	// Default settings
	var settings = {
		className: 'jquery-selectbox',
		animationSpeed: "fast",
		listboxMaxSize:20,
		replaceInvisible: false
	};
	var commonClass = 'jquery-custom-selectboxes-replaced';
	var listOpen = false;
	var showList = function(listObj) {
		var selectbox = listObj.parents('.' + settings.className + '');
		listObj.slideDown(settings.animationSpeed, function(){
			listOpen = true;
			
		});

		selectbox.addClass('selecthover');
		jQuery(document).bind('click', onBlurList);
		return listObj;
	}
	var hideList = function(listObj) {
		var selectbox = listObj.parents('.' + settings.className + '');
		listObj.slideUp(settings.animationSpeed, function(){
			listOpen = false;
			jQuery(this).parents('.' + settings.className + '').removeClass('selecthover');
		});
		jQuery(document).unbind('click', onBlurList);
		return listObj;
	}
	var onBlurList = function(e) {
		var trgt = e.target;
		var currentListElements = jQuery('.' + settings.className + '-list:visible').parent().find('*').andSelf();
		if(jQuery.inArray(trgt, currentListElements)<0 && listOpen) {
			hideList( jQuery('.' + commonClass + '-list') );
		}
		return false;
	}
	
	// Processing settings 
	settings = jQuery.extend(settings, options || {});
	// Wrapping all passed elements
	return this.each(function() {
		var _this = jQuery(this);
		if(_this.filter(':visible').length == 0 && !settings.replaceInvisible)
			return;
		var replacement = jQuery(
			'<div class="' + settings.className + ' ' + commonClass + '">' +
				'<div class="' + settings.className + '-moreButton" />' +
				'<div class="' + settings.className + '-list ' + commonClass + '-list" />' +
				'<span class="' + settings.className + '-currentItem" />' +
			'</div>'
		);
		jQuery('option', _this).each(function(k,v){
			var v = jQuery(v);
			var listElement =  jQuery('<span class="' + settings.className + '-item value-'+v.val()+' item-'+k+'">' + v.text() + '</span>');	
			listElement.click(function(){
				var thisListElement = jQuery(this);
				var thisReplacment = thisListElement.parents('.'+settings.className);
				var thisIndex = thisListElement[0].className.split(' ');
				for( k1 in thisIndex ) {
					if(/^item-[0-9]+$/.test(thisIndex[k1])) {
						thisIndex = parseInt(thisIndex[k1].replace('item-',''), 10);
						break;
					}
				};
				var thisValue = thisListElement[0].className.split(' ');
				for( k1 in thisValue ) {
					if(/^value-.+$/.test(thisValue[k1])) {
						thisValue = thisValue[k1].replace('value-','');
						break;
					}
				};
				thisReplacment
					.find('.' + settings.className + '-currentItem')
					.text(thisListElement.text());
				thisReplacment
					.find('select')
					.val(thisValue)
					.triggerHandler('change');
				var thisSublist = thisReplacment.find('.' + settings.className + '-list');
				if(thisSublist.filter(":visible").length > 0) {
					hideList( thisSublist );
				}else{
					showList( thisSublist );
				}
			}).bind('mouseenter',function(){
				jQuery(this).addClass('listelementhover');
			}).bind('mouseleave',function(){
				jQuery(this).removeClass('listelementhover');
			});
			jQuery('.' + settings.className + '-list', replacement).append(listElement);
			if(v.filter(':selected').length > 0) {
				jQuery('.'+settings.className + '-currentItem', replacement).text(v.text());
			}
		});
		
		replacement.find('.' + settings.className + '-moreButton').click(function(){
			var thisMoreButton = jQuery(this);
			var otherLists = jQuery('.' + settings.className + '-list')
				.not(thisMoreButton.siblings('.' + settings.className + '-list'));
			hideList( otherLists );
			var thisList = thisMoreButton.siblings('.' + settings.className + '-list');
			if(thisList.filter(":visible").length > 0) {
				hideList( thisList );
			}else{
				
				showList( thisList );
				
			}
		}).bind('mouseenter',function(){
			jQuery(this).addClass('morebuttonhover');
		}).bind('mouseleave',function(){
			jQuery(this).removeClass('morebuttonhover');
		});
		
		
		replacement.find('.' + settings.className + '-currentItem').click(function(){
			var thisMoreButton = jQuery(this);
			var otherLists = jQuery('.' + settings.className + '-list')
				.not(thisMoreButton.siblings('.' + settings.className + '-list'));
			hideList( otherLists );
			var thisList = thisMoreButton.siblings('.' + settings.className + '-list');
			if(thisList.filter(":visible").length > 0) {
				hideList( thisList );
			}else{
				showList( thisList );

			}
		}).bind('mouseenter',function(){
			//jQuery(this).addClass('morebuttonhover');
		}).bind('mouseleave',function(){
			//jQuery(this).removeClass('morebuttonhover');
		});
		
		
		_this.hide().replaceWith(replacement).appendTo(replacement);
		var thisListBox = replacement.find('.' + settings.className + '-list');
		var thisListBoxSize = thisListBox.find('.' + settings.className + '-item').length;
		if(thisListBoxSize > settings.listboxMaxSize)
			thisListBoxSize = settings.listboxMaxSize;
		if(thisListBoxSize == 0)
			thisListBoxSize = 1;	
		var thisListBoxWidth = Math.round(_this.width() + 5);
		if(jQuery.browser.safari)
			thisListBoxWidth = thisListBoxWidth * 0.94;
		replacement.css('width', thisListBoxWidth + 'px');
		thisListBox.css({
			width: Math.round(thisListBoxWidth-5) + 'px',
			height: thisListBoxSize + 'em'
		});
	});
}
jQuery.fn.unselectbox = function(){
	var commonClass = 'jquery-custom-selectboxes-replaced';
	return this.each(function() {
		var selectToRemove = jQuery(this).filter('.' + commonClass);
		selectToRemove.replaceWith(selectToRemove.find('select').show());		
	});
}






function inputFocus(){
	browser = navigator.appName
	ie = 'Microsoft Internet Explorer'
	el = document.getElementsByTagName('input')
	elt = document.getElementsByTagName('textarea')
	for (i=0;i<el.length;i++) {
		el[i].oldValue = el[i].getAttribute('value')
		el[i].oldType = el[i].getAttribute('type')
		
		if(el[i].getAttribute('type')=='text' | el[i].getAttribute('type')=='password'){
			if(browser != ie){
				el[i].type = 'text'
			}
			else{
				el[i].value = ''
				}
			el[i].onfocus = function(){
				if(browser != ie){
					this.type = this.oldType
				}
				if(this.className == ''){
					this.className='focus'
				}
				else{
					this.className+=' focus'
				}
				
				if(this.value == this.getAttribute('value')){
					this.value = ''
				}
			}//end onfocus
			
			el[i].onblur = function(){
				this.className = this.className.replace('focus','')
				if (this.value=='') {
					this.type = 'text'
					this.value = this.oldValue;
				}
			}//end onblur
			
		}//end if
		
	}//end for(input type's text and password)
	
	for(i=0; i<elt.length;i++){
		elt[i].onfocus = function(){
			this.className += ' focus'
		}//end focus
		elt[i].onblur = function(){
			this.className = this.className = this.className.replace('focus','')
		}//end blur
	}//end for (textarea)
	
}//end function


addEvent(window, "load", inputFocus);


/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	Add Title
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
// JavaScript Document
	function addTitle(el){
			var a = document.getElementsByTagName(el);
			for(i=0;i<a.length;i++){
					a[i].title = (a[i].title=='')?a[i].innerHTML : a[i].title;				
				}
		}
	window.onload = function(){
		addTitle('A');
	}