fr=0;

function oldsetInsParms( Parms ){
		exists = GetCookie('INS');
		if (!exists) {
			SourceCodes = (parent.location.search) ? parent.location.search : ("?" + Parms)
			SetCookie('INS',SourceCodes,'/');
		}
	}

function setInsParms( Parms ){

if (parent.window.location.search.indexOf("srcsite") != -1)
{
Parms=Parms.replace("&srcsite=TD","");
}
          exists = GetCookie('INS');
          if (!exists) {
               if (parent.location.search){
        			URLParms = parent.location.search
     				SplitParms = Parms.split("&")
     				for (i=0; i<SplitParms.length; i++){
      					SourceCodes = URLParms.replace(SplitParms[i], "");
						URLParms = SourceCodes;
     				}
     				SourceCodes = SourceCodes + "&" + Parms
     				re = /%26/gi
     				SourceCodes = SourceCodes.replace(re,"&")
     				re = /&&/gi
     				SourceCodes = SourceCodes.replace(re,"&")
      			}
      			else {
        			SourceCodes = "?" + Parms
      			}
               SetCookie('INS',SourceCodes,'/');
          }
     }
function getAllParms( moreParms ){

	cgiParms="https://www.tdcanadatrust.com/tdinsurance/app.jsp?"

 	SetCookie('QUOTE','OK','/');
 	OK = GetCookie('QUOTE');

 	if (!OK) // no cookie - no quote
 	{
 			if (fr) {
 				alert ("Pour pouvoir débuter une soumission en ligne, il est primordial que votre " +
 "navigateur accepte les témoins de session (session cookies). Si cette option " +
 "n'est pas activée, vous ne serez pas en mesure d'utiliser notre service en ligne.")
 			}
 			else
 			{
 				alert ("To access our online quote, it is essential that your browser setting " +
 "enables session cookies. If this option is not activated, you will not be able to use our online service.")
 			}
 			return;
 	}
	exists = GetCookie('INS');

	if (!exists) {
		exists = "";
		URLArg = window.location + "";
		if (URLArg.indexOf(".tdcanadatrust.com/francais")!= -1) { exists = "brand=TDCT&language=FR&rg=7001"; }
		else if (URLArg.indexOf(".tdcanadatrust.com/")!= -1)    { exists = "brand=TDCT&language=EN&rg=7001"; }
		else if (URLArg.indexOf(".primmum.com/francais/")!= -1) { exists = "brand=PRID&language=FR"; }
		else if (URLArg.indexOf(".primmum.com/")!= -1)          { exists = "brand=PRID&language=EN"; }
		else if (URLArg.indexOf(".tdiha.com/")!= -1)			{ exists = "brand=CTDI&language=EN"; }
		else if (URLArg.indexOf(".tdaha.com/")!= -1)			{ exists = "brand=CTDI&language=FR"; }
		else if (URLArg.indexOf(".melochemonnex.com/en")!= -1)	{ exists = "brand=MMI&language=EN"; }
		else if (URLArg.indexOf(".melochemonnex.com/fr")!= -1)	{ exists = "brand=MMI&language=FR"; }
	}


	sAgent = navigator.userAgent;
	bIsIE6 = sAgent.indexOf("IE 6")  > -1;

	if (bIsIE6){
		if (!fr) {
	 ie6 = "NOTICE TO USERS OF INTERNET EXPLORER 6.0\n " +
"Please be advised that the Internet Explorer 6.0 software has not been fully "+
"tested for compatibility with our website, and as such, we are unable to "+
"provide support for this product. As with the first release of any software "+
"you may experience stability and compatibility issues. We recommend the use "+
"of Microsoft Internet Explorer version 4.0 to 5.5.";
		}
		else
		{
	 ie6= "AVIS AUX UTILISATEURS D'INTERNET EXPLORER 6.0\n" +
"Veuillez prendre note que les vérifications concernant la compatibilité du "+
"logiciel Internet Explorer 6.0 avec notre site Web n'ont pas été effectuées. "+
"Par conséquent, nous sommes dans l'impossibilité d'offrir un soutien "+
"technique pour ce produit. Lors du lancement de tout logiciel, il est "+
"possible que des problèmes de compatibilité et de stabilité surviennent."+
"Nous recommandons l'utilisation de Internet Explorer version 4.0 à 5.5.";
		}
		//alert (ie6);- removed aug8,02
	}
               if (parent.location.search){
        			URLParms = parent.location.search
     				re = /\?/gi
     				URLParms = URLParms.replace(re,"")
     				SplitParms = URLParms.split("&")
     				for (i=0; i<SplitParms.length; i++){
						if (SplitParms[i].indexOf("srcsite") != -1)
						{
						exists = exists + "&" + SplitParms[i]
						}
						if (SplitParms[i].indexOf("campaignid") != -1)
						{
						exists = exists + "&" + SplitParms[i]
						}
						if (SplitParms[i].indexOf("associationid") != -1)
						{
						exists = exists + "&" + SplitParms[i]
						}

     				}
				}
// changing srcsite for EasyWeb traffic

		if (typeof srcSite != "undefined") {
			exists = exists.replace("&srcsite=TD","&srcsite=" + srcSite);
		}

		Parms = exists.split("&")
		for (x=0; x < Parms.length; x++) {

    		if ((Parms[x].indexOf("campaignid") != -1) && (cgiParms.indexOf("campaignid") != -1))
			{ // avoid doubling campaignid
			continue;
			}

    		if ((Parms[x].indexOf("associationid") != -1) && (moreParms.indexOf("associationid") != -1))
			{ // avoid doubling associationid
			continue;
			}

    		if (Parms[x].indexOf("language") != -1)
			{
			Parms[x]="language=EN";
			}

    		if (Parms[x].indexOf("province") == -1){ // don't take province from cookie
     		cgiParms=cgiParms+Parms[x]+"&"
			}

		}
			// form name used - selecter1

				cgiParms = cgiParms+moreParms;


    				re = /\&\&/gi
     				cgiParms = cgiParms.replace(re,"&")
					re = /\?\?/gi
     				cgiParms = cgiParms.replace(re,"?")

if (cgiParms.indexOf("language=") == -1)
{
	cgiParms = cgiParms + "&brand=TDCT&language=EN";
}
				parent.window.location.href = cgiParms
	//change Aug 26, 2004 by jb to open application in same window.
			//win=window.open(cgiParms,'quote','scrollbars=yes,resizable=yes,width=800,height=600');
			//win.focus();


		}

function chkFrProv( Parms ){
		Parms = Parms.split("&")
		for (x=0; x < Parms.length; x++) {
    		if (Parms[x].indexOf("province") != -1){
     		SubParms = Parms[x].split("=")
     		Province = SubParms[1]
    	    }
			if (Parms[x].indexOf("language") != -1){
				if (fr) {
				Parms[x]="language=FR" // FRENCH version
				} else {
				Parms[x]="language=EN" // ENGLISH version
				}
			}
		}
		inParms=""
		for (x=0; x < Parms.length; x++) {
			inParms=inParms+Parms[x]+"&"
		}
		if (Province != "QC" && Province != "NB" && fr)
		{
		alert("Veuillez prendre note que pour une question pratique, nous vous "+
	"offrons la possibilité d'obtenir une soumission en ligne en français. "+
	"Toutefois, le service à la clientèle et la documentation reliée à nos  "+
	"programmes d'assurance seront disponibles en anglais seulement. "+
	"Nous vous remercions de votre compréhension. ");
		}
		return(inParms);
	}

function getProvince(){
  exists = GetCookie('INS');
 if (exists) {  Parms = exists.split("&");
  for (x=0; x < Parms.length; x++) {
  	if (Parms[x].indexOf("province") != -1){
       SubParms = Parms[x].split("=")
        Province = SubParms[1]    //form1 is the name of the form
    //selectbox is the name of the select kitem
    for (var i=0; i < document.selecter1.selectbox.length ; i++) {
     if (document.selecter1.selectbox.options[i].value == Province) {
      document.selecter1.selectbox.options[i].selected=true
     }
    }
   }
  }
 }
}

function SendParms(Page) {
	var Goto = Page
	if (location.search){
		Goto = Goto + location.search
	}
	location.href = Goto
}

