var NS4 = (document.layers)? true:false;
var IE4 = (document.all)? true:false;
var TimerID = new Array();

//Obre finestra
	function obrir(nompag,wi,he,id) {
		form=window.open(nompag+".asp?id="+id,nompag,"status=0,top=100,left=100,toolbar=0,scrollbars=no,menubar=0,directories=0,height="+ he + ",width=" + wi);
	}
	function obrir2(nompag,wi,he,id,sub_id) {
		form=window.open(nompag+".asp?id="+id+"&sub_id="+sub_id,nompag,"status=0,top=100,left=100,toolbar=0,scrollbars=no,menubar=0,directories=0,height="+ he + ",width=" + wi);
	}
	function obrir3(nompag,wi,he) {
		form=window.open(nompag+".asp","confirma","status=0,top=150,left=250,toolbar=0,scrollbars=no,menubar=0,directories=0,height="+ he + ",width=" + wi);
		if (form.opener == null) form.opener = window; 
		form.opener.name = "opener";
	}

	function obrirfinestra(nompag,wi,he) {
		remote = window.open(nompag,"finestra","status=0,top=150,left=250,toolbar=0,scrollbars=no,menubar=0,directories=0,height="+ he + ",width=" + wi);
		
		if (remote.opener == null) remote.opener = window; 
		remote.opener.name = "opener";
		remote.focus();		
	}
	
	function obrir_conf(nompag,wi,he) {
		form=window.open(nompag,"confirma","status=0,top=150,left=250,toolbar=0,scrollbars=no,menubar=0,directories=0,height="+ he + ",width=" + wi);
		if (form.opener == null) form.opener = window; 
		form.opener.name = "opener";
	}

	function TractaTxt(camp) {
		var rExp = //gi;
		camp.value = camp.value.replace(rExp,"'");
	}
	
	function obrirAvis(nompag,wi,he) {
		form=window.open(nompag,"Avis","status=0,top=50,left=80,toolbar=0,scrollbars=yes,menubar=0,directories=0,height="+ he + ",width=" + wi);
	}

	function ObreFinestra() {
		remote = window.open("curriculum_dades.asp","Curriculum","status=0,top=15,left=250,toolbar=0,scrollbars=2,menubar=0,directories=0,height=700,width=560");
	
		if (remote.opener == null) remote.opener = window; 
		remote.opener.name = "opener";
		remote.focus();		
	}
	
	function ObreOferta(id) {
		// Mida de la finestra
		var wi = 560,he = 600;
		
		var seleccio;	
		var w = 800, h = 600;
		var popW = wi, popH = he;
		
		/* Centrem la finestra a la pantalla */
		if (document.all || document.layers) {
		   w = screen.availWidth;
		   h = screen.availHeight;
		}
		
		var leftPos = (w-popW)/2;
		var topPos = (h-popH)/2;	
				
		winpop = window.open("oferta_ampliada.asp?id=" + id,"Oferta","status=0,top=" + topPos + ",left=" + leftPos + ",toolbar=0,scrollbars=2,menubar=0,directories=0,height="+ he + ",width=" + wi);
		if (!winpop.opener)
			winpop.opener = self;
		self.name = "opener";
		winpop.focus();
	}
	
	function over_btn(obj, bool) {
	   obj.className = (bool) ? "frm_btn_over" : "frm_btn";
	}
		
	function over_btn2(obj, bool) {
	   obj.className = (bool) ? "frm_btn2_over" : "frm_btn2";
	}
			
	function replaceCharacters(conversionString,inChar,outChar) {
		var convertedString = conversionString.split(inChar);
		convertedString = convertedString.join(outChar);
		return convertedString;
	}
	
// * Dependencies * 
// this function requires the following snippets:
// JavaScript/readable_MM_functions/findObj
//
// Accepts a variable number of arguments, in triplets as follows:
// arg 1: simple name of a layer object, such as "Layer1"
// arg 2: ignored (for backward compatibility)
// arg 3: 'hide' or 'show'
// repeat...
//
// Example: showHideLayers(Layer1,'','show',Layer2,'','hide');
function showHideLayers()
{ 
  var i, visStr, obj, args = showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
  {
    if ((obj = findObj(args[i])) != null)
    {
      visStr = args[i+2];
      if (obj.style)
      {
        obj = obj.style;
        if(visStr == 'show') visStr = 'visible';
        else if(visStr == 'hide') visStr = 'hidden';
      }
      obj.visibility = visStr;
	 
    }
  }
}

function showHideLayers2()
{ 
  var i, visStr, obj, args = showHideLayers2.arguments;
  for (i=0; i<(args.length-2); i+=3) {
    if ((obj = findObj(args[i])) != null) {
      visStr = args[i+2];
      if (obj.style) {
        obj = obj.style;
        if(visStr == 'show') {
			obj.visibility = 'visible';
			obj.display = 'block';
		}
        else if(visStr == 'hide') {
			obj.visibility = 'hidden';
			obj.display = 'none';
		}
      }
    }
  }
}

// Example: obj = findObj("image1");
function findObj(theObj, theDoc)
{
  var p, i, foundObj;
 
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
	
  if(!foundObj && document.getElementById) 
	  foundObj = theDoc.getElementById(theObj);
  
  return foundObj;
}


function redimBarra() {
	var isIE=document.all?1:0;
	
	if (!isIE) {
		MM_findObj('Cos').style.height = document.documentElement.offsetHeight - 105;
		MM_findObj('Peu').style.position = 'relative';
		MM_findObj('Peu').style.top =  -1;
	}
}

function Fixselect(param) {
	if (param == 1) {
		if (document.all) document.body.className = "fix";		
	} else {
		if (document.all) document.body.className = "";
	}
}

function WinBorrar(msg,accio,param) {
		if (param == 1) {
			/*msg = "Vols borrar el grup?";*/
			accio = "javascript: document.location.href='" + accio + "'";
		} 
			
		showHideLayers('pleasewait','','show');
		
		if (document.all) document.body.className = "fix";
	
		ErrorMessage(msg,1,'',accio);
}
		
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


	function DoModal(pag,wi,he) {
			winpop = window.open(pag,"Modal","status=0,top=200,left=250,toolbar=0,scrollbars=no,menubar=0,directories=0,height="+ he + ",width=" + wi);
			if (!winpop.opener)
   				winpop.opener = self;
			self.name = "opener";
	}
		
	/**
	* script para validar fechas en una caja de texto.
	*@Autor  Luciano Moreno  WebMaster de HTMLWeb  http://www.htmlweb.net
	*/
    
    /**
    * definimos las variables globales que van a contener la fecha completa, cada una de sus partes
    * y los dias correspondientes al mes de febrero segun sea el aņo bisiesto o no
    */
    var a, mes, dia, anyo, febrero;
    
	function Bisiestus(dnaix,davui) {
		var cont = 0;
		
		for (i=dnaix;i<davui;i++) {
			if (anyoBisiesto(i)) cont++;
		}
		//alert(cont);
		return cont;
	}
	
    /**
    * funcion para comprobar si una aņo es bisiesto
    * argumento anyo > aņo extraido de la fecha introducida por el usuario
    */
    function anyoBisiesto(anyo)
    {
        /**
        * si el aņo introducido es de dos cifras lo pasamos al periodo de 1900. Ejemplo: 25 > 1925
        */
        if (anyo < 100)
            var fin = anyo + 1900;
        else
            var fin = anyo ;

        /*
        * primera condicion: si el resto de dividir el aņo entre 4 no es cero > el aņo no es bisiesto
        * es decir, obtenemos aņo modulo 4, teniendo que cumplirse anyo mod(4)=0 para bisiesto
        */
        if (fin % 4 != 0)
            return false;
        else
        {
            if (fin % 100 == 0)
            {
                /**
                * si el aņo es divisible por 4 y por 100 y divisible por 400 > es bisiesto
                */
                if (fin % 400 == 0)
                {
                    return true;
                }
                /**
                * si es divisible por 4 y por 100 pero no lo es por 400 > no es bisiesto
                */
                else
                {
                    return false;
                }
            }
            /**
            * si es divisible por 4 y no es divisible por 100 > el aņo es bisiesto
            */
            else
            {
                return true;
            }
        }
    }
    
    /**
    * funcion principal de validacion de la fecha
    * argumento fecha > cadena de texto de la fecha introducida por el usuario
    */
    function ValidaData(indata)
    {
		/**
       	* obtenemos la fecha introducida y la separamos en dia, mes y aņo
       	*/
       	a=indata.value;

		dia=a.split("/")[0];
       	mes=a.split("/")[1];
       	anyo=a.split("/")[2];
		if (mes!=null&&mes!='') {
			if (mes.charAt(0)=='0'&&mes.length>1) {
				mes = mes.charAt(1)
			} 
		}
		dia=parseInt(dia);
       	mes=parseInt(mes);
       	anyo=parseInt(anyo);
		
	   	if (dia==null||mes==null||anyo==null||dia==''||mes==''||anyo==''||dia.toString()=="NaN"||mes.toString()=="NaN"||anyo.toString()=="NaN") {
	   		dia=a.split("-")[0];
       		mes=a.split("-")[1];
       		anyo=a.split("-")[2];
			if (mes!=null&&mes!='') {
				if (mes.charAt(0)=='0'&&mes.length>1) {
					mes = mes.charAt(1)
				} 
			}
			dia=parseInt(dia);
       		mes=parseInt(mes);
       		anyo=parseInt(anyo);
		    
			
	   		if (dia==null||mes==null||anyo==null||dia==''||mes==''||anyo==''||dia.toString()=="NaN"||mes.toString()=="NaN"||anyo.toString()=="NaN") {
				alert("Data incompleta o errōnia.");
				indata.focus();
           		indata.select();
				return false;
	   	 	}
	   }
	   
       if(anyoBisiesto(anyo))
           febrero=29;
       else
           febrero=28;
       /**
       * si el mes introducido es negativo, 0 o mayor que 12 > alertamos y detenemos ejecucion
       */
       if ((mes<1) || (mes>12))
       {
           alert("El mes introduīt no és vālid.");
           indata.focus();
           indata.select();
           return false;
       }
       /**
       * si el mes introducido es febrero y el dia es mayor que el correspondiente 
       * al aņo introducido > alertamos y detenemos ejecucion
       */
       if ((mes==2) && ((dia<1) || (dia>febrero)))
       {
           alert("El dia introduīt no és vālid.");
           indata.focus();
           indata.select();
           return false;
       }
       /**
       * si el mes introducido es de 31 dias y el dia introducido es mayor de 31 > alertamos y detenemos ejecucion
       */
       if (((mes==1) || (mes==3) || (mes==5) || (mes==7) || (mes==8) || (mes==10) || (mes==12)) && ((dia<1) || (dia>31)))
       {
           alert("El dia introduīt no és vālid.");
           indata.focus();
           indata.select();
           return false;
       }
       /**
       * si el mes introducido es de 30 dias y el dia introducido es mayor de 301 > alertamos y detenemos ejecucion
       */
       if (((mes==4) || (mes==6) || (mes==9) || (mes==11)) && ((dia<1) || (dia>30)))
       {
           alert("El dia introduīt no és vālid.");
           indata.focus();
           indata.select();
           return false;
       }
       /**
       * si el mes aņo introducido es menor que 1900 o mayor que 2010 > alertamos y detenemos ejecucion
       * NOTA: estos valores son a eleccion vuestra, y no constituyen por si solos fecha erronea
       */
       if ((anyo<0) || (anyo>3000))
       {
           alert("L'any introduīt no és vālid. Per favor, introdueixi un any positiu menor de 3000.");
           indata.focus();
           indata.select();
		   return false;
       } 
       /**
       * en caso de que todo sea correcto > enviamos los datos del formulario
       * para ello debeis descomentar la ultima sentencia
       */
       else
          //alert("La fecha introducida es correcta. Gracias por su colaboraciķn");
		  return true;
    }
	
	


	//Inverteix Dia i Mes per convertir correctament a objecte Date
	function ConvDate(valor) {
       	dia=valor.split("/")[0];
       	mes=valor.split("/")[1];
       	anyo=valor.split("/")[2];
       
	   	if (dia==null||mes==null||anyo==null||dia==''||mes==''||anyo=='') {
	   		dia=valor.split("-")[0];
       		mes=valor.split("-")[1];
       		anyo=valor.split("-")[2];
			
			if (dia==null||mes==null||anyo==null||dia==''||mes==''||anyo=='') {
				return "NaN"
			}
		}
		return mes+"/"+dia+"/"+anyo
	}
	
	//Gestiķ Capes
	function initObject(obj,TimeID){

		if (NS4) this.css = document.layers[obj+'Div'];

 		if (IE4) this.css = document.all[obj+'Div'].style;
		
		this.name = obj;
		this.ID = obj;
		this.next = 0;
		this.x = 0;
		this.xl = 0;
		this.y = 0;
		this.yl = 0;
		this.TimeID = TimeID;
		this.moving = false;
			
		this.show = function show(){
			if (NS4) this.css.visibility = "show";
			if (IE4) this.css.visibility = "visible";
		}
	
		this.hide = function hide(){
			if (NS4) this.css.visibility = "hide";
			if (IE4) this.css.visibility = "hidden";
		}
	}





var ie = document.all ? 1 : 0
var ns = document.layers ? 1 : 0
var ns6 = document.getElementById && !document.all; 

IExplore = (navigator.appName == "Microsoft Internet Explorer");
BrowserVer = parseInt(navigator.appVersion);
NetScape=(navigator.appName=="Netscape")?1:0;	

function HideMsgWin() {
	showHideLayers('pleasewait','','hide');
	showHideLayers('clientok1','','hide'); 
	showHideLayers('error','','hide'); 
	
	if (document.all) document.body.className = "";
}

function nowait() {
	showHideLayers('pleasewait','','hide');
	showHideLayers('WinWait','','hide');
	if (document.all) document.body.className = "";
}


//Example: preloadImages('file.gif', 'http://www.x.com/y.gif');
function preloadImages()
{
  if(document.images)
  {
    if(!document.imageArray) document.imageArray = new Array();
    var i,j = document.imageArray.length, args = preloadImages.arguments;
    
    for(i=0; i<args.length; i++)
    {
      if (args[i].indexOf("#")!=0)
      {
        document.imageArray[j] = new Image;
        document.imageArray[j++].src = args[i];
      }
    }
  }
}

// Accepts a variable number of arguments, in triplets as follows:
// arg 1: simple name of a layer object, such as "Layer1"
// arg 2: ignored (for backward compatibility)
// arg 3: 'hide' or 'show'
// repeat...
// Example: showHideLayers(Layer1,'','show',Layer2,'','hide');
function showHideLayers()
{ 
  var i, visStr, obj, args = showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
  {
    if ((obj = findObj(args[i])) != null)
    {
      visStr = args[i+2];
      if (obj.style)
      {
        obj = obj.style;
        if(visStr == 'show') visStr = 'visible';
        else if(visStr == 'hide') visStr = 'hidden';
      }
      obj.visibility = visStr;
    }
  }
}


function MM_validateForm() { //v4.0
	var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  	var primer;
  
	for (i=0; i<(args.length-2); i+=3) { 
  		test=args[i+2]; 
		val=findObj(args[i]);
		if (val) { 
			nm=val.name; 
			if ((val=val.value)!="") {
      			if (test.indexOf('isEmail')!=-1) { 
	  				p=val.indexOf('@');
        			if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      			} else if (test!='R') {
        			if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        			if (test.indexOf('inRange') != -1) { 
						p=test.indexOf(':');
          				min=test.substring(8,p); max=test.substring(p+1);
          				if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    				} 
				} 
			} else if (test.charAt(0) == 'R') errors += 'El campo de texto ' + args[i] + ' no puede dejarse vacío.\n'; 
		}
		val=findObj(args[i]);
		if (val&&errors&&!primer) {
			primer = val;
		}
  	} 
  	if (errors) {
		alert('Atenciķn:\n'+errors);
		primer.focus();
	}
  	document.MM_returnValue = (errors == '');
}

//function alert error message
function ErrorMessage(a,par,coordinata,action){
	//	a - our message for user
	//	par - if it's value is 0 - we have only one button "ok" on the layer
	//		  if it's value is 1 - we have two buttons "ok" and "cancel" on the layer
	//	coordinata - if it is defined, our layer will be replaced to top of this value
	//	action - if it is defined, action of the "ok" button will be change
	clentok1_content = "<input type=\"button\" class=\"Iboto\" name=\"Accio\" value=\"Aceptar\" onClick=\"" + action + "\">";
	
//	clentok1_content = "<a href=\""+action+"\"><img src=\"images/"+DocumentMainLanguage+"/ok.gif\" width=\"68\" height=\"16\" border=\"0\" alt=\"\"></a>&nbsp;<a href=\"javascript:showHideLayers('error','','hide'); showHideLayers('clientok1','','hide'); showHideLayers('clientok','','hide');\"><img src=\"images/"+DocumentMainLanguage+"/cancel.gif\" width=\"68\" height=\"16\" alt=\"\" border=\"0\"></a>";
	
	var flag=0;

	self.scrollTo(0,0);
	
	//a="<table align=center border=0 width=100%><td align=center><a class=\"errormes\">"+a+"</a></td></table>";
	
	if (ns) {
		document.layers['error'].document.layers['clientheader'].document.write("");
		document.layers['error'].document.layers['clientheader'].document.close();
		document.layers['error'].document.layers['clienterror'].document.write(a);
		document.layers['error'].document.layers['clienterror'].document.close();
		var wc=parseInt(self.innerWidth);
		var hc=parseInt(self.innerHeight);
		var layobj=eval("document.layers['error']");
		
		if(action) {
			setTimeout("document.layers['error'].document.layers['clientok1'].document.write(clentok1_content)",5);
			setTimeout("document.layers['error'].document.layers['clientok1'].document.close()",6);
		}
	} else if (ie) {
		
		writetoLyr('clienterror',a);
		var wc=parseInt(document.body.offsetWidth);
		var hc=parseInt(document.body.offsetHeight);
		var layobj=eval("document.all['error'].style");

		if(action) {
			re = /\'/g;
			clentok1_content = clentok1_content.replace(re,"\\'");
			
			//writetoLyr('clientok1',clentok1_content);
			// in a few version of I.Explorer 5.0 there is a problem, so the div content will
			// be written after 0.2 seconds.
			setTimeout("writetoLyr('clientok1',clentok1_content)",5);
		}
	} else {
		writetoLyr('clienterror',a);
		var wc=parseInt(document.body.offsetWidth);
		var hc=parseInt(document.body.offsetHeight);
		var layobj=eval("document.getElementById('error').style");

		if(action) {
			//writetoLyr('clientok1',clentok1_content);
			setTimeout("writetoLyr('clientok1',clentok1_content)",5);
		}
	}
	
	var width="300", height="160";
	
  	if (ns) {
		DocWidth = parseInt(self.innerWidth);
		DocHeight = parseInt(self.innerHeight);
	}
	else {
		DocWidth = parseInt(document.body.clientWidth);
		DocHeight = parseInt(document.body.clientHeight);
	}
				
	var left = (DocWidth/2) - width/2;
  	var top = (DocHeight/2) - height/2;
	
	layobj.left = left;
	layobj.top = top;
	
	if (action) showHideLayers('clientok1','','show');
	
	showHideLayers('error','','show');
	
}

function writetoLyr(id,message)
{
	/*
	message=message.replace(/\\#/gi,"\\");
	message=message.replace(/(\r\n|\r|\n)/gi,"@##@");
	message=message.replace(/\\'/gi,"'");
	message=message.replace(/'/gi,"\\'");
	*/
	
	if (ns) {
		document.layers[id].document.write("'"+message+"'");
		document.layers[id].document.close();
	} 
	else if (ie) 
		eval("document.all."+id+".innerHTML='"+message+"'");
	else 
		document.getElementById(id).innerHTML = message;
}


/****************************************************************************************************/
/****************************************************************************************************/
/********************  IE CODE ********************************/
if (ie) {
	drag = 0
	move = 0
		
	// register key events
	window.document.onkeydown   = function() 	{ _ieOnKeyDown		(event); }
	
	// register mouse events
	window.document.onclick 	= function() 	{ _ieOnClick		(event); }
	window.document.ondragstart = function() 	{ _ieOnDragStart	(event); }
	window.document.onmousedown = function() 	{ _ieOnMouseDown	(event); }
	window.document.onmousemove = function() 	{ _ieOnMouseMove	(event); }
	window.document.onmouseup   = function() 	{ _ieOnMouseUp  	(event); }
	
	function _ieOnKeyDown(ev)
	{
		switch (ev.keyCode) {
		// BACKSPACE - override default IE handling (which is history.back())
		case 8: 
			var srcType = ev.srcElement.type + '';
			
			switch (srcType) {
				case "text":
				case "textarea":
				case "password":
					if (ev.srcElement.readOnly)
						ev.returnValue = false;
					break;
				default: 
					ev.returnValue = false;
					break;
			}
	
			break;
		}
	}
		
	function _ieOnClick(ev)
	{ 
		var srcType = ev.srcElement.type + '';
		var srcName = ev.srcElement.name + '';
		if ((srcType == 'undefined') && (srcName == 'undefined')) {
			ev.returnValue = false;
		}
		else if (srcType.indexOf('select') >= 0) {
			ev.returnValue = false;
		}
	}
	
	function _ieOnDragStart(ev)
	{
		ev.returnValue = false;
	}
	
	function _ieOnMouseDown(ev)
	{
		if (drag){
			clickleft = ev.x - parseInt(document.all[dragObj].style.left);
			clicktop = ev.y - parseInt(document.all[dragObj].style.top);
			//document.all[dragObj].style.zIndex += 1;
			move = 1;
		}
	}
	
	function _ieOnMouseMove(ev)
	{
		if (move){
			if (ev.x > 20){
				document.all[dragObj].style.left = ev.x - clickleft;
			} else {
				document.all[dragObj].style.left = 5;
			}
			if (ev.y > 2){
				document.all[dragObj].style.top = ev.y - clicktop;
			} else {
				document.all[dragObj].style.top = 7;
				move = 0;
			}
		}
	}
	
	function _ieOnMouseUp()
	{
		move = 0;
	}

}
	/***************  /IE CODE   *****************************/		
	/***************  NETSCAPE CODE   *****************************/
else if (ns) {
	//alert(BrowserVer);
	function NetScapeMoveLayer(iegear){
		currentX = currentY = 0;
				
		function grabGear(gear) {
	       currentX = gear.pageX;
	        currentY = gear.pageY;
	        captureEvents(Event.MOUSEMOVE);
	        onmousemove = moveGear;
		 }
				                  
		function moveGear(gear) {
	        distanceX = (gear.pageX - currentX);
	        distanceY = (gear.pageY - currentY);
	        currentX = gear.pageX;
	        currentY = gear.pageY;
			if (currentX < 15){
				distanceX = 25;
				dropGear();
			}
			if (currentY < 15){
				distanceY = 55;
				dropGear();
			}		
	        document[iegear].moveBy(distanceX,distanceY);
		
		 }
		
		function dropGear() {
			releaseEvents(Event.MOUSEMOVE);
		}
		
		document[iegear].document.onmousedown = grabGear;
		document[iegear].document.onmouseup = dropGear;
	}
}
//if Netscape version is +5
else {
	function NetScape5MoveLayer(iegear){
		clickleft = clicktop = 0;
		up = 0;
		
		function grabGear(gear) {
			obj = findObj(dragObj);
			clickleft = gear.pageX - parseInt(obj.style.left);
		   	clicktop = gear.pageY - parseInt(obj.style.top);
		   
		    up = 1;
	        captureEvents(Event.MOUSEMOVE);
    	    onmousemove = moveGear;
		 }
				                  
		function moveGear(gear) {
			if (up) {
		   		document.getElementById(iegear).style.left = gear.pageX - clickleft;
		   		document.getElementById(iegear).style.top = gear.pageY - clicktop;
			}
		 }
		
		function dropGear() {
			up = 0;
    	    releaseEvents(Event.MOUSEMOVE);
		}
				
	   	document.getElementById(iegear).onmousedown = grabGear;
		document.getElementById(iegear).onmouseup = dropGear;				
	}
}
