/**
* Função js para fazer chamado a arquivos em flash sem borda.
* @package index.php
* @author Murillo <webmaster2@netcompuradores.com.br>
* @version 0.0.1
* @date 2008-11-24 15:08:00
*/
function Swf($file,$height,$width,$id){
	document.writeln('	  <div id="popup" style="position:absolute; width:' + $width + 'px; height:' + $height + 'px; z-index:1;"> ');
    document.writeln('    <object id="globalnav-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="' + $width + '" height="' + $height + '" id="' + $id + '" name="' + $id + '" align="top"> ');
	document.writeln('        <param name="movie" value="' + $file + '" />');
    document.writeln('        <param name="FlashVars" value="loc=en_US&htmlApp=false&gatewayURL=gwurl" />');
    document.writeln('        <param name="bgcolor" value="#ffffff" />');
    document.writeln('        <param name="menu" value="true" />');
    document.writeln('        <param name="quality" value="high" />');
    document.writeln('        <param name="salign" value="tl" />');
    document.writeln('        <param name="scale" value="noscale" />');
    document.writeln('        <param name="wmode" value="transparent"  />');
    document.writeln('        <embed id="globalnav-embed" src="' + $file + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" flashvars="loc=en_US&htmlApp=false&gatewayURL=gwurl" bgcolor="#ffffff" menu="false" quality="high"  align="top"  salign="tl" scale="noscale" id="' + $id + '" width="' + $width + '" height="' + $height + '"></embed>');
    document.writeln('    </object>');
	document.writeln('    </div>');
}

/**
* Função js para criação de pop´s.
* @author Marcos (MKV) <webmaster@netcompuradores.com.br>
* @version 0.1.0
* @date 2008-12-04 10:12
* @Var dest = destinho
* @Var w = width
* @Var h = height
*/

function criaJanela(dest,w,h){
	window.open(dest, 'winnew', 'width='+ w +', height='+ h +'')
}

function trocaimg(destProImg,alvoProImg){
	document.getElementById("dtProimg").innerHTML = '<img src="'+ alvoProImg +'" border="0">';
}

// limpa espaço em branco 
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g, '');
}

function maskIt(w,e,m,r,a){
    
	// Cancela se o evento for Backspace
    if (!e) var e = window.event
    if (e.keyCode) code = e.keyCode;
    else if (e.which) code = e.which;
    
    // Variáveis da função
    var txt  = (!r) ? w.value.replace(/[^\d]+/gi,'') : w.value.replace(/[^\d]+/gi,'').reverse();
    var mask = (!r) ? m : m.reverse();
    var pre  = (a ) ? a.pre : "";
    var pos  = (a ) ? a.pos : "";
    var ret  = "";

    if(code == 9 || code == 8 || txt.length == mask.replace(/[^#]+/g,'').length) return false;

    // Loop na máscara para aplicar os caracteres
    for(var x=0,y=0, z=mask.length;x<z && y<txt.length;){
        if(mask.charAt(x)!='#'){
            ret += mask.charAt(x); x++;
        } else{
            ret += txt.charAt(y); y++; x++;
        }
    }
    
    // Retorno da função
    ret = (!r) ? ret : ret.reverse()    
    w.value = pre+ret+pos;
}

// Novo método para o objeto 'String'
String.prototype.reverse = function(){
    return this.split('').reverse().join('');
};

function randd(){
	return Math.ceil( Math.random() * 100000 );
}


function busProduto(e,v) {
	var tecla;
	if (e.keyCode) { // IE
		tecla = e.keyCode;
	}else if (e.which) { // Firefox
		tecla = e.which;
	}
	if ((tecla == 13) || (tecla == 1) || (v == 'v')){ //enter ou clique do mouse
		if(document.getElementById('chave').value==""){
			alert("A busca não pode ser vazia");
			return false;
		}else{	
			location.href = 'http://netcomputadores.com.br/sti_pg_busca_produto.php?mu=2&idPesquisa=4&chavePesqu='+document.getElementById('chave').value+'&x='
		}
	}
}

function busCompatibilidade(e,v) {
	var tecla;
	if (e.keyCode) { // IE
		tecla = e.keyCode;
	}else if (e.which) { // Firefox
		tecla = e.which;
	}
	if ((tecla == 13) || (tecla == 1) || (v == 'v')){ //enter ou clique do mouse
		if(document.getElementById('compativel').value==""){
			alert("A busca não pode ser vazia");
			return false;
		}else{	
			location.href = 'http://netcomputadores.com.br/sti_pg_busca_produto.php?mu=2&idPesquisa=7&chaveComp='+document.getElementById('compativel').value+'&x='
		}
	}
}
