// JavaScript Document funcoes comuns de javascrip vão aqui
function checkemail(str){
//var str=document.validation.emailcheck.value
var testresults;
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
if (filter.test(str))
testresults=true;
else{
testresults=false;
}
return (testresults);
}

function trimAll( strValue ) {
 var objRegExp = /^(\s*)$/;

    //check for all spaces
    if(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '');
       if( strValue.length == 0)
          return strValue;
    }

   //check for leading & trailing spaces
   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) {
       //remove leading and trailing whitespace characters
       strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;
}

function favoritos(){
var bookmarkurl="http://www.ideiasfrescas.com"
var bookmarktitle="Ideias Frescas, design e multimédia, Lda."

if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

function mudar_economico(cor) {
	if (cor == "preto") {
		document.getElementById('IfTopo').style.backgroundImage = "url('imgs_site/gerais/gif/bleed_top_black.gif')";
		document.getElementById('IfTopo').innerHTML = '<img src="imgs_site/gerais/gif/bleed_top_black.gif" width="1026" height="1">';
		document.getElementById('IfLatEsQ').style.backgroundImage = "url('imgs_site/gerais/gif/bleed_left_black.gif')";
		document.getElementById('IfLatEsQ').innerHTML = '<img src="imgs_site/gerais/gif/bleed_left_black.gif" width="1" height="100%">';
		document.getElementById('IfDir').style.backgroundImage = "url('imgs_site/gerais/gif/bleed_right_black.gif')";
		document.getElementById('IfDir').innerHTML = '<img src="imgs_site/gerais/gif/bleed_right_black.gif" width="1" height="100%">';
		document.body.background="";
		document.body.bgColor ="#000000";
		document.getElementById('topoMain').style.bgColor = '#000000';
		document.getElementById('mnFlashHolder').innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="1024" height="502">          <param name="movie" value="if_base_index_com_economizar_pt.swf">          <param name="quality" value="high">          <embed src="if_base_index_com_economizar_pt.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="1024" height="502"></embed>        </object>';
		document.getElementById('IfInnerLeft').style.backgroundColor = '#000000';
		document.getElementById('IfInnerLeft').innerHTML = '<img src="imgs_site/gerais/gif/preto_black.gif" width="47" height="100">';
		document.getElementById('IfInnerRight').style.backgroundColor = '#000000';
		document.getElementById('IfInnerRight').innerHTML = '<img src="imgs_site/gerais/gif/preto_black.gif" width="44" height="100">';
		document.getElementById('IfRodape').style.backgroundColor = '#000000';
		document.getElementById('IfOne').innerHTML = '<img src="imgs_site/gerais/gif/resolucao_preto_pt.gif" width="311" height="48">';
		document.getElementById('IfRodape2').style.backgroundImage = "url('imgs_site/gerais/gif/bleed_bottom_black.gif')";
		document.getElementById('IfRodape2').innerHTML = '<img src="imgs_site/gerais/gif/bleed_bottom_black.gif" width="1026" height="1">';
	}
	else {
		document.getElementById('IfTopo').style.backgroundImage = "url('imgs_site/gerais/gif/bleed_top.gif')";
		document.getElementById('IfTopo').innerHTML = '<img src="imgs_site/gerais/gif/bleed_top.gif" width="1026" height="1">';
		document.getElementById('IfLatEsQ').style.backgroundImage = "url('imgs_site/gerais/gif/bleed_left.gif')";
		document.getElementById('IfLatEsQ').innerHTML = '<img src="imgs_site/gerais/gif/bleed_left.gif" width="1" height="100%">';
		document.getElementById('IfDir').style.backgroundImage = "url('imgs_site/gerais/gif/bleed_right_black.gif')";
		document.getElementById('IfDir').innerHTML = '<img src="imgs_site/gerais/gif/bleed_right_black.gif" width="1" height="100%">';
		document.body.background="imgs_site/gerais/jpg/fundo.jpg";
		document.body.bgColor ="#000000";
		document.getElementById('topoMain').style.bgColor = '#FFFFFF';
		document.getElementById('mnFlashHolder').innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="1024" height="502">          <param name="movie" value="if_base_index_sem_economizar_pt.swf">          <param name="quality" value="high">          <embed src="if_base_index_sem_economizar_pt.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="1024" height="502"></embed>        </object>';
		document.getElementById('IfInnerLeft').style.backgroundColor = '#FFFFFF';
		document.getElementById('IfInnerLeft').innerHTML = '<img src="imgs_site/gerais/gif/branco_white.gif" width="47" height="100">';
		document.getElementById('IfInnerRight').style.backgroundColor = '#FFFFFF';
		document.getElementById('IfInnerRight').innerHTML = '<img src="imgs_site/gerais/gif/branco_white.gif" width="44" height="100">';
		document.getElementById('IfRodape').style.backgroundColor = '#FFFFFF';
		document.getElementById('IfOne').innerHTML = '<img src="imgs_site/gerais/gif/resolucao_pt.gif" width="311" height="48">';
		document.getElementById('IfRodape2').style.backgroundImage = "url('imgs_site/gerais/gif/bleed_right.gif')";
		document.getElementById('IfRodape2').innerHTML = '<img src=""imgs_site/gerais/gif/bleed_right.gif" width="1026" height="1">';
	}
}

function trimAll( strValue ) {
 var objRegExp = /^(\s*)$/;

    if(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '');
       if( strValue.length == 0)
          return strValue;
    }

   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;
}

function naovazio( strValue ) {
   var strTemp = strValue;
   strTemp = trimAll(strTemp);
   if(strTemp.length > 0){
     return true;
   }
   return false;
}

function show_pop(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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_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_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 findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

var crossobj="";
	//define reference to the body object in IE
var iebody="";

function setup_google() {
	if (document.getElementById("pub1")) {
		var obj = document.getElementById("madre");
		var pos = findPos(obj);
	
		crossobj=document.all? document.all.pub1 : document.getElementById("pub1");
		iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;
		if (document.all||document.getElementById){
			crossobj.style.top = (pos[1]+110)+"px";		
			if (document.all) {	
				crossobj.style.left = Math.round(((obj.offsetWidth-pos[0])+140)/2)+"px";			
			}
			else {
				crossobj.style.left = Math.round(((window.innerWidth-pos[0])+140)/2)+"px";
			}
			crossobj.style.display = "block";
		}
	}
	
	/*y_actual = pos[1]+110;	
		
	//define universal reference to "staticcontent"
	crossobj=document.all? document.all.googlel : document.getElementById("googlel");
	iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;
	if (document.all||document.getElementById){
		crossobj.style.top = (pos[1]+110)+"px";		
		if (document.all) {	
			crossobj.style.left = (pos[0] + 1 + obj.offsetWidth)+"px";
		}
		else {
			crossobj.style.left = (window.innerWidth-215)+"px";
		}
		crossobj.style.display = "block";
	}
	window.onscroll = function () {
		var dsoctop=document.all? iebody.scrollTop : pageYOffset
		if (document.all||document.getElementById){
			crossobj.style.top=dsoctop+y_actual+"px"
		}
	}*/
	
}