
var a_cruLenAssignment = new Array;
function changeMapping(theForm) {
  var monthMapArray = new Array(17);
  var monthTextArray = new Array(28);
  var monthValueArray = new Array(28);  
    monthTextArray[0] = "December-2010";
  monthValueArray[0] = "2010-12";
    monthTextArray[1] = "January-2011";
  monthValueArray[1] = "2011-01";
    monthTextArray[2] = "February-2011";
  monthValueArray[2] = "2011-02";
    monthTextArray[3] = "March-2011";
  monthValueArray[3] = "2011-03";
    monthTextArray[4] = "April-2011";
  monthValueArray[4] = "2011-04";
    monthTextArray[5] = "May-2011";
  monthValueArray[5] = "2011-05";
    monthTextArray[6] = "June-2011";
  monthValueArray[6] = "2011-06";
    monthTextArray[7] = "July-2011";
  monthValueArray[7] = "2011-07";
    monthTextArray[8] = "August-2011";
  monthValueArray[8] = "2011-08";
    monthTextArray[9] = "September-2011";
  monthValueArray[9] = "2011-09";
    monthTextArray[10] = "October-2011";
  monthValueArray[10] = "2011-10";
    monthTextArray[11] = "November-2011";
  monthValueArray[11] = "2011-11";
    monthTextArray[12] = "December-2011";
  monthValueArray[12] = "2011-12";
    monthTextArray[13] = "January-2012";
  monthValueArray[13] = "2012-01";
    monthTextArray[14] = "February-2012";
  monthValueArray[14] = "2012-02";
    monthTextArray[15] = "March-2012";
  monthValueArray[15] = "2012-03";
    monthTextArray[16] = "April-2012";
  monthValueArray[16] = "2012-04";
    monthTextArray[17] = "May-2012";
  monthValueArray[17] = "2012-05";
    monthTextArray[18] = "June-2012";
  monthValueArray[18] = "2012-06";
    monthTextArray[19] = "July-2012";
  monthValueArray[19] = "2012-07";
    
	  monthMapArray[0]= new Array("2050","2011-05","2011-06","2011-07","2011-08","2011-09"); 
	  monthMapArray[1]= new Array("1704","2011-02","2011-03"); 
	  monthMapArray[2]= new Array("89","2010-12","2011-01","2011-02","2011-03","2011-04"); 
	  monthMapArray[3]= new Array("1295","2010-12","2011-01","2011-02","2011-03","2011-04","2011-05","2011-06","2011-07","2011-08","2011-09","2011-10","2011-11","2011-12","2012-01","2012-02","2012-03"); 
	  monthMapArray[4]= new Array("1035","2011-04","2011-05","2011-06","2011-07","2011-08","2011-09","2011-10"); 
	  monthMapArray[5]= new Array("1294",""); 
	  monthMapArray[6]= new Array("24","2010-12","2011-01","2011-02","2011-03","2011-04","2011-05","2011-06","2011-07","2011-08","2011-09","2011-10","2011-11","2011-12","2012-01","2012-02","2012-03"); 
	  monthMapArray[7]= new Array("23","2011-02","2011-03","2011-04","2011-05","2011-06","2011-07","2011-08","2011-09","2011-10"); 
	  monthMapArray[8]= new Array("26","2010-12","2011-01","2011-02","2011-03","2011-04","2011-05","2011-06","2011-07","2011-08","2011-09","2011-10","2011-11","2011-12","2012-01"); 
	  monthMapArray[9]= new Array("7","2010-12","2011-01","2011-02","2011-03","2011-04","2011-07","2011-10","2011-11","2012-03"); 
	  monthMapArray[10]= new Array("1977","2011-07"); 
	  monthMapArray[11]= new Array("2017","2011-01"); 
	  monthMapArray[12]= new Array("240","2010-12","2011-01","2011-02","2011-03","2011-04"); 
	  monthMapArray[13]= new Array("1296",""); 
	  monthMapArray[14]= new Array("579",""); 
	  monthMapArray[15]= new Array("1896","2011-05"); 
	  monthMapArray[16]= new Array("2047",""); 
	    a_cruLenAssignment['2050'] = ['7','6'];		 
		
	    a_cruLenAssignment['1704'] = ['24','15'];		 
		
	    a_cruLenAssignment['89'] = ['35','2'];		 
		
	    a_cruLenAssignment['1295'] = ['7','3'];		 
		
	    a_cruLenAssignment['1035'] = ['7','6'];		 
		
	    a_cruLenAssignment['1294'] = ['',''];		 
		
	    a_cruLenAssignment['24'] = ['21','4'];		 
		
	    a_cruLenAssignment['23'] = ['21','7'];		 
		
	    a_cruLenAssignment['26'] = ['14','7'];		 
		
	    a_cruLenAssignment['7'] = ['30','3'];		 
		
	    a_cruLenAssignment['1977'] = ['4','4'];		 
		
	    a_cruLenAssignment['2017'] = ['1','1'];		 
		
	    a_cruLenAssignment['240'] = ['18','10'];		 
		
	    a_cruLenAssignment['1296'] = ['',''];		 
		
	    a_cruLenAssignment['579'] = ['',''];		 
		
	    a_cruLenAssignment['1896'] = ['7','1'];		 
		
	    a_cruLenAssignment['2047'] = ['',''];		 
		 var monthDefaultOption = new Option();
  monthDefaultOption.text = "Select Month";
  monthDefaultOption.value = "";
  theForm.fromMonthYear.options[0] = monthDefaultOption;
  var destinationId = theForm.geographicRegion.options[theForm.geographicRegion.selectedIndex].value;
  if (destinationId != "") {  
    updateOptions( destinationId, monthMapArray, monthTextArray, monthValueArray, theForm.fromMonthYear );
  } else {
    populateDefaultOptions( monthValueArray, monthTextArray, theForm.fromMonthYear);
  }
  populateCruLengthOpt(destinationId);
}
function updateOptions( destinationId, mapArray, textArray, valueArray, selectElement)
{
    var optionIndex = 0;
    for (i=0;i<mapArray.length;i++) {
	    if (destinationId == mapArray[i][0]) {
        for (j=1; j< mapArray[i].length; j++) {
          optionObject = new Option();
          optionObject.value = mapArray[i][j];
          optionObject.text = '';
          for (k=0; k < valueArray.length; k++) {
            if (valueArray[k] == optionObject.value) {
              optionObject.text = textArray[k];
              break;
            }
          }
		  if (optionObject.text == '') {
		    continue;
		  }
          selectElement.options[++optionIndex] = optionObject;
        }
      }
    }
    optionIndex++;
    finalOptionIndex = optionIndex;
    while (optionIndex  <= valueArray.length) {
      selectElement.options[finalOptionIndex] = null;
      optionIndex++;
    }
}

function populateDefaultOptions (valueArray, textArray, selectElement)
{
    var optionIndex = 0;
    for (i = 1; i < textArray.length; i++) {
      if (textArray[i] != null) {
        option = new Option();
        option.value = valueArray[i];
        option.text = textArray[i];
        selectElement.options[++optionIndex] = option;
      }
    }
}
function populateCruLengthOpt (s_destId) {
 var a_fieldVals = new Array; var a_fieldTxt = new Array; var s_showOptions; var s_maxCruLen; var s_minCruLen; var j = 1;
 var a_fieldVals = ['1-2','3-6','7-9','10-14','14-']; 
 var a_fieldTxt = ['1-2 Nights','3-6 Nights','7-9 Nights','10-14 Nights','Over 14 Nights']; 
 if(s_destId) {
	 s_maxCruLen = "a_cruLenAssignment['"+s_destId+"'][0]";
	 s_maxCruLen = eval(s_maxCruLen); 
	 s_minCruLen = "a_cruLenAssignment['"+s_destId+"'][1]";
	 s_minCruLen = eval(s_minCruLen); 	 
	 s_maxCruLen = (findOptSegment(s_maxCruLen)-1);
	 s_minCruLen = (findOptSegment(s_minCruLen)-1);
 } else {
     s_minCruLen = '0'; 
     s_maxCruLen = '4'; 
 }
 	 document.getElementById('cruiseLength').options.length = 0;	 
	 document.getElementById('cruiseLength').options[0] = new Option('Any Length','');
	 for (i=s_minCruLen; i <= (s_maxCruLen); i++) {
	    //alert(a_fieldVals[i]+'-'+a_fieldTxt[i]);
		option = new Option();
        option.value = a_fieldVals[i];
        option.text = a_fieldTxt[i];        
        document.getElementById('cruiseLength').options[j] = option;
		j++;		   
	 } 
}
function findOptSegment (s_cruLen) {
      var s_showOptSegment;
      if (s_cruLen <= 2) {
	    s_showOptSegment = '1'
	  } else if (s_cruLen >= 3 && s_cruLen <= 6) {
	    s_showOptSegment = '2'
	  } else if (s_cruLen >= 7 && s_cruLen <= 9) {
	    s_showOptSegment = '3'
	  } else if (s_cruLen >= 10 && s_cruLen <= 14) {
	    s_showOptSegment = '4'
	  } else {
	    s_showOptSegment = '5'
	  } 
	  return s_showOptSegment;
}
function specRates(e,cbxMode,dep) {
  eL = document.getElementById(e);
   switch(cbxMode) {
      case "sp1":
	  if (eL.checked || eL.checked == "checked") {
		  noneBlock('cb_resSt!1');
	  } else {
		  noneBlock('cb_resSt!0','prevCruise!0');
		  if(dep) {
		  cbxdep = dep.split("!");
			  for (i=0;i < cbxdep.length;i++) {
			  document.getElementById(cbxdep[i]).checked = false;
			  }
		  }
		  document.getElementById('resSt').options.selectedIndex = "0";
		  prevCruiseCk = document.getElementById('prevCruise').getElementsByTagName("input");
		  for (j=0;j < prevCruiseCk.length;j++) {
		  if (prevCruiseCk[j].name == "ppV"){prevCruiseCk[j].checked = false;}
		  }
	  }
	  break;
	  case "sp2":
     if (eL.checked || eL.checked == "checked") {
		  noneBlock('prevCruise!1');
	  } else {
		  noneBlock('prevCruise!0');
		  prevCruiseCk = document.getElementById('prevCruise').getElementsByTagName("input");
		  for (j=0;j < prevCruiseCk.length;j++) {
		  if (prevCruiseCk[j].name == "ppV"){prevCruiseCk[j].checked = false;}
		  }
	  }
	  break;
   }
}
var destSelectList = '  <option value="2050">&#187;&nbsp;Alaska</option>  <option value="1704">&#187;&nbsp;Asia</option>  <option value="89">&#187;&nbsp;Australia/New Zealand</option>  <option value="1295">Bahamas</option>  <option value="1035">Bermuda</option>  <option value="24">Caribbean - All</option>  <option value="23">Europe - All</option>  <option value="26">Hawaii</option>  <option value="7">Mexico - All</option>  <option value="1977">Gulf of Mexico</option>  <option value="2017">Nowhere</option>  <option value="240">Panama Canal</option>  <option value="1896">U.S. Pacific Coast</option>';
//var monthSelectList = '<option value="2010-12">December-2010</option><option value="2011-01">January-2011</option><option value="2011-02">February-2011</option><option value="2011-03">March-2011</option><option value="2011-04">April-2011</option><option value="2011-05">May-2011</option><option value="2011-06">June-2011</option><option value="2011-07">July-2011</option><option value="2011-08">August-2011</option><option value="2011-09">September-2011</option><option value="2011-10">October-2011</option><option value="2011-11">November-2011</option><option value="2011-12">December-2011</option><option value="2012-01">January-2012</option><option value="2012-02">February-2012</option><option value="2012-03">March-2012</option><option value="2012-04">April-2012</option><option value="2012-05">May-2012</option><option value="2012-06">June-2012</option><option value="2012-07">July-2012</option>';


var monthSelectList = getMonthList();

function getMonthList()
{
	var strMonthArr = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	var strMonths = "";
	var  d = new Date();
	var year = d.getFullYear();
	var month = d.getMonth();	
for(var i=1;i<25;i++)
	{


		if(month == 11)
		{
			strMonths += '<option value="' + year + '-' + (parseInt(month)+ 1) +  '">' + strMonthArr[month] + ' ' + year + '</option>'
			year++;
			month = 0;
		}
		else
		{
			strMonths += '<option value="' + year + '-' + (parseInt(month)+ 1) + '">' + strMonthArr[month] + ' ' + year + '</option>'
month++;
		}
		
		
	}
	return strMonths;
}



 var sList ="opt_Azamara Club Cruises_opt!223|Azamara Journey!251|Azamara Questopt_Carnival Cruise Lines_opt!146|Carnival Conquest <font color='#C81D00'>- Refurbished!</font>!11|Carnival Destiny <font color='#C81D00'>- Refurbished!</font>!260|Carnival Dream <font color='#C81D00'>- New!</font>!3|Carnival Ecstasy!7|Carnival Elation!4|Carnival Fantasy <font color='#C81D00'>- Refurbished!</font>!1|Carnival Fascination!217|Carnival Freedom!168|Carnival Glory!6|Carnival Imagination!25|Carnival Inspiration!151|Carnival Legend!200|Carnival Liberty!275|Carnival Magic <font color='#C81D00'>- New!</font>!182|Carnival Miracle!8|Carnival Paradise!145|Carnival Pride!27|Carnival Sensation!106|Carnival Spirit!254|Carnival Splendor!82|Carnival Triumph!190|Carnival Valor!81|Carnival Victory opt_Celebrity Cruises_opt!264|Celebrity Eclipse <font color='#C81D00'>- New!</font>!259|Celebrity Equinox <font color='#C81D00'>- New!</font>!283|Celebrity Silhouette <font color='#C81D00'>- New!</font>!255|Celebrity Solstice <font color='#C81D00'>- Editor's Favorite!</font>!187|Celebrity Xpedition!62|Century!148|Constellation!118|Infinity!9|Mercury!80|Millennium!117|Summitopt_Costa Cruises_opt!222|Costa Allegra!225|Costa Atlantica!226|Costa Classica!227|Costa Concordia!272|Costa Deliziosa <font color='#C81D00'>- New!</font>!282|Costa Favolosa <font color='#C81D00'>- New!</font>!229|Costa Fortuna!271|Costa Luminosa <font color='#C81D00'>- New!</font>!224|Costa Magica!230|Costa Marina!231|Costa Mediterranea!273|Costa Pacifica <font color='#C81D00'>- New!</font>!232|Costa Romantica!250|Costa Serena!249|Costa Victoriaopt_Crystal Cruises_opt!154|Crystal Harmony!167|Crystal Serenity!155|Crystal Symphonyopt_Cunard_opt!274|Queen Elizabeth!236|Queen Mary 2!235|Queen Victoriaopt_Disney Cruise Line_opt!270|Disney Dream&#174<font color='#C81D00'>- New!</font>!285|Disney Fantasy&#174<font color='#C81D00'>- New!</font>!74|Disney Magic!73|Disney Wonder&#174opt_Holland America Line_opt!84|Amsterdam!253|Eurodam!47|Maasdam!269|Nieuw Amsterdam <font color='#C81D00'>- New!</font>!213|Noordam!169|Oosterdam!150|Prinsendam!49|Rotterdam!51|Ryndam <font color='#C81D00'>- Refurbished!</font>!50|Statendam <font color='#C81D00'>- Refurbished!</font>!34|Veendam <font color='#C81D00'>- Refurbished!</font>!85|Volendam!178|Westerdam!86|Zaandam!153|Zuiderdam <font color='#C81D00'>- Refurbished!</font>opt_MSC Cruises_opt!243|Armonia!267|Fantasia <font color='#C81D00'>- New!</font>!208|Lirica!263|Magnifica <font color='#C81D00'>- New!</font>!244|Melody!246|Musica!209|Opera!252|Orchestra!262|Poesia <font color='#C81D00'>- New!</font>!248|Sinfonia!268|Splendida <font color='#C81D00'>- New!</font>opt_Norwegian Cruise Line_opt!156|Norwegian Dawn!265|Norwegian Epic <font color='#C81D00'>- New!</font>!221|Norwegian Gem!257|Norwegian Jade <font color='#C81D00'>- Refurbished!</font>!202|Norwegian Jewel!218|Norwegian Pearl!176|Norwegian Sky <font color='#C81D00'>- Refurbished!</font>!186|Norwegian Spirit!129|Norwegian Star!119|Norwegian Sun!181|Pride of Americaopt_Oceania Cruises_opt!206|Insignia!276|Marina <font color='#C81D00'>- New!</font>!207|Nautica <font color='#C81D00'>- Refurbished!</font>!205|Regattaopt_Orient Lines_opt!211|Marco Poloopt_Paul Gauguin Cruises_opt!159|Paul Gauguin <font color='#C81D00'>- Refurbished!</font>opt_Princess Cruises_opt!185|Caribbean Princess <font color='#C81D00'>- Refurbished!</font>!152|Coral Princess!212|Crown Princess !99|Dawn Princess!170|Diamond Princess!219|Emerald Princess !113|Golden Princess <font color='#C81D00'>- Refurbished!</font>!103|Grand Princess!166|Island Princess!97|Ocean Princess <font color='#C81D00'>- Refurbished!</font>!41|Pacific Princess!216|Royal Princess!258|Ruby Princess<font color='#C81D00'>- New!</font>!171|Sapphire Princess!94|Sea Princess!132|Star Princess <font color='#C81D00'>- Refurbished!</font>!95|Sun Princessopt_Regent Seven Seas Cruises_opt!162|Seven Seas Mariner <font color='#C81D00'>- Refurbished!</font>!158|Seven Seas Navigator <font color='#C81D00'>- Refurbished!</font>!161|Seven Seas Voyager <font color='#C81D00'>- Refurbished!</font>opt_Royal Caribbean Int'l_opt!115|Adventure of the Seas!266|Allure of the Seas <font color='#C81D00'>- New!</font>!149|Brilliance of the Seas!23|Enchantment of the Seas!105|Explorer of the Seas!204|Freedom of the Seas!22|Grandeur of the Seas!256|Independence of the Seas <font color='#C81D00'>- New!</font>!180|Jewel of the Seas!78|Legend of the Seas!220|Liberty of the Seas!18|Majesty of the Seas!174|Mariner of the Seas!19|Monarch of the Seas!165|Navigator of the Seas!261|Oasis of the Seas <font color='#C81D00'>- New!</font>!116|Radiance of the Seas!20|Rhapsody of the Seas!173|Serenade of the Seas!63|Splendour of the Seas!17|Vision of the Seas!79|Voyager of the Seasopt_Yachts of Seabourn_opt!278|Seabourn Legend!279|Seabourn Odyssey!280|Seabourn Pride!284|Seabourn Quest!277|Seabourn Sojourn!281|Seabourn Spirit";
function doShipSel(sId){
	sopt = sList.split("opt_");
	defOpt = '0';
	document.getElementById(sId).innerHTML = '';
	defVal = doShipSel.arguments[1];
	for(i=0;i<sopt.length;i++){
		if(sopt[i]!=''){
			if(defOpt=='0' && defVal){
				dopt = document.createElement("option");
				dopt.innerHTML = defVal;
				document.getElementById(sId).appendChild(dopt);
				defOpt = '1';
			}
			soptVars = sopt[i].split("_opt");
			vName = soptVars[0];
			nOpt = document.createElement("optgroup");
			nOpt.label = vName;
			sNames = soptVars[1];
			shVars = sNames.split("!");
			for(j=0;j<shVars.length;j++){
			    if(shVars[j]!=''){
				shipVars = shVars[j].split("|");
				sNum = shipVars[0];
				sName = shipVars[1];
				nOp = document.createElement("option");
				nOp.value = "ship_"+sNum;
				nOp.innerHTML = sName;
				nOpt.appendChild(nOp);
				}
			}
			document.getElementById(sId).appendChild(nOpt);
		}
	}
}
var vList ="57|Azamara Club Cruises!9|Carnival Cruise Lines!14|Celebrity Cruises!52|Costa Cruises!24|Disney Cruise Line!15|Holland America Line!51|MSC Cruises!7|Norwegian Cruise Line!48|Oceania Cruises!28|Princess Cruises!46|Regent Seven Seas Cruises!5|Royal Caribbean Int'l!";
function doVendorSel(sId){
   defOpt = '0';
   defVal = doVendorSel.arguments[1];
   oSel = document.getElementById(sId);
   oSel.innerHTML = '';
   vopt = vList.split("!");
   for(i=0;i<vopt.length;i++){
		if(defOpt=='0' && defVal){
			dopt = document.createElement("option");
			dopt.value = "";
			dopt.innerHTML = defVal;
			document.getElementById(sId).appendChild(dopt);
			defOpt = '1';
		}
       if(vopt[i]!=''){
			nOpt = document.createElement("option");
			vopts = vopt[i].split("|");
			optVal = vopts[0];
			optName = vopts[1];
			nOpt.value = optVal;
			nOpt.innerHTML = optName;
			oSel.appendChild(nOpt);
	    }
   }
}

