﻿var arrDList = new Array();
var arrDL1 = new Array();

arrDL1[1] = "";		        // Name of parent list box
arrDL1[2] = "aspnetForm";		// Name of form containing parent list box
arrDL1[3] = "select2";		// Name of child list box
arrDL1[4] = "aspnetForm";		// Name of form containing child list box
arrDL1[5] = arrDList;	    // No need to do anything here  

 arrDList[0] = "10"
 arrDList[1] = "Adelaide"
 arrDList[2] = "45"

 arrDList[3] = "1"
 arrDList[4] = "Athens"
 arrDList[5] = "2"

 arrDList[6] = "11"
 arrDList[7] = "Auckland"
 arrDList[8] = "79"

 arrDList[9] = "10"
 arrDList[10] = "Aus. Multistop"
 arrDList[11] = "76"

 arrDList[12] = "9"
 arrDList[13] = "Bali (Denpasar)"
 arrDList[14] = "37"

 arrDList[15] = "8"
 arrDList[16] = "Bangkok"
 arrDList[17] = "28"

 arrDList[18] = "7"
 arrDList[19] = "Beijing"
 arrDList[20] = "26"

 arrDList[21] = "13"
 arrDList[22] = "Bogota"
 arrDList[23] = "61"

 arrDList[24] = "6"
 arrDList[25] = "Bombay (Mumbai)"
 arrDList[26] = "20"

 arrDList[27] = "14"
 arrDList[28] = "Bridgetown"
 arrDList[29] = "68"

 arrDList[30] = "10"
 arrDList[31] = "Brisbane"
 arrDList[32] = "42"

 arrDList[33] = "8"
 arrDList[34] = "Brunei"
 arrDList[35] = "36"

 arrDList[36] = "13"
 arrDList[37] = "Buenos Aires"
 arrDList[38] = "56"

 arrDList[39] = "10"
 arrDList[40] = "Cairns"
 arrDList[41] = "78"

 arrDList[42] = "4"
 arrDList[43] = "Cairo"
 arrDList[44] = "15"

 arrDList[45] = "6"
 arrDList[46] = "Calcutta"
 arrDList[47] = "21"

 arrDList[48] = "14"
 arrDList[49] = "Cancun"
 arrDList[50] = "65"

 arrDList[51] = "3"
 arrDList[52] = "Cape Town"
 arrDList[53] = "11"

 arrDList[54] = "13"
 arrDList[55] = "Caracas"
 arrDList[56] = "62"

 arrDList[57] = "11"
 arrDList[58] = "Christchurch"
 arrDList[59] = "79"

 arrDList[60] = "6"
 arrDList[61] = "Colombo"
 arrDList[62] = "22"

 arrDList[63] = "12"
 arrDList[64] = "Cook Is. (Raratonga)"
 arrDList[65] = "51"

 arrDList[66] = "3"
 arrDList[67] = "Dar es Salaam"
 arrDList[68] = "8"

 arrDList[69] = "10"
 arrDList[70] = "Darwin"
 arrDList[71] = "40"

 arrDList[72] = "6"
 arrDList[73] = "Delhi"
 arrDList[74] = "19"

 arrDList[75] = "4"
 arrDList[76] = "Dubai"
 arrDList[77] = "17"

 arrDList[78] = "12"
 arrDList[79] = "Fiji (Nadi)"
 arrDList[80] = "50"

 arrDList[81] = "14"
 arrDList[82] = "Guatemala City"
 arrDList[83] = "66"

 arrDList[84] = "8"
 arrDList[85] = "Hanoi"
 arrDList[86] = "32"

 arrDList[87] = "3"
 arrDList[88] = "Harare"
 arrDList[89] = "5"

 arrDList[90] = "12"
 arrDList[91] = "Hawaii"
 arrDList[92] = "55"

 arrDList[93] = "7"
 arrDList[94] = "Hong Kong"
 arrDList[95] = "27"

 arrDList[96] = "3"
 arrDList[97] = "Johannesburg"
 arrDList[98] = "10"

 arrDList[99] = "6"
 arrDList[100] = "Kathmandu"
 arrDList[101] = "24"

 arrDList[102] = "13"
 arrDList[103] = "La Paz"
 arrDList[104] = "63"

 arrDList[105] = "13"
 arrDList[106] = "Lima"
 arrDList[107] = "58"

 arrDList[108] = "15"
 arrDList[109] = "Los Angeles"
 arrDList[110] = "70"

 arrDList[111] = "8"
 arrDList[112] = "Manila"
 arrDList[113] = "33"

 arrDList[114] = "9"
 arrDList[115] = "Medan"
 arrDList[116] = "39"

 arrDList[117] = "10"
 arrDList[118] = "Melbourne"
 arrDList[119] = "78"

 arrDList[120] = "14"
 arrDList[121] = "Mexico City"
 arrDList[122] = "64"

 arrDList[123] = "14"
 arrDList[124] = "Montego Bay"
 arrDList[125] = "69"

 arrDList[126] = "1"
 arrDList[127] = "Moscow"
 arrDList[128] = "1"

 arrDList[129] = "3"
 arrDList[130] = "Nairobi"
 arrDList[131] = "6"

 arrDList[132] = "10"
 arrDList[133] = "Perth"
 arrDList[134] = "78"

 arrDList[135] = "13"
 arrDList[136] = "Quito"
 arrDList[137] = "59"

 arrDList[138] = "13"
 arrDList[139] = "Rio de Janeiro"
 arrDList[140] = "60"

 arrDList[141] = "8"
 arrDList[142] = "Saigon"
 arrDList[143] = "31"

 arrDList[144] = "14"
 arrDList[145] = "San Jose"
 arrDList[146] = "67"

 arrDList[147] = "13"
 arrDList[148] = "Santiago"
 arrDList[149] = "57"

 arrDList[150] = "8"
 arrDList[151] = "Singapore"
 arrDList[152] = "30"

 arrDList[153] = "10"
 arrDList[154] = "Sydney"
 arrDList[155] = "78"

 arrDList[156] = "12"
 arrDList[157] = "Tahiti (Papeete)"
 arrDList[158] = "54"

 arrDList[159] = "7"
 arrDList[160] = "Tokyo"
 arrDList[161] = "25"

 arrDList[162] = "12"
 arrDList[163] = "Tonga"
 arrDList[164] = "52"

 arrDList[165] = "15"
 arrDList[166] = "U. S. Single"
 arrDList[167] = "73"

 arrDList[168] = "1"
 arrDList[169] = "U.K."
 arrDList[170] = "75"

 arrDList[171] = "15"
 arrDList[172] = "U.S. Multistop"
 arrDList[173] = "72"

 arrDList[174] = "15"
 arrDList[175] = "Vancouver"
 arrDList[176] = "71"

 arrDList[177] = "3"
 arrDList[178] = "Victoria Falls"
 arrDList[179] = "7"

 arrDList[180] = "12"
 arrDList[181] = "W.Somoa (Apia)"
 arrDList[182] = "53"

 arrDList[183] = "11"
 arrDList[184] = "Wellington"
 arrDList[185] = "79"

 arrDList[186] = "3"
 arrDList[187] = "Windhoek"
 arrDList[188] = "12"
 
 function HideAll(showLayer){
    MM_showHideLayers('Region1','','hide','Region2','','hide','Region3','','hide','Region4','','hide','Region5','','hide','Region6','','hide','Region7','','hide','Region8','','hide','Region9','','hide','Region10','','hide','Region11','','hide','Region12','','hide','Region12b','','hide','Region13','','hide','Region14','','hide','Region15','','hide');
    if (showLayer) {	
	    MM_showHideLayers(showLayer,'','show');
    }
}

function setDList(arrDL,theRegion){
 var oList2 = MM_findObj(arrDL[3]);
 var arrList = arrDL[5];
 clearDList(oList2);
 var zzz = MM_findObj('ctl00_cphMain_currentRegion');
 zzz.value = theRegion;
 MM_showHideLayers('formElements','','show');
 MM_showHideLayers('layerPlan','','hide');
 populateDList(oList2, theRegion, arrList);
 return true;
}
 
function clearDList(oList){
//oList = MM_findObj("select2");
 for (var i = oList.options.length; i >= 0; i--){
  oList.options[i] = null;
 }
 oList.selectedIndex = -1;
}
 
function populateDList(oList, nIndex, aArray){
oList = MM_findObj("select2");
oList[oList.length]= new Option("Any in Region",0);
 for (var i = 0; i < aArray.length; i= i + 3){
  if (aArray[i] == nIndex){
   oList.options[oList.options.length] = new Option(aArray[i + 1], aArray[i + 2]);
  }
 }
 if (oList.options.length == 1){
  oList.options[oList.options.length] = new Option(":: No SubCategories Available ::");
 }
 oList.selectedIndex = 0; 
  Fat.fade_element("ListBorder")
}
 
var selectNo = new Array();
var selectRegion = new Array();
var selectCount = 0;
var currentPlace;

function selectedPlace(zz)
{
	theSelectedPlace = ('layerSelected' + zz);
	DR_setTextOfLayer(theSelectedPlace,'','<span class="bodyWhite">' + currentPlace + '</span>');
	MM_showHideLayers(theSelectedPlace,'','show');
      //fade in new destination
     Fat.fade_element(theSelectedPlace)
}

function regionNames(ex)
{
  switch (ex)
  {
    case '1': { currentPlace = 'Any in region, Europe'; break }
    case '3': { currentPlace = 'Any in region, S.Africa'; break }
    case '4': { currentPlace = 'Any in region, M.East'; break }
    case '6': { currentPlace = 'Any in region, Indian.S.C.'; break }
    case '7': { currentPlace = 'Any in region, N.E.Asia'; break }
    case '8': { currentPlace = 'Any in region, S.E.Asia'; break }
    case '9': { currentPlace = 'Any in region, Indonesia'; break }
    case '10': { currentPlace = 'Any in region, Australia'; break }
    case '11': { currentPlace = 'Any in region, N.Z.'; break }
    case '12': { currentPlace = 'Any in region, P.Islands'; break }
    case '13': { currentPlace = 'Any in region, S.America'; break }
    case '14': { currentPlace = 'Any in region, C.America'; break }
    case '15': { currentPlace = 'Any in region, N.America'; break }
    default: { alert('Error - please refresh this page & try again: ' +ex); break }		
  }
}

function addDestination()
{
	var theForm = MM_findObj("aspnetForm");	
	selectCount += 1;
	currentPlace = (theForm.select2.options[theForm.select2.selectedIndex].value)
	selectNo[selectCount] = currentPlace;
	selectRegion[selectCount] = theForm.ctl00_cphMain_currentRegion.value;		
	theForm.ctl00_cphMain_hiddenCount.value = selectCount;
		
	if (currentPlace == 0) 
	{ // check to see if region name is required for "any in region"
	 	regionNames(selectRegion[selectCount]);
	} else 
	{
		currentPlace = theForm.select2.options[theForm.select2.selectedIndex].text;		
	}
	
	var writeHtml = true;
	for (var i = 1; i <= selectCount-1; i++)
	{
		if (selectNo[selectCount] == selectNo[i] && selectRegion[selectCount] == selectRegion[i] ) {
			alert('You have already chosen this destination, please try again')
				selectCount -= 1;
				writeHtml = false;
		}
	}
 	if (writeHtml == true) //update selected destinations in html
	{ 
		selectedPlace(selectCount,currentPlace) 
	} 
	theRegion = eval('theForm.ctl00_cphMain_r' + selectCount);
	theRegion.value = selectRegion[selectCount];
	theDest = eval('theForm.ctl00_cphMain_d' + selectCount);
	theDest.value = selectNo[selectCount];
	
	if (selectCount == 4) {
		MM_showHideLayers('submitSelection','','show')
		Fat.fade_element("submitSelection")
	} 
	if (selectCount == 6) { 
		submitform();
		Fat.fade_element("submitSelection")
	}
}

function DR_setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

function submitform() {
	//__doPostBack('ctl00$cphMain$LinkButton1','');
	document.aspnetForm.submit();
	
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}


// @name      The Fade Anything Technique
// @namespace http://www.axentric.com/aside/fat/
// @version   1.0-RC1
// @author    Adam Michela

var Fat = {
	make_hex : function (r,g,b) 
	{
		r = r.toString(16); if (r.length == 1) r = '0' + r;
		g = g.toString(16); if (g.length == 1) g = '0' + g;
		b = b.toString(16); if (b.length == 1) b = '0' + b;
		return "#" + r + g + b;
	},
	fade_all : function ()
	{
		var a = document.getElementsByTagName("*");
		for (var i = 0; i < a.length; i++) 
		{
			var o = a[i];
			var r = /fade-?(\w{3,6})?/.exec(o.className);
			if (r)
			{
				if (!r[1]) r[1] = "";
				if (o.id) Fat.fade_element(o.id,null,null,"#"+r[1]);
			}
		}
	},
	fade_element : function (id, fps, duration, from, to) 
	{
		if (!fps) fps = 30;
		if (!duration) duration = 3000;
		if (!from || from=="#") from = "#FFFF33";
		if (!to) to = this.get_bgcolor(id);
		
		var frames = Math.round(fps * (duration / 1000));
		var interval = duration / frames;
		var delay = interval;
		var frame = 0;
		
		if (from.length < 7) from += from.substr(1,3);
		if (to.length < 7) to += to.substr(1,3);
		
		var rf = parseInt(from.substr(1,2),16);
		var gf = parseInt(from.substr(3,2),16);
		var bf = parseInt(from.substr(5,2),16);
		var rt = parseInt(to.substr(1,2),16);
		var gt = parseInt(to.substr(3,2),16);
		var bt = parseInt(to.substr(5,2),16);
		
		var r,g,b,h;
		while (frame < frames)
		{
			r = Math.floor(rf * ((frames-frame)/frames) + rt * (frame/frames));
			g = Math.floor(gf * ((frames-frame)/frames) + gt * (frame/frames));
			b = Math.floor(bf * ((frames-frame)/frames) + bt * (frame/frames));
			h = this.make_hex(r,g,b);
		
			setTimeout("Fat.set_bgcolor('"+id+"','"+h+"')", delay);

			frame++;
			delay = interval * frame; 
		}
		setTimeout("Fat.set_bgcolor('"+id+"','"+to+"')", delay);
	},
	set_bgcolor : function (id, c)
	{
		var o = document.getElementById(id);
		o.style.backgroundColor = c;
	},
	get_bgcolor : function (id)
	{
		var o = document.getElementById(id);
		while(o)
		{
			var c;
			if (window.getComputedStyle) c = window.getComputedStyle(o,null).getPropertyValue("background-color");
			if (o.currentStyle) c = o.currentStyle.backgroundColor;
			if ((c != "" && c != "transparent") || o.tagName == "BODY") { break; }
			o = o.parentNode;
		}
		if (c == undefined || c == "" || c == "transparent") c = "#FFFFFF";
		var rgb = c.match(/rgb\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/);
		if (rgb) c = this.make_hex(parseInt(rgb[1]),parseInt(rgb[2]),parseInt(rgb[3]));
		return c;
	}
}

window.onload = function () 
	{
	Fat.fade_all();
	}