function pickRandom(range) {
if (Math.random)
return Math.round(Math.random() * (range-1));
else {
var now = new Date();
return (now.getTime() / 1000) % range;
}
}
function ShowPicture(urlImage, iWidth, iHeight)
		{
		var url = "view_image.aspx?img=" + urlImage;
		
		var width=iWidth-10;
		var height=iHeight-10;
		var LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
		var TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
		if(iHeight<screen.height)
		{
			window.open(url,pickRandom(1000),'top='+TopPosition+',left='+LeftPosition+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+width+',height='+height+'').focus();
		}
		else
		{
			window.open(url,pickRandom(1000),'top='+TopPosition+',left='+LeftPosition+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+width+',height='+height+'').focus();
		}
		}
function doSearchAll()
{
var keyword= document.getElementById("keyword").value;
var cbCategory= document.getElementById("cbCategory").value;
window.location.href="search.aspx?action=searchresult&keyword=" + keyword + "&cbCategory=" + cbCategory;
}
function openPollWindow(PollID)
{
	var answer = "";
	var frmForm = document.PollForm;
	for (i = 0; i < frmForm.elements.length; i++)
	{	
		e = frmForm.elements[i];
		if (e.name == "Poll" + PollID && e.checked == true)
		{
			answer = answer + "&answer=" +  e.value;
		}
	}
	//alert(answer);
	pollWindow = window.open('poll_result.aspx?pid=' + PollID + answer,'AQContextHelp','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=300,height=300').focus();
}
function viewPollWindow(PollID)
{
	var answer = "";
	pollWindow = window.open('poll_result.aspx?pid=' + PollID + answer,'AQContextHelp','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=300,height=300').focus();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function openEditor(formName, ImageFolder, strUrl)
{
	
	strUrl = strUrl + "?form=" + formName + "&folder=" + ImageFolder;
	var width=680;
	var height=400;
	var LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
	window.open(strUrl,'OnlineEditor','top='+TopPosition+',left='+LeftPosition+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+'').focus();

}

function checkMemberLogin(strReturnUrl)
{
	var objUsername = document.getElementById('txtLoginUserName');
	var objPassword = document.getElementById('txtLoginPassword');
	var strAlert = "";
	strAlert = strAlert + EsolCheckRequireField(objUsername, "Please enter your username!\n");
	strAlert = strAlert + EsolCheckRequireField(objPassword, "Please enter your password!\n");
	if(strAlert != "")
	{
		alert(strAlert);
		return false;
	}
	else
	{
		document.frmForm.action = "login.aspx?returnUrl=" + strReturnUrl;
		return true;
	}
}
function doSearch()
{
	var objKeyword = document.getElementById('txtKeywordSearch');
	
	window.location.href="search.aspx?keyword=" + objKeyword.value;
}