function NewWindow(mypage,myname,w,h,scroll,resize){
	var win=null;
	LeftPosition=(screen.width)?(screen.width-w)/2:100;
	TopPosition=(screen.height)?(screen.height-h)/2:100;
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable='+resize+'';
	win=window.open(mypage,myname,settings);
}
function mostrar(nombreCapa){
	popId = document.getElementById(nombreCapa);
	if(document.getElementById("recomendar")) ocultar("recomendar");
	if(document.getElementById("contacto")) ocultar("contacto");
	if(document.getElementById("buscador")) ocultar("buscador");

	winsize = getWinSize();
	scrollsize = getScrollXY();
	popleft = parseInt(winsize[0]/2) - parseInt(220);
	poptop  = parseInt(winsize[1]/2) - parseInt(150) + scrollsize[1];
	popId.style.left = popleft+'px';
	popId.style.top  = poptop+'px';
	popId.style.visibility="visible";
}
function ocultar(nombreCapa){
	document.getElementById(nombreCapa).style.visibility="hidden";
}
function showID(id){
	if (document.getElementById){ // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}else{
		if (document.layers){ // Netscape 4
			document.id.display = 'block';
		}else{ // IE 4
			document.all.id.style.display = 'block';
		}
	}
}
function hideID(id){
	if (document.getElementById){ // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}else{
		if (document.layers){ // Netscape 4
			document.id.display = 'none';
		}else{ // IE 4
			document.all.id.style.display = 'none';
		}
	}
}
function setStyle(obj,stl,val){
	document.getElementById(obj).style[stl] = val;
}
function checkCode (e,idtexto,mensaje) {
	var charCode;
	if(e && e.which){
		e=e;
		charCode=e.which;
	}else{
		charCode=e.keyCode;
	}
	if(charCode==13 && document.getElementById(idtexto).value.length < 2){
		alert(mensaje);
		return false;
	}else{
		return true;
	}
}
function buscar(){
	if(document.getElementById('busca-txt').value.length < 2){
		alert('Ingrese el nombre de producto o modelo que desea buscar');
	}else{
		document.getElementById('buscadorelectro').submit();
	}
}
function listaprecios(){
	if(document.getElementById('precio-txt').value.length==0){
		alert('Por Favor ingrese su dirección de correo electrónico');
	}else{
		document.getElementById('precios').submit();
	}
}
function ofertas(){
	if(document.getElementById('oferta-txt').value.length==0){
		alert('Por Favor ingrese su dirección de correo electrónico');
	}else{
		document.getElementById('ofertas').submit();
	}
}
function AServicio(){
	vent=window.open('http://servicio.electromisiones.net',"SERVBASE","height=450,width=650,left="+((screen.width / 2) -330)+",top="+((screen.height / 2) -240)+" ,toolbar = NO, scrollbars=yes, status =no");
}
function AElectroWEB(){
	vent=window.open("http://200.45.71.57/electroweb/acceso_electro_web.php?W=1","electroWeb","height=380,width=650,left="+((screen.width / 2) -330)+",top="+((screen.height / 2) -190)+" ,toolbar = NO, scrollbars=NO, status =no");
}
function buscarpro(){
	window.scrollTo(0,2000);
	document.getElementById('buscar').focus();
	document.getElementById('buscar').style.background = '#FFFFBF';
}
function buscarProducto(){
	document.getElementById('buscarProducto').submit();
}

/* FUNCIONES CARRITO DE COMPRAS */
function isVisible(id){
	if (document.getElementById){ // DOM3 = IE5, NS6
		if(document.getElementById(id).style.display == 'none') return false; else return true;
	}else{
		if (document.layers){ // Netscape 4
			if(document.id.display == 'none') return false; else return true;
		}else{ // IE 4
			if(document.all.id.style.display == 'none') return false; else return true;
		}
	}
}
function actCantidad(id){
	var cant = parseInt(document.getElementById('cant'+id).value);
	if(isNaN(cant) || cant==0){
		alert("Ingrese la cantidad deseada del producto. Para eliminar el producto del carro use el boton 'X'.");
	}else{
		window.location = "micarro.php?act=true&agregar="+id+"&cantidad="+cant;
	}
}
function setCantidad(id,cantidad){
	window.location = "micarro.php?act=true&agregar="+id+"&cantidad="+cantidad;
}
function removerProd(id){
	window.location = "micarro.php?remover="+id;
}
function setIva(ivacodigo){
	if(ivacodigo == 3){
		document.getElementById('nrocuit').disabled = true;
	}else{
		document.getElementById('nrocuit').disabled = false;
	}
}
function Finalizar(){
	document.getElementById('finalizar').style.display = 'block';
}
function checkEnter(e,id,act){
	var characterCode;
	if(e && e.which){
		characterCode = e.which;
	}else{
		characterCode = e.keyCode;
	}
	if(characterCode == 13){
		if(act==true) actCantidad(id); else agregarProd(id);
	}
	return true;
}
/* Manejo de popups */
function getWinSize(){
	var myWidth=0,myHeight=0;
	if(typeof(window.innerWidth)=='number'){
		//Non-IE
		myWidth=window.innerWidth;
		myHeight=window.innerHeight;
	}else if(document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight)){
		//IE6+ standards compliant mode
		myWidth=document.documentElement.clientWidth;
		myHeight=document.documentElement.clientHeight;
	}else if(document.body && (document.body.clientWidth || document.body.clientHeight)){
		//IE4 compatible
		myWidth=document.body.clientWidth;
		myHeight=document.body.clientHeight;
	}
	return [myWidth,myHeight];
}
function getScrollXY(){
	var scrOfX=0,scrOfY=0;
	if(typeof(window.pageYOffset)=='number'){
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	}else if(document.body && (document.body.scrollLeft || document.body.scrollTop)){
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	}else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)){
		//IE6+ standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	return [scrOfX,scrOfY];
}