
var a_cruLenAssignment = new Array;
function changeMapping(theForm) {
  var monthMapArray = new Array(18);
  var monthTextArray = new Array(28);
  var monthValueArray = new Array(28);  
    monthTextArray[0] = "June-2009";
  monthValueArray[0] = "2009-06";
    monthTextArray[1] = "July-2009";
  monthValueArray[1] = "2009-07";
    monthTextArray[2] = "August-2009";
  monthValueArray[2] = "2009-08";
    monthTextArray[3] = "September-2009";
  monthValueArray[3] = "2009-09";
    monthTextArray[4] = "October-2009";
  monthValueArray[4] = "2009-10";
    monthTextArray[5] = "November-2009";
  monthValueArray[5] = "2009-11";
    monthTextArray[6] = "December-2009";
  monthValueArray[6] = "2009-12";
    monthTextArray[7] = "January-2010";
  monthValueArray[7] = "2010-01";
    monthTextArray[8] = "February-2010";
  monthValueArray[8] = "2010-02";
    monthTextArray[9] = "March-2010";
  monthValueArray[9] = "2010-03";
    monthTextArray[10] = "April-2010";
  monthValueArray[10] = "2010-04";
    monthTextArray[11] = "May-2010";
  monthValueArray[11] = "2010-05";
    monthTextArray[12] = "June-2010";
  monthValueArray[12] = "2010-06";
    monthTextArray[13] = "July-2010";
  monthValueArray[13] = "2010-07";
    monthTextArray[14] = "August-2010";
  monthValueArray[14] = "2010-08";
    monthTextArray[15] = "September-2010";
  monthValueArray[15] = "2010-09";
    monthTextArray[16] = "October-2010";
  monthValueArray[16] = "2010-10";
    monthTextArray[17] = "November-2010";
  monthValueArray[17] = "2010-11";
    monthTextArray[18] = "December-2010";
  monthValueArray[18] = "2010-12";
    monthTextArray[19] = "January-2011";
  monthValueArray[19] = "2011-01";
    
	  monthMapArray[0]= new Array("1201","2009-09"); 
	  monthMapArray[1]= new Array("2050","2009-07","2009-08","2009-09","2010-05","2010-06","2010-07","2010-08","2010-09"); 
	  monthMapArray[2]= new Array("1704","2009-07","2009-09","2009-10","2009-11","2009-12","2010-01","2010-02","2010-03","2010-04","2011-01","2011-02"); 
	  monthMapArray[3]= new Array("89","2009-08","2009-10","2009-11","2009-12","2010-01","2010-02","2010-03","2010-04","2010-10","2010-11","2010-12","2011-01","2011-02","2011-03","2011-04"); 
	  monthMapArray[4]= new Array("1295","2009-07","2009-08","2009-09","2009-10","2009-11","2009-12","2010-01","2010-02","2010-03","2010-04","2010-05","2010-06","2010-07","2010-08","2010-09","2010-10","2010-11","2010-12","2011-01","2011-02","2011-03","2011-04"); 
	  monthMapArray[5]= new Array("1035","2009-07","2009-08","2009-09","2009-10","2009-11","2010-04","2010-05","2010-06","2010-07","2010-08","2010-09","2010-10","2010-11","2011-04"); 
	  monthMapArray[6]= new Array("1294","2009-07","2009-08","2009-09","2009-10","2010-06","2010-07","2010-08","2010-09","2010-10"); 
	  monthMapArray[7]= new Array("24","2009-07","2009-08","2009-09","2009-10","2009-11","2009-12","2010-01","2010-02","2010-03","2010-04","2010-05","2010-06","2010-07","2010-08","2010-09","2010-10","2010-11","2010-12","2011-01","2011-02","2011-03","2011-04","2011-05","2011-06"); 
	  monthMapArray[8]= new Array("23","2009-07","2009-08","2009-09","2009-10","2009-11","2009-12","2010-01","2010-02","2010-03","2010-04","2010-05","2010-06","2010-07","2010-08","2010-09","2010-10","2010-11","2010-12","2011-01","2011-02","2011-03","2011-04"); 
	  monthMapArray[9]= new Array("26","2009-07","2009-08","2009-09","2009-10","2009-11","2009-12","2010-01","2010-02","2010-03","2010-04","2010-05","2010-06","2010-07","2010-08","2010-09","2010-10","2010-11","2010-12","2011-01","2011-02","2011-03","2011-04","2011-05","2011-06"); 
	  monthMapArray[10]= new Array("7","2009-07","2009-08","2009-09","2009-10","2009-11","2009-12","2010-01","2010-02","2010-03","2010-04","2010-05","2010-06","2010-07","2010-08","2010-09","2010-10","2010-11","2010-12","2011-01","2011-02","2011-03","2011-04"); 
	  monthMapArray[11]= new Array("1977",""); 
	  monthMapArray[12]= new Array("2017","2009-09","2009-10","2009-11","2010-01","2010-09","2010-10","2011-01","2011-02"); 
	  monthMapArray[13]= new Array("240","2009-09","2009-10","2009-11","2009-12","2010-01","2010-02","2010-03","2010-04","2010-05","2010-09","2010-10","2010-11","2010-12","2011-01","2011-02","2011-03","2011-04","2011-05"); 
	  monthMapArray[14]= new Array("1296","2009-07","2009-08","2009-10","2009-11","2009-12","2010-01","2010-02","2010-03","2010-04","2010-05","2010-06","2010-07","2010-08","2010-09","2010-10","2010-11","2010-12","2011-01","2011-02","2011-03","2011-04"); 
	  monthMapArray[15]= new Array("579","2009-08","2009-09","2009-10","2009-11","2009-12","2010-04"); 
	  monthMapArray[16]= new Array("1896","2009-09","2009-10","2010-04","2010-05","2010-09","2010-10","2011-05"); 
	  monthMapArray[17]= new Array("2047","2009-08","2009-09","2009-10","2009-11","2009-12","2010-01","2010-02","2010-03","2010-04"); 
	    a_cruLenAssignment['1201'] = ['31','31'];		 
		
	    a_cruLenAssignment['2050'] = ['14','4'];		 
		
	    a_cruLenAssignment['1704'] = ['47','3'];		 
		
	    a_cruLenAssignment['89'] = ['35','2'];		 
		
	    a_cruLenAssignment['1295'] = ['9','2'];		 
		
	    a_cruLenAssignment['1035'] = ['9','5'];		 
		
	    a_cruLenAssignment['1294'] = ['15','4'];		 
		
	    a_cruLenAssignment['24'] = ['20','3'];		 
		
	    a_cruLenAssignment['23'] = ['33','2'];		 
		
	    a_cruLenAssignment['26'] = ['21','7'];		 
		
	    a_cruLenAssignment['7'] = ['13','3'];		 
		
	    a_cruLenAssignment['1977'] = ['',''];		 
		
	    a_cruLenAssignment['2017'] = ['2','1'];		 
		
	    a_cruLenAssignment['240'] = ['28','9'];		 
		
	    a_cruLenAssignment['1296'] = ['32','3'];		 
		
	    a_cruLenAssignment['579'] = ['17','7'];		 
		
	    a_cruLenAssignment['1896'] = ['12','1'];		 
		
	    a_cruLenAssignment['2047'] = ['49','14'];		 
		 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="1201">Africa/India</option>  <option value="2050">&#187;&nbsp;Alaska</option>  <option value="1704">Asia</option>  <option value="89">Australia/New Zealand</option>  <option value="1295">Bahamas</option>  <option value="1035">Bermuda</option>  <option value="1294">Canada/New England</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="2017">Nowhere</option>  <option value="240">Panama Canal</option>  <option value="1296">South America</option>  <option value="579">Tahiti</option>  <option value="1896">U.S. Pacific Coast</option>  <option value="2047">World</option>';
var monthSelectList = '<option value="2009-06">June-2009</option><option value="2009-07">July-2009</option><option value="2009-08">August-2009</option><option value="2009-09">September-2009</option><option value="2009-10">October-2009</option><option value="2009-11">November-2009</option><option value="2009-12">December-2009</option><option value="2010-01">January-2010</option><option value="2010-02">February-2010</option><option value="2010-03">March-2010</option><option value="2010-04">April-2010</option><option value="2010-05">May-2010</option><option value="2010-06">June-2010</option><option value="2010-07">July-2010</option><option value="2010-08">August-2010</option><option value="2010-09">September-2010</option><option value="2010-10">October-2010</option><option value="2010-11">November-2010</option><option value="2010-12">December-2010</option><option value="2011-01">January-2011</option>';

 var sList ="opt_Azamara Cruises_opt!223|Azamara Journey !251|Azamara Quest <font color='#C81D00'>- New!</font>opt_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 <font color='#C81D00'>- New!</font>!168|Carnival Glory!2|Carnival Holiday!6|Carnival Imagination <font color='#C81D00'>- Refurbished!</font>!25|Carnival Inspiration <font color='#C81D00'>- Refurbished!</font>!151|Carnival Legend!200|Carnival Liberty!182|Carnival Miracle!8|Carnival Paradise!145|Carnival Pride!27|Carnival Sensation!106|Carnival Spirit!254|Carnival Splendor <font color='#C81D00'>- New!</font>!82|Carnival Triumph!190|Carnival Valor <font color='#C81D00'>- Refurbished!</font>!81|Carnival Victory <font color='#C81D00'>- Refurbished!</font>opt_Celebrity Cruises_opt!264|Celebrity Eclipse <font color='#C81D00'>- New!</font>!259|Celebrity Equinox <font color='#C81D00'>- New!</font>!255|Celebrity Solstice <font color='#C81D00'>- New!</font>!187|Celebrity Xpedition!62|Century!148|Constellation!118|Infinity!9|Mercury!80|Millennium!117|Summit <font color='#C81D00'>- Refurbished!</font>opt_Disney Cruise Line_opt!74|Disney Magic&#174 <font color='#C81D00'>- Refurbished!</font>!73|Disney Wonder&#174opt_Holland America Line_opt!84|Amsterdam!253|Eurodam <font color='#C81D00'>- New!</font>!47|Maasdam!269|Nieuw Amsterdam <font color='#C81D00'>- New!</font>!213|Noordam!169|Oosterdam!150|Prinsendam!49|Rotterdam!51|Ryndam!50|Statendam!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!208|Lirica!263|Magnifica!244|Melody!209|Opera!252|Orchestra!262|Poesia!248|Sinfoniaopt_Norwegian Cruise Line_opt!156|Norwegian Dawn!265|Norwegian Epic <font color='#C81D00'>- New!</font>!221|Norwegian Gem <font color='#C81D00'>- New!</font>!257|Norwegian Jade <font color='#C81D00'>- Refurbished!</font>!202|Norwegian Jewel!15|Norwegian Majesty!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!207|Nautica <font color='#C81D00'>- Refurbished!</font>!205|Regattaopt_Orient Lines_opt!211|Marco Poloopt_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 <font color='#C81D00'>- New!</font>!113|Golden Princess!103|Grand Princess!166|Island Princess!97|Ocean Princess!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 Princess!64|Tahitian Princessopt_Regent Seven Seas Cruises_opt!159|Paul Gauguin <font color='#C81D00'>- Refurbished!</font>!162|Seven Seas Mariner <font color='#C81D00'>- Refurbished!</font>!158|Seven Seas Navigator !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 <font color='#C81D00'>- Refurbished!</font>!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 Seas";
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 Cruises!9|Carnival Cruise Lines!14|Celebrity 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);
	    }
   }
}
