
IE4 = document.all;
function newAlert(title,mess,icon,mods) {
   (IE4) ? makeMsgBox(title,mess,icon,0,0,mods) : alert(mess);
}

function newConfirm(title,mess,icon,defbut,mods) {
   if (IE4) {
      defbut = (defbut==0) ? 0 : 1;
      retVal = makeMsgBox(title,mess,icon,4,defbut,mods);
      retVal = (retVal==6);
   }
   else {
      retVal = confirm(mess);
   }
   return retVal;
}

function pageDelete(newURL) {
	
	if (newConfirm('Confirm Delete','Are you sure you want to delete this record? This action cannot be undone.', 1,1,0)) {
		window.location.replace(newURL);
	}
}

// preload main navigation arrows
{
    Arrow0 = new Image();
	Arrow0.src = "en/images/nav_arrow_off.gif"; 
	Arrow1 = new Image();
	Arrow1.src = "en/images/nav_arrow_on.gif";
	Arrow2 = new Image();
	Arrow2.src = "en/images/nav_arrow_select.gif";  
	Arrow3 = new Image();
	Arrow3.src = "en/images/nav_arrow_select_on.gif";       
}

// dropdown linkage
function sel(Url) {
	Url=document.dropdown.choice[document.dropdown.choice.selectedIndex].value;
	document.location = Url;
}

// new window for remote sites
function newWindow(url) {
	var newwin;
	newwin = window.open(url,'RemoteSite','width=600,height=500,screenX=50,screenY=50,top=50,left=50,resizable=yes,toolbar=yes,scrollbars=yes,location=yes')
	newwin.focus();
}

// selected menu variables
var selected_mainNav;
var selected_nav;

// main navigation highlight when in particular main area
function mainnavSelect(navNamea,navNameb,navArrow,section) {
	selected_mainNav = navArrow.substring(5,navArrow.length);
	
	if (document.getElementById) {
    	document.getElementById(navNamea).style.backgroundImage = "url(en/images/navselect.gif)";
    	document.getElementById(navNameb).style.backgroundImage = "url(en/images/navselect.gif)";
		document.getElementById(section).style.color = "#c52e0c";
    	if (document.images[navArrow].complete) {
    		document.images[navArrow].src = Arrow2.src;
    	}
	}
	else if (document.all) {
		document.all[navNamea].style.backgroundImage = "url(en/images/navselect.gif)";
		document.all[navNameb].style.backgroundImage = "url(en/images/navselect.gif)";
		document.all[section].style.color = "#c52e0c";
		if (document.images[navArrow].complete) {
    		document.images[navArrow].src = Arrow2.src;
    	}
	}
}

// main navigation highlight rollover
function mainnavOn(navNamea,navNameb,navArrow,section) {
	if (document.getElementById) {
		if ((document.images[navArrow].src == Arrow2.src) || (document.images[navArrow].src == Arrow3.src)) {
    		document.getElementById(navNamea).style.backgroundImage = "url(en/images/navselect_on.gif)";
    		document.getElementById(navNameb).style.backgroundImage = "url(en/images/navselect_on.gif)";
    	}
    	else {
    		document.getElementById(navNamea).style.backgroundColor = "#990000";
    		document.getElementById(navNameb).style.backgroundColor = "#990000";
    	}
    	if (document.getElementById(section).style.color != "#c52e0c") {
    		document.getElementById(section).style.color = "#ffffff";
    	}
    	else {
    		document.getElementById(section).style.color = "#fcfcfc";
    	}
    	if ((document.images[navArrow].src != Arrow2.src) && (document.images[navArrow].complete))  {
			document.images[navArrow].src = Arrow1.src;
		}
		else {
			document.images[navArrow].src = Arrow3.src;
		}
	}
	else if (document.all) {
		if ((document.images[navArrow].src == Arrow2.src) || (document.images[navArrow].src == Arrow3.src)) {
			document.all[navNamea].style.backgroundImage = "url(en/images/navselect_on.gif)";
			document.all[navNameb].style.backgroundImage = "url(en/images/navselect_on.gif)";
    	}
    	else {
    		document.all[navNamea].style.backgroundColor = "#990000";
    		document.all[navNameb].style.backgroundColor = "#990000";
    	}
    	if (document.all[section].style.color != "#c52e0c") {
    		document.all[section].style.color = "#ffffff";
    	}
    	else {
    		document.all[section].style.color = "#fcfcfc";
    	}
    	if ((document.images[navArrow].src != Arrow2.src) && (document.images[navArrow].complete))  {
			document.images[navArrow].src = Arrow1.src;
		}
		else {
			document.images[navArrow].src = Arrow3.src;
		}
	}
}

// main navigation normal state rolloff
function mainnavOff(navNamea,navNameb,navArrow,section) {
	if (document.getElementById) {
		if ((document.images[navArrow].src == Arrow2.src) || (document.images[navArrow].src == Arrow3.src)) {
    		document.getElementById(navNamea).style.backgroundImage = "url(en/images/navselect_off.gif)";
    		document.getElementById(navNameb).style.backgroundImage = "url(en/images/navselect_off.gif)";
    	}
    	else {
    		document.getElementById(navNamea).style.backgroundColor = "#4092c6";
    		document.getElementById(navNameb).style.backgroundColor = "#4092c6";
    	}	
    	if (document.getElementById(section).style.color != "#fcfcfc") {
    		document.getElementById(section).style.color = "#ffffff";
    	}
    	else {
    		document.getElementById(section).style.color = "#c52e0c";
    	}
    	if ((document.images[navArrow].src == Arrow1.src) && (document.images[navArrow].complete)) {
			document.images[navArrow].src = Arrow0.src;
		}
		else if ((document.images[navArrow].src == Arrow3.src) && (document.images[navArrow].complete))  {
			document.images[navArrow].src = Arrow2.src;
		}
	}
	else if (document.all) {
		if ((document.images[navArrow].src == Arrow2.src) || (document.images[navArrow].src == Arrow3.src)) {
			document.all[navNamea].style.backgroundImage = "url(en/images/navselect_off.gif)";
			document.all[navNameb].style.backgroundImage = "url(en/images/navselect_off.gif)";
    	}
    	else {
    		document.all[navNamea].style.backgroundColor = "#4092c6";
    		document.all[navNameb].style.backgroundColor = "#4092c6";
    	}
    	if (document.all[section].style.color != "#fcfcfc") {
    		document.all[section].style.color = "#ffffff";
    	}
    	else {
    		document.all[section].style.color = "#c52e0c";
    	}
    	if ((document.images[navArrow].src == Arrow1.src) && (document.images[navArrow].complete)) {
			document.images[navArrow].src = Arrow0.src;
		}
		else if ((document.images[navArrow].src == Arrow3.src) && (document.images[navArrow].complete))  {
			document.images[navArrow].src = Arrow2.src;
		}
	}
}

// sub navigation highlight when on particular page
function navSelect(navNamea,navNameb,navNamec) {
	//selected_nav = navArrow.substring(5,navArrow.length); //navNamea.charAt(1);
	
	if (document.getElementById) {
    	document.getElementById(navNamea).style.backgroundImage = "url(en/images/subselect.gif)";
    	document.getElementById(navNameb).style.backgroundImage = "url(en/images/subselect.gif)";
    	document.getElementById(navNamec).style.backgroundImage = "url(en/images/subselect.gif)";
	}
	else if (document.all) {
		document.all[navNamea].style.backgroundImage = "url(en/images/subselect.gif)";
		document.all[navNameb].style.backgroundImage = "url(en/images/subselect.gif)";
		document.all[navNamec].style.backgroundImage = "url(en/images/subselect.gif)";
	}
}


// sub navigation highlight rollover
function navOn(navNamea,navNameb,navNamec) {
	if (document.getElementById) {
		if (document.getElementById(navNamea).style.backgroundImage != "url(en/images/subselect.gif)") {
    		document.getElementById(navNamea).style.backgroundColor = "#990000";
    	}
    	if (document.getElementById(navNameb).style.backgroundImage != "url(en/images/subselect.gif)") {
    		document.getElementById(navNameb).style.backgroundColor = "#990000";
    	}
    	if (document.getElementById(navNamec).style.backgroundImage != "url(en/images/subselect.gif)") {
    		document.getElementById(navNamec).style.backgroundColor = "#990000";
    	}
	}
	else if (document.all) {
		if (document.all[navNamea].style.backgroundImage != "url(en/images/subselect.gif)") {
			document.all[navNamea].style.backgroundColor = "#990000";
    	}
    	if (document.all[navNameb].style.backgroundImage != "url(en/images/subselect.gif)") {
			document.all[navNameb].style.backgroundColor = "#990000";
    	}
    	if (document.all[navNamec].style.backgroundImage != "url(en/images/subselect.gif)") {
			document.all[navNamec].style.backgroundColor = "#990000";
    	}
	}
}

// sub navigation normal state rolloff
function navOff(navNamea,navNameb,navNamec) {
	if (document.getElementById) {
		if (document.getElementById(navNamea).style.backgroundImage != "url(en/images/subselect.gif)") {
    		document.getElementById(navNamea).style.backgroundColor = "#cc5227";
    	}
    	if (document.getElementById(navNameb).style.backgroundImage != "url(en/images/subselect.gif)") {
    		document.getElementById(navNameb).style.backgroundColor = "#cc5227";
    	}
    	if (document.getElementById(navNamec).style.backgroundImage != "url(en/images/subselect.gif)") {
    		document.getElementById(navNamec).style.backgroundColor = "#cc5227";
    	}
	}
	else if (document.all) {
		if (document.all[navNamea].style.backgroundImage != "url(en/images/subselect.gif)") {
			document.all[navNamea].style.backgroundColor = "#cc5227";
    	}
    	if (document.all[navNameb].style.backgroundImage != "url(en/images/subselect.gif)") {
			document.all[navNameb].style.backgroundColor = "#cc5227";
    	}
    	if (document.all[navNamec].style.backgroundImage != "url(en/images/subselect.gif)") {
			document.all[navNamec].style.backgroundColor = "#cc5227";
    	}
	}
}

// menu delay variables
var dhtml_nav_timeout = 500;
var timeout_obj_text;
var timeout_obj_spacer;
var timeout_obj_main;
var navs = new Array('Who','What','Why','How');

function closeOpenNavs(cur_nav) {
	for (i = 0; i < navs.length; i++) {
		if (navs[i] != cur_nav) {
			//hideMenu('navdiv' + navs[i]);
			hideMenu('navdiv' + navs[i] + 'text');
			if (navs[i] == selected_mainNav) {
				mainnavSelect('main' + navs[i],'main' + navs[i] + 'b','arrow' + navs[i],'main' + navs[i] + 'c');
			} else {
				mainnavOff('main' + navs[i],'main' + navs[i] + 'b','arrow' + navs[i],'main' + navs[i] + 'c');
			}
		}
	}
}

// show menu
function showMenu(menuName) {
    if (document.getElementById) {
    	document.getElementById(menuName).style.zIndex = 10;
    	document.getElementById(menuName).style.visibility = "visible";
    }
    else if (document.all) {
		document.all[menuName].style.zIndex = 10;
		document.all[menuName].style.visibility = "visible";
	}
	else if (document.layers) {
		document.layers[menuName].zIndex = 10;
		document.layers[menuName].visibility = "visible";
	}
}

// hide menu
function hideMenu(menuName) {
    if (document.getElementById) {
    	document.getElementById(menuName).style.visibility = "hidden";
    }
   	else if (document.all) {
		document.all[menuName].style.visibility = "hidden";
	}
	else if (document.layers) {
		document.layers[menuName].visibility = "hidden";
	}
}

// menu delay functions

function showMenuDelayed(navName) {
	closeOpenNavs(navName);
	window.clearTimeout(timeout_obj_text);
	window.clearTimeout(timeout_obj_spacer);
	window.clearTimeout(timeout_obj_main);
	//showMenu('navdiv' + navName);
	showMenu('navdiv' + navName + 'text');
	mainnavOn('main' + navName,'main' + navName + 'b','arrow' + navName,'main' + navName + 'c');
}

function hideMenuDelayed(navName) {
	//timeout_obj_spacer = window.setTimeout('hideMenu(\'navdiv' + navName + '\')',dhtml_nav_timeout);
	timeout_obj_text = window.setTimeout('hideMenu(\'navdiv' + navName + 'text\')',dhtml_nav_timeout);
	if (navName == selected_mainNav) {
		timeout_obj_main = window.setTimeout('mainnavSelect(\'main' + navName + '\',\'main' + navName + 'b\',\'arrow' + navName + '\',\'main' + navName + 'c\')',dhtml_nav_timeout);
	} else {
		timeout_obj_main = window.setTimeout('mainnavOff(\'main' + navName + '\',\'main' + navName + 'b\',\'arrow' + navName + '\',\'main' + navName + 'c\')',dhtml_nav_timeout);
	}
}

function showPage(pageID, sectionID, pageType) {
	//NEED TO MAKE THIS A SWITCH WHEN IT'S FINISHED
	if (pageType == 1) {
		if (pageID==36) {
			window.location = 'benefits.aspx';
		}
		else if (pageID==39) {
			window.location = 'foreign.aspx';
		}
		else if (pageID==42) {
			window.location = 'contact.aspx';
		}
		else if (pageID==44) {
			window.location = 'privacy.aspx';
		}
		else if (pageID == 45) {
		    window.location = 'legal.aspx';
		}
		else {
			window.location = 'jnj-sectionID_' + sectionID + '-pageID_'+ pageID + '-dsc-landing.aspx';
		}
	}
	else if (pageType == 2) {
		window.location = 'jnj-sectionID_' + sectionID + '-pageID_' + pageID + '-dsc-graphic.aspx';
	}
	else if (pageType==3) {
		if (pageID==31) {
			window.location = 'profiles.aspx';
		}
		else if (pageID==32) {
			window.location = 'scholarship_search.aspx';
		}
		else if (pageID==33) {
			window.location = 'program_search.aspx';
		}
		else if (pageID==34) {
			window.location = 'specialties.aspx';
		}
		else if (pageID==59) {
			window.location = 'AskANurse.aspx';
		}
		else if (pageID == 60) {
		    window.location = 'tuition_reim_search.aspx';
		}
	}
}

function openLink(url) {
    if (isFriendUrl(url)) {
        window.open(url);
    }
    else {
        var newwin;
        url = escape(url);
        newwin = window.open('privacy_policy_notice.aspx?url=' + url, 'openlink', 'width=330,height=160,screenX=100,screenY=100,top=100,left=100,resizable=no,toolbar=no,scrollbars=no')
        newwin.focus();
    }
}

function isFriendUrl(url) {
    return (url.indexOf('discovernursing.com') >= 0 || url.indexOf('campaignfornursing.com') >= 0);
}

function init() {

	var links = document.getElementsByTagName('a');

	for (var i = links.length; i != 0; i--) {
		
		var a = links[i-1];
		if (!a.href) continue;
		if (a.href.indexOf('http') != -1 && a.href.indexOf(window.location.hostname) == -1 && window.location.href.indexOf('admin') == -1 && (!a.className || a.className.indexOf('no-privacy') == -1)) {
			a.onclick = PopWin;
		}
		
	}
}

function PopWin(e) {

	if (!e) var e = window.event;
//	alert(this.href);
	var a = e.target ? e.target : e.srcElement;
	var newwin;
	if (isFriendUrl(this.href)) {
	    newwin = window.open(url);
	}
	else {
	    newwin = window.open('privacy_policy_notice.aspx?url=' + encodeURIComponent(this.href), 'openlink', 'width=330,height=160,screenX=100,screenY=100,top=100,left=100,resizable=yes,toolbar=no,scrollbars=no')
	}
	if (newwin) { newwin.focus(); }
	return !newwin; 
}

function enlargeProduct(e, w, h) {
	var newwin = window.open('enlarge_product.aspx?image=' + e,'openlink','width=' + w + ',height=' + h + ',screenX=100,screenY=100,top=100,left=100,resizable=no,toolbar=no,scrollbars=no');
	newwin.focus();
}

function showVideo(e, w, h) {
	var newwin = window.open('show_video.aspx?src=' + encodeURIComponent(e),'openlink','width=' + w + ',height=' + h + ',screenX=100,screenY=100,top=100,left=100,resizable=no,toolbar=no,scrollbars=no');
	newwin.focus();
}

onload = init;

