// *************************************************************
// file: global_styles.js
// created: Aug-23-2001
// modified: February-20-2001
// description: JavaScript fuctions for the corporate Web sites.
// *************************************************************


var beenFocused = false;
document.onmousedown = markFocused;
function markFocused() {
	beenFocused = true;
}


function setFocusOnLoad() {
	if (!beenFocused) { loader(); }
}


/********
 * Image rollovers for global navigation
********/

function globalNavOver(image_name) {
	image_name.src = "/web-common/assets/rt_blu_arrow.gif";
}

function globalNavOut(image_name) {
	image_name.src = "/web-common/assets/1x1_spacer.gif";
}

/********
 * Image swaping (mouseover) for the Web site
********/

function swapImage(daImage, daSrc){
var objStr, obj;
    if(document.images){
        if (typeof(daImage) == 'string') {
            objStr = 'document.' + daImage;
            obj = eval(objStr);
            obj.src = daSrc;
        } else if ((typeof(daImage) == 'object') && daImage && daImage.src) {
            daImage.src = daSrc;
        }
    }
}

/********
 * Opens a new window
********/

var curPopupWindow = null;

function openWindow(url, winName, width, height, center, winType) {

   var xposition = 50; // Postions the window vertically in px
   var yposition = 50; // Postions the window horizontally in px
   var location, menubar, resizable, scrollbars, status, titlebar;

   if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
       xposition = (screen.width - 800) / 2;
       yposition = (screen.height - 600) / 2;
   } 
   
   if (winType == "1") {           // winType 1 is for regular popup windows
      location=1;
      menubar=1;
      resizable=1;
      scrollbars=1;
      status=1;
      titlebar=1;
   } else if (winType == "2") {   // winType 2 is for Quick Tour like popups
      location=0;
      menubar=0;
      resizable=0;
      scrollbars=0;
      status=0;
      titlebar=1;
   } else if (winType == "3") {   // winType 3 is for footer like popups
      location=0;
      menubar=0;
      resizable=1;
      scrollbars=1;
      status=0;
      titlebar=1;
   } else if (winType == "4") { // winType 4 sforce footer - no resizing
      location=0;
      menubar=0;
      resizable=0;
      scrollbars=1;
      status=0;
      titlebar=0;
   } else if (winType == "5") {
      location=0;
      menubar=1;
      resizable=0;
      scrollbars=1;
      status=0;
      titlebar=0;
   }else {                       // if no arg is passed for winType
      location=1;
      menubar=1;
      resizable=1;
      scrollbars=1;
      status=1;
      titlebar=1;
   } 
   
   // Features to specify for a new window
   args = "width=" + width + ","
   + "height=" + height + ","
   + "location=" + location + ","
   + "menubar=" + menubar + ","
   + "resizable=" + resizable + ","
   + "scrollbars=" + scrollbars + ","
   + "status=" + status + ","
   + "titlebar=" + titlebar + ","
   + "toolbar=0,"
   + "hotkeys=0,"
   + "screenx=" + xposition + ","  //NN Only
   + "screeny=" + yposition + ","  //NN Only
   + "left=" + xposition + ","     //IE Only
   + "top=" + yposition;           //IE Only
   
	// Performs the opening of the window (and closing of a window already opened for that page).
	if (curPopupWindow != null) {
		curPopupWindow.close();
	}
	curPopupWindow = window.open(url, winName, args, false);
	curPopupWindow.focus();
}


/********
 * Opens a URL location in the parent window of a popup
********/

function switchWindows(url) {
   parent.opener.location.href = url; 
}

/********
 * Close tour window and bring up signup screen(s)
********/

function switchAndClose(url) {
   top.opener.location.href=url;    
   top.close();
   top.opener.focus();
}

/********
 * Takes a Select option value and loads it into a higher level frame
********/

function goto_URL(object) {
   parent.frames[0].location.replace(object.options[object.selectedIndex].value);
}

/********
 * Takes a Select option value and loads reloads the URL in the current window
********/

function goto_URL_2(object) {
   location.replace(object.options[object.selectedIndex].value);
}


function isValidEmail(emailad) {

   var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
   var check=/@[\w\-]+\./;
   var checkend=/\.[a-zA-Z]{2,4}$/;
   if(((emailad.search(exclude) != -1) ||
       (emailad.search(check)) == -1) ||
       (emailad.search(checkend) == -1)){
      return false;
   } else {
      return true;
   }
}