//-------------------------------------------------------------------------------------------
// dailies-lensarr.js
//-------------------------------------------------------------------------------------------


var colorArray = new Array(1);

// one-day lenses
var onedaylense = [["dailies-aqua-comfort","DAILIES&reg; AquaComfort Plus&reg;"],
			["focus-dailies","Focus&reg; DAILIES&reg;"],
			["1-day-acuvue","1-DAY ACUVUE&reg;"], 
			["1-day-acuvue-trueye","1-DAY ACUVUE&reg; TruEye&trade;"], 
			["1-day-acuvue-moist","1-DAY ACUVUE&reg; MOIST&reg;"],
			["clear-sight","ClearSight<sup>&trade;</sup> 1-Day"],
			["proclear","Proclear&reg; 1-Day"], 
			["softlense","SofLens&reg; Daily Disposable"], 
			["other","Other"]];

// 2 Week or One-Month Lenses
var onemonthlense = [["air-optix-aqua",'AIR OPTIX&reg; AQUA'], 
					["air-optix-night-day","AIR OPTIX&reg; NIGHT & DAY&reg; AQUA"],
					["o2optix",'O2OPTIX&reg;'],
					["acuvue-advance","ACUVUE&reg; ADVANCE&reg;"],
					["acuvue-2","ACUVUE&reg; 2&trade;"],
					["acuvue-oasys","ACUVUE&reg; OASYS&trade;"],
					["biofinity","Biofinity&reg;"], 
					["softlense","SofLens&reg;"],
					["other","Other"]];

// Contact Lenses for Astigmatism/Toric
var astiglense = [["air-optix-astigmatism","AIR OPTIX&reg; for ASTIGMATISM"],
			["focus-dailies-toric","Focus&reg; DAILIES&reg; Toric"],
			["acuvue-advance","ACUVUE&reg; ADVANCE&reg; for ASTIGMATISM"],
			["acuvue-oasys","ACUVUE&reg; OASYS&trade; for ASTIGMATISM"],
			["clearsight","ClearSight&trade; 1-Day Toric"],
			["proclear","Proclear&reg; Toric"],
			["pure-vision-toric","PureVision&reg; Toric"],
			["softlens","SofLens&reg; for Astigmatism"],
			["other","Other"]];

// Contact Lenses for Presbyopia/Multi-focal/Progressives
var presbylense =[["air-optix-aqua-multifocal","AIR OPTIX&reg; AQUA Multifocal"],
			["focus-dailies","Focus&reg; DAILIES&reg; Progressives"],
			["acuvue-oasys","ACUVUE&reg; OASYS&trade; for PRESBYOPIA"],
			["acuvue-bifocal","ACUVUE&reg; BIFOCAL"], 
			["proclear-multifocal","Proclear&reg; Multifocal"],
			["purevision-multifocal","PureVision&reg; Multi-focal"],
			["softlens-multifocal","SofLens&reg; Multi-focal"],
			["other","Other"]];

// Color Contact Lenses
var colorlense = [["freshlook","FreshLook&reg;"],
			["freshlook-oneday","FreshLook&reg; ONE-DAY"],
			["freshlook-colorblend","FreshLook&reg; Colorblends Toric"],
			["acuvue-colours","ACUVUE&reg; 2 COLOURS&trade;"],
			["other","Other"]];



function getLensesSel(index,frm,showID,selFld,selVal)
{

   with(frm)
   {
	var si = 0;

	if(index>0 && index<6)
	{
		selFld.options.length = null;

		if(index==1) colorArray = onedaylense;
		if(index==2) colorArray = onemonthlense;
		if(index==3) colorArray = astiglense;
		if(index==4) colorArray = presbylense;
		if(index==5) colorArray = colorlense;

		$('#'+showID).show();

		selFld.options[0] = new Option("Select One","No Selection");

		for(var i=0; i<colorArray.length; i++)
		{
		   eachOption = colorArray[i];
		   selFld.options[i+1] = new Option(eachOption[1],eachOption[0]);
		   selFld.options[i+1].innerHTML = eachOption[1];
		   //alert("see if "+eachOption[0]+ " equals "+selVal);
		   if(eachOption[0]==selVal)
		   {
			selFld.selectedIndex = (i+1);
		   }
		}

		if(!scripts_isIE6) $('#b3_Product_Name').selectbox();
	}

	else {
	  if(!scripts_isIE6) $('#b3_Product_Name').selectbox();
	  $('#'+showID).hide();
	  //selFld.options[0] = new Option("Select One","No Selection");
	}
   }
}


//gets the colors based on product
function getLenses( id, form ) {
 var eachOption;
  //when ever user changes the selection we have to override the passed values of product and model
   useJSForProduct = true;

  //reset the current color option list
  form.b3_Product_Name.options.length = null;
  form.b3_Product_Name.style.display = "block";
  document.getElementById('contlensbrand').style.display = "block";

  if (id==0 || id=="No Selection"){
	form.b3_Product_Name.style.display = "none";
  }
  else if (id == "2Week or One-Month Lenses")
  {
    colorArray = onemonthlense;
    pName = "onemonthlense";
  }
  else if (id == "One-Day Lenses")
  {
    colorArray = onedaylense;
    pName = "onedaylense";
  }
  else if (id == "Contact Lenses for AstigmatismToric")
  {
    colorArray = astiglense;
    pName = "astiglense";
  }
  else if (id == "Contact Lenses for PresbyopiaMultifocalProgressives")
  {
    colorArray = presbylense;
    pName = "presbylense";
  }

   else if (id == "Color Contact Lenses")
  {
    colorArray = colorlense;
    pName = "colorlense";
  }

   else if (id == "dont know")
  {
	colorArray = "";
   form.b3_Product_Name.style.display = "none";
   document.getElementById('contlensbrand').style.display = "none";
  }

   else if (id == "Dont Wear Contacts")
  {
	   colorArray = "";
   form.b3_Product_Name.style.display = "none";
   document.getElementById('contlensbrand').style.display = "none";
  }

  form.b3_Product_Name.options[0] = new Option("Select one","No Selection");
  for (var i = 0; i < colorArray.length; i++)
  {
	eachOption = colorArray[i];
	form.b3_Product_Name.options[i+1] = new Option(eachOption[1],eachOption[0]);
  }

  // now fix html symbols
  for(var i=0; i<form.b3_Product_Name.length-1; i++)
  {
	eachOption = colorArray[i];
	form.b3_Product_Name.options[i+1].innerHTML = eachOption[1];
  }

}

function getLensQryStr()
{
  var product = getParameterValue1("b1_CVBrand_Interest");
  var product2 = getParameterValue1("b2_Product_Modality");
  var product3 = getParameterValue1("b3_Product_Name");
  var qrystr = "?";
  qrystr += (product=="" || product==null ? '' : 'b1_CVBrand_Interest='+escape(product))
  qrystr += (product2=="" || product2==null ? '' : (qrystr==""?"":"&")+'b2_Product_Modality='+escape(product2))
  qrystr += (product3=="" || product3==null ? '' : (qrystr==""?"":"&")+'b3_Product_Name='+escape(product3));

  return qrystr;
}

//function gives the parameter value from the query string, takes query string and parameter name as parameters
function getParameterValue1(parameterName){
	var queryString = window.location.search.substring(1);
    var paramName = parameterName + "=";
    var begin;
    var end;
    if(queryString.length > 0){
        begin = queryString.indexOf(paramName);
        if(begin != -1){
            begin = begin + paramName.length;
            end = queryString.indexOf("&",begin);
            if(end == -1)
                            end = queryString.length;

	    var ret = queryString.substring(begin,end);
	    ret = ret.replace(/\+/g, ' ');
            return unescape(ret);
        }
    }
    return null;
}

//function gives the parameter value from the query string, takes query string and parameter name as parameters
function getParameterValue2(parameterName){
	var queryString = parent.window.location.search.substring(1);
    var paramName = parameterName + "=";
    var begin;
    var end;
    if(queryString.length > 0){
        begin = queryString.indexOf(paramName);
        if(begin != -1){
            begin = begin + paramName.length;
            end = queryString.indexOf("&",begin);
            if(end == -1)
                            end = queryString.length;

	    var ret = queryString.substring(begin,end);
	    ret = ret.replace(/\+/g, ' ');
            return unescape(ret);
        }
    }
    return null;
}
