
// CODE FOR POPUP WINDOWS
function launch(newURL, newName, newFeatures, orgName){
  var remote = window.open(newURL, newName, newFeatures);
  if (remote.opener == null)
    	remote.opener = window;
 		remote.opener.name = orgName;
  return remote;
}


function enlargeImage(uri, width, height){
	url = '/media/img/'+uri;
	popup(url,uri,width,height);
}

function popup(url, name, width, height){
	mywinpos = findscreencenter(width,height);
	settings=
	"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width="+width+",height="+height+",top="+mywinpos[0]+",left="+mywinpos[1];
	orgname="mainWin";
	MyNewWindow=launch(url,name,settings,orgname);
}

function bigImageOld(imgID){	// this is a product  Image
	inc = 60;	
	height = 500;
	width = 640;
	height2 = height + inc;
	width2 = width + inc ;
	name = 'invoice';
	url = "/dynimage/?id=" + imgID + "&w=" + width;
	mywinpos = findscreencenter(width,height);
	settings=
	"toolbar=np,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width="+width2+",height="+height2+",top="+mywinpos[0]+",left="+mywinpos[1];
	orgname="mainWin";
	MyNewWindow=launch(url,name,settings,orgname);
}
function bigImage(imgID){	// this is a product  Image
	ID = document.getElementById('mainImageOverlay'); 
	width = 500;
	name = 'invoice';
	url = "/dynimage/?id=" + imgID + "&w=" + width;
	ID.innerHTML = "<a href='javascript:closeBigImage()'><img src="+url+" border=0/></a>";
	ID.style.display = 'inline';
	ID2 = document.getElementById('smallImage'); 
	ID2.style.display = 'none';
}

function closeBigImage(){
	ID = document.getElementById('mainImageOverlay'); 
	ID.style.display = 'none';
	ID2 = document.getElementById('smallImage'); 
	ID2.style.display = 'inline';
	
}



function receipt(saleID){
	height = 600;
	width = 840;
	name = 'invoice';
	url = '/admin/workspace/offline-sale/print/?saleID='+saleID;
	mywinpos = findscreencenter(width,height);
	settings=
	"toolbar=np,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width="+width+",height="+height+",top="+mywinpos[0]+",left="+mywinpos[1];
	orgname="mainWin";
	MyNewWindow=launch(url,name,settings,orgname);
}

function findscreencenter( pwinwidth, pwinheight ){
    winpos = new Array(2);
    scrheight = screen.height;
    scrwidth = screen.width;
    wintop = (scrheight - pwinheight-100) / 2;
    winleft = (scrwidth - pwinwidth) / 2;
    winpos[0] = wintop;
    winpos[1] = winleft;
    return winpos;
}