//===============================================================
// Put Allowed Countries into the hidden field
//===============================================================
function putAllowedCountries(){
if(document.getElementById("Countries_Allowed").value ==""){
document.getElementById("Countries_Allowed").value = document.getElementById("countries_list").value; }
else {
document.getElementById("Countries_Allowed").value = document.getElementById("Countries_Allowed").value+","+document.getElementById("countries_list").value;
}
}

//===============================================================
// Mark all selected items in the countries list
//===============================================================
function GetSelectedItem() {
len = document.getElementById("countries_list").length;
i = 0;
var chosen = "";
for (i = 0; i < len; i++) {
if (document.getElementById("countries_list")[i].selected) {
chosen += document.getElementById("countries_list")[i].value + ",";
}
}
document.getElementById("Countries_Allowed").value= chosen;
} 

//===============================================================
// Show selected Package duration
//===============================================================
function showPackageDays(num)
  {
  var theHtml= "";
  var tonum = 1;
    if(num > 0){
	        theHtml = "<table width='100%' border='0' cellspacing='0' cellpadding='3' align='center'>";
			var old_number = document.getElementById("iNum").value;
			var old_data = document.getElementById("tour_itinerary").value;

					var old_number = parseFloat(old_number);
					var num = parseFloat(num);
				
				if(old_number>num){
						old_number = num;
				}
					if(old_data!=""){
        			for(i=tonum;i<=old_number;i++){
						var prevValueDays = document.getElementById("day"+i).value;
						var prevValueDesc = document.getElementById("day"+i+"_desc").value;
						var expectedValueDesc = "Day "+i+" Description";

theHtml += "<tr><td colspan='2'><input type='text' name='day"+i+"' id='day"+i+"' value='"+prevValueDays+"' onBlur='getItineraryValues();'/></td></tr>";

			if(expectedValueDesc!=prevValueDesc){
			theHtml += "<tr><td colspan='2'><textarea name='day"+i+"_desc' id='day"+i+"_desc' cols='55' rows='3' onBlur='getItineraryValues();'>"+prevValueDesc+"</textarea></td></tr>";
			}else{
				theHtml += "<tr><td colspan='2'><textarea name='day"+i+"_desc' id='day"+i+"_desc' cols='55' rows='3' onFocus='if (this.value == \"Day "+i+" Description\"){ this.value = \"\"; this.style.color = \"#000000\"; }' onBlur='getItineraryValues();if (this.value == \"\"){ this.value = \"Day "+i+" Description\"; this.style.color = \"#999999\"; }' style='color:#999999;'>Day "+i+" Description</textarea></td></tr>";
				
			}
tonum++;
          }
}       		
        for(n=tonum;n<=num;n++){
            theHtml += "<tr><td colspan='2'><input type='text' name='day"+n+"' id='day"+n+"' value='Day "+n+"' onBlur='getItineraryValues();'/></td></tr>";
			theHtml += "<tr><td colspan='2'><textarea name='day"+n+"_desc' id='day"+n+"_desc' cols='55' rows='3' onFocus='if (this.value == \"Day "+n+" Description\"){ this.value = \"\"; this.style.color = \"#000000\"; }' onBlur='getItineraryValues();if (this.value == \"\"){ this.value = \"Day "+n+" Description\"; this.style.color = \"#999999\"; }' style='color:#999999;'>Day "+n+" Description</textarea></td></tr>";
          }
		          theHtml += "</table>";

		  }
	document.getElementById("tourdays").innerHTML = theHtml;
	document.getElementById("iNum").value = num;

  }


//===============================================================
// Put the package itinerary into the hidden field
//===============================================================
  
  function getItineraryValues()
  { 
  var num= document.getElementById("durationdays").value;
	document.getElementById("tour_itinerary").value="";
        for(i=1;i<=num;i++)
          {
	document.getElementById("tour_itinerary").value += "[Day]"+document.getElementById("day"+i+"").value+"[/Day]\n";
	document.getElementById("tour_itinerary").value += "[Desc]"+document.getElementById("day"+i+"_desc").value+"[/Desc]\n\n";
          }
  }

//===============================================================
// Show selected Inclusions
//===============================================================
function showInclusions(num)
  {
  var theHtml= "";
  var tonum = 1;
    if(num > 0){
			
			var old_number = document.getElementById("InclusionsOldNum").value;
			var old_data = document.getElementById("InclusionsF").value;
				
					var old_number = parseFloat(old_number);
					var num = parseFloat(num);
				
				if(old_number>num){
						old_number = num;
				}
					if(old_data!=""){
        			for(i=tonum;i<=old_number;i++){
						
						var prevValue = document.getElementById("Inclusions"+i).value;
						var expectedValue = "Inclusion "+i+"";
					if(prevValue!=expectedValue){
			  theHtml += "<input size='70' type='text' name='Inclusions"+i+"' id='Inclusions"+i+"' value='"+prevValue+"' onBlur='getInclusionValues();'/><br><br>";
					}else{
				theHtml += "<input size='70' type='text' name='Inclusions"+i+"' id='Inclusions"+i+"' value='Inclusion "+i+"' onFocus='if (this.value == \"Inclusion "+i+"\"){ this.value = \"\"; this.style.color = \"#000000\"; }' onBlur='getInclusionValues(); if (this.value == \"\"){ this.value = \"Inclusion "+i+"\"; this.style.color = \"#999999\"; }' style='color:#999999;'/><br><br>";
					}
	tonum++;
          }
}       
		for(n=tonum;n<=num;n++){
      theHtml += "<input size='70' type='text' name='Inclusions"+n+"' id='Inclusions"+n+"' value='Inclusion "+n+"' onFocus='if (this.value == \"Inclusion "+n+"\"){ this.value = \"\"; this.style.color = \"#000000\"; }' onBlur='getInclusionValues(); if (this.value == \"\"){ this.value = \"Inclusion "+n+"\"; this.style.color = \"#999999\"; }' style='color:#999999;'/><br><br>";
          }

		  }
	document.getElementById("InclusionArea").innerHTML = theHtml;
	document.getElementById("InclusionsOldNum").value = num;
  }
  
//===============================================================
// Put the package Inclusions into the hidden field
//===============================================================
  
  function getInclusionValues()
  { 
  var num= document.getElementById("Inclusions").value;
	document.getElementById("InclusionsF").value="";
        for(i=1;i<=num;i++)
          {
	document.getElementById("InclusionsF").value += "[Inclusions]"+document.getElementById("Inclusions"+i+"").value+"[/Inclusions]\n";
	
          }
  }

//===============================================================
// Show selected Exclusions
//===============================================================
function showExclusions(num)
  {
  var theHtml= "";
  var tonum = 1;
    if(num > 0){
		
		
		var old_number = document.getElementById("ExclusionsOldNum").value;
			var old_data = document.getElementById("ExclusionsF").value;
				
					var old_number = parseFloat(old_number);
					var num = parseFloat(num);
				
				if(old_number>num){
						old_number = num;
				}
					if(old_data!=""){
        			for(i=tonum;i<=old_number;i++){
								var prevValue = document.getElementById("Exclusions"+i).value;
								var expectedValue = "Exclusion "+i+"";
						if(prevValue!=expectedValue){
			  theHtml += "<input size='70' type='text' name='Exclusions"+i+"' id='Exclusions"+i+"' value='"+prevValue+"' onBlur='getExclusionValues();'/><br><br>";
					}else{
				theHtml += "<input size='70' type='text' name='Exclusions"+i+"' id='Exclusions"+i+"' value='Exclusion "+i+"' onFocus='if (this.value == \"Exclusion "+i+"\"){ this.value = \"\"; this.style.color = \"#000000\"; }' onBlur='getExclusionValues(); if (this.value == \"\"){ this.value = \"Exclusion "+i+"\"; this.style.color = \"#999999\"; }' style='color:#999999;'/><br><br>";
					}
	tonum++;
          }
}       
		
		
        for(n=tonum;n<=num;n++){
      theHtml += "<input size='70' type='text' name='Exclusions"+n+"' id='Exclusions"+n+"' value='Exclusion "+n+"' onFocus='if (this.value == \"Exclusion "+n+"\"){ this.value = \"\"; this.style.color = \"#000000\"; }' onBlur='getExclusionValues(); if (this.value == \"\"){ this.value = \"Exclusion "+n+"\"; this.style.color = \"#999999\"; }' style='color:#999999;'/> <br><br>";
          }

		  }
	document.getElementById("ExclusionsArea").innerHTML = theHtml;
	document.getElementById("ExclusionsOldNum").value = num;

  }
  
//===============================================================
// Put the package Exclusions into the hidden field
//===============================================================
  
  function getExclusionValues()
  { 
  var num= document.getElementById("Inclusions").value;
	document.getElementById("ExclusionsF").value="";
        for(i=1;i<=num;i++)
          {
	document.getElementById("ExclusionsF").value += "[Exclusions]"+document.getElementById("Exclusions"+i+"").value+"[/Exclusions]\n";
          }
  }
  
//===============================================================
// Show seasons
//===============================================================
function showSeasons(num){
var numSeasons = 0;
var tonum = "1";
theHtml = "";
  if (num > 0) {
    theHtml = "<table width='550' border='0' cellspacing='0' cellpadding='3' align='center'>";

    for (n = tonum; n <= num; n++) {
      theHtml += "<tr><td colspan='2'>Season #"+n+"</td></tr>" +
        "<tr><td width='110'>Valid from: </td><td><input name='fdate"+n+"' type='text' size='15' value='' readonly> <a href='javascript:void(0)' onclick='if(self.gfPop)gfPop.fStartPop(document.form1.fdate"+n+",document.form1.tdate"+n+");return false;' ><img class='PopcalTrigger' align='absmiddle' src='../calendar/calbtn.gif' width='34' height='22' border='0'></a></td></tr>"+
        "</td></tr><tr><td width='110'>Valid to: </td><td>"+
        "<input name='tdate"+n+"' type='text' size='15' value='' readonly> <a href='javascript:void(0)' onclick='if(self.gfPop)gfPop.fEndPop(document.form1.fdate"+n+",document.form1.tdate"+n+");return false;' ><img class='PopcalTrigger' align='absmiddle' src='../calendar/calbtn.gif' width='34' height='22' border='0'></a>" +
        "</td></tr><tr><td>Prices:</td><td>Adults <input name='priceadult"+ n +"' type='text' size='5' value=''> Children <input name='pricechild"+ n +"' type='text' size='5' value=''> Infant <input name='priceinfant"+ n +"' type='text' size='5' value=''> (leave blank if free)</td></tr><tr><td></td></tr>";
    }

    theHtml += "</table><br>";
  }
  document.getElementById("seasons").innerHTML = theHtml;
  numSeasons = num;
  }
  
  
//===========================================================================
// Get room Facilities from check boxes
//===========================================================================

function GetRoomFacilities() {
	var c_value = "";
for (var i=0; i<document.form1.room_facilities.length; i++)
   {
  if (document.form1.room_facilities[i].checked)
     {
     c_value = c_value + document.form1.room_facilities[i].value + ",";
      }
  }
  document.form1.r_fac.value = c_value;
   }
   
 //===========================================================================
// Get Accommodation Facilites from check boxes
//===========================================================================

function GetAccFacilities() {
	var c_value = "";
for (var i=0; i<document.form1.ACC_facilities.length; i++)
   {
  if (document.form1.ACC_facilities[i].checked)
     {
     c_value = c_value + document.form1.ACC_facilities[i].value + ",";
      }
  }
  document.form1.A_fac.value = c_value;
   } 
   
   //===============================================================
// Limit the text area characters with a counter
//===============================================================
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}

//===============================================================
// Validate form DREAMWEAVER Validation
//===============================================================
function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

//===============================================================
// Gallery script.
//===============================================================
function LoadGallery(pictureName,imageFile,titleCaption,captionText)
{
  document.getElementById(pictureName).src = imageFile;
  document.getElementById(titleCaption).innerHTML=captionText;
}

//===============================================================
// Popup Window.
//===============================================================
function popUp(URL){
window.open(URL, "Test", 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=300,height=300,left = 490,top = 150');
}

//===============================================================
// Confirm Submission
//===============================================================
function confirmSubmit(msg){
var agree= confirm(msg);
if (agree)
	return true ;
else
	return false ;
}
//===============================================================
// Flash Connections
//===============================================================
function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
      return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else//if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}
function highlightCountry(countryName){
     var flashMovie=getFlashMovieObject("africamap");
    flashMovie.TGotoFrame("/"+countryName,1);
	flashMovie.TPlay("/"+countryName);
}
function returnCountry(countryName){
     var flashMovie=getFlashMovieObject("africamap");
	flashMovie.TGotoFrame("/"+countryName,0);
}
