// Insere flash sem borda
function swf(url, w, h, bg, vars, id) {
	
	if(bg) {
		ie_bg = '<param name="bgcolor" value="'+ bg +'" />';
		ff_bg = 'bgcolor="'+ bg +'"';			
	}else {
		ie_bg = '<param name="wmode" value="transparent" />';
		ff_bg = 'wmode="transparent"';
	}
	
	if(vars) {
		ie_vars = '<param name="flashvars" value="'+ vars +'" />';
		ff_vars = 'flashvars="'+ vars +'"';			
	}else {
		ie_vars =
		ff_vars = '';
	}
	
	cd_flash  = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
	cd_flash += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
	cd_flash += 'width="' + w + '" ';
	cd_flash += 'height="'+ h + '" ';
	cd_flash += 'id="'+ id +'" ';
	cd_flash += 'name="'+ id +'">';
	cd_flash += '<param name="movie" value="' + url + '" />';
	cd_flash += '<param name="menu" value="false" />';
	cd_flash += '<param name="quality" value="high" />';
	cd_flash += '<param name="salign" value="tl" />';
	cd_flash += '<param name="scale" value="noscale" />';
	cd_flash += ie_bg;
	cd_flash += ie_vars;
	cd_flash += '<embed src="' + url + '" type="application/x-shockwave-flash" ';
	cd_flash += 'pluginspage="http://www.macromedia.com/go/getflashplayer" ';
	cd_flash += 'menu="false" quality="high" salign="tl" scale="noscale" ';
	cd_flash += 'width="' + w + '" ';
	cd_flash += 'height="'+ h + '" ';
	cd_flash += 'id="'+ id +'" ';
	cd_flash += ff_bg;
	cd_flash += ff_vars;
	cd_flash += '></embed>';
	cd_flash += '</object>';
	
	document.write(cd_flash);
	
}

verPg = function(acha,pg) {
    urlComp = document.location.href;
    url = urlComp.split("?")[0];
    pgEnc = url.slice( (url.lastIndexOf("/")+1) , url.length);
    
    pgEnc = pgEnc.toLowerCase();
    
    
    if(acha) {
        return pgEnc;
    }else {
        pg = pg.toLowerCase();
        
        if(pg == pgEnc) {
            return true;
        }else {
            return false;
        }
    }
}

// Função de para limpar o campo ou retornar o valor default
limpaCampo = function(ac, cp) {
	vlr = cp.value;
	if(ac=='focus' && vlr == cp.defaultValue) {
		cp.value = '';
	}else if(ac=='blur' && vlr=='') {
		cp.value = cp.defaultValue;
	}
}

var pops = new Array();
pops['manual'] = ['730', '580', 'auto'];

/* EVENTOS ----------------------------------------------------------------------------- */

$(document).ready(function() {
	pgAtual = verPg(true);
	if(pgAtual=='galeria.php' || pgAtual=='equipamentos.php' || pgAtual=='portifolio.php') $(function() { $('ul.galeria a').lightBox(); });
	
	if(pgAtual=='equipamentos.php') {
		$('a[rel="lytebox_a"]').lightBox();
		$('a[rel="lytebox_b"]').lightBox();
		$('a[rel="lytebox_c"]').lightBox();
		$('a[rel="lytebox_d"]').lightBox();
	}
	
	$('input, textarea').focus(function() { limpaCampo('focus', this); });
	$('input, textarea').blur(function() { limpaCampo('blur', this); });
	
	$('#cp_tel, #cp_cel').focus(function() {
		if(this.value == this.defaultValue) this.value = '';
		$(this).mask('?(99) 9999-9999');
	});
	
	$('a[rel="popup"]').click(function() {

		w = pops[$(this).attr('id')][0];
		h = pops[$(this).attr('id')][1];
		bScroll = pops[$(this).attr('id')][2];
		url = $(this).attr('href');
		
		alt = window.screen.height;
		larg = window.screen.width;
		pTop = ( (alt/2) - (h/2) );
		pLeft = ( (larg/2) - (w/2) );
		window.open(url,"pop","width="+w+", height="+h+", top="+pTop+", left="+pLeft+" scrollbars="+bScroll+", statusbar=no, menubar=no, titlebar=no, resizable=no, toolbar=no");

		return false;
	});
	
	$('#cp_tel, #cp_cel').blur(function() {
		if(this.value == this.defaultValue || this.value == '' || this.value == '(__) ____-____') {
			$(this).unmask();
			this.value = this.defaultValue;
		}
	});
});




