function maximizeWindow( )
{//Quang Le
    var offset = (navigator.userAgent.indexOf("Mac") != -1 || 
                  navigator.userAgent.indexOf("Gecko") != -1 || 
                  navigator.appName.indexOf("Netscape") != -1) ? 0 : 4;
    window.moveTo(-offset, -offset);
    window.resizeTo(screen.availWidth + (2 * offset), 
                   screen.availHeight + (2 * offset));
}        

function OpenWindow(script)
{
	window.open(script);
	return true;
}

function OpenWindow_ExceptBrowsers(script,browserNotAllowed,msgAlert)
{
	if (browserNotAllowed.indexOf(navigator.appName) < 0)
	{
		window.open(script,'_blank','fullscreen=no,resizable=yes,scrollbars=yes,toolbar=no,status=yes');
	}
	else
	{
		alert(msgAlert);
	}
	return true;
}

function ConfirmAction(script)
{
	return confirm(script);
}

function Open(pageName,param1,size)
{
	window.open(pageName,param1,size);
	//return true;
}

function window_onload(focusItem) 
		{				
			var focusCtrl = document.getElementById(focusItem);
			if (focusCtrl);//'SearchRestaurant1_txtResName) 
			{
				focusCtrl.select();
				focusCtrl.focus();
			}
			//	window.status="BestRestaurantInSaigon CopyRight \© BaoSolutions";
		}
			
	function OpenPhoto(imgUrl,width,height)
	{
		var originW = width;
		var originH = height;
		
		width = width + 80;
		height = height + 100;
		var top, left;
		var locate;	
		var frm = window.document.forms[0];
		top = 100;
		left = 150;										
		var scroll = "no";
		if(width > 800)
		{
			width = 800;
			scroll = "yes";
		}
		if(height > 600)
		{
			height = 600;
			scroll = "yes";
		}		
		locate = "left=" + left + "px," +"top=" + top + "px";
		locate= locate + ",height=" + height + "px,width=" + width + "px,center=yes,help=No,scrollbars=" + scroll + ",resizable=yes,toolbar=no,menubar=no,location=no";
		window.open('OriginalPhoto.aspx?imgUrl=' + imgUrl + '&w=' + originW + '&h=' + originH, '',locate);					
		return false; 
	}
	
	function CheckEmpty(ExecutiveObj)
	{
		var obj = document.getElementById(ExecutiveObj);
		if (obj.value == '')
			return false;
		return true;        
	}
	
	function SetVisible2Obj(objIdVisible,objIdHidden)
	{
		/*for (j = 0 ; j < document.all.length ; j++)
		{
			var str_id = document.all(j).id ;
			alert(str_id);
		}*/
		
		var objVisible = document.getElementById(objIdVisible);
		if (objVisible)
		{
			objVisible.style.visibility = 'visible';
			objVisible.style.display = 'block';
		}
		
		var objHidden = document.getElementById(objIdHidden);
		if (objHidden)
		{
			objHidden.style.visibility = 'hidden';
			objHidden.style.display = 'none';
		}
		
		return false;
	}
	
	function Test(objIdVisible,objIdHidden)
	{
		if (i == 0)
		{
			var objVisible = document.getElementById(objIdVisible);
			if (objVisible)
			{
				objVisible.style.visibility = 'visible';
				objVisible.style.display = 'block';
			}
			
			var objHidden = document.getElementById(objIdHidden);
			if (objHidden)
			{
				objHidden.style.visibility = 'hidden';
				objHidden.style.display = 'none';
			}
			
			i ++;
		}
		return false;
	}
	
	function TrimString(sInString) 
	{
		sInString = sInString.replace( /^\s+/g, "" );// strip leading
		return sInString.replace( /\s+$/g, "" );// strip trailing
	}
	
	function FitWindowByImageSize(imgId)
	{
		var NS = (navigator.appName=="Netscape")?true:false; 
		//iWidth = (NS)?window.innerWidth:document.body.clientWidth; 
		//iHeight = (NS)?window.innerHeight:document.body.clientHeight;
		iWidth = document.body.clientWidth; 
		iHeight = document.body.clientHeight;
		
		var img = document.getElementById(imgId)
		//alert('imgw:'+img.width+' imgh:'+img.height)
		var iWidth = img.width - iWidth;
		var iHeight = img.height - iHeight; //document.images[0].height - iHeight;
		window.resizeBy(iWidth,iHeight);
	}
	
	
	function RandomBgImages(objId,arr_BgImages,numberImage,intervalInSecond,arr_BgImages_Name)
	{
			var interval = intervalInSecond; // delay between rotating images (in seconds)
			interval *= 1000;
			var maxImg = numberImage * 1;
			var new_image = Math.floor(Math.random()*maxImg);
			
			if (document.getElementById(objId))
			{
				//document.getElementById(objId).setAttribute('class','bg');
			
				document.getElementById(objId).style.backgroundImage = arr_BgImages[new_image];
				var recur_call = "RandomBgImages('"+objId+"',"+arr_BgImages_Name+","+numberImage+","+intervalInSecond+",'"+arr_BgImages_Name+"')";
				setTimeout(recur_call, interval);
			}
   }
   function Getctrl(control_name)
   {
	//find the control that have 'control_name' in its id
	var ret_control;
	for(var x=0;x<document.all.length;x++)
	{
		if (document.all(x).id.indexOf(control_name,0)>=0) 
		{
			ret_control = document.all(x);
			break;
		}
	}
	return ret_control;
	}	
		
		