//--------------------------------------------------
//  IMAGE ROLLOVERS
//--------------------------------------------------

function rollover(tagName, fileName) {
	document.images[tagName].src = fileName;
}

//handles errors
window.onerror = errorHandler;
function errorHandler(msg,url,lno)
{ 
	return (true);
}

if(typeof(tamar_rollover_warnings) == 'undefined') {
  tamar_rollover_warnings = false;
}

tamar_rollovers = new Array();

function tamar_rollover(obj, onSrc, offSrc) {

  //if the objects already in the array, leave it
  for (var i=0; i<tamar_rollovers.length; i++) {
    if (obj == tamar_rollovers[i].obj) return
  }

  //assign image object to this object and create image objects
  this.obj     = obj;
  this.off     = new Image();
  this.off.src = offSrc || obj.src;
  this.on      = new Image();
 
  //see if an onSrc image was supplied
  if (onSrc) {
    //it was so set the mouseover image source the supplied one
	this.on.src = onSrc;
    
    //see if the on and off images supplied are the same. If they are fail. We only need to check here
    //as if an onSrc wasn't supplied we know they should take the form _on/_off
    if (this.off.src == this.on.src) {
      //this.error_msg('image with tamar_rollover has the same mouseover/mouseout image');
      return;
    }
  } else {
    //a mouseover image was not supplied, so we're going to work it out
    //the original image should have the format imagename_off.ext
    //the new image will have the format imagename_on.ext
    
    //onSrc = /(\w*)Off\.(\w\w\w\w?)$/.exec(this.off.src)
    
	//Some images end in 'On' and some in 'on' etc therefore need to check cases
	if (this.off.src.indexOf('off') > -1) {
		newString = this.off.src.replace(/off/,"on");
		this.on.src = newString;
	}
	else if (this.off.src.indexOf('Off') > -1) {
		newString = this.off.src.replace(/Off/,"On");
		this.on.src = newString;
	}
	else{
		//the image didn't follow the pattern imagename_off.ext
        //this.error_msg('image with tamar_rollover failed to load a correct filename.\n(file should be called [name]_off.gif)');
	    return;
    }
  }
  
  //check the mouseover images filesize to see if it has been loaded properly
  /*
  if (this.on.fileSize <= 0) {
    //this.error_msg('image with tamar_rollover failed to load mouseover (on) image. '+this.on.src+' could not be found');
    return;
  }
  */
  if ((this.on.width != this.off.width || this.on.height != this.off.height) && tamar_rollover_warnings) {
    //this.error_msg('warning: image with tamar_rollover, dimensions of rollover images don\'t match');
  }

  //assign this object (tamar_rollover) to variable so we can assign it in functions below
  var thisObject  = this;
  
  //create handlers for image that change the image
  obj.onmouseover = function() { obj.src = thisObject.on.src  }
  obj.onmouseout  = function() { obj.src = thisObject.off.src }
  
  //push this object into the rollovers array
  tamar_rollovers[tamar_rollovers.length] = this;
}

tamar_rollover.prototype.error_msg = function(message) {
  //alert(message);
  this.obj.style.border = '3px solid #ff3333';
}


//--------------------------------------------------
//  END IMAGE ROLLOVERS
//--------------------------------------------------



//--------------------------------------------------
//  PHONE ME
//--------------------------------------------------

function popup(url, aname, theheight, thewidth, scrollers) {
  //var aname = 'popup' ;
  var winX = 0;
  var winY = 0;
  var winnX =  (screen.width-thewidth)/2;
  var winnY = (screen.height-theheight)/2;
  str_WinParams = 'top=' + winnY+',left=' + winnX +',toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+thewidth+',height='+theheight;
  thewindowobject = window.open(url,aname, str_WinParams);
  if (window.focus) thewindowobject.focus()
}

//--------------------------------------------------
//  END PHONE ME
//--------------------------------------------------



//--------------------------------------------------
//  FAQ
//--------------------------------------------------

function ShowFAQ()
{
    if (navigator.appName == "Netscape")
    {
        var Benefits_win = window.open("wcHouseholdQuote.asp?WCI=FAQ&amp;WCE=Show&amp;WCU", "FAQ", "toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=400");
           Benefits_win.focus();
    }

    if (navigator.appName == "Microsoft Internet Explorer")
    {
        var Benefits_win = window.open("wcHouseholdQuote.asp?WCI=FAQ&amp;WCE=Show&amp;WCU", "FAQ", "toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=400");
    }
}
//--------------------------------------------------
//  END FAQ
//--------------------------------------------------




//
//  STYLE SHEET SWAPPER
//
/*
function styleSwap(object, state){
  if (state == 'on'){
    object.style.backgroundColor = '#fff89d'
    object.style.color = '#000000'
  }else{
    object.style.backgroundColor = '#FFFFCC'//.className ='inputBody'
    object.style.color = '#666666'
  }
}
*/

function styleSwap(object, state){
  if (state == 'on'){
    object.className ='inputBodyFocus';
  }else{
    object.className ='inputBody';
  }
}




//
//  FRAMESET ALIGNMENT
//

function windowSize() {  
		var myWidth = 0;
		var myHeight = 0;  
		if (document.getElementById('footballer_nav')){   
			var extraSpace = document.body.clientWidth;
			var imagePos = 770 + ((extraSpace -770)/2);
			document.getElementById('footballer_nav').style.left = imagePos-200 + 'px';
			document.getElementById('footballer_nav').style.visibility = 'visible'; 
		}
}


//
//  HELP
//

  function startHelp() {
    showDiv('Default',1); //show a div on page load (and init with a fresh value of 1)
  }

  function showDiv(id,fresh) {
  if (fresh==1) {
    prevId = 'Default';
  }
  if (typeof(prevId) != "undefined") {
    if (prevId){
      document.getElementById('lyr_'+prevId).style.visibility = 'hidden';
    }
    
    document.getElementById('lyr_'+id).style.visibility = 'visible';
    prevId = id;
  }
  }
  
  function newWindow(url) 
  {
  	theWindow = window.open(url,'rollover','width=650,height=465,toolbar=no,location=no,scrollbars=yes,status=no,resizable=no')  
  }

  function startUp(fld){
	  document.getElementById(fld).focus();
  }	




function printIt()
{  
	if (window.print) {
		window.print() ;  
	} 
	else
	{
    	var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    	WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
	}
}

