var intHide=new Array(25);
var intShow=new Array(25);
var intHide1;
var intShow1;
var	CurrentWindow=0;

var ElemntList=new Array("DiscountTable","QuoteLookup","ClientInfo");
var AccountInfoElemntList=new Array("ChangePasswordWindow","ChangeUserNameWindow");

var index=0;
var StdLeftHidden=-610;
var StdLeftShown=150;
var IsNetscape=false;
var speed=35;

function NewWindow(URL,width,height )
{
	window.open(URL,"_blank","height = "+height+", width = "+width);
}

function SetBorderStyle(Element,Style)
{
	Element.style.borderStyle=Style;
}

function SetInset(Element)
{
	Element.style.borderStyle="inset";
}

function SetOutset(Element)
{
	Element.style.borderStyle="outset";
}

function loadAction(loc)
{
	window.open (loc, "_blank", "height=480, width=800, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no");
}

function OpenNewWindow(loc)
{
	window.open (loc, "_blank", "height=480, width=800, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes, location=yes, directories=no, status=yes");
}

function SelfDestruct(Element)
{
	if (Element.parentNode)
	{
		Element.parentNode.removeChild(Element);
	}
}


function SetFocusOnElement(Element)
{
	var Done=false;
	if (Element!=null)
	{
		try
		{
			if (Element.type=="hidden" ||
				(Element.tagName!="INPUT" &&
				Element.tagName!="SELECT"))
			{
			}
			else
			{
				Element.focus();
				if (Element.type!="button" &&
					Element.type!="submit")
					Element.select();
				Done=true;
			}
		}
		catch(e)
		{
			try
			{
			if (Element.type=="hidden" ||
				(Element.tagName!="INPUT" &&
				Element.tagName!="SELECT"))
				{
				}
				else
				{
					Element.focus();
					Done=true;
				}
			}
			catch(e2)
			{
				
			}
		}
	}
	return Done;
}

function FindNextFocusAbleElement(Element,thePast)
{
	var Done=false;
	if (Element==null)
	{
		return;
	}
	var start=0;
	for (var k=0;k < Element.childNodes.length;++k)
	{
		if (thePast==Element.childNodes[k])
			start=k;
	}
	for (var i=start;i < Element.childNodes.length;++i)
	{
		if (Done==false && thePast!=Element.childNodes[i])
		{
			if (SetFocusOnElement(Element.childNodes[i]))
			{
				Done=true;
				break;
			}
			else
			{	
				Done=FindNextFocusAbleElement(Element.childNodes[i],Element);
			}
		}
	}
	if (Done==false && thePast!=Element.parentNode)
		Done=FindNextFocusAbleElement(Element.parentNode,Element);
	return Done;
}


function FocusOnNextElement(PreviousElementName)
{
	
	var PreviousElement=document.getElementById(PreviousElementName.split("$").join("_"));
	if (PreviousElement==null)
		PreviousElement=document.getElementsByName(PreviousElementName.split("$").join(":"))[0];
	if (PreviousElement!=null)
	{
		if (PreviousElement.tagName=="SELECT")
		{
			PreviousElement.focus();
			return;
		}
		
		FindNextFocusAbleElement(PreviousElement,null);
	}
}

function IsInputKindOfControl(Element)
{
	if (Element!=null)
	{
		if (Element.type!="hidden" &&
			(Element.tagName=="INPUT" ||
			Element.tagName=="SELECT"))
			return true;
		else
			return false;
	}
	else
		return false;
}

function FindLastInputChild(Element)
{
	var LastChild=null;
	if (Element!=null)
	{
		for (var i=0;i < Element.childNodes.length;++i)
		{
			if (Element.childNodes[i].childNodes.length > 0 && Element.childNodes[i].tagName!="SELECT")
			{
				Result=FindLastInputChild(Element.childNodes[i]);
				if (Result!=null)
					LastChild=Result;
			}
			else
			{
				if (IsInputKindOfControl(Element.childNodes[i]))
					LastChild=Element.childNodes[i];
			}
		}
	}
	return LastChild;
}

function FindLastInputChildInElement(ElementName)
{
	var Element=document.getElementById(ElementName.split("$").join("_"));
	if (Element==null)
		Element=document.getElementsByName(ElementName.split("$").join(":"))[0];
	if (Element!=null)
	{
		//debugger;
		var temp=FindLastInputChild(Element);
		return temp;
	}
	else
		return null;
}

function GiveHex(Dec)
{
   if(Dec == 10)
      Value = "A";
   else
   if(Dec == 11)
      Value = "B";
   else
   if(Dec == 12)
      Value = "C";
   else
   if(Dec == 13)
      Value = "D";
   else
   if(Dec == 14)
      Value = "E";
   else
   if(Dec == 15)
      Value = "F";
   else
      Value = "" + Dec;

   return Value;
}



function setOpacity(Element,value)
{
    Element.style.opacity = value/10;
    Element.style.filter = 'alpha(opacity=' + value*10 + ')';
}

function myInfoType()
{
    var Form=null;
    var BackgroundNode=null;
}

function DoAlert(doc,s_caption,s_message)
{
    var Form=doc.forms[0];
    var ModalNode = doc.createElement("span");
    var BackgroundNode = doc.createElement("span");
   
    Form.appendChild(BackgroundNode);
    Form.appendChild(ModalNode);

    BackgroundNode.style.zIndex=170;
    BackgroundNode.style.position="absolute";
    BackgroundNode.style.left="0px";
    BackgroundNode.style.top="0px";
    BackgroundNode.style.height="100%";
    BackgroundNode.style.width="100%";
    BackgroundNode.style.backgroundColor="gray";
    BackgroundNode.style.display="inline";
    BackgroundNode.innerHTML="<br>";

    setOpacity(BackgroundNode,6);
   
    ModalNode.style.zIndex=170;
    ModalNode.style.display="inline";
    ModalNode.style.position="absolute";
    ModalNode.style.left="20%";
    ModalNode.style.top="30%";
    ModalNode.style.height="150px";
    ModalNode.style.width="400px";

    ModalNode.myInfo=new myInfoType();
    ModalNode.myInfo.Form=Form;
    ModalNode.myInfo.BackgroundNode=BackgroundNode;
    ModalNode.style.border="solid 1px black";
    ModalNode.style.backgroundColor="whitesmoke";

 
    var HTML="<div style=\"position:absolute;Top:0px;Left:0px;Width:400px;Height:24px;background-image:url('Images/button_ltblue.jpg');background-repeat:repeat-x;font-size:larger;font-weight:bold;\">"
    HTML+="&nbsp;&nbsp;"+s_caption+"\n";
    HTML+="</div>\n";
    HTML+="<div style=\"z-index:170;position:absolute;Top:25px;Left:0px;Width:400px;Height:95px;color:black;\"><br>&nbsp;&nbsp;"+s_message+"<br><br></div>";

    ModalNode.innerHTML=HTML;

    var spantag=doc.createElement("span");
    ModalNode.appendChild(spantag);
    spantag.style.position="absolute";
    spantag.style.display="inline";
    spantag.style.left="0px";
    spantag.style.top="120px";
    spantag.style.width="100%";
    spantag.style.height="30px";
   
    var okbutton=doc.createElement("input");
    okbutton.type="button";
    spantag.appendChild(okbutton);
    okbutton.value="Yes";
    okbutton.style.position="absolute";
    okbutton.style.left="170px";
    okbutton.style.top="2px";
    okbutton.style.width="60px";
    okbutton.style.height="24px";
	okbutton.focus();
   
  	if (IsIE6orOlder())
	{
		EncapsulateWithAnIFrame(doc,ModalNode);
	}
   okbutton.onclick=function(){return ReturnAlert(ModalNode,true,null);};
}


function DoConfirm(doc,s_caption,s_message,ResponseEvent)
{
    var Form=doc.forms[0];
    var ModalNode = doc.createElement("span");
    var BackgroundNode = doc.createElement("span");
   
    Form.appendChild(BackgroundNode);
    Form.appendChild(ModalNode);

    BackgroundNode.style.zIndex=170;
    BackgroundNode.style.position="absolute";
    BackgroundNode.style.left="0px";
    BackgroundNode.style.top="0px";
    BackgroundNode.style.height="100%";
    BackgroundNode.style.width="100%";
    BackgroundNode.style.backgroundColor="gray";
    BackgroundNode.style.display="inline";
    BackgroundNode.innerHTML="<br>";

    setOpacity(BackgroundNode,6);
   
    ModalNode.style.zIndex=170;
    ModalNode.style.display="inline";
    ModalNode.style.position="absolute";
    ModalNode.style.left="20%";
    ModalNode.style.top="30%";
    ModalNode.style.height="150px";
    ModalNode.style.width="400px";

    ModalNode.myInfo=new myInfoType();
    ModalNode.myInfo.Form=Form;
    ModalNode.myInfo.BackgroundNode=BackgroundNode;
    ModalNode.style.border="solid 1px black";
    ModalNode.style.backgroundColor="whitesmoke";

    var HTML="<div style=\"position:absolute;Top:0px;Left:0px;Width:398px;Height:24px;background-image:url('Images/button_ltblue.jpg');background-repeat:repeat-x;font-size:larger;font-weight:bold;\">"
    HTML+="&nbsp;&nbsp;"+s_caption+"\n";
    HTML+="</div>\n";
    HTML+="<div style=\"z-index:170;position:absolute;Top:25px;Left:0px;Width:400px;Height:95px;color:black;\"><br>&nbsp;&nbsp;"+s_message+"<br><br></div>";

    ModalNode.innerHTML=HTML;

    var spantag=doc.createElement("span");
    ModalNode.appendChild(spantag);
    spantag.style.position="absolute";
    spantag.style.display="inline";
    spantag.style.left="0px";
    spantag.style.top="120px";
    spantag.style.width="100%";
    spantag.style.height="30px";
   
    var okbutton=doc.createElement("input");
    okbutton.type="button";
    spantag.appendChild(okbutton);
    okbutton.value="Yes";
    okbutton.style.position="absolute";
    okbutton.style.left="130px";
    okbutton.style.top="2px";
    okbutton.style.width="60px";
    okbutton.style.height="24px";
   
    var cancelbutton=doc.createElement("input");
    cancelbutton.type="button";
    spantag.appendChild(cancelbutton);
    cancelbutton.value="No";
    cancelbutton.style.position="absolute";
    cancelbutton.style.left="210px";
    cancelbutton.style.top="2px";
    cancelbutton.style.width="60px";
    cancelbutton.style.height="24px";
	
	okbutton.focus();

 	if (IsIE6orOlder())
	{
		EncapsulateWithAnIFrame(doc,ModalNode);
	}
    okbutton.onclick=function(){return ReturnConfirm(ModalNode,true,ResponseEvent);};
    cancelbutton.onclick=function(){return ReturnConfirm(ModalNode,false,ResponseEvent);};
}

function DoPrompt(doc,s_caption,s_message,DefaultValue,ResponseEvent)
{
    var Form=doc.forms[0];
    var ModalNode = doc.createElement("span");
    var BackgroundNode = doc.createElement("span");
   
    Form.appendChild(BackgroundNode);
    Form.appendChild(ModalNode);

    BackgroundNode.style.zIndex=170;
    BackgroundNode.style.position="absolute";
    BackgroundNode.style.left="0px";
    BackgroundNode.style.top="0px";
    BackgroundNode.style.height="100%";
    BackgroundNode.style.width="100%";
    BackgroundNode.style.backgroundColor="gray";
    BackgroundNode.style.display="inline";
    BackgroundNode.innerHTML="<br>";

    setOpacity(BackgroundNode,6);
   
    ModalNode.style.zIndex=170;
    ModalNode.style.display="inline";
    ModalNode.style.position="absolute";
    ModalNode.style.left="20%";
    ModalNode.style.top="30%";
    ModalNode.style.height="150px";
    ModalNode.style.width="400px";

    ModalNode.myInfo=new myInfoType();
    ModalNode.myInfo.Form=Form;
    ModalNode.myInfo.BackgroundNode=BackgroundNode;
    ModalNode.style.border="solid 1px black";
    ModalNode.style.backgroundColor="whitesmoke";


    var HTML="<div style=\"z-index:170;position:absolute;Top:0px;Left:0px;Width:400px;Height:24px;background-image:url('Images/button_ltblue.jpg');background-repeat:repeat-x;font-size:larger;font-weight:bold;\">"
    HTML+="&nbsp;&nbsp;"+s_caption+"\n";
    HTML+="</div>\n";
    HTML+="<div style=\"z-index:170;position:absolute;Top:25px;Left:0px;Width:400px;Height:65px;color:black;\"><br>&nbsp;&nbsp;"+s_message+"<br><br></div>";

    ModalNode.innerHTML=HTML;

    var Textspantag=doc.createElement("span");
    ModalNode.appendChild(Textspantag);
    Textspantag.style.position="absolute";
   // Textspantag.style.display="inline";
    Textspantag.style.left="0px";
    Textspantag.style.top="90px";
    Textspantag.style.width="100%";
    Textspantag.style.height="30px";
    Textspantag.style.zIndex=170;

    var TextResponseInput=doc.createElement("input");
    TextResponseInput.type="text";
    Textspantag.appendChild(TextResponseInput);
    TextResponseInput.value=DefaultValue;
    TextResponseInput.style.position="absolute";
    TextResponseInput.style.left="20px";
    TextResponseInput.style.top="2px";
    TextResponseInput.style.width="360px";
    TextResponseInput.style.height="24px";

    var spantag=doc.createElement("span");
    ModalNode.appendChild(spantag);
    spantag.style.position="absolute";
  //  spantag.style.display="inline";
    spantag.style.left="0px";
    spantag.style.top="120px";
    spantag.style.width="100%";
    spantag.style.height="30px";
    spantag.style.zIndex=170;
   
    var okbutton=doc.createElement("input");
    okbutton.type="button";
    spantag.appendChild(okbutton);
    okbutton.value="OK";
    okbutton.style.position="absolute";
    okbutton.style.left="130px";
    okbutton.style.top="2px";
    okbutton.style.width="60px";
    okbutton.style.height="24px";
   
    var cancelbutton=doc.createElement("input");
    cancelbutton.type="button";
    spantag.appendChild(cancelbutton);
    cancelbutton.value="Cancel";
    cancelbutton.style.position="absolute";
    cancelbutton.style.left="210px";
    cancelbutton.style.top="2px";
    cancelbutton.style.width="60px";
    cancelbutton.style.height="24px";

	TextResponseInput.select();

 	if (IsIE6orOlder())
	{
		EncapsulateWithAnIFrame(doc,ModalNode);
	}
   okbutton.onclick=function(){return ReturnPrompt(ModalNode,true,TextResponseInput.value,ResponseEvent);};
    cancelbutton.onclick=function(){return ReturnPrompt(ModalNode,false,TextResponseInput.value,ResponseEvent);};
}

function ReturnAlert(ModalNode,Result,ResponseEvent)
{
    try
    {
        setOpacity(ModalNode,3);
		try
		{
	       ResponseEvent(Result);
		}
		catch (e2)
		{
		}
        ModalNode.myInfo.Form.removeChild(ModalNode.myInfo.BackgroundNode);
        ModalNode.myInfo.Form.removeChild(ModalNode);
        return Result;
    }
    catch(e)
    {
        return false;
    }
}

function ReturnConfirm(ModalNode,Result,ResponseEvent)
{
    try
    {
        setOpacity(ModalNode,3);
		try
		{
	       ResponseEvent(Result);
		}
		catch (e2)
		{
		}
        ModalNode.myInfo.Form.removeChild(ModalNode.myInfo.BackgroundNode);
        ModalNode.myInfo.Form.removeChild(ModalNode);
        return Result;
    }
    catch(e)
    {
        return false;
    }
}

function ReturnPrompt(ModalNode,Result,TextResponse,ResponseEvent)
{
    try
    {
        setOpacity(ModalNode,3);
		try
		{
	       ResponseEvent(Result,TextResponse);
		}
		catch (e2)
		{
		}
        ModalNode.myInfo.Form.removeChild(ModalNode.myInfo.BackgroundNode);
        ModalNode.myInfo.Form.removeChild(ModalNode);
        return Result;
    }
    catch(e)
    {
        return false;
    }
}

function IsIE6orOlder()
{
	if (window.XMLHttpRequest) 
	{
		// IE 7, mozilla, safari, opera 9
		return false;
	} else 
	{
		// IE6, older browsers
		return true;
	}
}

function EncapsulateWithAnIFrame(doc,myObject)
{
	var somespan=doc.createElement("span");
	somespan.style.top="0px";
	somespan.style.left="0px";
	somespan.style.width=myObject.style.width;
	somespan.style.height=myObject.style.height;
	somespan.style.zIndex="170";
    somespan.style.overflow="visible";
	somespan.style.position="absolute";
	
	for (i=0;i < myObject.childNodes.length;++i)
	{
		var count=myObject.childNodes.length;

		somespan.appendChild(myObject.childNodes[i]);
		try
		{
			if (count==myObject.childNodes.length)
				myObject.removeChild(myObject.childNodes[i]);
		}
		catch(e)
		{
		}
	}
	
	var theiframe=doc.createElement("iframe");
	theiframe.style.top="0px";
	theiframe.style.left="0px";
	theiframe.style.width="100%";
	theiframe.style.height="100%";
	theiframe.style.zIndex="169";
	theiframe.style.position="absolute";
	//theiframe.src="";
	
	myObject.appendChild(somespan);
	myObject.appendChild(theiframe);
	myObject.myInfo.HasIFrame=true;
}

var timeoutdoc;
function SetTimeOutAlert(doc,caption,message,time)
{
	timeoutdoc=doc;
	setTimeout("CallAlert(\""+caption+"\",\""+message+"\")",time*60000);
}

function CallAlert(caption,message)
{
	DoConfirm(timeoutdoc,caption,message,CallRepost);
}

function CallRepost(repostvalue)
{
	if (repostvalue)
		timeoutdoc.location.reload();
}


function AddIFRAMEBackDrop(Element,Document)
{
	//I will assume that the Element is something like a DIV
	if (navigator.appName.indexOf("Internet Explorer") == -1)
		return;
	try
	{

		if (Document==null)
			if (document!=null)
				var Document=document;
			else
				return;
		var tempiframe=Document.createElement("iframe");
		tempiframe.style.width=Element.style.width;
		tempiframe.style.height=Element.style.height;
		tempiframe.src="";
		tempiframe.style.zIndex=169;
		var tempDiv=Document.createElement("span");
		tempDiv.style.position="absolute";
		tempDiv.style.width=Element.style.width;
		tempDiv.style.height=Element.style.height;
		tempDiv.style.zIndex=170;
		tempDiv.style.backgroundColor=Element.style.backgroundColor;
		tempDiv.style.border=Element.style.border;
		Element.style.border="";
		tempDiv.style.left="0px";
		tempDiv.style.top="0px";
		tempDiv.innerHTML=Element.innerHTML;
		Element.innerText="";

		Element.appendChild(tempiframe);
		Element.appendChild(tempDiv);
	}
	catch(e)
	{
		alert("Exception thrown: "+e);
	}
}


//this is primarily for checking whether or not a first and last name are present when saving a quote
function CheckClientNameValidator(FirstNameID,LastNameID,FirstNameValidatorID,LastNameValidatorID)
{
  var IsValid=false;
  var FirstNameValid=false;
  var LastNameValid=false;
  //debugger;
  ClientFirstName=new String(document.getElementById(FirstNameID).value);
  ClientLastName=new String(document.getElementById(LastNameID).value);
  if (ClientFirstName.length == 0)
  {
		document.getElementById(FirstNameValidatorID).innerHTML="*";
		FirstNameValid=false;
  }
  else
  {
		document.getElementById(FirstNameValidatorID).innerHTML=" ";
		FirstNameValid=true
  }
  if (ClientLastName.length == 0)
  {
		document.getElementById(LastNameValidatorID).innerHTML="*";
		LastNameValid=false;
  }
  else
  {
		document.getElementById(LastNameValidatorID).innerHTML=" ";
		LastNameValid=true
  }
  if (FirstNameValid && LastNameValid)
	IsValid=true;
  else
	IsValid=false;
  return IsValid;
}

//this is primarily for checking whether or not a first and last name are present when saving a quote
function CheckClientNameAndDBAValidator(FirstNameID,LastNameID,FirstNameValidatorID,LastNameValidatorID,DBAID,DBAValidatorID)
{
  var IsValid=false;
  var FirstNameValid=false;
  var LastNameValid=false;
  var DBAValid=false;
  //debugger;
  ClientFirstName=new String(document.getElementById(FirstNameID).value);
  ClientLastName=new String(document.getElementById(LastNameID).value);
  DBA=new String(document.getElementById(DBAID).value);
  if (ClientFirstName.length == 0)
  {
		
		FirstNameValid=false;
  }
  else
  {
		FirstNameValid=true
  }
  if (ClientLastName.length == 0)
  {
		
		LastNameValid=false;
  }
  else
  {
		LastNameValid=true
  }
  if (DBA.length == 0)
  {
		
		DBAValid=false;
  }
  else
  {
		DBAValid=true
  }

  if ((FirstNameValid && LastNameValid) ||
      DBAValid)
  {
	IsValid=true;
	document.getElementById(FirstNameValidatorID).innerHTML=" ";
	document.getElementById(LastNameValidatorID).innerHTML=" ";
	document.getElementById(DBAValidatorID).innerHTML=" ";
  }
  else
  {
	IsValid=false;
	if (!FirstNameValid)
		document.getElementById(FirstNameValidatorID).innerHTML="*";
	else	
		document.getElementById(FirstNameValidatorID).innerHTML=" ";
	if (!LastNameValid)
		document.getElementById(LastNameValidatorID).innerHTML="*";
	else
		document.getElementById(LastNameValidatorID).innerHTML=" ";
	if (!DBAValid)
		document.getElementById(DBAValidatorID).innerHTML="*";
	else
		document.getElementById(DBAValidatorID).innerHTML=" ";
  }
  return IsValid;
}

//this is primarily for checking whether or not a first and last name are present AND a physical address and CSZ are present when saving a quote
function CheckClientNameAndDBAAndPhysAndCSZValidator(FirstNameID,LastNameID,FirstNameValidatorID,LastNameValidatorID,DBAID,DBAValidatorID,PhysAddID,PhysAddValidatorID,CSZID,CSZValidatorID)
{
  var IsValid=false;
  var FirstNameValid=false;
  var LastNameValid=false;
  var DBAValid=false;
  var PhysAddValid=false;
  var CSZValid=false;
  //debugger;
  ClientFirstName=new String(document.getElementById(FirstNameID).value);
  ClientLastName=new String(document.getElementById(LastNameID).value);
  DBA=new String(document.getElementById(DBAID).value);
  PhysAdd=new String(document.getElementById(PhysAddID).value);
  CSZ=new String(document.getElementById(CSZID).value);
  if (ClientFirstName.length == 0)
  {
		
		FirstNameValid=false;
  }
  else
  {
		FirstNameValid=true
  }
  if (ClientLastName.length == 0)
  {
		
		LastNameValid=false;
  }
  else
  {
		LastNameValid=true
  }
  if (DBA.length == 0)
  {
		
		DBAValid=false;
  }
  else
  {
		DBAValid=true
  }
  if (PhysAdd.length == 0)
  {
		
		PhysAddValid=false;
  }
  else
  {
		PhysAddValid=true
  }
  if (CSZ.length == 0)
  {
		
		CSZValid=false;
  }
  else
  {
		CSZValid=true
  }



  if (((FirstNameValid && LastNameValid) ||
      DBAValid) &&
		PhysAddValid && CSZValid)
  {
	IsValid=true;
	document.getElementById(FirstNameValidatorID).innerHTML=" ";
	document.getElementById(LastNameValidatorID).innerHTML=" ";
	document.getElementById(DBAValidatorID).innerHTML=" ";
	document.getElementById(PhysAddValidatorID).innerHTML=" ";
	document.getElementById(CSZValidatorID).innerHTML=" ";
  }
  else
  {
	IsValid=false;
	if (!FirstNameValid)
		document.getElementById(FirstNameValidatorID).innerHTML="*";
	else	
		document.getElementById(FirstNameValidatorID).innerHTML=" ";
	if (!LastNameValid)
		document.getElementById(LastNameValidatorID).innerHTML="*";
	else
		document.getElementById(LastNameValidatorID).innerHTML=" ";
	if (!DBAValid)
		document.getElementById(DBAValidatorID).innerHTML="*";
	else
		document.getElementById(DBAValidatorID).innerHTML=" ";
	if (!PhysAddValid)
		document.getElementById(PhysAddValidatorID).innerHTML="*";
	else
		document.getElementById(PhysAddValidatorID).innerHTML=" ";
	if (!CSZValid)
		document.getElementById(CSZValidatorID).innerHTML="*";
	else
		document.getElementById(CSZValidatorID).innerHTML=" ";

  }
  return IsValid;
}


function EnforceWithinRange(Value,HighValue,LowValue)
{
	return EnforceLowRange(EnforceHighRange(Value,HighValue),LowValue);
}

function EnforceLowRange(Value,LowValue)
{
	var tempValue=ToDouble(Value);
	var tempLow=ToDouble(LowValue);
	if (tempValue < tempLow)
		return tempLow;
	return tempValue;
}

function EnforceHighRange(Value,HighValue)
{
	var tempValue=ToDouble(Value);
	var tempHigh=ToDouble(HighValue);
	if (tempValue > tempHigh)
		return tempHigh;
	return tempValue;
}

//this works.  It only strips out $ for now though
function ToDouble(StringNum)
{
	var Temp=String(StringNum);
	Temp=Temp.replace('$','');
	try
	{
		var Result=parseFloat(Temp);
		if (isNaN(Result))
			Result=0.0;
	}
	catch(error)
	{
		var Result=0.0;
	}
	return Result;
}

/*
function MakeTextBoxRequired(TextBox)
{
	var text=new String();
	var newid=new String();
	var newstyle=new String();
	newid=TextBox.id+"Validator";
	newstyle="Left: "+(TextBox.style.leftPos+TextBox.style.widthPos+10)+
			 "px; Top: "+TextBox.style.Top+
			 "; position:"+TextBox.style.position+
			 "; Z-INDEX: "+TextBox.style.zindex+
			 ";  COLOR: red";
	TextBox.onblur=checkRequired
}

function checkRequired(parentNode,Tag,id,style,attributes,inner)
{
	if (this.value.length==0)
	{
		if (!DoesNodeExist(this.parentNode,newid))
		{
			myCreateElement(this.parentNode,"DIV",newid,newstyle," ","* Required");
		}
	}
	else
	{
		if (DoesNodeExist(this.parentNode,newid))
		{
			myDeleteNode(this.parentNode,id);
		}
	}
};


function DoesNodeExist(parentNode,id)
{
	if (parentNode.document.getElementById(id))
		return true;
	else
		return false;
}

function myCreateElement(parentNode,Tag,id,style,attributes,inner)
{
	debugger;
	var tagtext=new String();
	
	tagtext="<"+Tag+" id='"+id+"' style='"+style+"' "+attributes+" ";
	if (Tag.indexOf("INPUT",0))
		tagtext+="/>";
	else
		tagtext+=">"+inner+"</"+Tag+">";
	var node = document.createElement(Tag);
	parentNode.appendChild(node);
	
}

function myDeleteNode(parentNode,id)
{
	var node=parentNode.document.getElementById(id);
	if (!node)
		return;
	parentNode.removeChild(node);
}
	

function CreateMyElement(Tag,id,style,attributes,inner)
{
	debugger;
	var tagtext=new String();
	
	tagtext="<"+Tag+" id='"+id+"' style='"+style+"' "+attributes+" ";
	if (Tag.indexOf("INPUT",0))
		tagtext+="/>";
	else
		tagtext+=">"+inner+"</"+Tag+">";
	var node = document.createElement(Tag);
	node.id=id;
//	node.
	return node;
	
}
*/

function GetAbsoluteLeft(Element)
{
	var Left=parseInt(Element.style.left);
	if (isNaN(Left))
		Left=0;
	var CurrElement=Element;
	//alert("Is Netscape = "+IsNetscape);
	while (CurrElement.parentNode)
	{
		CurrElement=CurrElement.parentNode;
		if (CurrElement.tagName!="TD")
		{
			if (IsNetscape)
			{
				if (CurrElement.style)
				{
					temp=parseInt(CurrElement.style.left);
					if (!isNaN(temp))
						Left+=temp;
				}
			}
			else
			{
				temp=parseInt(CurrElement.offsetLeft);
				if (isNaN(temp))
					temp=0;
				Left+=temp;
			}
		}
	}

	return Left;
}

function GetAbsoluteTop(Element)
{
	var Top=parseInt(Element.style.top);
	if (isNaN(Top))
		Top=0;

	var CurrElement=Element;
	while (CurrElement.parentNode)
	{
		CurrElement=CurrElement.parentNode;
//		Top+=CurrElement.offsetTop;
/*		if (CurrElement.style.posTop==0 && CurrElement.tagName=="TD")
		{
			Top+=CurrElement.offsetTop;
		}
		else
			Top+=CurrElement.style.posTop;
*/	

		if (CurrElement.tagName!="TD")
		{
			if (IsNetscape)
			{
				if (CurrElement.style)
				{
					temp=parseInt(CurrElement.style.top);
					if (!isNaN(temp))
						Top+=temp;
				}
			}
			else
			{
				temp=parseInt(CurrElement.offsetTop);
				if (isNaN(temp))
					temp=0;
				Top+=temp;
			}
		}

	}
	return Top;
}

function VerifyRangeInTextBox(Control,Lower,Upper,ShowError)
{
	var myValue=parseInt(Control.value,10);
	if (myValue < Lower)
		myValue=Lower;
	if (myValue > Upper)
		myValue=Upper;
	Control.value=myValue;
	Message="Number should be in the range of "+Lower+" - "+Upper;
	if (ShowError==true)
		alert(Message);

}

/*function VerifyRangeInTextBox(Control,Lower,Upper)
{
	var Show=1;
	VerifyRangeInTextBox(Control,Lower,Upper,Show)
}
*/

function SubmitApplication()
{
	var Result=window.confirm("Are you sure that you want to submit this indication for underwriting approval? (Click OK to send)");
	if (Result==true)
	{
		return true;
		//document.getElementById('SubmissionStatus').value="true";
		//document.getElementById('TestApp').click();
	}
	else
		return false;
}

function DisableElement(Element)
{
	Element.setAttribute("disabled","disabled");
}

function OnHighlight(Element)
{

	if (Element.mySelected==null)
		Element.style.backgroundColor="#bbb333";
	Element.style.textDecoration="none";
//	Element.style.borderLeftColor="silver";
//	Element.style.borderTopColor="silver";
}
function OnUnHighlight(Element)
{
	if (Element.mySelected==null)
		Element.style.backgroundColor="#ccc333";
	Element.style.textDecoration="none";
//	Element.style.borderLeftColor="black";
//	Element.style.borderTopColor="black";
}


function ChangeScreens(TargetElement,SourceElement)
{
	for (i=0;i < document.getElementById(TargetElement).parentNode.parentNode.children.length;++i)
	{
		document.getElementById(TargetElement).parentNode.parentNode.children[i].children[0].style.zIndex=100;
	}
	document.getElementById(TargetElement).style.zIndex=170;
	
	//debugger;
	if (SourceElement!=null)
	{
		for (y=0;y < SourceElement.parentNode.children.length;++y)
		{
			if (SourceElement.parentNode.children[y].mySelected!=null)
			{
				SourceElement.parentNode.children[y].mySelected=null;
				//debugger;
				//if (SourceElement.parentNode.children[y].style
				SourceElement.parentNode.children[y].style.backgroundColor="#ccc333";
				//SourceElement.parentNode.children[y].style.textDecoration="none";
				SourceElement.parentNode.children[y].style.borderLeftColor="black";
				SourceElement.parentNode.children[y].style.borderTopColor="black";
				//SourceElement.parentNode.children[y].style.borderRightColor="silver";
				//SourceElement.parentNode.children[y].style.color="black";
			}
		}

		if (SourceElement.document.getElementById("CurrentTab")!=null)
			SourceElement.document.getElementById("CurrentTab").value=SourceElement.id;
		SourceElement.style.backgroundColor="#999222";
	//	SourceElement.style.textDecoration="underline";
		SourceElement.style.borderLeftColor="silver";
		SourceElement.style.borderTopColor="silver";
		//SourceElement.style.borderRightColor="black";
		//SourceElement.style.color="yellow";
		SourceElement.mySelected="true";
	}	
}

//this doesn't work!
//
//	<DIV style="DISPLAY: block; Z-INDEX: 111; LEFT: 24px; WIDTH: 184px; POSITION: absolute; TOP: 520px; HEIGHT: 24px"
//		ms_positioning="GridLayout" onmouseover="javascript:SetupScroll(this);"><span style="Left:0px; position:relative">Test</span></DIV>

function SetupScroll(Element)
{
	SetInterval("ScrollThis("+Element+")",10);
}

function ScollThis(Element)
{
	//debugger;
	Element.children[0].style.posLeft += 10;
	//Element.scrollLeft=Element.scrollWidth;
	if (Element.children[0].style.posLeft >= Element.scrollWidth)
		 Element.children[0].style.posLeft=0;
}
/////////////

		
function TrapEnter(e)
{
	if(!e)
	 var e = window.event;

	var code;
	if (IsNetscape)
	{
		tname=e.target.tagName
		if (e.target.type!=null)
			tname=e.target.type;
		if(e.which)
			code = e.which;
	}
	else
	{
		tname=event.srcElement.tagName
		if (event.srcElement.type!=null)
			tname=event.srcElement.type;
		if(e.keyCode)
			code = e.keyCode;
	}

	if( code == 13 && tname!="submit" && tname!="button")
	 {
		code=9;
	}
	if (IsNetscape)
	{
		
		if(e.which)
			e.which = code;
			
	}
	else
	{
		if(e.keyCode && code!=e.keyCode)
			e.keyCode = code;
	}
	
}

function SetupHandlers()
{
	DetectNavigator();
	if (IsNetscape)
	{
		document.onkeydown = TrapEnter;	
	}
	else
	{
		document.onkeydown = TrapEnter;	
	}
}
		

		
function TrapEnterNetscape(e)
{

//	if (IsNetscape)//navigator.userAgent("Netscape")!=-1 || navigator.userAgent("Firefox")!=-1)
	{
		//var e = window.event;
		if (e) 
		{
			tname=e.target.tagName
			//opera.postError('OK 1'); // Debug message
			if (e.target.type!=null)
			{
				//opera.postError('OK 2'); // Debug message
				tname=e.target.type;
				//opera.postError('OK 3'); // Debug message
				
			}

			if (e.keyCode==13 && tname!="submit" && tname!="button")
			{
				try
				{
						//opera.postError('OK 4'); // Debug message
						e.keyCode=9;
				}
				catch (e2)
					{
						
						//alert ("Firefox sucks.(catch)")
						//opera.postError(e+'OK 5'); // Debug message
						return false;
					}
			}
		}
		else
		{
		//alert ("Firefox sucks.")
		}
		
	}
}

function TrapEnterIE()
{

	{
		tname=event.srcElement.tagName
		//opera.postError('OK 1'); // Debug message
		if (event.srcElement.type!=null)
		{
			//opera.postError('OK 2'); // Debug message
			tname=event.srcElement.type;
			//opera.postError('OK 3'); // Debug message
			
		}

		if (event.keyCode==13 && tname!="submit" && tname!="button")
		{
			try
			{
					//opera.postError('OK 4'); // Debug message
					event.keyCode=9;
			}
			catch (e)
				{
					//opera.postError(e+'OK 5'); // Debug message
					return false;
				}
		}

	}
}



function DetectNavigator()
{
bname=navigator.userAgent;
	//alert(bname);
	//bname=navigator.appName;
	if (bname.indexOf("Netscape")!=-1 || bname.indexOf("Firefox") != -1)
	{
	//alert(bname);
		IsNetscape=true;
//		if (bname.indexOf("Firefox") == -1)
			//window.location="NetscapeError.htm";
	}
	else
	{
	//alert(bname);
		IsNetscape=false;
	}

}		

function StoningtonLloydswn(elmnt)
{
	if (IsNetscape)
	{
		if (document.getElementById(elmnt).style.left >= "0px")
			return 1;
		else
			return 0;
	}
	else
	{
		if (document.getElementById(elmnt).style.posLeft >= 0)
			return 1;
		else
			return 0;
	}
}

function SetFocus(ID)
{
	document.getElementById(ID).focus();
}

function FlipMenus(elmnt,Left)
{
/*	if (IsNetscape)
	{
		for (index=0;index < ElemntList.length;++index)
		{
			if (StoningtonLloydswn(ElemntList[index]) && elmnt!=ElemntList[index])
			{
				document.getElementById(ElemntList[index]).style.left=StdLeftHidden+"px";
			}
		}
		showmenu(elmnt,Left);	
	}
	else
	{
		for (index=0;index < ElemntList.length;++index)
		{
			if (StoningtonLloydswn(ElemntList[index]) && elmnt!=ElemntList[index])
			{
				document.getElementById(ElemntList[index]).style.posLeft=StdLeftHidden;
			}
		}
		showmenu(elmnt,Left);	
	}
*/
}


function FlipMenusAccountPage(elmnt,Left)
{
	if (IsNetscape)
	{
		for (index=0;index < AccountInfoElemntList.length;++index)
		{
			if (StoningtonLloydswn(AccountInfoElemntList[index]) && elmnt!=AccountInfoElemntList[index])
			{
				document.getElementById(AccountInfoElemntList[index]).style.left=StdLeftHidden+"px";
			}
		}
		showmenu(elmnt,Left);	
	}
	else
	{
		for (index=0;index < AccountInfoElemntList.length;++index)
		{
			if (StoningtonLloydswn(AccountInfoElemntList[index]) && elmnt!=AccountInfoElemntList[index])
			{
				document.getElementById(AccountInfoElemntList[index]).style.posLeft=StdLeftHidden;
			}
		}
		showmenu(elmnt,Left);	
	}
}




function showmenu(elmnt,Left)
{
	if (IsNetscape)
	{
		document.getElementById(elmnt).style.left=Left+"px";
	
//		if (intShow[CurrentWindow]!=null)
//			CurrentWindow++;
//		intShow[CurrentWindow]=setInterval("show('"+elmnt+"',"+Left+")",10);
	}
	else
	{
		if (intShow[CurrentWindow]!=null)
			CurrentWindow++;
		intShow[CurrentWindow]=setInterval("show("+elmnt+","+Left+")",10);
	}
}

function hidemenu(elmnt,Left)
{
	if (IsNetscape)
	{
		document.getElementById(elmnt).style.left=Left+"px";
//		if (intHide[CurrentWindow]!=null)
//			CurrentWindow++;
//		intHide[CurrentWindow]=setInterval("hide('"+elmnt+"',"+Left+")",10);
	}
	else
	{
		if (intHide[CurrentWindow]!=null)
			CurrentWindow++;
		intHide[CurrentWindow]=setInterval("hide("+elmnt+","+Left+")",10);
	}
}

function show(elmnt,Left)
{
	if (IsNetscape)
	{
		if (document.getElementById(elmnt).style.left < Left)
		{
			document.getElementById(elmnt).style.left=document.getElementById(elmnt).style.left+speed;
		}
		else
		{
			document.getElementById(elmnt).style.left=Left;
			clearInterval(intShow[CurrentWindow]);
			CurrentWindow--;
		}
	}
	else
	{
		if (elmnt.style.posLeft < Left)
		{
			elmnt.style.posLeft=elmnt.style.posLeft+speed;
		}
		else
		{
			elmnt.style.posLeft=Left;
			clearInterval(intShow[CurrentWindow]);
			CurrentWindow--;
		}
	}
}

function hide(elmnt,Left)
{
	if (IsNetscape)
	{
		if (document.getElementById(elmnt).style.left > Left)
		{
			document.getElementById(elmnt).style.left=document.getElementById(elmnt).style.left-speed;
		}
		else
		{
			clearInterval(intHide[CurrentWindow]);
			CurrentWindow--;
		}
	}
	else
	{
		if (elmnt.style.posLeft > Left)
		{
			elmnt.style.posLeft-=speed;
		}
		else
		{
			clearInterval(intHide[CurrentWindow]);
			CurrentWindow--;
		}
	}
}		

mouseover=false;
function coordinates(elmnt)
{
	if (event.srcElement.id!=elmnt)
	{
		mouseover=false;
		return;
	}
	if (event.srcElement.id==elmnt)
	{
		mouseover=true;
		pleft=document.getElementById(elmnt).style.pixelLeft;
		ptop=document.getElementById(elmnt).style.pixelTop;
		xcoor=event.clientX;
		ycoor=event.clientY;
		//var temp=moveImage(elmnt)
		//document.onmouseover=temp;
		
//		document.getElementById(elmnt).onmousemove=moveImage(elmnt);
	}
}

function moveImage(elmnt)
{
	if (mouseover&&event.button==1)
	{
		document.getElementById(elmnt).style.pixelLeft=pleft+event.clientX-xcoor;
		document.getElementById(elmnt).style.pixelTop=ptop+event.clientY-ycoor;
		return false;
	}
}

function mouseup()
{
	mouseover=false;
}




function DragWindow(elmnt)
{
}

function ReleaseWindow(elmnt)
{
}


/////////////////////////
//Older Functions - Need to have dependability for these removed
/////////////////////////
function showmenu1(elmnt)
{
	if (IsNetscape)
	{
		document.getElementById(elmnt).style.left="150px";
//		clearInterval(intHide1);
//		intShow1=setInterval("show1('"+elmnt+"')",10);
	}
	else
	{
		clearInterval(intHide1);
		intShow1=setInterval("show1("+elmnt+")",10);
	}

}

function hidemenu1(elmnt)
{
	if (IsNetscape)
	{
		document.getElementById(elmnt).style.left="-610px";
		//clearInterval(intShow1);
		//intHide1=setInterval("hide1('"+elmnt+"')",10);
	}
	else
	{
		clearInterval(intShow1);
		intHide1=setInterval("hide1("+elmnt+")",10);
	}
}

function show1(elmnt)
{
	if (IsNetscape)
	{
		if (document.getElementById(elmnt).style.left < 150)
		{
			document.getElementById(elmnt).style.left=document.getElementById(elmnt).style.left+speed;
		}
		else
		{
			document.getElementById(elmnt).style.left=150;
			clearInterval(intShow1);
		}
	}
	else
	{
		if (elmnt.style.posLeft < 150)
		{
			elmnt.style.posLeft=elmnt.style.posLeft+speed;
		}
		else
		{
			elmnt.style.posLeft=150;
			clearInterval(intShow1);
		}
	}
}

function hide1(elmnt)
{
	if (IsNetscape)
	{
		if (document.getElementById(elmnt).style.left > -610)
		{
			document.getElementById(elmnt).style.left-=speed;
		}
		else
		{
			clearInterval(intHide1);
		}
	}
	else
	{
		if (elmnt.style.posLeft > -610)
		{
			elmnt.style.posLeft-=speed;
		}
		else
		{
			clearInterval(intHide1);
		}
	}
}		

function DisplayMenu(elmnt,Top,Left)
{

	if (IsNetscape)
	{
		elmnt.style.left=Left+"px";
		elmnt.style.top=Top+"px";
		//alert("DisplayMenu is running - IsNetscape=TRUE");
		
	}
	else
	{
		//alert("DisplayMenu is running - IsNetscape=FALSE");
		elmnt.style.posLeft=Left;
//		elmnt.style.posTop=Top-elmnt.style.posHeight;
		elmnt.style.posTop=Top;
	}
}

function PutAwayMenu(elmnt)
{
	//if (
	if (IsNetscape)
	{
		//alert("PutAwayMenu is running");
		elmnt.style.left="-610px"
	}
	else
	{
		elmnt.style.posLeft=-610;
	}
}

function OnRollover()
{
	if (this.event.toElement.tagName=="TD")
		this.event.toElement.style.backgroundColor="#81bfe7";
	else
		if (this.event.toElement.tagName=="A")
			this.event.toElement.parentNode.style.backgroundColor="#81bfe7";
}

function OnRollOut()
{

	if (this.event.fromElement.tagName=="TD")
		this.event.fromElement.style.backgroundColor="#70aed6";//"#ffffff";
	else
		if (this.event.fromElement.tagName=="A")
			this.event.fromElement.parentNode.style.backgroundColor="#70aed6";//"#ffffff";
}
