function OpenPictureByAddress(ImageAddress)
{
	tmpImg = new Image();
	tmpImg.src = ImageAddress;
	newWindow=window.open(ImageAddress,'ImagePreview','scrollbars=yes,toolbar=no,width=' + tmpImg.width + ',height=' + tmpImg.height);
	newWindow.document.write('<html><head><title>ImagePreview<\/title><\/head><body background="' + ImageAddress + '" style="background-repeat: no-repeat"><\/body><\/html>');
	newWindow.resizeBy(tmpImg.width - newWindow.document.body.clientWidth, tmpImg.height-newWindow.document.body.clientHeight);
	newWindow.focus();
	
}
function OpenFileManager(serverFoder,managerType,managerRequests,RelatedScript)
{
	
	window.open(serverFoder + '/MainControls/RavianFileManager.aspx?ManagerType=' + managerType + '&PS=' + RelatedScript + managerRequests,'ImageManager','width=550,height=400,scrollbars=no');
	//ShowPopup(serverFoder + '/MainControls/RavianFileManager.aspx?ManagerType=' + managerType + '&PS=' + RelatedScript + managerRequests,'ImageManager',500,500,'no','true');
}

function ShowFullSizeImage(imgUrl)
{
	newWindow = window.open(imgUrl,'ImagePreview','scrollbars=no,toolbar=no,status=no,width=1,height=1');
	newWindow.document.write('<html><head><title>ImagePreview<\/title><script type="text/javascript">var resizeInterval;function MoveToCenter(){window.moveTo((screen.availWidth - document.body.clientWidth)/2, (screen.availHeight - document.body.clientHeight)/2);}function ResizeStep(width, height, step){var widthFull = false;var heightFull = false;var widthChange;var heightChange;if(document.body.clientWidth + step < width){widthChange = step;}else{widthChange = width - document.body.clientWidth;widthFull = true;}if(document.body.clientHeight + step < height){heightChange = step;}else{heightChange = height - document.body.clientHeight;heightFull = true;}window.resizeBy(widthChange, heightChange);MoveToCenter();if(widthFull && heightFull){clearInterval(resizeInterval);}}function Resize(width, height, step, delay){resizeInterval = setInterval(\'ResizeStep(\' + width + \',\' + height + \',\' + step + \')\', delay);}<\/script><\/head><body style="margin:0"><img  src="' + imgUrl + '" onreadystatechange="Resize(this.width, this.height, 5, 10)" /><\/body><\/html>');
}


function MoveToCenter()
{
	window.moveTo((screen.availWidth - document.body.clientWidth)/2, (screen.availHeight - document.body.clientHeight)/2);
}
var resizeInterval;
function ResizeStep(width, height, step)
{
	var widthFull = false;
	var heightFull = false;
	var widthChange;
	var heightChange;
	if(document.body.clientWidth + step < width)
	{
		widthChange = step;
	}
	else
	{
		widthChange = width - document.body.clientWidth;
		widthFull = true;
	}
	if(document.body.clientHeight + step < height)
	{
		heightChange = step;
	}
	else
	{
		heightChange = height - document.body.clientHeight;
		heightFull = true;
	}
	window.resizeBy(widthChange, heightChange);
	MoveToCenter();
	if(widthFull && heightFull)
	{
		clearInterval(resizeInterval);
	}
}
function Resize(width, height, step, delay)
{
	resizeInterval = setInterval('ResizeStep(' + width + ',' + height + ',' + step + ')', delay);
}

function LoginStudent(pageID)
{
	var username = document.getElementById(pageID + '_stUserName');
	var password = document.getElementById(pageID + '_stPassword');
	var thisUrl = document.location.href;
	
	if(!username || !password)
	{
		return;
	}
	if(username.value == null || username.value == '' )
	{
		document.getElementById(pageID + '_RFVUserName').style.display = 'inline';
	}
	else
	{
		document.getElementById(pageID + '_RFVUserName').style.display = 'none';
	}
	if(password.value == null || password.value == '')
	{
		document.getElementById(pageID + '_RFVPassword').style.display = 'inline';
	}
	else
	{
		document.getElementById(pageID + '_RFVPassword').style.display = 'none';
	}
	if(username.value != null && username.value != '' )
	{
		if(password.value != null && password.value != '')
		{
			var tmp = '?';
			if(thisUrl.indexOf('?') != -1)
			{
				tmp = '&';
			}
			window.navigate(thisUrl + tmp + 'PCLientID=' + pageID + '&Student_Login=1&stUserName=' + username.value + '&stPassword=' + password.value);
		}
	}
	
}
function LoginStudentScript(pClientID,val)
{
	document.getElementById(pClientID + '_LoginError').style.display = val ;
}
