function getUrlParam( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

//Open Calc Function, used in related link content
function open_calc_window(strLocation, strWinName) 
{	
	rexp = /https:/	
	if(rexp.test(strLocation)) 
    {
	   	msgWindow = window.open(strLocation, null,'height=500,width=500,location=no,scrollbars=yes,status=yes,menubars=no,toolbars=no,resizable=yes');
    } else {
		msgWindow = window.open(strLocation, null,'height=500,width=500,location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=yes');
	}
	msgWindow.opener = self;
}

//PHP Add Bookmark Function
function addbookmark()
{
	var bookmarkurl= window.location;
	var bookmarktitle= ("Prudential Web Site");
	if (document.all)
		window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

//Table resizer - if user enters a table/mage width that exceeds these values, the table/image will be resized.
function tableResize() {
   var c = document.getElementById('content');
   if(c) {
      tables = c.getElementsByTagName('table');
      for(i = 0; i < tables.length; i++) {
         (tables[i].width > 650) ? tables[i].width = '630':'';
         }
      }
   var cw = document.getElementById('content-wide');
   if(cw) {
      tables = cw.getElementsByTagName('table');
      for(i = 0; i < tables.length; i++) {
         (tables[i].width > 940) ? tables[i].width = '930':'';
         }
      }
   }
   
function imageResize() {
   var c = document.getElementById('content');
   if(c) {
      images = c.getElementsByTagName('img');
      for(i = 0; i < images.length; i++) {
         (images[i].width > 650) ? images[i].width = '630':'';
         }
      }
   var cw = document.getElementById('content-wide');
   if(cw) {
      images = cw.getElementsByTagName('img');
      ;
      for(i = 0; i < images.length; i++) {
         (images[i].width > 940) ? images[i].width = '930':'';
         }
      }
   }
   
function initHighlight() {
    if (!document.getElementsByTagName){ return; }
    var allfields = document.getElementsByTagName("input");
    // loop through all input tags and add events
    for (var i=0; i<allfields.length; i++){
        var field = allfields[i];
        if ((field.id == "headerQuery" && field.getAttribute("type") == "text") || (field.getAttribute("type") == "password") ) {
			field.onfocus = function () {this.className = 'highlightActiveField'; this.value = "";}
            field.onblur = function () {this.className = 'highlightInactiveField'; if(this.value == "") this.value = "SEARCH"}
        }
    }
}


//PHP Sitemap (160)
function gotoState(){
	if (document.stateForm.stateSelector.options[document.stateForm.stateSelector.selectedIndex].value!=""){
		window.location.hash=document.stateForm.stateSelector.options[document.stateForm.stateSelector.selectedIndex].value;
	}
}


window.onload=function(){
	//tableResize(); //Will Resize table width entered via eWebeditPro if it exceeds reasonable width.
	//imageResize(); //Will Resize image width entered via eWebeditPro if it exceeds reasonable width.
	initHighlight(); //On focus, background image swap.
}


