// Kiem Tra LangCode Kiem Tra : en-US , vi-VN
function Check_Lang(url)
{
	var _bool=false;
	var frank_param = url;
	var is_protocol_ok=frank_param.indexOf('en-US');
	if (is_protocol_ok==-1)
	{ 
		_bool=true;
	}
	else
	{
		_bool=false;
	}
}


function openWebLink(url)
{	
	
	if (url.length>0)
	window.open(url,'popup','location=yes,directories=yes,resizable=yes,status=yes,toolbar=yes,menubar=yes, width=610,height=500,scrollbars=yes,top=50,left=200'); 
}		

function showCoords(map,area,x,y,w,h) {
	function parseDMS(v,n){var d,m,s; d=parseInt(v); m=Math.abs(parseFloat(v-d)*60); s=Math.abs(parseFloat(parseInt(m)-m)*60); return Math.abs(d)+"° "+parseInt(m)+"' "+parseInt(s)+"'' "+n;}	
	if(map=="Bandovung") {
		var obj, country = "", lon = (x*360/w)-180, lat = 90-(y*180/h);
		lon = parseDMS(lon,lon!=0?(lon<0?"W":"E"):""); lat = parseDMS(lat,lat!=0?(lat<0?"S":"N"):"");
		if(area!=0) {obj = document.getElementById(area); country = "  ("+(obj.title||obj.alt)+")";} 
		var tmp="";
		tmp="<p class='coords'>Latitude: "+lat+"  Longitude: "+lon+country;
		tmp=tmp + "<br>";
		tmp=tmp + "With=" + w + "&nbsp;Height=" + h;
		tmp=tmp + "<br>";
		tmp=tmp + "x=" + x + "&nbsp;y=" + y +"<\/p>";
		document.getElementById("Bandovung_blind").innerHTML = tmp;	
	}
}


var randomNumber;
randomNumber=Math.floor(Math.random()*12321);
function showpic(imgID,imgWidthFix,imgHeightFix,orSize,isresizewidth) {
if (imgID == null) return;
var imgPic = document.getElementById('img_'+imgID);
getImgSizePhoto(imgPic,imgWidthFix,imgHeightFix,orSize,isresizewidth);
}
function getImgSizePhoto(ImgID,imgWidthFix,imgHeightFix,orSize,isresizewidth)
{
   var newImg = new Image();
   newImg.src =ImgID.src;
   var height = newImg.height;
   var width = newImg.width;
   var imgHeight, imgWidth;
   
   if (orSize != null)
   {
		imgWidth=imgWidthFix;
		imgHeight=imgHeightFix;
   }
   else
   {   
		
		if(isresizewidth=='yes')
		{
			//fix chieu rong
			imgWidth=imgWidthFix;
			imgHeight  = Math.round(height / (width/imgWidth));	
		}		
		else
		{
			if (width < imgWidthFix && height < imgHeightFix)
			{
				imgWidth=width;
				imgHeight=height;
			}
			else if (width > height)
			{
				imgHeight = imgWidthFix;
				imgWidth  = Math.round(height / (width/imgWidth));	
			}
			else
			{
				//fix chieu cao			
				imgHeight = imgHeightFix;
				imgWidth  = Math.round(width / (height/imgHeight));	
			}			
		}		
		
   }
   
   ImgID.width=imgWidth;
   ImgID.height=imgHeight;
}


//showpic photo
function showpicphoto(src,id,imgWidthFix,imgHeightFix,orSize) 
{
try
{
	if (src == '') return;
	var imgID ="img_" + id;
	getImgSize(src,imgID,imgWidthFix,imgHeightFix,orSize);
}
catch(e)
{
	return;
	//alert(src + '\r\r' + e.message + '\r\r' + imgPic);
}

}
function getImgSize(imgSrc, ImgID,imgWidthFix,imgHeightFix,orSize)
{
try
{
   var newImg = new Image();
   newImg.src = imgSrc;
   var height = newImg.height;
   var width = newImg.width;
   var imgHeight, imgWidth
   
   if (width < imgWidthFix && height < imgHeightFix)
	{
		imgWidth=width;
		imgHeight=height;
	}
	else if(width > height)
	{
		imgWidth = imgWidthFix;
		imgHeight  = Math.round(height / (width/imgWidth));	
	}
	else
	{
		//fix chieu cao			
		imgHeight = imgHeightFix;
		imgWidth  = Math.round(width / (height/imgHeight));	
	}		
   if (orSize != null)
   {
	document.getElementById(ImgID).style.width=imgWidthFix;
	document.getElementById(ImgID).style.height=imgHeightFix;
   }
   else
   {
   document.getElementById(ImgID).style.width=imgWidth;
   document.getElementById(ImgID).style.height=imgHeight;
   }
}
catch(e)
{
	//alert(e.name );
	document.getElementById(ImgID).style.width=imgWidthFix;
	document.getElementById(ImgID).style.height=imgHeightFix;
	//alert(imgSrc + '\r\r' + e.message + '\r\r' + width+ '\r\r' + height);
}
 
}