var dragapproved=false;
var minrestore=0;
var initialwidth,initialheight;
var ie5=document.all&&document.getElementById;
var ns6=document.getElementById&&!document.all;

function iecompattest(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function drag_drop_non_stoc(e){
if (ie5&&dragapproved&&event.button==1){
document.getElementById("dwindow_non_stoc").style.left=tempx+event.clientX-offsetx+"px";
document.getElementById("dwindow_non_stoc").style.top=tempy+event.clientY-offsety+"px";
}
else if (ns6&&dragapproved){
document.getElementById("dwindow_non_stoc").style.left=tempx+e.clientX-offsetx+"px";
document.getElementById("dwindow_non_stoc").style.top=tempy+e.clientY-offsety+"px";
}
}

function initializedrag_non_stoc(e){
offsetx=ie5? event.clientX : e.clientX;
offsety=ie5? event.clientY : e.clientY;
document.getElementById("dwindowcontent_non_stoc").style.display="none"; //extra
tempx=parseInt(document.getElementById("dwindow_non_stoc").style.left);
tempy=parseInt(document.getElementById("dwindow_non_stoc").style.top);

dragapproved=true
document.getElementById("dwindow_non_stoc").onmousemove=drag_drop_non_stoc;
}

function loadwindow_non_stoc(url,width,height){
	
if (!ie5&&!ns6)
window.open(url,"","width=width,height=height,scrollbars=1");
else{
document.getElementById("dwindow_non_stoc").style.display='';
document.getElementById("dwindow_non_stoc").style.width=initialwidth=width+"px";
//document.getElementById("dwindow_non_stoc").style.height=initialheight=height+"px";
document.getElementById("dwindow_non_stoc").style.height=450+"px";
document.getElementById("dwindow_non_stoc").style.left="250px";
document.getElementById("dwindow_non_stoc").style.top=-ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px";
document.getElementById("cframe_non_stoc").src=url;

}
}

function maximize_non_stoc(){
if (minrestore==0){
minrestore=1 ;//maximize window
document.getElementById("maxname_non_stoc").setAttribute("src","restore.gif");
document.getElementById("dwindow_non_stoc").style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px";
document.getElementById("dwindow_non_stoc").style.height=ns6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px";
}
else{
minrestore=0; //restore window
document.getElementById("maxname_non_stoc").setAttribute("src","max.gif");
document.getElementById("dwindow_non_stoc").style.width=initialwidth;
document.getElementById("dwindow").style.height=initialheight;
}
document.getElementById("dwindow_non_stoc").style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px";
document.getElementById("dwindow_non_stoc").style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px";
}

function closeit_non_stoc(){

document.getElementById("dwindow_non_stoc").style.display="none";
}

function stopdrag_non_stoc(){
dragapproved=false;
document.getElementById("dwindow_non_stoc").onmousemove=null;
document.getElementById("dwindowcontent_non_stoc").style.display=""; //extra
}

//update by Alexandru Popa on 28.06.06. Added precommand popup function

function drag_drop_precomanda(e)
{
	if (ie5&&dragapproved && event.button == 1)
	{
		document.getElementById("dwindow_precomanda").style.left = tempx + event.clientX - offsetx + "px";
		document.getElementById("dwindow_precomanda").style.top = tempy + event.clientY - offsety + "px";
	}
	else if (ns6 && dragapproved)
	{
		document.getElementById("dwindow_precomanda").style.left = tempx + e.clientX - offsetx + "px";
		document.getElementById("dwindow_precomanda").style.top = tempy + e.clientY - offsety + "px";
	}
}

function initializedrag_precomanda(e)
{
	offsetx = ie5? event.clientX : e.clientX;
	offsety = ie5? event.clientY : e.clientY;
	document.getElementById("dwindowcontent_precomanda").style.display = "none"; //extra
	tempx=parseInt(document.getElementById("dwindow_precomanda").style.left);
	tempy=parseInt(document.getElementById("dwindow_precomanda").style.top);

	dragapproved = true;
	document.getElementById("dwindow_precomanda").onmousemove=drag_drop_precomanda;
}

function loadwindow_precomanda(url, width, height)
{
	if (!ie5 && !ns6)
		window.open(url, "", "width=" + width + ", height=" + height + ", scrollbars = 1");
	else
	{
		document.getElementById("dwindow_precomanda").style.display = '';
		document.getElementById("dwindow_precomanda").style.width = initialwidth = width + "px";
		document.getElementById("dwindow_precomanda").style.height = 450 + "px";
		document.getElementById("dwindow_precomanda").style.left = "250px";
		document.getElementById("dwindow_precomanda").style.top =- ns6? window.pageYOffset * 1 + 30 + "px" : iecompattest().scrollTop * 1 + 30 + "px";
		document.getElementById("cframe_precomanda").src = url;

	}
	
}

function maximize_precomanda()
{
	if (minrestore == 0)
	{
		minrestore = 1 ;//maximize window
		document.getElementById("maxname_precomanda").setAttribute("src", "restore.gif");
		document.getElementById("dwindow_precomanda").style.width = ns6? window.innerWidth-20 + "px" : iecompattest().clientWidth + "px";
		document.getElementById("dwindow_precomanda").style.height = ns6? window.innerHeight-20 + "px" : iecompattest().clientHeight + "px";
	}
	else
	{
		minrestore = 0; //restore window
		document.getElementById("maxname_precomanda").setAttribute("src", "max.gif");
		document.getElementById("dwindow_precomanda").style.width = initialwidth;
		document.getElementById("dwindow").style.height = initialheight;
	}
	document.getElementById("dwindow_precomanda").style.left = ns6? window.pageXOffset + "px" : iecompattest().scrollLeft + "px";
	document.getElementById("dwindow_precomanda").style.top = ns6? window.pageYOffset + "px" : iecompattest().scrollTop + "px";
}

function closeit_precomanda()
{
	document.getElementById("dwindow_precomanda").style.display = "none";
}

function stopdrag_precomanda()
{
	dragapproved = false;
	document.getElementById("dwindow_precomanda").onmousemove = null;
	document.getElementById("dwindowcontent_precomanda").style.display = ""; //extra
}
//end update
