	
	
function agentWidgetDisplay(messageId,agent,state, widgetType)
{

 var messageTag  = document.getElementById(messageId);
 var agentText = "'" + agent + "'";
 var stateTest = "'" + state + "'";
 var agentHtmlContent = '';


// White Widgets
    if(widgetType == 'AQLW001')

     {
	agentHtmlContent = '<div id="AQLink"><div id="AQLinkContent"><form action="" method="post" name="startQuoteForm">  <select name="stateCode" class="AQLinkFormTop"><option selected="selected">Select Your State</option><option value="AZ">Arizona</option><option value="CA">California</option><option value="FL">Florida</option><option value="GA">Georgia</option><option value="IL">Illinois</option></select><button type="button" name="startLrgStateRedButton" onclick="NewQuote(startQuoteForm.stateCode.value, ' + agentText + ')" style="width:30px">GO</button></form><br class="clearfloat"/><div id="AQLinkFormBottom">	<form action="" method="post" name="findQuoteForm" class="AQLFormBottom">Quote I.D.:<input type="text" name="quoteId" maxlength="10" size="10" value="">		&nbsp;Zip:<input type="text" name="zipCode" maxlength="5" size="5" value="">&nbsp;<button type="button" name="findQuoteButton" onclick="FindQuote(findQuoteForm.quoteId.value, findQuoteForm.zipCode.value, ' + agentText + ' ,' + stateTest + ')" style="width:30px">GO</button></form></div></div></div>';

     } else if (widgetType == 'AQLW002'){

	agentHtmlContent ='<div id="AQLink"><!-- Start content div --><div id="AQLinkContent"><form action="" method="post" name="startQuoteForm"><a href="javascript:NewQuote(' + stateTest + ',' + agentText + ')"><img class="AQLinkFormButton" id="startQuoteForm" src="https://quote.mercuryinsurance.com/advertising/AQL/images/AQL_BtnSmallWhite.gif" border =0 /> </a></form><br class="clearfloat"/><!-- Start lower form div --><div id="AQLinkFormBottom"><form action="" method="post" name="findQuoteForm" class="AQLFormBottom">Quote I.D.:<input type="text" name="quoteId" maxlength="10" size="10" value="">&nbsp;Zip:<input type="text" name="zipCode" maxlength="5" size="5" value="">&nbsp;<button type="button" name="findQuoteButton" onclick="FindQuote(findQuoteForm.quoteId.value, findQuoteForm.zipCode.value, ' + agentText + ' ,' + stateTest + ')" style="width:30px">GO</button></form></div><!-- End lower form div --></div><!-- End content div --></div>	<!--End container div -->';

     } else if (widgetType == 'AQLW003'){

	agentHtmlContent ='<div id="AQLink"><form action="" method="post" name="startQuoteForm"><select name="stateCode" class="formField"><option selected="selected">Select Your State</option><option value="AZ">Arizona</option><option value="CA">California</option><option value="FL">Florida</option><option value="GA">Georgia</option><option value="IL">Illinois</option><option value="MI">Michigan</option><option value="NJ">New Jersey</option><option value="NY">New York</option> 			    <option value="NV">Nevada</option><option value="OK">Oklahoma</option><option value="PA">Pennsylvania</option><option value="TX">Texas</option><option value="VA">Virginia</option></select>&nbsp;	<button type="button" name="startLrgStateRedButton" onclick="NewQuote(startQuoteForm.stateCode.value, ' + agentText + ')"  style="width:30px">GO</button></form></div>';

     } else if (widgetType == 'AQLW004'){

	agentHtmlContent ='<div id="AQLink"><form name="startQuoteForm" method="post" action="" id="startQuoteForm"><a href="javascript:NewQuote(' + stateTest + ',' + agentText + ')"><img src="https://quote.mercuryinsurance.com/advertising/AQL/images/AQL_BtnSmallWhite.gif" border =0 /></a></form></div>';

     } else if (widgetType == 'AQLW005'){

	agentHtmlContent ='<div id="AQLink"><!--Start content div --><div id="AQLinkContent"><form action="" method="post" name="startQuoteForm"><select name="stateCode" class="AQLinkFormTop"><option selected="selected">-Select Your State</option><option value="AZ">Arizona</option><option value="CA">California</option><option value="FL">Florida</option><option value="GA">Georgia</option><option value="IL">Illinois</option><option value="MI">Michigan</option><option value="NJ">New Jersey</option><option value="NY">New York</option><option value="NV">Nevada</option><option value="OK">Oklahoma</option><option value="PA">Pennsylvania</option><option value="TX">Texas</option><option value="VA">Virginia</option></select><button type="button" name="startLrgStateRedButton" onclick="NewQuote(startQuoteForm.stateCode.value, ' + agentText + ')"  style="width:30px">GO</button></form><br class="clearfloat"/><!-- Start lower form div --><div id="AQLinkFormBottom"><form action="" method="post" name="findQuoteForm"   class="AQLForm"><table width="200" border="0" cellspacing="0" cellpadding="0"><tr><td width="52">Quote I.D.:</td><td width="92"><input name="quoteId" type="text" class="AQLFormQuoteID" value="" size="10" maxlength="10"></td><td width="56"><button type="button" name="findQuoteButton" onclick="FindQuote(findQuoteForm.quoteId.value, findQuoteForm.zipCode.value, ' + agentText + ' ,' + stateTest + ')" style="width:30px">GO</button></td></tr><tr><td>Zip:</td><td><input name="zipCode" type="text" class="AQLFormZip" value="" size="10" maxlength="5"></td><td>&nbsp;</td></tr></table></form></div><!-- End lower form div --></div><!--End content div --></div>';

     } else if (widgetType == 'AQLW006'){
    

	agentHtmlContent ='<div id="AQLink"><!--Start content div --><div id="AQLinkContent"><form action="" method="post" name="startQuoteForm"><a href="javascript:NewQuote(' + stateTest + ',' + agentText + ')"><img class="AQLinkFormButton" id="startQuoteForm" src="https://quote.mercuryinsurance.com/advertising/AQL/images/AQL_BtnSmallWhite.gif" border = 0/> </a></form><br class="clearfloat"/><!-- Start lower form div --><div id="AQLinkFormBottom"><form action="" method="post" name="findQuoteForm" class="AQLFormBottom"><table width="200" border="0" cellspacing="0" cellpadding="0"><tr><td width="52">Quote I.D.:</td><td width="92"><input name="quoteId" type="text" class="AQLFormQuoteID" value="" size="10" maxlength="10"></td><td width="56"><button type="button" name="findQuoteButton" onclick="FindQuote(findQuoteForm.quoteId.value, findQuoteForm.zipCode.value, ' + agentText + ' ,' + stateTest + ')" style="width:30px">GO</button></td></tr><tr><td>Zip:</td><td><input name="zipCode" type="text" class="AQLFormZip" value="" size="10" maxlength="5"></td><td>&nbsp;</td></tr></table></form></div><!-- End lower form div --></div><!--End content div --></div>';

     } else if (widgetType == 'AQLW007'){

	agentHtmlContent ='<div id="AQLink"><!--Start content div --><div id="AQLinkContent"><form action="" method="post" name="startQuoteForm"><a href="javascript:NewQuote(' + stateTest + ',' + agentText + ')"><img src="http://mercuryinsurance.com/advertising/AQL/images/AQL_BtnLrgWhite.gif" border =0/></a></form></div><!--End content div --></div>';
	
	

     } else if (widgetType == 'AQLW008'){

	agentHtmlContent = '<a href="javascript:NewQuote(' + stateTest + ',' + agentText + ')"><div id="AQLink"><!--Start content div --><div id="AQLinkContent"><form action="" method="post" name="startQuoteForm"></form></div><!--End content div --></a></div>';
	
	

     } else if (widgetType == 'AQLW009'){

	agentHtmlContent ='<a href="javascript:NewQuote(' + stateTest + ',' + agentText + ')"><div id="AQLink"><!--Start content div --><div id="AQLinkContent"><form action="" method="post" name="startQuoteForm"></form></div><!--End content div --></a></div>';
	
	

     } else if (widgetType == 'AQLW010'){

	agentHtmlContent ='<a href="javascript:NewQuote(' + stateTest + ',' + agentText + ')"><div id="AQLink"><!--Start content div --><div id="AQLinkContent"><form action="" method="post" name="startQuoteForm"></form></div><!--End content div --></a></div>';
	
	// Red Widgets

     }else if (widgetType == 'AQLR001'){

	agentHtmlContent = '<div id="AQLink"><div id="AQLinkContent"><form action="" method="post" name="startQuoteForm">  <select name="stateCode" class="AQLinkFormTop"><option selected="selected">Select Your State</option><option value="AZ">Arizona</option><option value="CA">California</option><option value="FL">Florida</option><option value="GA">Georgia</option><option value="IL">Illinois</option></select><button type="button" name="startLrgStateRedButton" onclick="NewQuote(startQuoteForm.stateCode.value, ' + agentText + ')" style="width:30px">GO</button></form><br class="clearfloat"/><div id="AQLinkFormBottom">	<form action="" method="post" name="findQuoteForm" class="AQLFormBottom">Quote I.D.:<input type="text" name="quoteId" maxlength="10" size="10" value="">		&nbsp;Zip:<input type="text" name="zipCode" maxlength="5" size="5" value="">&nbsp;<button type="button" name="findQuoteButton" onclick="FindQuote(findQuoteForm.quoteId.value, findQuoteForm.zipCode.value, ' + agentText + ' ,' + stateTest + ')" style="width:30px">GO</button></form></div></div></div>';
	
	
     } else if (widgetType == 'AQLR002'){

	agentHtmlContent ='<div id="AQLink"><!-- Start content div --><div id="AQLinkContent"><form action="" method="post" name="startQuoteForm"><a href="javascript:NewQuote(' + stateTest + ',' + agentText + ')"><img class="AQLinkFormButton" id="startQuoteForm" src="https://quote.mercuryinsurance.com/advertising/AQL/images/AQL_BtnSmallRed.gif" border =0 /> </a></form><br class="clearfloat"/><!-- Start lower form div --><div id="AQLinkFormBottom"><form action="" method="post" name="findQuoteForm" class="AQLFormBottom">Quote I.D.:<input type="text" name="quoteId" maxlength="10" size="10" value="">&nbsp;Zip:<input type="text" name="zipCode" maxlength="5" size="5" value="">&nbsp;<button type="button" name="findQuoteButton" onclick="FindQuote(findQuoteForm.quoteId.value, findQuoteForm.zipCode.value, ' + agentText + ' ,' + stateTest + ')" style="width:30px">GO</button></form></div><!-- End lower form div --></div><!-- End content div --></div>	<!--End container div -->';

    } else if (widgetType == 'AQLR003'){
 
	agentHtmlContent ='<div id="AQLink"><form action="" method="post" name="startQuoteForm"><select name="stateCode" class="formField"><option selected="selected">Select Your State</option><option value="AZ">Arizona</option><option value="CA">California</option><option value="FL">Florida</option><option value="GA">Georgia</option><option value="IL">Illinois</option><option value="MI">Michigan</option><option value="NJ">New Jersey</option><option value="NY">New York</option> 			    <option value="NV">Nevada</option><option value="OK">Oklahoma</option><option value="PA">Pennsylvania</option><option value="TX">Texas</option><option value="VA">Virginia</option></select>&nbsp;	<button type="button" name="startLrgStateRedButton" onclick="NewQuote(startQuoteForm.stateCode.value, ' + agentText + ')" style="width:30px">GO</button></form></div>';

    } else if (widgetType == 'AQLR004'){

	agentHtmlContent ='<div id="AQLink"><form name="startQuoteForm" method="post" action="" id="startQuoteForm"><a href="javascript:NewQuote(' + stateTest + ',' + agentText + ')"><img src="https://quote.mercuryinsurance.com/advertising/AQL/images/AQL_BtnSmallRed.gif" border =0 /></a></form></div>';

    } else if (widgetType == 'AQLR005'){

	agentHtmlContent ='<div id="AQLink"><!--Start content div --><div id="AQLinkContent"><form action="" method="post" name="startQuoteForm"><select name="stateCode" class="AQLinkFormTop"><option selected="selected">-Select Your State</option><option value="AZ">Arizona</option><option value="CA">California</option><option value="FL">Florida</option><option value="GA">Georgia</option><option value="IL">Illinois</option><option value="MI">Michigan</option><option value="NJ">New Jersey</option><option value="NY">New York</option><option value="NV">Nevada</option><option value="OK">Oklahoma</option><option value="PA">Pennsylvania</option><option value="TX">Texas</option><option value="VA">Virginia</option></select><button type="button" name="startLrgStateRedButton" onclick="NewQuote(startQuoteForm.stateCode.value, ' + agentText + ')"  style="width:30px">GO</button></form><br class="clearfloat"/><!-- Start lower form div --><div id="AQLinkFormBottom"><form action="https://quote2.mercuryinsurance.com/WebQuote/startQuote.do" method="post" name="findQuoteForm"   class="AQLForm"><table width="200" border="0" cellspacing="0" cellpadding="0"><tr><td width="52">Quote I.D.:</td><td width="92"><input name="quoteId" type="text" class="AQLFormQuoteID" value="" size="10" maxlength="10"></td><td width="56"><button type="button" name="findQuoteButton" onclick="FindQuote(findQuoteForm.quoteId.value, findQuoteForm.zipCode.value, ' + agentText + ' ,' + stateTest + ')" style="width:30px">GO</button></td></tr><tr><td>Zip:</td><td><input name="zipCode" type="text" class="AQLFormZip" value="" size="10" maxlength="5"></td><td>&nbsp;</td></tr></table></form></div><!-- End lower form div --></div><!--End content div --></div>';

    } else if (widgetType == 'AQLR006'){

	agentHtmlContent ='<div id="AQLink"><!--Start content div --><div id="AQLinkContent"><form action="" method="post" name="startQuoteForm"><a href="javascript:NewQuote(' + stateTest + ',' + agentText + ')"><img class="AQLinkFormButton" id="startQuoteForm" src="https://quote2.mercuryinsurance.com/advertising/AQL/images/AQL_BtnSmallRed.gif" border = 0/> </a></form><br class="clearfloat"/><!-- Start lower form div --><div id="AQLinkFormBottom"><form action="" method="post" name="findQuoteForm" class="AQLFormBottom"><table width="200" border="0" cellspacing="0" cellpadding="0"><tr><td width="52">Quote I.D.:</td><td width="92"><input name="quoteId" type="text" class="AQLFormQuoteID" value="" size="10" maxlength="10"></td><td width="56"><button type="button" name="findQuoteButton" onclick="FindQuote(findQuoteForm.quoteId.value, findQuoteForm.zipCode.value, ' + agentText + ' ,' + stateTest + ')" style="width:30px">GO</button></td></tr><tr><td>Zip:</td><td><input name="zipCode" type="text" class="AQLFormZip" value="" size="10" maxlength="5"></td><td>&nbsp;</td></tr></table></form></div><!-- End lower form div --></div><!--End content div --></div>';

  }



// Make the agent div visible and fill the content

   messageTag.innerHTML = agentHtmlContent;
   messageTag.style.display='inline';
}




// Function for New quote

function NewQuote(state,agentNum)
   {
     
	var frmStartQuote = document.forms.startQuoteForm;
  	var url='';
  	
  	if(state == 'CA' || state == 'IL' || state == 'VA' || state == 'GA' || state == 'NY' || 
  	   state == 'TX' || state == 'FL'){  	   
  	     if(state == 'TX' && agentNum.length == 4){
  	     	  agentNum = 42 + agentNum;
  	     }  
  	     if(state == 'IL' && agentNum.length == 4){
	       	  agentNum = 12 + agentNum;
  	     }  
  	     if(state == 'GA' && agentNum.length == 4){
	     	  agentNum = 10 + agentNum;
  	     }
		
		 url = "https://quote2.mercuryinsurance.com/WebQuote/startQuote.do?submitName=startQuote&RedSt=" + state + "&src=agentlink&agentcode=" + agentNum;
	}else{
		url = "https://quote1.mercuryinsurance.com/startQuote.jsp?RedSt=" + state + "&src=agentlink&AgencyID=" + agentNum;		
	}

	OpenWin = this.open(url, "CtrlWindow", "toolbar=no,menubar=no,statusbar=no,location=no,scrollbars=yes,resizable=yes");
  }


// Function for exisitng quote

function FindQuote(quoteId,zipcode,agentNum,state)
   {
        var url='';
   	if(state == 'CA' || state == 'IL' || state == 'VA' || state == 'GA' || state == 'NY' || 
     	   state == 'TX' || state == 'FL')
     	{   
     		 if(state == 'TX' && agentNum.length == 4){
     		 	agentNum = 42 + agentNum;
   		 } 
		
     		 if(state == 'IL' && agentNum.length == 4){
     		 	agentNum = 12 + agentNum;
   		 }
   		 if(state == 'GA' && agentNum.length == 4){
		    	  agentNum = 10 + agentNum;
  	     	 }
   		 
   		 url = "https://quote2.mercuryinsurance.com/WebQuote/startQuote.do?submitName=findQuote&RedSt=" +state+ "&src=agentlink&agentcode=" +agentNum+"&QuoteID=" + quoteId + "&zip=" + zipcode;
   	}else{
   	
   		 url = "https://quote1.mercuryinsurance.com/startQuote.jsp?RedSt=" + state + "&Zip=" +zipcode+"&src=agentlink&AgencyID=" + agentNum+"&QuoteID=" + quoteId;		
	}

	var frmfindQuote = document.forms.findQuoteForm;
	var sFormAction = '';
	sFormAction = url;

	OpenWin = this.open(sFormAction, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");
 
  }
