function NewWindow(u,n,w,h,f,p,x,y){
/*  Copyright Eric King : http://www.ericking.us/ - &copy; 2000 - 2010
   	This script is free to use for any non profit website as long as this info is left in  */
	w=(w)?w:sw;h=(h)?h:sh;var ws=window.screen?1:0,m=Math,C='center',R='random',M='custom',sw=screen.availWidth,sh=screen.availHeight,T=(p==C&&ws||!p)?(sh-h)/2:(p==R&&ws)?(m.floor(m.random()*(sh-h))):(p==M&&h!=sh)?y:0,L=(p==C&&ws||!p)?(sw-w)/2:(p==R&&ws)?(m.floor(m.random()*(sw-w))):(p==M&&w!=sw)?x:0,s='width='+w+',height='+h+',top='+T+',screeny='+T+',left='+L+',screenx='+L;s+=(!f||f=='')?'':','+f;
	var win=window.open((u)?u:'http://ericking.us/',(n)?n:'',s);
	if(win && !win.closed){win.focus();return win;}
	if(!win){//alert('popup blocker!');
		document.location=u;
	}
	return false;
}

function modalWindow(u,n,w,h,f,p,x,y){
	var win			= null;
	var resizable	= (f!=null)?/resizable/.test(f):false;
	var status		= (f!=null)?/status/.test(f):false;
	var scroll		= (f!=null)?/scroll/.test(f):false;
	var mFeatures	= [	"center:"+(p.toLowerCase()=="center"?1:0),
						"dialogHeight:"+h+"px",
						"dialogWidth:"+w+"px",
						"help:yes",
						"resizable:"+(resizable==true?1:0),
						"status:"+(status==true?1:0),
						"scroll:"+(scroll==true?1:0),
						"edge:raised"];
	if(x!=null && mFeatures[0]==1)mFeatures.push("dialogLeft:"+x+"px");
	if(y!=null && mFeatures[0]==1)mFeatures.push("dialogTop:"+y+"px");
				
	if("undefined"!=typeof window.showModelessDialog){// IE 7
		win=window.showModelessDialog(u,n,mFeatures.join(';'));		
	} else if("undefined"!=typeof window.showModalDialog){
		win=window.showModalDialog(u,n,mFeatures.join(';'));
	} else {// Firefox
		win=NewWindow(u,n,w,h,f+',modal=yes',p,x,y);	
	}
	return win;
}
