
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) {
	document.write("<iframe class='rounded' name='"+id+"' id='"+id+"' style='position: absolute; top:"+top+"px; left:"+left+"px;' width='"+(width)+"px' height='"+(height)+"px' src='"+href+"' frameborder='0' scrolling='"+scroll+"' allowtransparency='true'></iframe>");
}


function roundedTabs(id,top,left,width,height) {
	
	var containerTop = 24;
	if (document.all) containerTop += 1;
	document.write('<div id="'+id+'" style="position:absolute;top:'+(top+containerTop)+'px; left:'+left+'px; height:'+(height-containerTop)+'px;width:'+(width-2)+'px"></div>');

	document.write('<div id="'+id+'_rounded" style="position:absolute;top:'+top+'px; left:'+left+'px; height:'+height+'px; width:'+(width)+'px">');

	document.write('<div id="tabber" class="tabber" style="position:relative;top:'+0+'px; left:'+0+'px; width:'+(width)+'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:1px; left:1px;" width="'+(width-12)+'px" height="'+(height-26)+'px" src="'+aTabs[i].src+'" frameborder="0" scrolling="no" allowtransparency="true"></iframe>');
	
		document.write('</div>');
	}
	document.write('</div>');
	document.write('</div>');


	tabber = tabberAutomatic(tabberOptions);	
	

}

function roundedDiv(id,top,left,width,height,html) {
	
	document.write("<div id='"+id+"' name='"+id+"' style='border:position: relative; top: 5px; left: 0px; width: "+(width)+"px; height:"+(height)+"px; padding:0;'></div>");
	
	document.getElementById(id).innerHTML = html;
	
}		

function resizerounded(id,top,left,height,width) {

	document.getElementById(id).width = width+"px";
	document.getElementById(id).height = height+"px";
	document.getElementById(id).style.left = left+"px";
	document.getElementById(id).style.top = top+"px";
	
	document.getElementById(id).style.width = width+"px";
	document.getElementById(id).style.height = height+"px";
	
}	



function resizetabs(id,top,left,height,width) {
	
	document.getElementById(id).style.width = (width-5)+"px";
	document.getElementById(id).style.height = (height-21)+"px";
	document.getElementById(id).style.left = left+"px";
	document.getElementById(id).style.top = (top+20)+"px";
	
	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-3)+"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-35)+"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-5)+"px";
	
	document.getElementById("tabber").style.width = (width-3)+"px";
	
	for (i=0;i<aTabs.length;i++) {
		document.getElementById(aTabs[i].id).width = (width-25)+"px";
		document.getElementById(aTabs[i].id).height = (height-35)+"px";
	}
	
	
}			

function ortotopoTool(id,top,left,width,height,topPadding,leftPadding) {	
	
	
	document.write("<div name='"+id+"' id='"+id+"' style='display:none;z-index:100;position:absolute;width:"+width+"px;height:"+height+"px;top:"+(top+topPadding)+"px;left:"+(left+leftPadding)+"px;'>");
	document.write("<table><tr>");
	for (i = 0; i < backgrounds.length; i++) {
		document.write("<td id='"+backgrounds[i].name+"' class='ortotopo' onclick='changeBackground(\""+backgrounds[i].name+"\");ortotopoToolActivate(\""+backgrounds[i].name+"\");'>"+backgrounds[i].title+"</a></td>");
		document.write("<td></a></td>");
	}
	document.write("</tr></table>");
	document.write("</div>");
	
		
	ortotopoToolActivate(id);
}

function ortotopoToolActivate(id) {
	var map = getMapObject();
	
	if (map) {
		document.getElementById(id).style.display = "";
		for (i = 0; i < backgrounds.length; i++) {
			if (map.getvisible(backgrounds[i].server, backgrounds[i].name)) {
				document.getElementById(backgrounds[i].name).style.borderStyle = "inset";
				document.getElementById(backgrounds[i].name).style.fontWeight = "bold";
			}
			else {
				document.getElementById(backgrounds[i].name).style.borderStyle = "outset";
				document.getElementById(backgrounds[i].name).style.fontWeight = "normal";
			}
		}
	}
	else
		setTimeout("ortotopoToolActivate('"+id+"');",500);
}

function ortotopoToolPosition(id,top,left,topPadding,leftPadding) {
	
	var ortoTopo = document.getElementById(id);
	
	ortoTopo.style.top = (top+topPadding)+"px";
	ortoTopo.style.left = (left+leftPadding)+"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 += "<div id=\"franja_superior\"><span id=\"data\">";
	headerHTML += "<div id=\"title\">Mapa i planejament urbanístic de Ripoll</div>";
	headerHTML += "<div id=\"title2\">Mapa i planejament urbanístic de Ripoll</div>";
	headerHTML += "<div id=\"escut\"><img src=\"planejament/img/banner.gif\"></img></div></div>";
	headerHTML += "<div id=\"menu_superior\">";
	headerHTML += 			"<ul>";
	headerHTML += 				"<li><a href=\"http://www.geodata.es\" target='_blank'>www.geodata.es</a></li>";
	headerHTML += 			"</ul>";
	headerHTML += 		"</div>";
	
	return headerHTML;
	
}


			

