var actImgTag;
var selImgTag;
var clsRoll;
var imgList;
var images;
var activeImages;
var inactiveImages;

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function addUnloadEvent(func) {
  var oldonunload = window.onunload;
  if (typeof window.onunload != 'function') {
    window.onunload = func;
  } else {
    window.onunload = function() {
      oldonunload();
      func();
    }
  }
}

function mostrarPromo(url, idPromo, caducidad){
	var promo=getCookie("SOC_Promo_"+idPromo);
	if (promo==null || promo=="")
	{
		setCookie("SOC_Promo_"+idPromo,idPromo,caducidad);
		window.open(url,'','');	
	}
}

function mostrarPromoFeinaActiva(){
	mostrarPromo('campanyes/feinaactiva/index.jsp','feinaactiva',1);
}


function mostrarAvisPanicRenovacio(){
	//mostrarAvisPanic('Missatges.do?idMissatge=missatge.servei.renovacio.saturat');
	tancarWeb('Missatges.do?idMissatge=missatge.servei.renovacio.saturat');
}

function mostrarAvisPanic(url){
	var painWindow=window.open(url,'','width=650,height=525,menubar=no,scrollbars=no,status=yes,resizable=no');	
	painWindow.focus();
}

function tancarWeb(url){
	document.location.href=url;
}


function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
  {
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}

function redireccionarUrl(url){
  window.close();
  if(url!=''){
    window.opener.location.href=url;
  }
}


function solicitar (_location) {
   window.opener.location.href = _location;
   window.close();
}

function imprimir(nomForm){
     if (document.getElementById(nomForm)){
		document.getElementById('formulari').style.display='none';
		for(var i=0;document.getElementsByTagName('P').length;i++){
			if(document.getElementsByTagName('P')[i].className){
				if(document.getElementsByTagName('P')[i].className=='ratllat'){
					document.getElementsByTagName('P')[i].style.display='none';
					break;
				}
			}
		}
    }
		
   window.print();
}

function popUp(url) {
   newWin = window.open(url,'_blank','width=700,height=450,menubar=yes,scrollbars=yes,status=yes,resizable=yes');
   newWin.focus();
}

function popUpDardoHTML(url) {
   newWin = window.open(url,'_blank','width=750,height=600,menubar=yes,scrollbars=yes,status=yes,resizable=no');
   newWin.focus();
}

function popUpMatriz(url) {
   newWin = window.open(url,'_blank','width=480,height=450,menubar=no,scrollbars=yes,status=yes,resizable=yes');
   newWin.focus();
}

function popUpCurriculum(url) {
   newWin = window.open(url,'_blank','width=800,height=450,menubar=no,scrollbars=yes,status=yes,resizable=yes');
   newWin.focus();
}

function popUpFitxa(url) {
   newWin = window.open(url,'_blank','top=0,left=0,width=1024,height=450,menubar=no,scrollbars=yes,status=yes,resizable=yes');
   newWin.focus();
}

function popUpDistrTerri(url) {
   newWin = window.open(url,'_blank','top=0,left=0,width=1024,height=550,menubar=no,scrollbars=yes,status=yes,resizable=yes');
   newWin.focus();
}

function popUpJornada(url) {
   newWin = window.open(url,'_blank','width=800,height=600');
   newWin.focus();
}

function popUpEntitat(url) {
   newWin = window.open(url,'_blank','width=600,height=200,top=50,left=50,menubar=no,scrollbars=yes,status=yes,resizable=yes');
   newWin.focus();
}

function popUpGestioOfertes(url) {
   newWin = window.open(url,'_blank','top=0,left=0,width=1024,height=580,menubar=no,scrollbars=yes,status=yes,resizable=yes');
   newWin.focus();
}

function popUpCloe(url) {
   newWin = window.open(url,'_blank','width=800,height=650,menubar=no,scrollbars=0,status=yes,resizable=yes');
   newWin.focus();
}

function popUpComparaOfertes(url) {
   newWin = window.open(url,'_blank','top=0,left=0,width=1020,height=675,menubar=no,scrollbars=yes,status=yes,resizable=yes');
   newWin.focus();
}

function tancarFinestra(){
   window.close();
}

function selOpcionsLlistaRadios(path){
  for (var i=0;i<document.forms[0].elements.length;i++){
    if (document.forms[0].elements[i].checked){
      popUp(path + "?accio=" + document.forms[0].elements[i].value);
    }
  }
}
function selOpt(fId, fV) {
   if (document.getElementById) {
      objS = window.opener.document.getElementById(fId);
      objS.value = fV;
      window.close();
   }
}

function selOptUrl(url){
   opener.document.location=url;
   window.close();	
}

// UIR (Unobtrusive Image Rollover) v2.0.1-20060309
if (document.getElementById) {
   function initUIR() {
      actImgTag = "_on";
      selImgTag = "_sel";
      clsRoll = "roll";

      imgList = '';
      var images = document.getElementsByTagName('img');
   
      for (var i=0; i<images.length; i++) {
         if (eval('/' + clsRoll + '/').test(images[i].className)) {
            imgList += images[i].src + ",";
            setEvents(images[i]);
         }
      }
      if (imgList != '') {
         imgList = imgList.substring(0, imgList.length-1);
         preload(imgList.split(","));
      }
   }
   
   function setEvents(element) {
      element.parentNode.onmouseover = function() { roll(this); }
      element.parentNode.onmouseout = function() { roll(this); }
      element.parentNode.onfocus = function() { roll(this); }
      element.parentNode.onblur = function() { roll(this); }
   }
   
   function preload(imgList) {
      activeImages = new Array(imgList.length);
      inactiveImages = new Array(imgList.length);
      
      for (var i=0; i<imgList.length; i++) {
         activeImages[i] = new Image();
         activeImages[i].src = getBaseName(imgList[i]) + actImgTag + getExt(imgList[i]);
         inactiveImages[i] = new Image();
         inactiveImages[i].src = getBaseName(imgList[i]) + getExt(imgList[i]);
      }
   }
   
   function getBaseName(filename) {
      if (eval('/'+actImgTag+'\./').test(filename)) filename = filename.replace(actImgTag+'.', '.');
      if (eval('/'+selImgTag+'\./').test(filename)) filename = filename.replace(selImgTag+'.', '.');
      return filename.substring(0, filename.lastIndexOf('.'));
   }
   
   function getExt(filename) {
      return filename.substring(filename.lastIndexOf('.'), filename.length);
   }
   
   function getImage(imageName, isActive) {
      (isActive==0) ? images = inactiveImages : images = activeImages;
      for (var i=0; i<images.length; i++) {
         if (getBaseName(imageName) == getBaseName(images[i].src)) {
            return images[i];
            break;
         }
      }
      return [];
   }
   
   function roll(element) {
      var src, newSrc;
      var node, currNode;
      
      for (var i=0; i<element.childNodes.length; i++) {
         currNode = element.childNodes[i];
         if (currNode.nodeType==1 && /img/i.test(currNode.nodeName)) {
            node = i;
            break;
         }
      }
      src = element.childNodes[node].src;
      if (!(eval('/'+selImgTag+'\./').test(src))) {
         newSrc = getImage(src,!(eval('/'+actImgTag+'\./').test(src))).src;
      }
      if (!(typeof(newSrc)=='undefined')) element.childNodes[node].src = newSrc;
   }

   addLoadEvent(initUIR);
} // (C) 2005 Emanuele Rodriguez @ TangentDigital (http://www.tangent.es)

function trim(value) {
   var temp = value;
   var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
   
   if (obj.test(temp))
      temp = temp.replace(obj, '$2');

   var obj = / +/g;
   temp = temp.replace(obj, ' ');

   if (temp == ' ')
      temp = '';

   return temp;
}

function checkForGeckoParseError(xmlDocument) {
   var errorNamespace = 'http://www.mozilla.org/newlayout/xml/parsererror.xml';
   var documentElement = xmlDocument.documentElement;
   var parseError = { errorCode : 0 };

   if (documentElement.nodeName == 'parsererror' && documentElement.namespaceURI == errorNamespace) {
      parseError.errorCode = 1;
      var sourceText = documentElement.getElementsByTagNameNS(errorNamespace, 'sourcetext')[0];
      if (sourceText != null) {
         parseError.srcText = sourceText.firstChild.data
      }
      parseError.reason = documentElement.firstChild.data;
   }
   return parseError;
}

String.prototype.toDOM = function() {
   var domFile = this;
   var parser;

   if (window.ActiveXObject) {
		domFile = new ActiveXObject("Msxml2.DOMDocument");
		domFile.async = false;
      var loaded = domFile.loadXML(this);
      if (loaded) return domFile;
         //else alert(domFile.parseError.reason + domFile.parseError.srcText);
   }
   else if (document.implementation && document.implementation.createDocument) {
      if (window.XSLTProcessor) {
         parser = new DOMParser();
         domFile = parser.parseFromString(this, 'text/xml');

         var parseError = checkForGeckoParseError(domFile);
         if (parseError.errorCode == 0) return domFile;
            //else alert(parseError.reason + '\r\n' + parseError.srcText);
      }
   }

   return undefined;
}


function disabledIdentitat(idOrigen,idDisabled){
	var ele = document.getElementById(idOrigen);
	if(ele.value != "") {
		document.getElementById(idDisabled).disabled = true;
		document.getElementById(idDisabled).value = "";
	}else{
		document.getElementById(idDisabled).disabled = false;
	}
}


function escriuDataActual(){
	var data=new Date();
	var mes =data.getMonth();
	mes++;
	mes=(mes.toString().length==1)?"0"+mes.toString():mes.toString();
	var cadena=data.getDate().toString() + " / " + mes.toString() + " / " + data.getFullYear().toString();
	document.write(cadena);
}


// Javascript de la galeria d'imatges

// Begin User Configurable Variables:

var imgsPerPg = 30; // number of img elements in the html
var imgsMax = 30;  // total number of images
var slideTimeout = 5; // seconds before loading the next slide

var gPath = '/web_jornada_17maig07/imatges_jornades/';  // gallery files (thumbnails) path, include trailing slash
var gPrefix = '';
var gSuffix = 'th';
var gExt = '.jpg';
var gZeros = true; // filename uses leading zeros?
var gDigits = 3    // total digits in filename, including leading zeros

var sPath = '/web_jornada_17maig07/imatges_jornades/'; // slideshow files (big imgs) path, include trailing slash
var sPrefix = 'img';
var sSuffix = '';
var sExt = '.jpg';
var sZeros = true; // filename uses leading zeros?                     
var sDigits = 3    // total digits in filename, including leading zeros

var captions = new Array();
// There must be (imgsMax + 1) captions.
// captions[0] is currently not used.
captions[0] = "not used";
captions[1] = "";
captions[2] = "";
captions[3] = "";
captions[4] = "";
captions[5] = "";
captions[6] = "";
captions[7] = "";
captions[8] = "";
captions[9] = "";
captions[10] = "";
captions[11] = "";
captions[12] = "";
captions[13] = "";
captions[14] = "";
captions[15] = "";
captions[16] = "";
captions[17] = "";
captions[18] = "";
captions[19] = "";
captions[20] = "";
captions[21] = "";
captions[22] = "";
captions[23] = "";
captions[24] = "";
captions[25] = "";
captions[26] = "";
captions[27] = "";
captions[28] = "";
captions[29] = "";
captions[30] = "";


// End User Configurable Variables

/* Development Notes and Script Assumptions:

1) Optional URL arguments: g = 'gallery first num', s = 'slideshow img num'.
   For example:
   img_gallery_2.php?g=21
   img_gallery_2.php?s=30

2) IMG IDs begin with 'g' (for gallery) or 's' (for slideshow)
   then are numbered sequentially beginning with 1. No leading zeros.

3) Gallery (thumbnail) image pathnames: gPath + gPrefix + seq_num + gSuffix + gExt
   SlideShow (large image) pathnames:   sPath + sPrefix + seq_num + sSuffix + sExt
   Leading zeros (as part of seq_num) are optional.

4) The captions array initializations could be generated server-side.

5) This file does not have to be a PHP file - I use it here for my page-template, not for this demo.
*/

/* xImgGallery, Copyright (C) 2004,2005 Michael Foster (Cross-Browser.com)
   Distributed under the terms of the GNU LGPL.
*/

// don't change these:
var galMode = true;
var autoSlide = false;
var slideTimer = null;
var slideCounter = 0;
var currentSlide = 1;

function xImgGallery()
{
  if (document.getElementById && document.getElementById('nav').style) {
    var n = 1, a = xGetURLArguments();
    if (a.length) {
      var arg = a['g'] || a['s'];
      if (arg) {
        n = parseInt(arg, 10);
        if (n <= 0 || n > imgsMax) { n = 1; } 
        if (a['s']) { galMode = false; }
      }
    }
    gal_paint(n);
    //document.getElementById('time').style.display = 'none';
  }
}
function gal_paint(n)
{
  gal_setImgs(n);
  gal_setNav(n);
}
function gal_setImgs(n)
{
  var ssEle = document.getElementById('slideshow');
  var galEle = document.getElementById('gallery');
  var i, imgTitle, pth, img, id, src, ipp, idPrefix, imgSuffix, imgPrefix;
  var zeros, digits, capEle, capPar;
  if (galMode) {
    ipp = imgsPerPg;
    idPrefix = 'g';
    imgPrefix = gPrefix;
    imgSuffix = gSuffix + gExt;
    imgTitle = titol_imatge;
    ssEle.style.display = 'none';
    galEle.style.display = 'block';
    pth = gPath;
    zeros = gZeros;
    digits = gDigits;
  }
  else {
    currentSlide = n;
    ipp = 1;
    idPrefix = 's';
    imgPrefix = sPrefix;
    imgSuffix = sSuffix + sExt;
    imgTitle = '';
    ssEle.style.display = 'block';
    galEle.style.display = 'none';
    pth = sPath;
    zeros = sZeros;
    digits = sDigits;
  }
  for (i = 0; i < ipp; ++i) {
    id = idPrefix + (i + 1);
    img = document.getElementById(id);
    capEle = document.getElementById((galMode ? 'gc':'sc') + (i + 1));
    if (capEle) capPar = capEle.parentNode;
    if ((n + i) <= imgsMax) {
      if (zeros) src = xPad(n + i, digits, '0', true);
      else src = (n + i) + "";
      img.title = imgTitle;
      img.alt = src;
      img.src = pth + imgPrefix + src + imgSuffix; // img to load now
      img.onerror = imgOnError;
      if (galMode) {
        img.style.cursor = 'pointer';
        img.slideNum = n + i; // slide img to load onclick
        img.onclick = imgOnClick;
      }
      if (capEle) {
        capEle.innerHTML = captions[i + n];
        if (capPar) capPar.style.display = 'block';
      }
      img.style.display = 'inline';
    }
    else {
      img.style.display = 'none';
      if (capEle) {
        if (capPar) capPar.style.display = 'none';
      }
    }
  }  
}
function imgOnClick()
{
  galMode = false;
  document.getElementById("nav").style.display='block';
  gal_paint(this.slideNum);
}
function imgOnError()
{
  var p = this.parentNode;
  if (p) p.style.display = 'none';
}
function gal_setNav(n)
{
  var ipp = galMode ? imgsPerPg : 1;
  // Next
  var e = document.getElementById('next');
  if (n + ipp <= imgsMax) {
    e.nextNum = n + ipp;
    e.onclick = next_onClick;
    e.style.display = 'inline';
  }
  else {
    e.nextNum = 1;
  }
  // Previous
  e = document.getElementById('prev');
  e.style.display = 'inline';
  e.onclick = prev_onClick;
  if (n > ipp) {
    e.prevNum = n - ipp;
  }
  else {
    e.prevNum = galMode ? normalize(imgsMax) : imgsMax;
  }
  // Back
  e = document.getElementById('back');
  if (!galMode) {
    e.onclick = back_onClick;
    e.style.display = 'inline';
    e.backNum = normalize(n);
  }
  else {
    e.style.display = 'none';
  }
  // Auto Slide
  e = document.getElementById('auto');
  if (!galMode) {
    e.onclick = auto_onClick;
    e.style.display = 'inline';
  }
  else {
    e.style.display = 'none';
  }
}
function normalize(n)
{
  return 1 + imgsPerPg * (Math.ceil(n / imgsPerPg) - 1);
}
function next_onClick(e)
{
  gal_paint(this.nextNum);
}
function prev_onClick(e)
{
  gal_paint(this.prevNum);
}
function back_onClick(e)
{
  galMode = true;
  if (slideTimer) {
    clearTimeout(slideTimer);
  }
  autoSlide = false;
  gal_paint(this.backNum);
  //document.getElementById('time').style.display = 'none';
  document.getElementById('auto').innerHTML=comencar_automatic;
  document.getElementById("nav").style.display='none';
}
function auto_onClick(e)
{
  //var ele = document.getElementById('time');
  autoSlide = !autoSlide;
  if (autoSlide) {
    slideCounter = 0;
    slideTimer = setTimeout("slide_OnTimeout()", slideTimeout);
   // ele.style.display = 'none';
   document.getElementById('auto').innerHTML=parar_automatic;
  }
  else if (slideTimer) {
    clearTimeout(slideTimer);
    document.getElementById('auto').innerHTML=comencar_automatic;
    //ele.style.display = 'none';
  }
}
function slide_OnTimeout()
{
  slideTimer = setTimeout("slide_OnTimeout()", 1000);
  ++slideCounter;
  //document.getElementById('time').innerHTML = slideCounter + '/' + slideTimeout;
  if (slideCounter == slideTimeout) {
    if (++currentSlide > imgsMax) currentSlide = 1; 
    gal_paint(currentSlide);
    slideCounter = 0;
  }
}

/* xGetURLArguments and xPad are part of the X library,
   distributed under the terms of the GNU LGPL,
   and maintained at Cross-Browser.com.
*/
function xGetURLArguments()
{
  var idx = location.href.indexOf('?');
  var params = new Array();
  if (idx != -1) {
    var pairs = location.href.substring(idx+1, location.href.length).split('&');
    for (var i=0; i<pairs.length; i++) {
      nameVal = pairs[i].split('=');
      params[i] = nameVal[1];
      params[nameVal[0]] = nameVal[1];
    }
  }
  return params;
}
function xPad(str, finalLen, padChar, left)
{
  if (typeof str != 'string') str = str + '';
  if (left) { for (var i=str.length; i<finalLen; ++i) str = padChar + str; }
  else { for (var i=str.length; i<finalLen; ++i) str += padChar; }
  return str;
}

function fer_onload_galeria(){
if (document.getElementById('gallery')) xImgGallery();
}
addLoadEvent(fer_onload_galeria)

var wSocTramits=null;		
function popupTramits(mylink, windowname){
	try{
		if (!window.focus)return true;
	}
	catch(e){}
	var href;
	if (typeof(mylink) == 'string')
		href=mylink;
	else
		href=mylink.href;
	wSocTramits=window.open(href, windowname, 'width=1024,height=600,scrollbars=no');
	try{
		wSocTramits.focus();
	}
	catch(e){}
	return false;
}

function redirectTramits(mylink, theWindow){
	
	theWindow.resizeTo(1050,850);
	theWindow.moveTo(0,0);
	var href;
	
	if (typeof(mylink) == 'string'){
		href=mylink;
	}
	else{
		href=mylink.href;
	}
	theWindow.document.location.href=href;
	
	try{
		theWindow.focus();
	}
	catch(e){}
	return false;
}

var wSocEmpreses=null;
function popupEmpreses(mylink, windowname){
	try{
		if (!window.focus)return true;
	}
	catch(e){}
	var href;
	if (typeof(mylink) == 'string')
		href=mylink;
	else
		href=mylink.href;
	wSocEmpreses=window.open(href, windowname, 'width=1024,height=600,scrollbars=no');
	try{
		wSocEmpreses.focus();
	}
	catch(e){}
	return false;
}

function redirectEmpreses(mylink, theWindow){

	theWindow.resizeTo(1050,850);
	theWindow.moveTo(0,0);
	var href;
	
	if (typeof(mylink) == 'string'){
		href=mylink;
	}
	else{
		href=mylink.href;
	}
	theWindow.document.location.href=href;
	
	try{
		theWindow.focus();
	}
	catch(e){}
	return false;
}

function popupSubmit(myForm){
	
	var id_wInf=new Date().getTime();
	var wInf=window.open('about:blank', id_wInf, 'width=850,height=625,menubar=yes,scrollbars=yes,status=yes,resizable=yes');
	myForm.target=id_wInf;
	try{
		wInf.focus();
	}
	catch(e){}

	myForm.submit();

}

/******************************************* comparativa d'ofertes ****************************************/

function imprimirComparativa(){
    document.getElementById("impresion").style.display='none';
    document.getElementById("comparativa").style.display='none';
    document.getElementById("contingut").style.display='inline';
    
    var capc=document.getElementById("cap");
    var divs=capc.getElementsByTagName("div");
	for(i=0; i<=divs.length-1; i++){
	  if(divs[i].className=="verd" || divs[i].className=="mig" ){
	    divs[i].style.display='none';
	    
	  }
	}
   window.print(); 
   setTimeout("mostrar();",8000);


}

function mostrar(){

    document.getElementById("impresion").style.display='inline';
    document.getElementById("comparativa").style.display='inline';
    document.getElementById("contingut").style.display='none';

var capc=document.getElementById("cap");
    var divs=capc.getElementsByTagName("div");
	for(i=0; i<=divs.length-1; i++){
	  if(divs[i].className=="verd" || divs[i].className=="mig" ){
	    divs[i].style.display='inline';
 	   
	  }
	}

}

var wSocCitaPrevia=null;
function popupCitaPrevia(mylink, windowname){

	try{
		if (!window.focus)return true;
	}
	catch(e){}
	var isForm=0;
	var href;
	if (typeof(mylink) == 'string')
		href=mylink;
	else{
		
		try{
			if(typeof(mylink.action)!='undefined'){
				isForm=1;
			}
		}
		catch(e){}
		if(isForm==0){
			href=mylink.href;
		}
	}

	if(isForm==0){
		wSocCitaPrevia=window.open(href, windowname,'width=1024,height=600,menubar=yes,scrollbars=yes,status=yes,resizable=yes');
	}
	else{
		wSocCitaPrevia=window.open('about:blank', windowname,'width=1024,height=600,menubar=yes,scrollbars=yes,status=yes,resizable=yes');
		mylink.target=windowname;
		mylink.submit();
	}

	try{
		wSocCitaPrevia.focus();
	}
	catch(e){}
	return false;
}

function redirectCitaPrevia(mylink, theWindow){

	theWindow.resizeTo(1050,800);
	theWindow.moveTo(0,0);

	var isForm=0;
	var href;
	if (typeof(mylink) == 'string')
		href=mylink;
	else{
		
		try{
			if(typeof(mylink.action)!='undefined'){
				isForm=1;
			}
		}
		catch(e){}
		if(isForm==0){
			href=mylink.href;
		}
	}
	
	if(isForm==0){
		theWindow.document.location.href=href;
	}
	else{
		mylink.submit();
	}

	try{
		theWindow.focus();
	}
	catch(e){}

	try{
		theWindow.focus();
	}
	catch(e){}
	return false;
}


var wSocCercadors=null;
function popupCercadors(mylink, windowname){

	try{
		if (!window.focus)return true;
	}
	catch(e){}
	var href;
	if (typeof(mylink) == 'string')
		href=mylink;
	else{
		var isForm=0;
		try{
			if(typeof(mylink.action)!='undefined'){
				isForm=1;
			}
		}
		catch(e){}
		if(isForm==0){
			href=mylink.href;
		}
	} 

	if(isForm==0){
		wSocCercadors=window.open(href, windowname,'width='+screen.availWidth+',height='+screen.availHeight+',menubar=yes,scrollbars=yes,toolbar=yes,location=yes,directories=yes,status=yes,resizable=yes');
	}
	else{
		wSocCercadors=window.open('about:blank', windowname,'width='+screen.availWidth+',height='+screen.availHeight+',menubar=yes,scrollbars=yes,toolbar=yes,location=yes,directories=yes,status=yes,resizable=yes');
		mylink.target=windowname;
		mylink.submit();
	}

	try{
		wSocCercadors.focus();
	}
	catch(e){}
	return false;
} 

function redirectCercadors(mylink, theWindow){

	theWindow.resizeTo(screen.availWidth,screen.availHeight);
	theWindow.moveTo(0,0);
	
	var isForm=0;
	var href;
	if (typeof(mylink) == 'string')
		href=mylink;
	else{
		
		try{
			if(typeof(mylink.action)!='undefined'){
				isForm=1;
			}
		}
		catch(e){}
		if(isForm==0){
			href=mylink.href;
		}
	} 

	if(isForm==0){
		theWindow.document.location.href=href;
	}
	else{
		mylink.submit();
	}

	try{
		theWindow.focus();
	}
	catch(e){}
	return false;
}

function popUpDetallCurs(url) {
   newWin = window.open(url,'_blank','width=900,height=750,menubar=yes,scrollbars=yes,status=yes,resizable=yes');
   newWin.focus();
}

function popUpDetallEspecialitat(url) {
   newWin = window.open(url,'_blank','width=900,height=500,menubar=yes,scrollbars=yes,status=yes,resizable=yes');
   newWin.focus();
}

var wSocResum=null;
function popupResum(mylink, windowname){

	try{
		if (!window.focus)return true;
	}
	catch(e){}
	var href;
	if (typeof(mylink) == 'string')
		href=mylink;
	else{
		var isForm=0;
		try{
			if(typeof(mylink.action)!='undefined'){
				isForm=1;
			}
		}
		catch(e){}
		if(isForm==0){
			href=mylink.href;
		}
	} 

	if(isForm==0){
		wSocResum=window.open(href, windowname,'width=900,height=800,menubar=yes,scrollbars=yes,status=yes,resizable=yes');
	}
	else{
		wSocResum=window.open('about:blank', windowname,'width=900,height=800,menubar=yes,scrollbars=yes,status=yes,resizable=yes');
		mylink.target=windowname;
		mylink.submit();
	}

	try{
		wSocResum.focus();
	}
	catch(e){}
	return false;
}

var wSocFormacioFitxes=null;
function popupFormacioFitxes(mylink, windowname){

	try{
		if (!window.focus)return true;
	}
	catch(e){}
	var href;
	if (typeof(mylink) == 'string')
		href=mylink;
	else{
		var isForm=0;
		try{
			if(typeof(mylink.action)!='undefined'){
				isForm=1;
			}
		}
		catch(e){}
		if(isForm==0){
			href=mylink.href;
		}
	} 

	if(isForm==0){
		wSocFormacioFitxes=window.open(href, windowname,'width=900,height=800,menubar=yes,scrollbars=yes,status=yes,resizable=yes');
	}
	else{
		wSocFormacioFitxes=window.open('about:blank', windowname,'width=900,height=800,menubar=yes,scrollbars=yes,status=yes,resizable=yes');
		mylink.target=windowname;
		mylink.submit();
	}

	try{
		wSocFormacioFitxes.focus();
	}
	catch(e){}
	return false;
}  

var wSocDetallCurs=null;
function popUpDetallCursDesdeEspecialitat(mylink, windowname){

	try{
		if (!window.focus)return true;
	}
	catch(e){}
	var href;
	if (typeof(mylink) == 'string')
		href=mylink;
	else{
		var isForm=0;
		try{
			if(typeof(mylink.action)!='undefined'){
				isForm=1;
			}
		}
		catch(e){}
		if(isForm==0){
			href=mylink.href;
		}
	} 

	if(isForm==0){
		wSocDetallCurs=window.open(href, windowname,'width=900,height=750,menubar=yes,scrollbars=yes,status=yes,resizable=yes');
	}
	else{
		wSocDetallCurs=window.open('about:blank', windowname,'width=900,height=750,menubar=yes,scrollbars=yes,status=yes,resizable=yes');
		mylink.target=windowname;
		mylink.submit();
	}

	try{
		wSocDetallCurs.focus();
	}
	catch(e){}
	return false;
}


function testFormObj(obj){
	if(obj.value!=null && obj.value!='null' && obj.value!=''){
		return true;
	}
	return false;
}

function createFormObj(objNameOrig,objNameDesti, formOrig, formDesti){
	
	var objForm=document.createElement('INPUT');
		
  var attrType = document.createAttribute('type');
  attrType.value = 'hidden';
  objForm.setAttributeNode(attrType);
  
  var attrID = document.createAttribute('id');
  attrID.value = objNameDesti;
  objForm.setAttributeNode(attrID);
  
  var attrName = document.createAttribute('name');
  attrName.value = objNameDesti;
  objForm.setAttributeNode(attrName);
  	
  var attrValue = document.createAttribute('value');
  attrValue.value = formOrig.elements[objNameOrig].value;
  objForm.setAttributeNode(attrValue);
  	
	formDesti.appendChild(objForm);
	
}


function enviarSubscripcio(formOrig, formDesti, windowname){
   
  var objNameOrig='';
  var objNameDesti='';
   
	try{
		objNameOrig='palabra';
		objNameDesti='paraulaClau';

		if(testFormObj(formOrig.elements[objNameOrig])){
			createFormObj(objNameOrig,objNameDesti,formOrig, formDesti);
		}
	}
	catch(err){}
	try{
		objNameOrig='cod_prov';
		objNameDesti='cod_prov';

		if(testFormObj(formOrig.elements[objNameOrig])){
			createFormObj(objNameOrig,objNameDesti,formOrig, formDesti);
		}
	}
	catch(err){}
	try{
		objNameOrig='cod_com';
		objNameDesti='cod_com';

		if(testFormObj(formOrig.elements[objNameOrig])){
			createFormObj(objNameOrig,objNameDesti,formOrig, formDesti);
		}
	}
	catch(err){}
	try{
		objNameOrig='cod_muni';
		objNameDesti='cod_muni';

		if(testFormObj(formOrig.elements[objNameOrig])){
			createFormObj(objNameOrig,objNameDesti,formOrig, formDesti);
		}
	}
	catch(err){}
	try{
		objNameOrig='areaConeix';
		objNameDesti='cod_area_coneix';

		if(testFormObj(formOrig.elements[objNameOrig])){
			createFormObj(objNameOrig,objNameDesti,formOrig, formDesti);
		}
	}
	catch(err){}
	
	
	try{
		objNameOrig='areaConeix';
		objNameDesti='descAreaConeix';

		if(testFormObj(formOrig.elements[objNameOrig])){
			createFormObj(objNameOrig,objNameDesti,formOrig, formDesti);
		}
	}
	catch(err){}
	try{
		objNameOrig='tipusCurs';
		objNameDesti='tipusCurs';

		if(testFormObj(formOrig.elements[objNameOrig])){
			createFormObj(objNameOrig,objNameDesti,formOrig, formDesti);
		}
	}
	catch(err){}
	try{
		objNameOrig='idioma';
		objNameDesti='idioma';

		if(testFormObj(formOrig.elements[objNameOrig])){
			createFormObj(objNameOrig,objNameDesti,formOrig, formDesti);
		}
	}
	catch(err){}
	try{
		objNameOrig='localitat';
		objNameDesti='localitat';
		
		if(testFormObj(formOrig.elements[objNameOrig])){
			createFormObj(objNameOrig,objNameDesti,formOrig, formDesti);
		}
	}
	catch(err){}
	

	try{
		if (!window.focus)return true;
	}
	catch(e){}
	var href;
	

	wSusbscripcio=window.open('about:blank', windowname,'width=700,height=600,menubar=yes,scrollbars=yes,status=yes,resizable=yes');
	formDesti.target=windowname;
	formDesti.submit();
	

	try{
		wSusbscripcio.focus();
	}
	catch(e){}
	return false;
}
