/*
	Usage:
		<div id="MapID"></div>
		<script type="text/javascript">
			buildMap(x, y, width, height, MapID, url)
		</script>
*/

function buildMap(x, y, width, height, id, href){
	var left = 0;
	var top = 0;
	var div = document.getElementById(id);
	// Convert the width and height to string so substring() can work
	width += '';
	height += '';
		
	// Set the default size types
	width_type = 'px';
	height_type = 'px';
		
	// Remove and % or px from the width and parse the string as an integer
	if(width.substring(width.length-2) == 'px'){
		width = parseInt(width.substring(0,width.length-2))
		width_parsed = true;
	}else if(width.substring(width.length-1) == '%'){
		width_type = '%';
		width = parseInt(width.substring(0,width.length-1))
	}
		
	// Remove and % or px from the height and parse the string as an integer
	if(height.substring(height.length-2) == 'px'){
		height = parseInt(height.substring(0,height.length-2))
		width_parsed = true;
	}else if(height.substring(height.length-1) == '%'){
		height_type = '%';
		height = parseInt(height.substring(0,height.length-1))
	}
		
	// Set position from the left side of the document
	if(x == "center"){
		left = ($(document).width()/2) - (width/2);
	}else{
		left = x;
	}
		
	// Set the position from the top side of the document
	if(y == "center"){
		top = ($(document).height()/2) - (height/2);
	}else{
		top = y;
	}
		
	// Apply the styling to the div element
	$(div).css('position', 'absolute');
	$(div).css('left', left);
	$(div).css('top', top);
	$(div).css('width', width+width_type);
	$(div).css('height', height+height_type);
	$(div).html('<a style="display:block;width:'+width+width_type+';height:'+height+height_type+';" href="'+href+'"></a>')
}

