/*
	popup.js
	simplified version based on:
	http://www.alistapart.com/d/popuplinks/popup.js
	
	allows specification of width and height
	
	todo: make defaults for different popup types, as in,
	resourcePopup should get it's own defaults. Use structure
	for defaults/min/max dimensions.
*/

var _DEFAULT_WIDTH  = 420;
var _DEFAULT_HEIGHT = 500;

var	_MIN_WIDTH	= 200;
var _MAX_WIDTH	= 850;
var _MIN_HEIGHT	= 200;
var _MAX_HEIGHT	= 650;

var _POPUP_FEATURES  = 'scrollbars=1,resizable=1,menubar=1';
	
var _POPUP_TARGET = '_blank';

function isUndefined(v) {
    var undef;
    return v===undef;
}

function raw_popup(url,width,height) {
	if (isUndefined(width)) width = _DEFAULT_WIDTH;
	if (isUndefined(height)) height = _DEFAULT_HEIGHT;
	if ( width < _MIN_WIDTH || width > _MAX_WIDTH ) width = _DEFAULT_WIDTH;
	if ( height < _MIN_HEIGHT || height > _MAX_HEIGHT ) height = _DEFAULT_HEIGHT;
	var features = 'width=' + width + ',height=' + height + ',' + _POPUP_FEATURES;
	var target = _POPUP_TARGET;
	var thePopup = window.open(url, target, features);
	thePopup.focus();
	return thePopup;
}

function popup(src, width, height) {
	_POPUP_TARGET - '_blank' ;
    return raw_popup(src.getAttribute('href'),width,height);
}

function videopopup(src, width, height) {
	_POPUP_TARGET - '_blank' ;
    return raw_popup(src.getAttribute('href'),width,height);
}

function resourcePopup(src, height) {
	_POPUP_TARGET = 'hsaResource' ;
	return raw_popup(src.getAttribute('href'),0,height);
}

function hsaItemPopup(src) {
	_POPUP_TARGET = 'hsaItem' ;
	return raw_popup(src.getAttribute('href'),470,400);
}

function hsaVAP(src) {
	_POPUP_TARGET = 'hsaVAP' ;
	return raw_popup(src.getAttribute('href'),300,220);
}

function hsaMRS(src) {
	_POPUP_TARGET = 'hsaMRS' ;
	return raw_popup(src.getAttribute('href'),560,500);
}

function hsaCRI(src) {
	_POPUP_TARGET = 'hsaCRI' ;
	return raw_popup(src.getAttribute('href'),450,550);
}

function hsaVGP(src) {
	_POPUP_TARGET = 'hsaVGP' ;
	return raw_popup(src.getAttribute('href'),400,400);
}

function hsaVRP(src) {
	_POPUP_TARGET = 'hsaVRP' ;
	return raw_popup(src.getAttribute('href'),400,500);
}

function hsaMAN(src) {
	_POPUP_TARGET = 'hsaMAN' ;
	return raw_popup(src.getAttribute('href'),640,500);
}

function openVSCobjPopup(url) {
        var win;
        var winFeatures = 'width=370,height=330,scrollbars=1,resizable=1,status=0,left=1,top=1';
        var pg = url;
        win = open(pg,"windownew",winFeatures);
        win.focus();
}

function HsaAnimationPopup(src) {
	_POPUP_TARGET = 'HsaAnimation' ;
	return raw_popup(src.getAttribute('href'),580,510);
} 

function HsaAnimationWidePopup(src) {
	_POPUP_TARGET = 'HsaAnimation' ;
	return raw_popup(src.getAttribute('href'),660,480);
}
 
function HsaAnimationWidePopupSH(src) {
	_POPUP_TARGET = 'HsaAnimation' ;
	return raw_popup(src.getAttribute('href'),650,560);
}

function HsaAnimationWidePopupGrad(src) {
    _POPUP_TARGET = 'HsaAnimation' ;
    return raw_popup(src.getAttribute('href'),760,590);
}

function AYPAnimationPopup(src) {
	_POPUP_TARGET = 'AypAnimation' ;
	return raw_popup(src.getAttribute('href'),682,580);
} 

function tutorialPopup(src) {
	_POPUP_TARGET = 'tutorial' ;
	return raw_popup(src.getAttribute('href'),750,575);
}

function highTutorialPopup(src) {
	_POPUP_TARGET = 'tutorial' ;
	return raw_popup(src.getAttribute('href'),770,650);
}
function popupCFIP(src) {
	_POPUP_TARGET = 'tutorial' ;
	return raw_popup(src.getAttribute('href'),460,370);
}
/*
	GQA and FTR use hsaItemPopup
*/


