
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('<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:"+10+"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('<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: 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>");
//	document.write('</div>');


//	rounded.render(id+"_rounded");
	
}
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 squaredDiv(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: absolute; top: "+top+"px; left: "+left+"px; width: "+(width)+"px; height:"+(height)+"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 resizesquared(id,top,left,height,width) {
    if(width)
	document.getElementById(id).style.width = width+"px";
	if(height)
    document.getElementById(id).style.height = height+"px";
	if(left)
    document.getElementById(id).style.left = left+"px";
	if(top)
    document.getElementById(id).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 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,wTable) {
	
	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='"+wTable+"' align='center' border='0'>";
	headerHTML += "<tr border='0'>";
	headerHTML += "<td class='cellbg'><a href='http://"+logoHref+"' target='_blank'><img border='0' src='"+logoSrc+"' alt='"+logoAlt+"'/></a></td>";
	headerHTML += "<td class='cellbg'>&nbsp;</td>";
    headerHTML += "<td class='cellbg' valign='bottom' align='right'><h2>Guia Urbana</h2></td>";
    headerHTML += "<td class='cellbg' valign='bottom' width='100px' align='center'><a alt='AOC' href='http://www.aoc.cat/index.php/ezwebin_site/INICI' target='_blank'><img border='0' src='img/banner/aoc.jpg' /></a></td>";
	headerHTML += "</tr>";
	headerHTML += "</table>";
    

    /*headerHTML += "<table id='headerTable' style='top:"+tHeader+"px; height:"+hHeader+"px; width:100%; background-color: #fcfdfd; background-repeat:no-repeat;' cellspacing='0' cellpadding='0' align='center' border='0'>";
    headerHTML += "<tr valign='middle'>";
    headerHTML += "<td align='center' valign='middle'><img border='0' src='img/banner/banner_guia.gif' alt='banner' /></td>";
    headerHTML += "<td width='5%'>&nbsp;</td>";
	headerHTML += "</tr>";
    headerHTML += "</table>";*/


	return headerHTML;
	
}


			

