﻿// Archivo JScript
var TR_Marca;
var TR_clase;
function SetFocus(oF,szFN){
	try{
		if(typeof oF=="object"){
			var bF=false;
			var bL=true;
			if(szFN==""){
				bF=true;
			}
			for(i=0;i<oF.length;i++){
				try{
					var oI=oF.elements[i];
				}catch(e){continue;}
				if(oI.name==szFN){
					bF=true;
				}
				if(oI.type!="hidden"&&oI.disabled!=true&&oI.style.visibility!="hidden"&&bF){
					oI.focus();
//					if(oI.type=="text"||oI.type=="password"){
						oI.select();
//					}
					break;
				}
				if(i==oF.length-1&&bL){
					i=-1;
					bF=true;
					bL=false;
				}
			}
		}
	}catch(e){}
}

function Buscar(elCampo, laLabel, Tabla, ID, Desc, Cuantos)
{
	var win;
	win=window.open("frmRecerca.aspx?Taula=" + Tabla + "&ID=" + ID + "&Campo=" + elCampo + "&Label=" + laLabel + "&Desc=" + Desc + "&Cuantos=" + Cuantos,"Busqueda","width=600, height=500, toolbar=0,location=0,directories=0,status=0,menubar=0,titlebar=0,scrollbars=auto,resizable=1,dependent=1");
	win.focus();
	return false;
}

function MarcaLinea(oTR)
{
	if (TR_Marca!=null)
	{
		try
		{
			TR_Marca.classname=T_Clase;
			TR_Marca.marca=0;
			var newEvent = document.createEventObject();
			newEvent.clientX = 100;
			newEvent.clientY = 30;
			newEvent.cancelBubble = false;
			newEvent.button = 1;
			TR_Marca.fireEvent("onmouseout", newEvent);
		} catch (ex) {}
	}
	
	if(oTR.marca==0)
	{
		TR_Marca = oTR;
		T_Clase = oTR.classname;
		oTR.classname="grd_seleccion_1";
		oTR.marca = 1;
		document.all.cmdEdita.Codigo = oTR.sID;
		document.all.cmdDel.Codigo = oTR.sID;
	}
	
}


function SetTab()
{
	if (event.keyCode == 13) {
		event.keyCode=9;
		return true;
	}
}
function SetBus(Busqueda, ob)
{
	if (event.keyCode == 114)
	{
		document.all[Busqueda].focus();
		event.keyCode=13;
		return true;
	}
	else {
		if (event.keyCode == 13) {
			if (document.all[Busqueda].FuncionBusca != "") {
				try {
					eval(document.all[Busqueda].FuncionBusca);
					ob.focus();
				} catch (ex) {}
				return true;
			}
			else {
				ob.focus();
				event.keyCode=9;
				return true;
			}
		}
		else return false;
	}
}


function PosaDivBus()
{
	try
	{
		var z = document.all.txtCampos_1;
		var t = z.offsetTop;
		var l = z.offsetLeft;
		var d = document.all.divEspera_B;
		d.style.pixelTop = t+150;
		d.style.pixelLeft = l;
		d.style.visibility = "visible";
	} catch(ex) {}
}

function TreuDivBus()
{
	parent.ifrm_CENTRAL.document.all.divEspera_B.style.visibility = "hidden";
}


function BuscaSocis(Nom, Activitat, TClient)
{
	var win;
	win=window.open("frmPlanol.aspx?Nom=" + Nom + "&Activitat=" + Activitat + "&TClient=" + TClient ,"Planol","width=1000, height=700, toolbar=0,location=0,directories=0,status=0,menubar=0,titlebar=0,scrollbars=auto,resizable=1,dependent=1");
	win.focus();
	return false;
}

function getSelected(opt) {
    var selected = new Array();
    var index = 0;
    for (var intLoop = 0; intLoop < opt.length; intLoop++) {
       if ((opt[intLoop].selected) ||
           (opt[intLoop].checked)) {
          index = selected.length;
          selected[index] = new Object;
          selected[index].value = opt[intLoop].value;
          selected[index].index = intLoop;
       }
    }
    return selected;
}

function CargaSelect(opt, destino)
{
    var sel = getSelected(opt);
    var strSel = "";
    for (var item in sel)       
    {
        if (strSel=="")
            strSel +=  "'" + sel[item].value + "'" ;
        else
            strSel +=  ",'" + sel[item].value + "'";
    }
    document.all[destino].value = strSel;
}


function ObrirImg(gcID, Imagen,  Archivo, Contenido)
{
	var winus;
	var myWidth;
	var myHeight;
	var posx;
	var posy;
	myWidth=800;
	myHeight=600;
	posx=(screen.width-myWidth)/2;
	posy=(screen.height-myHeight)/3;
	var sF = "AmpliarImg.aspx?gcID=" + gcID + "&ImgURL=" + Imagen +  "&Arc=" + Archivo + "&Cont=" + Contenido;
//	winus = window.showModalDialog(sF,"","dialogHeight:"+myHeight+"px; dialogWidth:"+myWidth+"px; center:yes; status:no;")
	winus = window.open(sF,"Imatge","z-lock=1,toolbar=0,location=0,titlebar=0,caption=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,dependent=1,width="+myWidth+",height="+myHeight+",left="+posx+",top="+posy);
	winus.focus();
}

function ObreNoticia(sID, sTipus, gcID)
{
	var winus;
	var myWidth;
	var myHeight;
	var posx;
	var posy;
	myWidth=700;
	myHeight=500;
	posx=(screen.width-myWidth)/2;
	posy=(screen.height-myHeight)/2;
	var sF = "UnaNoticia.aspx?ID=" + sID + "&T=" + sTipus + "&gcID=" + gcID + "&W=" + myWidth + "&H=" + myHeight;
//	winus = window.showModalDialog(sF,"","dialogHeight:"+myHeight+"px; dialogWidth:"+myWidth+"px; center:yes; status:no; edge:raised; unadorned:no");
	winus = window.open(sF ,"Noticia","dependent=1, z-lock=1, scrollbars=0, toolbar=0, location=0, resizable=0, menubar=0, status=0, width="+myWidth+", height="+myHeight+", left="+posx+", top="+posy);
    winus.focus();
}

function onDone(src)
{
  oPopup.document.write(src); 
}

function ObreFinestra(sF)
{
	var winus;
	var myWidth;
	var myHeight;
	var posx;
	var posy;
	myWidth=700;
	myHeight=600;
	posx=(screen.width-myWidth)/2;
	posy=(screen.height-myHeight)/3;
//    winus = window.showModalDialog(sF,"","dialogHeight:"+myHeight+"px; dialogWidth:"+myWidth+"px; center:yes; status:no;")
	winus = window.open(sF,"Finestra","z-lock=1,toolbar=0,location=0,titlebar=0,caption=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,dependent=1,width="+myWidth+",height="+myHeight+",left="+posx+",top="+posy);
	winus.focus();
}

function ObreFinestraSimple(gcID, cID, myWidth, myHeight)
{
	var winus;
	var posx;
	var posy;
	posx=(screen.width-myWidth)/2;
	posy=(screen.height-myHeight)/3;
	var sF = "frmHTMLSimple.aspx?gcID=" + gcID + "&cID=" + cID;
	winus = window.open(sF,"FinestraSimple","z-lock=1,toolbar=0,location=0,titlebar=0,caption=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,dependent=1,width="+myWidth+",height="+myHeight+",left="+posx+",top="+posy);
//    winus = window.showModalDialog(sF,"","dialogHeight:"+myHeight+"px; dialogWidth:"+myWidth+"px; center:yes; status:no;")
	winus.focus();
}


function AnulaB()
{
	if (event.button == 2) {
		alert("(c) 2007 Sabadell Comerç Centre"); 
		return true;
	}
}

document.onmousedown=AnulaB;