var ampOBRIR = false;
var ampOBRIR2 = false;
var ampOBRIR3 = false;
var ampOBRIR4 = false;
var ampTEXT = "ampliacio";
var ampTEXT2 = "entrada";
var ampTEXT3 = "missatg";
var ampTEXT4 = "password";
var ruta = "";

function procescarregarFoto(ruta)
{
/*                var cadena = '<span><img src=\"' + ruta + 'imatges/waiting4.gif\"><img src=\"' + ruta + 'imatges/waitingCarregant.gif\"></span>';
$('#carregant').html(cadena);*/
                return;
}
		
function ampliacio_crearfinestra4() {
  // ventana
 // window.alert(ruta   +  "imatges/close.gif");

  var lb = document.getElementById(ampTEXT4);
  if (lb) return lb; 
  lb = document.createElement("div");
  lb.id = ampTEXT4;
  lb.style.position = "absolute";
  lb.style.display = "none";


  var close = document.createElement("img");
  close.id = "cerrar";
  close.src = ruta + "close.gif";
  close.src = "/close.gif";  
  close.alt = "Cerrar";
  close.onclick = ampliacio_tancar4;
  try {
    close.style.cursor = "pointer";
  } catch(e) {
    try {
      close.style.cursor = "hand";
    } catch(e) {
    }      
  }
  lb.appendChild(close);

  var title = document.createElement("h6");
  title.className = "linkaraLBtitle";
  lb.appendChild(title);


  var f = document.createElement("form");
  f.setAttribute('name','myForm');
  f.id =  "Form";
  f.setAttribute('id','Form');  
  f.setAttribute('action', ruta + 'recup.php');

//window.alert(ruta + 'login.php');
//  f.setAttribute('action','javascript:window.alert(link);');  
  f.setAttribute('target','_parent');
  f.setAttribute('method','post');
  f.setAttribute('enctype','multipart/form-data')

	/*
  var align =document.createElement("div");
  align.align('center');
  lb.appendChild(align);
  */
  
				
				
  var formText=document.createTextNode('email de registro: ');
 // -  next, create a text input where you'll enter your name
  var yourName=document.createElement('input');
  yourName.setAttribute('type','text');
  yourName.setAttribute('name','semail');
 yourName.setAttribute('id','semail');  
  yourName.setAttribute('value','');

  var linkactual=document.createElement('input');
  linkactual.setAttribute('type','hidden');
  linkactual.setAttribute('name','sLinkActual');
  linkactual.setAttribute('id','sLinkActual'); 
  linkactual.setAttribute('value',link);
  

  var b=document.createElement('input');
  b.setAttribute('type','submit');
  b.setAttribute('value','Entrar');


  f.appendChild(formText);

  f.appendChild(document.createElement('br'));
  f.appendChild(yourName);
  f.appendChild(document.createElement('br'));    
  f.appendChild(linkactual);  
  f.appendChild(document.createElement('br')); 
  f.appendChild(document.createElement('br'));   
  f.appendChild(b);

  lb.appendChild(f);

  
  document.body.appendChild(lb);

  document.body.bgcolor = "#ff0000";


  if (window.attachEvent && !window.opera) {
    var iframe = document.createElement("iframe");
    iframe.id = "ifrLB4";
    iframe.tabindex = -1;
    iframe.src = "javascript:false;";
    iframe.style.position = "absolute";

	

	
    iframe.style.display = "none";
	iframe.style.width = 800;
    lb.parentNode.appendChild(iframe);
  }

  return lb;
};



function ampliacio_crearfinestra() {
  // ventana
  var lb = document.getElementById(ampTEXT);
  if (lb) return lb; 
  lb = document.createElement("div");
  lb.id = ampTEXT;
  lb.style.position = "absolute";
  lb.style.display = "none";

  var close = document.createElement("img");
  close.id = "cerrar";
  close.src = ruta + "close.gif";
  close.src = "/close.gif";    
  close.alt = "Cerrar";
  close.title = "Cerrar";    
  close.onclick = ampliacio_tancar;
  try {
    close.style.cursor = "pointer";
  } catch(e) {
    try {
      close.style.cursor = "hand";
    } catch(e) {
    }      
  }
  lb.appendChild(close);

  var title = document.createElement("h6");
  title.className = "linkaraLBtitle";
  lb.appendChild(title);


  document.body.appendChild(lb);

  if (window.attachEvent && !window.opera) {
    var iframe = document.createElement("iframe");
    iframe.id = "ifrLB";
    iframe.tabindex = -1;
    iframe.src = "javascript:false;";
    iframe.style.position = "absolute";


    //iframe.style.top = iframe.style.left = "0";
    iframe.style.display = "none";
    lb.parentNode.appendChild(iframe);
  }
  return lb;
};

function ampliacio_crearfinestra2() {
  // ventana
 // window.alert(ruta   +  "imatges/close.gif");

  var lb = document.getElementById(ampTEXT2);
  if (lb) return lb; 
  lb = document.createElement("div");
  lb.id = ampTEXT2;
  lb.style.position = "absolute";
  lb.style.display = "none";

  var close = document.createElement("img");
  close.id = "cerrar";
  close.src = ruta + "close.gif";
  close.src = "/close.gif";    
  close.alt = "Cerrar";
  close.onclick = ampliacio_tancar2;
  try {
    close.style.cursor = "pointer";
  } catch(e) {
    try {
      close.style.cursor = "hand";
    } catch(e) {
    }      
  }
  lb.appendChild(close);

  var title = document.createElement("h6");
  title.className = "linkaraLBtitle";
  lb.appendChild(title);


  var f = document.createElement("form");
  f.setAttribute('name','myForm');
  f.id =  "Form";
  f.setAttribute('id','Form');  
  f.setAttribute('action', ruta + 'login.php');

//window.alert(ruta + 'login.php');
//  f.setAttribute('action','javascript:window.alert(link);');  
  f.setAttribute('target','_parent');
  f.setAttribute('method','post');
  f.setAttribute('enctype','multipart/form-data')

	/*
  var align =document.createElement("div");
  align.align('center');
  lb.appendChild(align);
  */
  
				
				
//  var formText=document.createTextNode('Nombre de usuario: ');
//  var formPassword=document.createTextNode('Contraseņa');  
 // -  next, create a text input where you'll enter your name
  var font1=document.createElement("font");
  font1.setAttribute("size","5");
  font1.setAttribute("face","Courier New");  
  font1.setAttribute("color","#666666");
  font1.appendChild(document.createTextNode('       Email '));

  var formPassword=document.createElement("font");
  formPassword.setAttribute("size","5");
  formPassword.setAttribute("face","Courier New");  
  formPassword.setAttribute("color","#666666");
  formPassword.appendChild(document.createTextNode('Contraseņa '));
/*
  var yourName=document.createElement('input');
  yourName.setAttribute('type','text');
  yourName.setAttribute('name','sAlies');
  yourName.setAttribute('id','sAlies');  
  yourName.setAttribute('value','33');
  //yourName.setAttribute('style','background-color:#f0f0f0');
*/
//yourName.setAttribute("style","color:#f0f0f0;size:25px;margin:4;width:200px;font-weight:bold;height:50px");
/*	var div1 = document.createElement('div');
	div1.setAttribute("style","width:110px;letter-spacing:-1px;font-size:25px;margin:4px;color:#E75A00;font-weight:bold;background-color:#f0f0f0;");
*/
  var yourName=document.createElement('input');
  yourName.setAttribute('type','text');
  yourName.setAttribute('name','sAlies');
  yourName.setAttribute('id','sAlies');  
  yourName.setAttribute('value','');
/*  yourName.bgcolor = 'ff0000';
  yourName.width = "300"; 
    yourName.height = "40"; 
	yourName.size='20';*/
  yourName.style.marginTop = "1px";
  yourName.style.height = "40px";
  yourName.style.width = "300px";
  yourName.style.background="#FFFFFF";
  yourName.style.color="#E75A00";
  //yourName.font-size="+3";  
  
  yourName.className = "selectores";
  //yourName.style.display = "none";	
	
//  div1.style.visibility = 'hidden';
/*  div1.style.color = '#f0f0f0';
  div1.appendChild(yourName);
*/
// var yourName=document.createElement("<input type='text' style='background-color:#FF0000'>");


  var password=document.createElement('input');
  password.setAttribute('type','password');
  password.setAttribute('name','sPassword');
  password.setAttribute('id','sPassword');  
  password.setAttribute('value','');
  password.style.marginTop = "1px";
  password.style.height = "40px";
  password.style.width = "200px";
  password.style.background="#FFFFFF";
  password.style.color="#E75A00";
  password.className = "selectores"; 
  
  var linkactual=document.createElement('input');
  linkactual.setAttribute('type','hidden');
  linkactual.setAttribute('name','sLinkActual');
  linkactual.setAttribute('id','sLinkActual'); 
  linkactual.setAttribute('value',link);
  

  var b=document.createElement('input');
  b.setAttribute('type','submit');
  b.setAttribute('value','Entrar');


  f.appendChild(document.createElement('br')); 
  f.appendChild(font1);
//  f.appendChild(document.createElement('br'));
//  f.appendChild(document.createElement('br'));
  f.appendChild(yourName);

  f.appendChild(document.createElement('br')); 
  f.appendChild(document.createElement('br'));  
  f.appendChild(formPassword);  
//  f.appendChild(document.createElement('br'));  
//    f.appendChild(document.createElement('br')); 
  f.appendChild(password);
  f.appendChild(linkactual);  
  f.appendChild(document.createElement('br')); 
  f.appendChild(document.createElement('br'));   
  f.appendChild(b);

  lb.appendChild(f);

  
  document.body.appendChild(lb);

  document.body.bgcolor = "#ff0000";
//  document.body.bgcolor = "#ff0000";  


  if (window.attachEvent && !window.opera) {
    var iframe = document.createElement("iframe");
    iframe.id = "ifrLB2";
    iframe.tabindex = -1;
    iframe.src = "javascript:false;";
    iframe.style.position = "absolute";

	

	
    iframe.style.display = "none";
	iframe.style.width = 800;
    lb.parentNode.appendChild(iframe);
  }
  return lb;
};


function ampliacio_crearfinestra3() {


  var lb = document.getElementById(ampTEXT3);
  if (lb) return lb; 
  lb = document.createElement("div");
  lb.id = ampTEXT3;
  lb.style.position = "absolute";
  lb.style.display = "none";

  var close = document.createElement("img");
  close.id = "cerrar";
  close.src = ruta + "close.gif";
  close.src = "/close.gif";    
  close.alt = "Cerrar";
  close.onclick = ampliacio_tancar3;
  try {
    close.style.cursor = "pointer";
  } catch(e) {
    try {
      close.style.cursor = "hand";
    } catch(e) {
    }      
  }
  lb.appendChild(close);

  var title = document.createElement("h6");
  title.className = "linkaraLBtitle";
  lb.appendChild(title);


  var f = document.createElement("form");
  f.setAttribute('name','myForm');
  f.id =  "Form";
  f.setAttribute('id','Form');  
  f.setAttribute('action', ruta + 'grabMissatge2.php');

  f.setAttribute('target','_parent');
  f.setAttribute('method','post');
  f.setAttribute('enctype','multipart/form-data')


  
				
				
  var formText=document.createTextNode('Que le quieres contar? ');
  var yourName=document.createElement('input');
  yourName.setAttribute('type','text');
  yourName.setAttribute('name','texte');
 yourName.setAttribute('id','texte');  
 yourName.setAttribute('size','50');   

  

  var linkreloadform=document.createElement('input');
  linkreloadform.setAttribute('type','hidden');
  linkreloadform.setAttribute('name','linkreload');
 linkreloadform.setAttribute('id','linkreload');  
 linkreloadform.setAttribute('size','50');   
  linkreloadform.setAttribute('value',linkreload);

  var linkactual=document.createElement('input');
  linkactual.setAttribute('type','hidden');
  linkactual.setAttribute('name','sLinkActual');
  linkactual.setAttribute('id','sLinkActual'); 
  linkactual.setAttribute('value',link);


  
  var usuari2=document.createElement('input');
  usuari2.setAttribute('type','hidden');
  usuari2.setAttribute('name','Usuari2');
  usuari2.setAttribute('id','Usuari2'); 
  usuari2.setAttribute('value',usuaridesti);

  var b=document.createElement('input');
  b.setAttribute('type','submit');
  b.setAttribute('value','Enviar mensage');


  f.appendChild(formText);

  f.appendChild(document.createElement('br'));
  f.appendChild(yourName);
    f.appendChild(linkreloadform);	

 f.appendChild(linkactual);

  f.appendChild(usuari2);  
  f.appendChild(document.createElement('br')); 
  f.appendChild(document.createElement('br'));   
  f.appendChild(b);

  lb.appendChild(f);

  
  document.body.appendChild(lb);

  document.body.bgcolor = "#ff0000";


  if (window.attachEvent && !window.opera) {
    var iframe = document.createElement("iframe");
    iframe.id = "ifrLB3";
    iframe.tabindex = -1;
    iframe.src = "javascript:false;";
    iframe.style.position = "absolute";

	

	
    iframe.style.display = "none";
	iframe.style.width = 800;
    lb.parentNode.appendChild(iframe);
  }

  return lb;
};




function ampliacio_obrir(link,rutatmp) {
  if (ampOBRIR) {
    ampliacio_tancar();
  };
  ruta = rutatmp;
  var lb = document.getElementById(ampTEXT) || ampliacio_crearfinestra();
  var title = lb.getElementsByTagName("H6")[0];
  title.innerHTML = link.title;
  var img = new Image();
  img.id = "fotolev";
  img.alt = link.title;
  img.style.visibility = "hidden";
  lb.appendChild(img);
  img.onload = ampliacio_carregar; 
  img.src = link.href;
  ampOBRIR = true;
  return false;
};


function ampliacio_obrir2(link,rutatmp,titol) {
  if (ampOBRIR2) {
    ampliacio_tancar2();
  };
ruta = rutatmp;
  var lb = document.getElementById(ampTEXT2) || ampliacio_crearfinestra2();

  var title = lb.getElementsByTagName("H6")[0];
  title.innerHTML = link.title;
  title.innerHTML = titol;
  var img = new Image();
  img.id = "fotolev";
  img.alt = link.title;
  img.style.visibility = "hidden";
  lb.appendChild(img);
  img.onload = ampliacio_carregar2; 
  
  if (BrowserDetect.browser == "Firefox")
  {

	img.src = rutatmp + "khacesfirefox.gif";	
  }
  else
  {

	img.src = rutatmp + "khaces_entrada2.gif";		  
  }

  ampOBRIR2 = true;
lb.top = 10;

  return false;
};


var usuaridesti='';
var linkreload='';

function ampliacio_obrir3(link,rutatmp,titol,usuaridestid,linkreloadd) {
	usuaridesti = usuaridestid;
	linkreload = linkreloadd;
  if (ampOBRIR3) {
    ampliacio_tancar3();
  };
ruta = rutatmp;
  var lb = document.getElementById(ampTEXT3) || ampliacio_crearfinestra3();

  var title = lb.getElementsByTagName("H6")[0];
  title.innerHTML = link.title;
  title.innerHTML = titol;
  var img = new Image();
  img.id = "fotolev";
  img.alt = link.title;
  img.style.visibility = "hidden";
  lb.appendChild(img);
  img.onload = ampliacio_carregar3; 
  
  if (BrowserDetect.browser == "Firefox")
  {

	img.src = rutatmp + "missatgefirefox.gif";	
  }
  else
  {

	img.src = rutatmp + "missatgeexplorer.gif";		  
  }

  ampOBRIR3 = true;


  return false;
};

function ampliacio_obrir4(link,rutatmp,titol,usuaridestid,linkreloadd) {
	usuaridesti = usuaridestid;
	linkreload = linkreloadd;
  if (ampOBRIR4) {
    ampliacio_tancar4();
  };
ruta = rutatmp;
  var lb = document.getElementById(ampTEXT4) || ampliacio_crearfinestra4();

  var title = lb.getElementsByTagName("H6")[0];
  title.innerHTML = link.title;
  title.innerHTML = titol;
  var img = new Image();
  img.id = "fotolev";
  img.alt = link.title;
  img.style.visibility = "hidden";
  lb.appendChild(img);
  img.onload = ampliacio_carregar4; 
  
  if (BrowserDetect.browser == "Firefox")
  {

	img.src = rutatmp + "missatgefirefox.gif";	
  }
  else
  {

	img.src = rutatmp + "missatgeexplorer.gif";		  
  }

  ampOBRIR4 = true;


  return false;
};


function a()
{
document.bgcolor = '#ff0000';
}


function ampliacio_carregar() {
    var vsize = getViewportSize();
    var osize = this.height;
    var lb = document.getElementById(ampTEXT);
    if (this.height + 60 > vsize[1]) {
      var nsize = this.height = vsize[1] - 80;
      var prop = nsize / osize;
      this.width = this.width * prop;
    }
    
    var iframe = document.getElementById("ifrLB");
     
    lb.style.width = this.width + 40 + "px";
    lb.style.height = this.height + 60 + "px";
    lb.style.zIndex = "10000";
    
    
    lb.style.display = '';
    lb.style.top = vsize[1] / 2 - parseInt(parseInt(lb.style.height, 10) / 2, 10) + getScrollingPosition()[1] + "px";
    lb.style.left = vsize[0] / 2 - parseInt(parseInt(lb.style.width, 10) / 2, 10) + "px";
    
    if (iframe) {
      iframe.style.width = parseInt(lb.style.width, 10) - 2 + "px";
      iframe.style.height = parseInt(lb.style.height, 10) - 2 + "px";
      iframe.style.zIndex = "9999";
      iframe.style.top = lb.style.top; 
      iframe.style.left = lb.style.left; 
      iframe.style.display = "block";
    }

   
    this.style.visibility = "visible";
	
/* $('#carregant').html('<span>' + '<img src=\"' +  ruta + 'imatges/waiting0.gif\"><img src=\"' + ruta + 'imatges/waiting0.gif\">' + '</span>');  	 */
}

function ampliacio_carregar2() {
    var vsize = getViewportSize();
    var osize = this.height;
    var lb = document.getElementById(ampTEXT2);
    if (this.height + 60 > vsize[1]) {
      var nsize = this.height = vsize[1] - 80;
      var prop = nsize / osize;
      this.width = this.width * prop;
    }
    
    var iframe = document.getElementById("ifrLB2");
     
    lb.style.width = this.width + 40 + "px";
    lb.style.width = this.width + 400 + "px";	
    lb.style.height = this.height + 60 + "px";
    lb.style.zIndex = "10000";
    
    
    lb.style.display = '';
    lb.style.top = vsize[1] / 2 - parseInt(parseInt(lb.style.height, 10) / 2, 10) + getScrollingPosition()[1] + "px";
    lb.style.left = vsize[0] / 2 - parseInt(parseInt(lb.style.width, 10) / 2, 10) + "px";
    
    if (iframe) {
      iframe.style.width = parseInt(lb.style.width, 10) - 2 + "px";
      iframe.style.height = parseInt(lb.style.height, 10) - 2 + "px";
      iframe.style.zIndex = "9999";
      iframe.style.top = lb.style.top; 
      iframe.style.left = lb.style.left; 
      iframe.style.display = "block";
    }
   
    this.style.visibility = "visible";
}


function ampliacio_carregar3() {
    var vsize = getViewportSize();
    var osize = this.height;
    var lb = document.getElementById(ampTEXT3);
    if (this.height + 60 > vsize[1]) {
      var nsize = this.height = vsize[1] - 80;
      var prop = nsize / osize;
      this.width = this.width * prop;
    }
    
    var iframe = document.getElementById("ifrLB3");
     
    lb.style.width = this.width + 40 + "px";
    lb.style.height = this.height + 60 + "px";
    lb.style.zIndex = "10000";
    
    
    lb.style.display = '';
    lb.style.top = vsize[1] / 2 - parseInt(parseInt(lb.style.height, 10) / 2, 10) + getScrollingPosition()[1] + "px";
    lb.style.left = vsize[0] / 2 - parseInt(parseInt(lb.style.width, 10) / 2, 10) + "px";
    
    if (iframe) {
      iframe.style.width = parseInt(lb.style.width, 10) - 2 + "px";
      iframe.style.height = parseInt(lb.style.height, 10) - 2 + "px";
      iframe.style.zIndex = "9999";
      iframe.style.top = lb.style.top; 
      iframe.style.left = lb.style.left; 
      iframe.style.display = "block";
    }
   
    this.style.visibility = "visible";
}

function ampliacio_carregar4() {
    var vsize = getViewportSize();
    var osize = this.height;
    var lb = document.getElementById(ampTEXT4);
    if (this.height + 60 > vsize[1]) {
      var nsize = this.height = vsize[1] - 80;
      var prop = nsize / osize;
      this.width = this.width * prop;
    }
    
    var iframe = document.getElementById("ifrLB4");
     
    lb.style.width = this.width + 40 + "px";
    lb.style.height = this.height + 60 + "px";
    lb.style.zIndex = "10000";
    
    
    lb.style.display = '';
    lb.style.top = vsize[1] / 2 - parseInt(parseInt(lb.style.height, 10) / 2, 10) + getScrollingPosition()[1] + "px";
    lb.style.left = vsize[0] / 2 - parseInt(parseInt(lb.style.width, 10) / 2, 10) + "px";
    
    if (iframe) {
      iframe.style.width = parseInt(lb.style.width, 10) - 2 + "px";
      iframe.style.height = parseInt(lb.style.height, 10) - 2 + "px";
      iframe.style.zIndex = "9999";
      iframe.style.top = lb.style.top; 
      iframe.style.left = lb.style.left; 
      iframe.style.display = "block";
    }
   
    this.style.visibility = "visible";
}


function ampliacio_tancar() {
  var lb = document.getElementById(ampTEXT);
  var iframe = document.getElementById("ifrLB");
  if (iframe) {
    iframe.style.display = 'none'; 
  }
  lb.style.display = "none";
  lb.removeChild(lb.getElementsByTagName("img")[1]);
  ampOBRIR = false;
}

function ampliacio_tancar2() {
  var lb = document.getElementById(ampTEXT2);
  var iframe = document.getElementById("ifrLB2");
  if (iframe) {
    iframe.style.display = 'none'; 
  }
  lb.style.display = "none";

  lb.removeChild(lb.getElementsByTagName("img")[1]);

  ampOBRIR2 = false;
}

function ampliacio_tancar3() {
  var lb = document.getElementById(ampTEXT3);
  var iframe = document.getElementById("ifrLB3");
  if (iframe) {
    iframe.style.display = 'none'; 
  }
  lb.style.display = "none";

  lb.removeChild(lb.getElementsByTagName("img")[1]);

  ampOBRIR3 = false;
}


function ampliacio_tancar4() {
  var lb = document.getElementById(ampTEXT4);
  var iframe = document.getElementById("ifrLB4");
  if (iframe) {
    iframe.style.display = 'none'; 
  }
  lb.style.display = "none";

  lb.removeChild(lb.getElementsByTagName("img")[1]);

  ampOBRIR4 = false;
}


function getViewportSize() {
  var size = [0, 0];
  if (typeof window.innerWidth != "undefined") {
    size = [ window.innerWidth, window.innerHeight];
  } else if (typeof document.documentElement != "undefined"
    && typeof document.documentElement.clientWidth != "undefined"
    && document.documentElement.clientWidth != 0) {
    size = [document.documentElement.clientWidth, document.documentElement.clientHeight];
  } else {
    size = [document.getElementsByTagName("body")[0].clientWidth, document.getElementsByTagName("body")[0].clientHeight];
  }
  return size;
}

function getScrollingPosition() {
  var pos = [0, 0];
  if (typeof window.pageXOffset != "undefined") {
    pos = [window.pageXOffset, window.pageYOffset];
  } else if (typeof document.documentElement.scrollTop != "undefined"
    && document.documentElement.scrollTop > 0){
    pos = [document.documentElement.scrollLeft, document.documentElement.scrollTop];
  } else if (typeof document.body.scrollTop != "undefined") {
    pos = [document.body.scrollLeft, document.body.scrollTop];
  }
  return pos;
}
