var winReference = null;

function refreshPage(){
	top.window.location = top.window.location;
}

function openPositionedWindow(url, name, width, height, x, y, status, scrollbars, moreProperties, openerName) {
	var agent = navigator.userAgent.toLowerCase();
	if (agent.indexOf("mac")!=-1 && agent.indexOf("msie") != -1 && agent.indexOf("msie 5.0")==-1) {
		height += 2;
		if (status) height += 15;
	}

	width += (scrollbars != '' && scrollbars != null && agent.indexOf("mac") == -1) ? 16 : 0;        
        if (!moreProperties || moreProperties == ''){ moreProperties = 'toolbar=1, status=1, resizable=1'; }
	var properties = 'width=' + width + ',height=' + height +  ((status) ? ',status' : '') + ',scrollbars' + ((scrollbars) ? '' : '=no') + ((moreProperties) ? ',' + moreProperties : '');
	var reference = openWindow(url, name, properties, openerName);
	return reference;
}

function popout(url, width, height, name, scrollbars, status, moreProperties, openerName) {
	var x = 0;
	var y = 0;
	if (screen) x = (screen.availWidth - width) / 2;
	if (screen) y = (screen.availHeight - height) / 2;
	if (!status) status == '';
	if (!openerName) openerName == '';	
	var reference = openPositionedWindow(url, name, width, height, x, y, status, scrollbars, moreProperties, openerName);
}	

function openMaxedWindow(url, name, scrollbars, openerName) {
	var width  = 600;
	var height = 800;
	if (screen) width  = screen.width - 10;
	if (screen) height = screen.height - 30;
	var reference = openPositionedWindow(url, name, width, height, 0, 0, false, scrollbars, openerName, moreProperties);
	return reference;
}

function openFullChromeWindow(url, name, openerName) {
	return openWindow(url, name, 'directories,location,menubar,resizable,scrollbars,status,toolbar');
}

function openWindow(url, name, properties, openerName) {
	var agent = navigator.userAgent.toLowerCase();
	if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) == 4 && agent.indexOf("msie 5") == -1 && agent.indexOf("msie5") == -1 && agent.indexOf("win") != -1 && url.indexOf('http://') == 0) {
		winReference = window.open('about:blank', name, properties);
		
		setTimeout('if (winReference && !winReference.closed) winReference.location.replace("' + url + '")', 300);
	}
	else {
		winReference = window.open(url, name, properties);
	}

	setTimeout('if (winReference && !winReference.closed) winReference.focus()', 200);
	
	if (openerName) self.name = openerName;
	return winReference;
}

function closeDialog(dialog) {
	if (dialog && dialog.closed != true) dialog.close();
}

function closeParentDialog() {
	if (top.opener && isWindowPopup(top.opener)) {
		root = top.opener.top.opener;
		top.opener.close();
		top.opener = root;
	}
}

function isWindowPopup(win) {
	return ((win.opener) ? true : false);
}

 function popup(url,nme,extra){ 
	  pop = window.open(url,nme,extra);                              
 } 

 function popRedirectWindow(){ 
	var urlRedirect = '/_redirect.cfm';
	pop = window.open(urlRedirect +'?referer=' + window.location,'redirectWindow','menubar=1,resizable=1,directories=1,location=1,status=1,toolbar=1,titlebar=1');                           
 } 

function loadParentWindow(parentUrl)
{
	if(window.opener && !window.opener.closed)	{
		window.opener.focus();
		opener.location=parentUrl;
	}else{
		IndexWin = window.open(parentUrl,'','menubar=1,resizable=1,directories=1,location=1,status=1,toolbar=1,titlebar=1');
		IndexWin.window.moveTo(0,0);
		IndexWin.window.resizeTo(screen.availWidth,screen.availHeight);
	}
	//self.close();
}

