function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
    vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}
function submitform(){
  document.order.submit();
}
function submitform2(){
  document.limite.submit();
}
function submitform3(formulario){
  document.forms[formulario].submit();
}
var Tooltip3GNTW = {
    init: function() {
		
        if (
            !document.getElementById ||
            !document.createElement ||
            !document.getElementsByTagName
        ) {
            return;
        }
        var current = document.getElementsByTagName('img');
        var curLen = current.length;

        for (var j = 0; j < curLen; j++) {
            // we must redefine regexps (JS bug)
            //var regexp_photos_mini = new RegExp('\/[0-9\/-]+\/(30|110)_F_');
            var regexp_photos_mini = new RegExp('\/produtos\/[a-zA-Z0-9]+_t\.');
			

            if (!current[j].src.match(regexp_photos_mini)) {
                continue;
            }

            var regexp = new RegExp('_t\.');
			var largeSrc = current[j].src.replace(regexp, '\.');

            current[j].setAttribute('largeSrc', largeSrc);

            var title = current[j].getAttribute('title');
            // remove title
            current[j].setAttribute('title', '');

            var tip = '<div class="tool"><img src="' + largeSrc + '" /></div>';
            new Tooltip(current[j], tip, {'html': true, 'classname': '3gntwTooltipObject'});
        }
    }
}

function tooltip_3gntw(){
	Tooltip3GNTW.init();
}

function confirmation(link, texto) {
	//var answer = confirm(texto)
	if (confirm(texto)){
		window.location = link;
	}
}

function alerta(texto){
	alert (texto);	
}

var newwindow;

function poptastic(url)
{
	newwindow=window.open(url,'name','height=100,width=100');
	if (window.focus) {newwindow.focus()}
}

function guardar_dados(teste, campo)
{
	new Ajax.Request('ajax.php', { method:'post' , parameters: {valor: teste, campos: campo}});
}

function addtocart(id, quant, text)
{
	if(quant == 0){
		new Ajax.Request('cart.php', { method:'get' , parameters: {id: id}});
		alert(text);
		new Ajax.Updater('orcamento', 'aj_cart.php');
	}else{
		new Ajax.Request('cart.php', { method:'get' , parameters: {id: id, quant: quant}});
		alert(text);
		new Ajax.Updater('orcamento', 'aj_cart.php');		
	}
}
