var params;
// Recupera els parāmetres
function getParams() {
var idx = document.URL.indexOf('?');
var params = new Array();
if (idx != -1) {
	var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
	for (var i=0; i<pairs.length; i++) {
		nameVal = pairs[i].split('=');
		params[nameVal[0]] = nameVal[1];
   }
}
return params;
}
// Cārrega inicial dels parāmetres a la plana
params = getParams();
// Recupera un parāmetre determinat
function getThisParam(p2get)
{
return (unescape(params[p2get]));
}


function urlencode(strText) {                             
var isObj;
var trimReg;
if( typeof(strText) == "string" ) {
	if( strText != null ) {
				trimReg = /(^\s+)|(\s+$)/g;
				strText = strText.replace( trimReg, '');
				for(i=32;i<256;i++) {               
					strText = strText.replace(String.fromCharCode(i),escape(String.fromCharCode(i)));                                                                 
				}
	}
}          
return strText;
}



function checkEmail(email) {
  var a= email.indexOf('@'), p=email.lastIndexOf('.'), l=email.length;
  if (a<1 || a>l-5 || a>p-2 || p<l-5 || p>l-3) return false;
  var especial=true;
  for (var i=a+1; i<l; i++) {
    var c= email.charAt(i).toLowerCase();
      if ((c>='0' && c<='9') || (c>='a' && c<='z')) especial=false;
      else if (c=='-' || c=='.') {
        if (especial) return false;
        especial= true;
      }
      else return false;
  }
  if (especial) return false;
  return true;
}


/*
.........................
:: Window Popper ::
.........................
*/

function pop(u,n,f, w, h, c) {
  if(window.screen)if(c)if(c=="1"){
    var l = (screen.width-w)/2;
    var t = (screen.height-h)/2;
    f+=(f!='')?',':'';
    f+='left='+l+',top='+t;
  }
  flop=window.open(u,n,f+((f!='')?',':'')+'width='+w+',height='+h);
  flop.focus();
}


/*
.........................
:: Switch Div ::
.........................
*/

function switchDiv(divNum){
	x=document.getElementById("s" + divNum);
	y=document.getElementById("i" + divNum);
	if(x.style.display != "block"){
		x.style.display="block";
		y.src="img/menuOpen.gif";
	}else{
		x.style.display="none";
		y.src="img/menuClosed.gif";
    }
}


/*
.........................
:: The xRollovers ::
.........................
*/

function xOn(theId) {
	xfile=document.getElementById(theId)
	xname=xfile.getAttribute('src')
	x=xname.length
	xext=xname.substring(x-4,xname.length)
	xname=xname.substring(0,x-4)
	xfile.src=xname+".on"+xext
}

function xOff(theId) {
	xfile=document.getElementById(theId)
	xname=xfile.getAttribute('src')
	x=xname.length
	xext=xname.substring(x-4,xname.length)
	xname=xname.substring(0,x-7)
	xfile.src=xname+xext
}


/*
.........................
:: Cookie Recipes ::
.........................
*/

function saveCookie(name,value,days) {
        if (days) {
                var date = new Date();
                date.setTime(date.getTime()+(days*24*60*60*1000))
                var expires = "; expires="+date.toGMTString()
        }
        else expires = ""
        document.cookie = name+"="+value+expires+"; path=/"
}

function readCookie(name) {
        var nameEQ = name + "="
        var ca = document.cookie.split(';')
        for(var i=0;i<ca.length;i++) {
                var c = ca[i];
                while (c.charAt(0)==' ') c = c.substring(1,c.length)
                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length)
        }
        return null
}

function deleteCookie(name) {
        saveCookie(name,"",-1)
}


/*
.........................
:: Event Listener Interface ::
.........................
*/

function addEvent(obj, evType, fn, useCapture){
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  } else {
    //alert("Handler could not be attached");
  }
}

function removeEvent(obj, evType, fn, useCapture){
  if (obj.removeEventListener){
    obj.removeEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.detachEvent){
    var r = obj.detachEvent("on"+evType, fn);
    return r;
  } else {
    //alert("Handler could not be removed");
  }
}

