
function windowsize() {

	// Calculate sizes (cross-browser) ---------------------------------
	if( typeof( window.innerWidth ) == 'number' ) {
	  wWindow = window.innerWidth;
	  hWindow = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	  wWindow = document.documentElement.clientWidth;
	  hWindow = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	  wWindow = document.body.clientWidth;
	  hWindow = document.body.clientHeight;
	}		
	
	if (wWindow > maxWidth) wWindow = maxWidth;
	if (wWindow < minWidth) wWindow = minWidth;
	if (hWindow > maxHeight) hWindow = maxHeight;
	if (hWindow < minHeight) hWindow = minHeight;
	
}


function roundedFrame(id,top,left,width,height,href,scroll,top2) {
	if (top2 == undefined) top2=10;
	document.write('<div id="'+id+'_rounded" style="top:'+top+'px; left:'+left+'px; height:'+height+'px; width:'+width+'px">');
	document.write("<iframe name='"+id+"' id='"+id+"' style='position: relative; top:"+top2+"px; left:"+10+"px; border: 0px solid #RGB(230,242,243)' width='"+(width-25)+"px' height='"+(height-30)+"px' src='"+href+"' frameborder='0' scrolling='"+scroll+"' allowtransparency='true'></iframe>");
	document.write('</div>');
	rounded.render(id+"_rounded");
}


function squaredFrame(id,top,left,width,height,href,scroll) {
	document.write("<iframe name='"+id+"' id='"+id+"' style='position: absolute; top:"+ top +"px; left:"+left+"px; border: 1px solid #RGB(230,242,243)' width='"+(width)+"px' height='"+(height)+"px' src='"+href+"' frameborder='0' scrolling='"+scroll+"' allowtransparency='true'></iframe>");
}


function roundedTabs(id,top,left,width,height) {
	
	document.write('<div id="'+id+'_rounded" style="top:'+top+'px; left:'+left+'px; height:'+height+'px; width:'+width+'px">');
	document.write('<div id="tabber" class="tabber" style="position:relative;top:10px; left:3px; width:'+(width-7)+'px">');
	
	for (i=0;i<aTabs.length;i++) {
		document.write('<div id="tabbertab_'+i+'" class="tabbertab">');
		document.write('<h2>'+aTabs[i].text+'</h2>');
		document.write('<iframe name="'+aTabs[i].id+'" id="'+aTabs[i].id+'" style="position: relative; top:10px; left:10px; border: 0px solid #RGB(230,242,243);" width="'+(width-25)+'px" height="'+(height-70)+'px" src="'+aTabs[i].src+'" frameborder="0" scrolling="auto" allowtransparency="true"></iframe>');
		document.write('</div>');	
	}
	
	document.write('</div>');
	
	tabber = tabberAutomatic(tabberOptions);	
	
	rounded.render(id+"_rounded");

}


function roundedDiv(id,top,left,width,height,html) {
	
	document.write('<div id="'+id+'_rounded" style="top:'+top+'px; left:'+left+'px; height:'+height+'px; width:'+width+'px">');
	document.write("<div id='"+id+"' name='"+id+"' style='border:0px solid red;position: relative; top: 5px; left: 0px; width: "+(width)+"px; height:"+(height-30)+"px; padding:0;'></div>");
	document.write('</div>');
	rounded.render(id+"_rounded");
	document.getElementById(id).innerHTML = html;
	document.getElementById(id+"Table").style.height = (height-30)+"px"
}		


function resizerounded(id,top,left,height,width) {

	document.getElementById(id+"_rounded").style.width = width+"px";
	document.getElementById(id+"_rounded").style.height = height+"px";
	document.getElementById(id+"_rounded").style.left = left+"px";
	document.getElementById(id+"_rounded").style.top = top+"px";
	
	document.getElementById(id).style.height = (height-30)+"px";
	document.getElementById(id).style.width = (width-25)+"px";
}	


function resizetabs(id,top,left,height,width) {
	if(document.all)
		resizetabsIE(id,top, left, height, width);
	else
		resizetabsFF(id,top, left, height, width);
}		


function resizetabsIE(id,top, left, height, width) {

	document.getElementById(id+"_rounded").style.width = width+"px";
	document.getElementById(id+"_rounded").style.height = height+"px";
	document.getElementById(id+"_rounded").style.left = left+"px";
	document.getElementById(id+"_rounded").style.top = top+"px";
	document.getElementById("tabber").style.width = (width-7)+"px";
	
	for (i=0;i<aTabs.length;i++) {
		document.getElementById(aTabs[i].id).style.width = (width-25)+"px";
		document.getElementById(aTabs[i].id).style.height = (height-70)+"px";
	}
	
}			


function resizetabsFF(id,top, left, height, width) {

  var tabs_div = document.getElementById(id+"_rounded");

	document.getElementById(id+"_rounded").style.width = width+"px";
	document.getElementById(id+"_rounded").style.height = height+"px";
	document.getElementById(id+"_rounded").style.left = left+"px";
	document.getElementById(id+"_rounded").style.top = top+"px";
	document.getElementById("tabber").style.width = (width-7)+"px";
	
	for (i=0;i<aTabs.length;i++) {
		document.getElementById(aTabs[i].id).width = (width-25)+"px";
		document.getElementById(aTabs[i].id).height = (height-70)+"px";
	}
	
}		


function createDivLegend(id,top,left,width,height){

  document.write("<div name='"+id+"' id='"+id+"' style='z-index:999;position:absolute;width:"+width+"px;height:"+height+"px;top:"+top+"px;left:"+left+"px;'>");
	document.write("<table width='100%' align='left'>");
	document.write("<tr><td class='field_3' style='padding: 0px 5px 0px 90px'><img src='img/db2p_red_circle.jpg'> Recol·lecci&oacute; de 1970 o posterior</td>");
	document.write("		<td class='field_3'><img src='img/db2p_red_triangle.jpg'> Registre bibliogr&agrave;fic de 1970 o posterior</td></tr>");
	document.write("<tr><td class='field_3' style='padding: 0px 5px 0px 90px'><img src='img/db2p_orange_circle.jpg'> Recol·lecci&oacute; anterior a 1970</td>");
	document.write("		<td class='field_3'><img src='img/db2p_orange_triangle.jpg'> Registre bibliogr&agrave;fic anterior a 1970</td></tr>");
	//document.write("<tr><td class='field_3' style='padding: 0px 5px 0px 90px'>Els s&iacute;mbols es mostren al centre del seu quadrat UTM</td></tr>");
	document.write("</div>");				
	
}


function createDivEspecie(id,top,left,width,height){

  document.write("<div class='status_2' name='"+id+"' id='"+id+"' style='z-index:998;position:absolute;width:"+width+"px;height:"+height+"px;top:"+top+"px;left:"+left+"px;'>");
  document.write("");
	document.write("</div>");				
	
}


function reloadPosition(id,top,left,width,height) {
	
	var legend = document.getElementById(id);
	legend.style.top = top+"px";
	legend.style.left = left+"px";
	legend.style.width = width+"px";
	legend.style.height = height+"px";		
	
}


function createHeader(titleHeaderDiv,logoHref,logoSrc,logoAlt,hLogo,hHeader,tHeader) {
	
	var headerHTML = "";
	
	var title = "";
	if (document.getElementById(titleHeaderDiv)) {
		title = document.getElementById(titleHeaderDiv).innerHTML;
		document.getElementById(titleHeaderDiv).style.display = "none";
		if (document.getElementById(titleHeaderDiv+"Delete")) {
			document.getElementById(titleHeaderDiv+"Delete").style.display = "none";
		}
	}
	
	headerHTML += "<table id='headerTable' style='top:"+(tHeader)+"px' cellpadding='0' cellspacing='0' width='100%' height='"+hHeader+"px' align='center' border='0'>";
	headerHTML += "<tr valign='center'>";
	headerHTML += "<td width='2%'>&nbsp;</td>";
	headerHTML += "<td align='left'><a href='http://"+logoHref+"' target='_blank'><img height='"+hLogo+"px' border='0' src='http://"+logoSrc+"' alt='"+logoAlt+"' /></a></td>";
	headerHTML += "<td align='center' valign='center'><div class='titol'>"+title+"</div></td>";
	
	headerHTML += "<td align='right'><a href='http://pagines.uab.cat/briologia' target='_blank'><sub><img height='"+hLogo+"px' border='0' src='img/logo_lab.jpg' alt='http://pagines.uab.cat/briologia' /></sub></a></td>";
	headerHTML += "<td width='1%'>&nbsp;</td>";
	headerHTML += "<td align='right'><a href='http://www.jb.ul.pt' target='_blank'><sub><img height='42px' border='0' src='img/logo_jb.jpg' alt='http://www.jb.ul.pt' /></sub></a></td>";
	headerHTML += "<td width='1%'>&nbsp;</td>";
	headerHTML += "</tr>";
	headerHTML += "</table>";
	
	return headerHTML;
	
}
			
