////////////////////////////////////////////////////////////////////////////
// Rutines Java Genèriques Mode 'Cs' v.4.0 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= //
// Copyright (c) 1999-2007 A. C. DiversiaWorld                            //
//                                                                        //
// Registrat en el Reg. Propietat Intel·lectual del Dept. de Cultura de   //
// la Generalitat de Catalunya                                            //
// Podeu fer-ne ús lliure en webs no comercials ni lucratives, avisant-ne //
// prèviament a l'autor mitjançant les URLs anteriors                     //
// Uso libre con fines no lucrativo previo aviso mediante las citadas URL //
////////////////////////////////////////////////////////////////////////////

// Genèriques

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function GP_popupConfirmMsg(msg) { //v1.0
  document.MM_returnValue = confirm(msg);
}
function MM_popupMsg(msg) { //v1.0
  alert(msg);
}
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 MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


// Funcions botó dret -----------------------------------------------------
var message="";
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

// Funcions antisel·lecció ------------------------------------------------
//document.onselectstart=new Function("return false");
	
// Funcions de formularis colorejats --------------------------------------
var highlightcolor="#FFFFCC"
var ns6=document.getElementById&&!document.all
var previous=''
var eventobj
var intended=/INPUT|TEXTAREA|SELECT/
function checkel(which){
if (which.style&&intended.test(which.tagName)){
if (ns6&&eventobj.nodeType==3)
eventobj=eventobj.parentNode.parentNode
return true
}
else
return false
}
function highlight(e){
eventobj=ns6? e.target : event.srcElement
if (previous!=''){
if (checkel(previous))
previous.style.backgroundColor=''
previous=eventobj
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
}
else{
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
previous=eventobj
}
}

// Funcions colorejar taula (v.2) -----------------------------------------
// Ús: <table onMouseover="changeto(event, 'lightgreen')" onMouseout="changeback(event, 'white')">
// Desús: id="ignora"

var ns6=document.getElementById&&!document.all
var ie=document.all

function changeto(e,highlightcolor){
source=ie? event.srcElement : e.target
if (source.tagName=="TR"||source.tagName=="TABLE")
return
while(source.tagName!="TD"&&source.tagName!="HTML")
source=ns6? source.parentNode : source.parentElement
if (source.style.backgroundColor!=highlightcolor&&source.id!="ignora")
source.style.backgroundColor=highlightcolor
}

function contains_ns6(master, slave) { 
while (slave.parentNode)
if ((slave = slave.parentNode) == master)
return true;
return false;
}

function changeback(e,originalcolor){
if
(ie&&(event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignora")||source.tagName=="TR"||source.tagName=="TABLE")
return
else if (ns6&&(contains_ns6(source, e.relatedTarget)||source.id=="ignora"))
return
if (ie&&event.toElement!=source||ns6&&e.relatedTarget!=source)
source.style.backgroundColor=originalcolor
}

// Funcions antispam ------------------------------------------------------
function correuNet(usuari,referencia,origen,domini,extensio) {
	ubicacio = "mailto:" + usuari + "@" + domini + "." + extensio;
	window.location = ubicacio;
	}

// Funcions del Cercle d'Amics --------------------------------------------
function ObreCercleES() { 
ObreFinestra('http://www.okeeo.com/cercleamics/index_es.php','Interactua','750','550','yes');
	}
function ObreCercleCA() { 
ObreFinestra('http://www.okeeo.com/cercleamics/index_ca.php','Interactua','750','550','yes');
	}

// Funcions del Missatger -------------------------------------------------
function ObreMsgrES() { 
ObreFinestra('http://www.okeeo.com/missatger/index_es.php','missatger','307','421');
	}
function ObreMsgrCA() { 
ObreFinestra('http://www.okeeo.com/missatger/index_ca.php','missatger','307','421');
	}

// Servei de Càrrega ------------------------------------------------------
function lon(target)
{
	if (undefined == target)
		target = this;

	if (undefined == target._lon_disabled_arr)
		target._lon_disabled_arr = new Array();
	else if (target._lon_disabled_arr.length > 0)
		return true;

	target.document.getElementById("loaderContainer").style.display = "";
	var select_arr = target.document.getElementsByTagName("select");

	for (var i = 0; i < select_arr.length; i++) {
		select_arr[i].disabled = true;
		_lon_disabled_arr.pop(select_arr[i]);
		var clone = target.document.createElement("input");
		clone.type = "hidden";
		clone.name = select_arr[i].name;
		var values = new Array();
		for (var n = 0; n < select_arr[i].length; n++) {
			if (select_arr[i][n].selected) {
				values[values.length] = select_arr[i][n].value;
			}
		}
		clone.value = values.join(",");
		select_arr[i].parentNode.insertBefore(clone, select_arr[i]);
	}
	return true;
}

function loff(target)
{
	if (undefined == target)
		target = this;

	target.document.getElementById("loaderContainer").style.display = "none";
	if (undefined == target._lon_disabled_arr)
		return true;

	for (;_lon_disabled_arr.legth > 0;) {
		var select = _lon_disabled_arr.push();
		select.disabled = false;

		var clones_arr = target.document.getElementsByName(select.name);
		for (var n = 0; n < clones_arr.length; n++) {
			if ("hidden" == clones_arr[n].type)
				clones_arr[n].parent.removeChild(clones_arr[n]);
		}
	}
	return true;
}

function _body_onload()
{
	loff();
}

function _body_onunload()
{
	lon();
}

// Funció de tremolar -----------------------------------------------------
var rector=1
var stopit=0 
var valora=1
function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0
}
function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return
if (valora==1){
shake.style.top=parseInt(shake.style.top)+rector
}
else if (valora==2){
shake.style.left=parseInt(shake.style.left)+rector
}
else if (valora==3){
shake.style.top=parseInt(shake.style.top)-rector
}
else{
shake.style.left=parseInt(shake.style.left)-rector
}
if (valora<4)
valora++
else
valora=1
setTimeout("rattleimage()",50)
}
function stoprattle(which){
stopit=1
which.style.left=0
which.style.top=0
}
