// JavaScript Document
// by Noor Alhiraki
// N'N Design Studio 2008

//alert(document.documentElement);
// Thumbnails Viewer
function openThumb(spicURL, sTitle, width, height)
{
	var bigpic = 0;
	if (screen.availWidth < width)
	{
		height = height * ((screen.availWidth-10) / width);
		width = screen.availWidth-10;
		bigpic = 1;
		xcen = 0;
	}
	if (screen.availHeight < height)
	{
		width = width * ((screen.availHeight-55) / height);
		height = screen.availHeight-55;
		bigpic = 1;
		ycen = 0;
	}
	
	var xcen = (screen.availWidth-width)/2;
	var ycen = (screen.availHeight-height)/2;
	
	win = window.open("", "", "status=yes,menubar=no,toolbar=no,resizable=1,scrollbars=" + bigpic + ",height=" + height + ",width=" + width + ",left=" + xcen + ",top=" + ycen);
	//win.focus();
	//win.moveTo(xcen, ycen);
	//win.resizeTo(width, height);
	win.document.open();
	win.document.write('<html><head><title>'+sTitle+'</title></head>');
	win.document.write('<body style="margin:0px;background:url(images/ui/loader.gif) no-repeat center">');
	win.document.write('<img style="cursor:pointer;width:'+width+'px;height:'+height+'px" src="'+spicURL+'" border="0" onclick="window.close()">');
	win.document.write('</body></html>');
	win.document.close();
	win.focus();
}

function openFullWin()
{
	this.resizeTo(screen.availWidth, screen.availHeight);
	this.moveTo(0, 0);
	this.focus();
}

var PopupWin = 0;
function openPopup(url, width, height)
{
	var xcen = (screen.availWidth - width) / 2;
	var ycen = (screen.availHeight - height) / 2;
	if(PopupWin)
	{
		if(!PopupWin.closed) PopupWin.close();
	}
	PopupWin = open(url, 'PopupWin', 'toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=no,copyhistory=no, height=' + height + ', width=' + width + ', screenX=' + xcen + ', screenY=' + ycen + ', left=' + xcen + ', top='+ycen);
}


// Validaton functions

function FormNullsAlert(idstocheckarr, alertstr)
{
	if (alertstr==null) alertstr = 'This field should not be empty!';
	for (var i = 0; i < idstocheckarr.length; i++)
	{
		if (TrimSpaces(idstocheckarr[i]) == '')
		{
			alert(alertstr);
			//document.getElementById(idstocheckarr[i]).style.borderColor = '#FF0000';
			document.getElementById(idstocheckarr[i]).focus();
			return false;
		}
	}
	return true;
}



// PNG Fix for IE5

//<![CDATA[
if (document.all && document.styleSheets && document.styleSheets[0] && document.styleSheets[0].addRule)
{
	document.styleSheets[0].addRule('*', 'behavior: url(scripts/iepngfix.htc)');
}
//]]>



// Panel Widget

function openPanel(url)
{
	var panel = new NN.widget.Panel	(
											"panel",
											{
												visible:false,
												width:"720px",
												height:"340px",
												constraintoviewport:true,
												fixedcenter:true,
												close:true,
												draggable:true,
												modal:true,
												underlay:"none",
												zindex:"100",
												effect:
												{
													effect:NN.widget.ContainerEffect.SLIDE,
													duration:0.3
												}
											}
										);
	panel.setHeader("");
	//panel.setBody("<div id=\"pan\"></div>");
	panel.setBody("<iframe frameborder=\"0\" id=\"panel-frame\" src=\"" + url + "\"></iframe>");
	panel.setFooter("");
	panel.render(document.body);
	panel.show();
}
//NN.util.Event.on("pbutton", "click", openPanel);


