function MapItem(name, x1, y1, x2, y2, source)
{
this.name=name;
this.x1=x1;
this.x2=x2;
this.y1=y1;
this.y2=y2;
this.source=source;
}
function CalculateResizeFactor(BaseMapWidth, BaseMapHeight)
{
var winWidth = window.innerWidth;
var colWidth = winWidth * .6666666; // Using Bootstrap col-md-8 and col-md-4
var a=colWidth-BaseMapWidth-2;
var winHeight = window.innerHeight;
var b=winHeight-BaseMapHeight-2;
var resizeFactor=1;
if ( !( a>0 && b>0))
{
if (b>=a)
{
resizeFactor= (colWidth-2)/BaseMapWidth;
}
else
{
resizeFactor= (winHeight-2)/BaseMapHeight;
}
}
return resizeFactor;
}
function reSizeMap(BaseMapImage, BaseMapArray){
var resize_factor=CalculateResizeFactor(BaseMapImage.width, BaseMapImage.height);
//First Generate Image code
var MapImage= jQuery.extend(true, {}, BaseMapImage);
MapImage.width=MapImage.width*resize_factor;
MapImage.height=MapImage.height*resize_factor;
var MapImage_html="";
document.getElementById("map_image").innerHTML=MapImage_html;
//Second Generate Map Item Code
var MapArray=$.extend(true, [], BaseMapArray);
var i;
for (i = 0; i < MapArray.length; i++) {
MapArray[i].x1 *= resize_factor;
MapArray[i].y1 *= resize_factor;
MapArray[i].x2 *= resize_factor;
MapArray[i].y2 *= resize_factor;
}
// Generated by mapper
var MapItems_html="";
document.getElementById("map_items").innerHTML=MapItems_html;
}