//BANNER FLOATER
function showHideLayer(id)
		{
			var element = document.getElementById(id)			
			if (element.style.display=="block")
				element.style.display = "none"
			else
				element.style.display = "block"
}

// EXIBE FLASH

function ExibeFlash(w,h,wmode,movie,flashVars) {
	var isFlashVars = arguments.length==5;
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+w+'" height="'+h+'">');
	document.write('<param name="wmode" value="'+wmode+'"/>');
	document.write('<param name="quality" value="high"/>');
	document.write('<param name="movie" value="'+movie+'"/>');
	if (isFlashVars){
		document.write('<param name="FlashVars" value="'+flashVars+'"/>');
	}
	document.write('<embed src="'+movie+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="'+wmode+'" width="'+w+'" height="'+h+'" ');
	if (isFlashVars){
		document.write(' FlashVars="'+flashVars+'"');
	}
	document.write('></embed>');
	document.write('</object>');
}
// ABRIR POPUPS
function OpenWindow(windowHeight, windowWidth, windowName, windowUri)
{
    var centerWidth = (window.screen.width - windowWidth) / 2;
    var centerHeight = (window.screen.height - windowHeight) / 2;

    newWindow = window.open(windowUri, windowName, 'resizable=0,width=' + windowWidth + 
        ',height=' + windowHeight + 
        ',left=' + centerWidth + 
        ',top=' + centerHeight);

    newWindow.focus();
    return newWindow.name;
}

// APARECE DIV
function displayDiv(name){
	/*if (document.all[name].style.display ==''){
		document.all[name].style.display ='none';
	}else{
		document.all[name].style.display ='';
	}*/
	var obj = document.getElementById(name);
	if (obj.style.display!='none'){
		obj.style.display='none';
	}else{
		obj.style.display='block';
	}
}


// MUDA FONTE

var tam = 12;

function mudaFonte( tipo ){
	if( tipo == 'mais' ){
		if( tam < 16 ) tam += 2 ;
	}else{
		if( tam > 9 ) tam -= 2 ;
	}
	if( document.getElementById( 'mudaFonte' ) )
		mudaFonteRecursiva( tipo , document.getElementById( 'mudaFonte' ) ) ;

	if( document.getElementById( 'mudaFoto' ) )
	mudaFonteRecursiva( tipo , document.getElementById( 'mudaFoto' ) ) ;
}

function mudaFonteRecursiva( tipo , domElement ){
	for( var i = 0 ; i < domElement.childNodes.length ; i++ ){
		mudaFonteRecursiva( tipo , domElement.childNodes.item( i ) ) ;
	}
	if( domElement.style )
	domElement.style.fontSize = tam+'px';
}


// MENU PRINCIPAL
function menuOver(menu){
	Spry.Utils.removeClassName(menu.id,'change-mouse-out');
	Spry.Utils.addClassName(menu.id,'change-mouse-over');
}
function menuOut(menu){
	Spry.Utils.addClassName(menu.id,'change-mouse-out');
	Spry.Utils.removeClassName(menu.id,'change-mouse-over');
}


function writeRandom(html,array,limit){
	var out = "";
	// ordem aleatória
	array.sort(function(){return 0.5 - Math.random()})
	// exibe a lista
	for(var i=0;i<array.length;i++){
		if(limit == i){
			break;
		}
		var item = array[i];
		var htmlItem = html;
		for (var j=0;j<item.length;j++){
			htmlItem = htmlItem.replace(new RegExp("\\{"+j+"\}","g"),item[j]);
		}
		out+=htmlItem;
	}
	document.write(out);
}


//
// validação indique
//

function validateonsubmitindiquecontent(form){
	if (Spry.Widget.Form.validate(form) == true){
		form.url.value = location.href;
		Spry.Utils.submitForm(form, function(req){
			Spry.Utils.setInnerHTML('motix-response-indique', req.xhRequest.responseText);
			form.reset();
		});
	}
	return false;
}


//
// validação indique
//

function validateonsubmitcomment(form){
	if (Spry.Widget.Form.validate(form) == true){
		Spry.Utils.submitForm(form, function(req){
			location.href = location.href;
		});
	}
	return false;
}


function textCounter(field,cntfield,maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	else
	cntfield.value = maxlimit - field.value.length;
}

// BANNER FLUTUANTE
function fecharBanner(){
	var oNodeToRemove = document.getElementById("apDiv1");
	if (oNodeToRemove!=null){
 		oNodeToRemove.parentNode.removeChild(oNodeToRemove);
	}
}