
// Remove annoying IE link focus
function init(){
if(document.all) {
  var total = document.links.length;
  var currentlink

  for (var n = 0; n < total; n++){
	  document.links[n].onfocus=document.links[n].blur;
	  currentlink = document.links[n];
	  }
}
}

function redirect(toUrl, description) {
	newLoc = new String();
	
	newLoc = '/LogClickThru?fromPage=' + escape(window.location.toString()) + '&toURL=' + escape(toUrl) + '&description=' + escape(description);

	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(newLoc, '" + id + "', 'menubar=yes,toolbar=yes,scrollbars=yes,status=yes,location=yes,personalbar=yes,resizable=yes');");
}

function redirectSameWindow(toUrl, description) {
	newLoc = new String();
	
	newLoc = '/LogClickThru?fromPage=' + escape(window.location.toString()) + '&toURL=' + escape(toUrl) + '&description=' + escape(description);

    window.location = newLoc;
}
/* 
For full Browser type and version - use methods in View Parent 
This just contains enough to detect Netscape 4
*/
    var agt=navigator.userAgent.toLowerCase();
    var is_major = parseInt(navigator.appVersion);
    var NS  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    var NS4 = (NS && (is_major == 4));

var isResized = false;

//to control resize in NS4
function pageResize() {
	isResized = true;
	if (NS4) 
		history.go(0);
}

//to get the selected value from the list box (for NS4, IE is OK with this too)
function findSelectValue(fieldNameWithForm)
{
    for (i = 0; i < fieldNameWithForm.length; i++)
    {
        if (fieldNameWithForm[i].selected ) 
        {
    	  return fieldNameWithForm[i].value;
    	}
    }
    // Return an EMPTY STRING if nothing selected!
    return("");	           
}        

// two functions to display and hide tooltips in Netscape
function showtip(current,e,text)
{
   if (document.all)
   {
      thetitle=text.split('<br>')
      if (thetitle.length > 1)
      {
        thetitles=""
        for (i=0; i<thetitle.length; i++)
           thetitles += thetitle[i] + "\r\n"
        current.title = thetitles
      }
      else current.title = text
   }

   else if (document.layers)
   {
       document.tooltip.document.write( 
           '<layer bgColor="#FFFFE7" style="border:1px ' +
           'solid black; font-size:12px;color:#000000;">' + text + '</layer>')
       document.tooltip.document.close()
       document.tooltip.left=e.pageX+5
       document.tooltip.top=e.pageY+5
       document.tooltip.visibility="show"
   }
}

function hidetip()
{
    if (document.layers)
        document.tooltip.visibility="hidden"
}

function selectEditor(link)
{	
	// remove controller from link and pass parameters to editor dialog...
	var parms = link.substring(link.indexOf('?'));
	var sLinkSrc = showModalDialog("/cms/SelectEditor.jsp"+parms,"","dialogHeight: 300px; dialogWidth: 250px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: No; resizable: Yes; status: No;");
	if(sLinkSrc == null) 
	{
		return false;
	}
	
	link = link + "&action=InsertNewElement&editor=" + sLinkSrc;
	window.location.href = link;
	return false;	
	
	
}

// Utility routine for parsing Email Addresses
function validateEmailFormat(fieldobj, obj, msgEmailFmt) {
	var myVar = new String();
	myVar = obj.toString();
	
	re1 = /^([a-zA-Z0-9_\-])([a-zA-Z0-9_\-\.]*)@(\[((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}|((([a-zA-Z0-9\-]+)\.)+))([a-zA-Z]{2,}|(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\])$/;
	
	if (myVar.search(re1)==-1) {	
		alert(msgEmailFmt);
		if (fieldobj != null) fieldobj.focus();
		return false;	
	}
	else
	{ return true; }
}

