// bwi_lib.js
var email_re = new RegExp(/^([\w\d\-\.]+)@{1}(([\w\d\-]{1,67})|([\w\d\-]+\.[\w\d\-]{1,67}))\.(([a-zA-Z\d]{2,4})(\.[a-zA-Z\d]{2})?)$/);
function IsValidEmail(obj, email) {
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  var inspace = theStr.indexOf(" ");
  
  if( ! theStr.length) {
      return true;
  }
  if (index > 0 && inspace == -1)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  if(result) {
      return true;
  }
  else {
      alert(email + " is not a valid email address. Re-Edit or Delete entry.");
	  obj.select();
  }
  

  //if (email.match(email_re) || ! email.length) {
  //  return true;
  //} else {
  //  alert(email + " is not a valid email address. Re-edit or delete entry.");
	//obj.select();
  //}
}

<!--
function validateEmail(obj) {
   var pat_email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
   //validate email
    if ( !pat_email.test(obj.value)) {
       return false;
    }
    return true;
}
//-->

function bwiConfirm(msg,loc) {
	var target = (arguments.length > 2) ? arguments[2] : top;
	var b = confirm(msg);
	if (b) {
		target.location = loc;
	}
}

function bwiGetURL(loc) {
	var target = (arguments.length > 1) ? arguments[2] : top;
	target.location = loc;
}

function orderDealerReel() {
	window.open("index.cfm?fuseaction=OrderDealerReel","DealerReel","width=400,height=265,top=50,left=50");
}

/////////////////////////////////////////////////////////////////////////////////////
///	Tool Tip Scripts
/////////////////////////////////////////////////////////////////////////////////////

var NN = 0;
var IE = 1;	
var toolTipDiv = "toolTip";
var padX = 15;
var padY = 0;

function initialize() {
	if (getBrowser() == NN) {
		window.captureEvents(Event.MOUSEMOVE);
		window.onmousemove = mouseMoveHandler;
	}
}
//initialize();

function getBrowser() {
	return (document.all) ? IE : NN ;
}

function getDocument() {
	return (getBrowser() == IE) ? document.all : document.layers ;
}

function getStyle() {
	return (getBrowser() == IE) ? "style" : null;
}

function getEvent() {
	return (getBrowser() == IE) ? event : null ;
}

function setVisible(target, visible) {
	if (getBrowser() == IE) {
		target[getStyle()].visibility = (visible) ? "visible" : "hidden";
	} else {
		target.visibility = (visible) ? "visible" : "hidden";
	}
}

function getVisible(target) {
	if (getBrowser() == IE) {
		return (target[getStyle()].visibility);
	} else {
		return (target.visibility);
	}
}

function isVisible(target) {
	return (getVisible(target) == "visible") ? true : false;
}

function moveToolTip(target) {
	if (getBrowser() == IE) {
		if (target) {
			target[getStyle()].top = getEvent()["y"] + padY + document.body.scrollTop;
			target[getStyle()].left = getEvent()["x"] + padX;
		}
	} else {
		target.top = arguments[1]["pageY"] + padY;
		target.left = arguments[1]["pageX"] + padX;
	}
}

/*
function mouseMoveHandler() {
	moveToolTip(getDocument()[toolTipDiv], arguments[0]);
}
*/

function whichBrs() {
var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("opera") != -1) return 'Opera';
if (agt.indexOf("staroffice") != -1) return 'Star Office';
if (agt.indexOf("beonex") != -1) return 'Beonex';
if (agt.indexOf("chimera") != -1) return 'Chimera';
if (agt.indexOf("netpositive") != -1) return 'NetPositive';
if (agt.indexOf("phoenix") != -1) return 'Phoenix';
if (agt.indexOf("firefox") != -1) return 'Firefox';
if (agt.indexOf("safari") != -1) return 'Safari';
if (agt.indexOf("skipstone") != -1) return 'SkipStone';
if (agt.indexOf("msie") != -1) return 'Internet Explorer';
if (agt.indexOf("netscape") != -1) return 'Netscape';
if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
if (agt.indexOf('\/') != -1) {
if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
return navigator.userAgent.substr(0,agt.indexOf('\/'));}
else return 'Netscape';} else if (agt.indexOf(' ') != -1)
return navigator.userAgent.substr(0,agt.indexOf(' '));
else return navigator.userAgent;
}

