    /* Consultes lingüístiques i terminològiques */
    /* Funcions de javascript */
    /* Última actualització: Agost de 2007*/


var newWindow = null;
var widthHeight = null;

function openWindow(contentURL,windowName,windowWidth,windowHeight) {
	widthHeight = 'height=' + windowHeight + ',width=' + windowWidth;
	newWindow = window.open(contentURL,windowName,widthHeight);
	newWindow.focus()
}


function closeWindow() {
	if (newWindow != null)  {
	 newWindow.close();
	 newWindow = null;
	}
}

function toggleWindow(contentURL,windowName,windowWidth,windowHeight) {
	if (newWindow == null) {
		widthHeight = 'height=' + windowHeight + ',width=' + windowWidth;
		newWindow = window.open(contentURL,windowName,widthHeight);
		newWindow.focus()
	}
	else {
	 	newWindow.close();
	 	newWindow = null;
	}
}

function openAdjunt(contentURL,windowName,windowWidth,windowHeight) {		
        widthHeight = 'height=' + windowHeight + ',width=' + windowWidth + ',scrollbars=yes' + ',statusbar=no';
		newWindow = window.open(contentURL,windowName,widthHeight);
		newWindow.focus();
}

function expand (postid) { 
		whichpost = document.getElementById(postid);
		whichpost.className="shown"; 
}

function collapse (postid) { 
		whichpost = document.getElementById(postid);
		whichpost.className="hidden"; 
}

function expandcollapse (postid) { 

   whichpost = document.getElementById(postid);
   
   if (whichpost.className=="shown") { 
      whichpost.className="hidden"; 
   } 
   else { 
      whichpost.className="shown"; 
   } 
}

function confirma (URI) {
	var name=confirm("Segur que voleu esborrar aquest registre?")
	if (name==true) {
		location.href = URI
	}
}

function go()
{
	box = document.forms[0].navi;
	destination = box.options[box.selectedIndex].value;
	if (destination) location.href = destination;
}

function respostesTerm(url, param1, param2){

        if (param1) {
		document.graella.resp_edita.value= param1;
	}
	if (param2) {
		document.graella.action = 'http://www2.ub.edu/assessling/cgi/consultes/editaGraella.pl?consultes_id=';
		document.graella.action += document.graella.consultes_id.value;
		document.graella.action += '&respostes_id=' + param2;
		document.graella.action += '&respostes_accio=Esborra';
	}
        document.graella.submit ();

}

function displayHTML(ident) {
  var inf = document.getElementById(ident).value;
  win = window.open('', 'popup', 'height=600,width=500,toolbar=no,status=no,resizable=no,menubar=no,location=no,scrollbars=yes');
  win.document.write(inf);
  win.document.close();
}

function printHTML(ident) {
  var inf = document.getElementById(ident).value;
  win = window.open('', 'popup', 'height=600,width=500,toolbar=no,status=no,resizable=no,menubar=no,location=no,scrollbars=yes');
  win.document.write(inf);
  win.print();
  win.document.close();
  win.close();
}

function uncheckTanca() {
	if (document.getElementById("consultes_estat").checked==false) {
		document.getElementById("consultes_correuEnviat").checked=false;
		document.getElementById("destacades").selectedIndex=0;
	}
}

function llistaUnchecked() {
	if (document.getElementById("destacades").selectedIndex!=0 && document.getElementById("consultes_esPublic").checked==false) {
		document.getElementById("destacades").selectedIndex=0;
	}
}

function uncheckLlista() {
	if (document.getElementById("consultes_esPublic").checked==false) {
		document.getElementById("destacades").selectedIndex=0;
	}
}

function insertReferencies() {

	var inputTag = document.getElementsByTagName("input");
	var cadenaHTML= '';

	for (i=0; i<inputTag.length; i++) {
		if (inputTag[i].checked && inputTag[i].checked == true) {
			var aux = document.getElementById(inputTag[i].name);
			cadenaHTML += "<p>" + aux.innerHTML + "</p>";
		}
	}
	
	if (window.opener) {
		window.opener.tinyMCE.execInstanceCommand("bibliografia","mceInsertContent", false, cadenaHTML);
	}

	window.close();
}

function ismaxlength(obj){
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}

