function ReDrawImage(ImgD,w,h)
{
	var image=new Image();
	image.src=ImgD.src;
	if(image.width>0 && image.height>0)
	{
		//width > height
		if(image.width/image.height>= w/h) 
		{
			if(image.width>w)
			{
				ImgD.width=w;
				ImgD.height=(image.height*w)/image.width;
			}
			else
			{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
			ImgD.style.display="block";
		}
		else
		{
			if(image.height>h)
			{
				ImgD.height=h;
				ImgD.width=(image.width*h)/image.height;
			}
			else
			{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
			ImgD.style.display="block";
		}
	}	
}


//<!-- get target position(x,y) -->
function realPosX (obj) {
	var realX = 0;
	if (obj.offsetParent) {
		do {
			realX += obj.offsetLeft;
		} while (obj = obj.offsetParent);
	}
	return realX;
}

function realPosY (obj) {
	var realY = 0;
	if (obj.offsetParent) {
		do {
			realY += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return realY;
}

function show_products(){
	var menutoggle_products = document.getElementById('menutoggle_products');
	var product_x = realPosX(menutoggle_products)+menutoggle_products.offsetWidth;
	var product_y = realPosY(menutoggle_products);
	//document.getElementById('products').style.backgroundImage.src='../images/menu_bg_green.jpg';
	document.getElementById('products').style.zIndex = 100;
	document.getElementById('products').style.display='block';
	document.getElementById('products').style.position='absolute';
	document.getElementById('products').style.left = product_x+'px';
	//shifting to top 20px
	document.getElementById('products').style.top = product_y-10+'px';
}

function show_submenu(obj, submenu){
	if(submenu){
		submenu.style.left = realPosX(obj)+'px';
		submenu.style.top = realPosY(obj)+obj.offsetHeight+'px';
		submenu.style.display = "block";
	}
}
