//////////////////////////////////////////////	PACKAGE SEARCHES	//////////////////////////////////////////////////////

function searchwhat(searchtype){

	waitdiv = 'DIVdep';
	hoteldiv = 'hotelSearch';
	packagediv = 'packageSearch'

  document.getElementById(hoteldiv).style.visibility='hidden';
  document.getElementById(hoteldiv).style.display='none';
  document.getElementById(packagediv).style.visibility='hidden';
  document.getElementById(packagediv).style.display='none';

	if(searchtype == '1'){								// package
  document.getElementById(waitdiv).style.visibility='visible';
  document.getElementById(waitdiv).style.display='block';

  document.getElementById(packagediv).style.visibility='visible';
  document.getElementById(packagediv).style.display='block';
  }

	if(searchtype == '2'){								// hotel only
  document.getElementById(waitdiv).style.visibility='hidden';
  document.getElementById(waitdiv).style.display='none';

  document.getElementById(hoteldiv).style.visibility='visible';
  document.getElementById(hoteldiv).style.display='block';
	}
}
///////////////////////////////////////////////////////////////////////////
function packDIVText(advert, adlink) {
  
depapt = document.searchform.depapt.options[document.searchform.depapt.selectedIndex].value;
destapt= document.searchform.destapt.options[document.searchform.destapt.selectedIndex].value;

if(advert == "1"){
if (destapt == ""){
	alert('You need to select an specific Destination airport to make a package search')
	return false;
}	
}

	var eTxt = "";
	if(document.getElementById('nights').value == "0")
	{ eTxt = eTxt + "\n- Please select number of nights required"; }

	if(eTxt=="")
	{ 

  waitdiv = 'DIVText3';
  waittxt = 'waittext';
  waitimg = 'waitimage';
	  document.getElementById(waitdiv).style.visibility='visible';
	  document.getElementById(waitdiv).style.display='inline';
	  //document.getElementById(waittxt).innerHTML = "We are now searching through millions of records<br />Step1 is select your holiday<br />Step2 is Telephone or send us your booking request";  
	
	  //document.getElementById(waitimg).innerHTML = "<img src='http://www.travelwasp.com/images/helicoptr.gif'>";  


//	  document.getElementById(waitimg).innerHTML = "<iframe src='http://www.travelwasp.com/copter.htm' width='120' height='120' align='center' frameborder='0' scrolling='no'></iframe>";  
	
	
	
//<img src='http://www.travelwasp.com/images/helicoptr.gif'>
	
	
	
	
	
		  document.getElementById('searchform').action = adlink;				//	'cgi-bin/searches/getpackages3.cgi'
		  document.getElementById('searchform').submit();
	}
	else
	{ 
		alert("The following error(s) occurred:" + eTxt); 
		return false; 
	}
}
///////////////////////////////////////////////////////////////////////////
function packDIV3Text(advert, adlink, link) {
//  whichdiv = 'DIVText' + advert;
//  hidediv = 'DIVText2';
//  waitdiv = 'DIVText3';
  fieldid = 'advert_offer_' + adlink;				// advert_offer_4

//searched= document.getElementById(fieldid).searched.value;
//fltselected= document.getElementById(fieldid).fltselected.value;
//htlselected= document.getElementById(fieldid).htlselected.value;

//url = 'http://www.travelwasp.com/cgi-bin/searches/request-package.cgi?;

  document.getElementById(fieldid).action = 'http://www.travelwasp.com/cgi-bin/searches/request-package.cgi';
  document.getElementById(fieldid).submit();

}
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
function changebill(diffbill){

//diffbill = document.emailme.type.options[document.emailme.type.selectedIndex].value;

//	alert('billdiff is=' + diffbill)

if (diffbill == '2'){
	showbill();
}
if (diffbill == '1'){
	hidebill();
}
}

function showbill() {
whichdiv = 'delivaddress';
  document.getElementById(whichdiv).style.visibility='visible';
  document.getElementById(whichdiv).style.display='block';
}

function hidebill(){
whichdiv = 'delivaddress';
  document.getElementById(whichdiv).style.visibility='hidden';
  document.getElementById(whichdiv).style.display='none';
}
//////////////////////////////////////////////////////////////////////////////////
function showdiv(advert) {
whichdiv = 'roomdiv_' + advert;
showbut = 'showbut_' + advert;
hidebut = 'hidebut_' + advert;
  document.getElementById(whichdiv).style.visibility='visible';
  document.getElementById(whichdiv).style.display='block';
  document.getElementById(showbut).style.visibility='hidden';
  document.getElementById(showbut).style.display='none';
  document.getElementById(hidebut).style.visibility='visible';
  document.getElementById(hidebut).style.display='block';
}

function closediv(advert){
whichdiv = 'roomdiv_' + advert;
showbut = 'showbut_' + advert;
hidebut = 'hidebut_' + advert;
  document.getElementById(whichdiv).style.visibility='hidden';
  document.getElementById(whichdiv).style.display='none';
  document.getElementById(showbut).style.visibility='visible';
  document.getElementById(showbut).style.display='block';
  document.getElementById(hidebut).style.visibility='hidden';
  document.getElementById(hidebut).style.display='none';
}
//////////////////////////////////////////////////////////////////////////////////
function moreflt() {
whichdiv = 'morflts';
otherdiv = 'othflts';
showfltbut = 'showfltbut_0';
hidefltbut = 'hidefltbut_0';
  document.getElementById(whichdiv).style.visibility='visible';
  document.getElementById(whichdiv).style.display='block';
  document.getElementById(otherdiv).style.visibility='hidden';
  document.getElementById(otherdiv).style.display='none';
  document.getElementById(showfltbut).style.visibility='hidden';
  document.getElementById(showfltbut).style.display='none';
  document.getElementById(hidefltbut).style.visibility='visible';
  document.getElementById(hidefltbut).style.display='block';
}

function lessflt(){
whichdiv = 'morflts';
otherdiv = 'othflts';
showfltbut = 'showfltbut_0';
hidefltbut = 'hidefltbut_0';
  document.getElementById(whichdiv).style.visibility='hidden';
  document.getElementById(whichdiv).style.display='none';
  document.getElementById(otherdiv).style.visibility='visible';
  document.getElementById(otherdiv).style.display='block';
  document.getElementById(showfltbut).style.visibility='visible';
  document.getElementById(showfltbut).style.display='block';
  document.getElementById(hidefltbut).style.visibility='hidden';
  document.getElementById(hidefltbut).style.display='none';
}

//////////////////////////////////////////////////////////////////////////////////
function showfilter() {
whichdiv = 'filteroptions';
showfilterbut = 'showfilterb_0';
hidefilterbut = 'hidefilterb_0';
  document.getElementById(whichdiv).style.visibility='visible';
  document.getElementById(whichdiv).style.display='block';
  document.getElementById(showfilterbut).style.visibility='hidden';
  document.getElementById(showfilterbut).style.display='none';
  document.getElementById(hidefilterbut).style.visibility='visible';
  document.getElementById(hidefilterbut).style.display='block';
}

function hidefilter(){
whichdiv = 'filteroptions';
showfilertbut = 'showfilterb_0';
hidefilertbut = 'hidefilterb_0';
  document.getElementById(whichdiv).style.visibility='hidden';
  document.getElementById(whichdiv).style.display='none';
  document.getElementById(showfilterbut).style.visibility='visible';
  document.getElementById(showfilterbut).style.display='block';
  document.getElementById(hidefilterbut).style.visibility='hidden';
  document.getElementById(hidefilterbut).style.display='none';
}

//////////////////////////////////////////////////////////////////////////////////
function updateprice(amount, trantype, thisrate, prpolicy){							/// 34.56, 	Taxi,34.56,per unit

newamnt = parseFloat(amount);
newamnt = r2(newamnt);
pricediv = 'newtotprice';
fieldid = 'flthotprice';
baskettot = 'newtotpr';
baskettr = 'transrate';
basketty = 'trantype';
tranny = trantype + '|' + thisrate + '|' + prpolicy;


flthotpr = document.emailme.flthotprice.value;
//flthotpr = parseFloat(document.emailme.flthotprice.value);
document.emailme.transprice.value = newamnt;
document.emailme.transfers.value = tranny;

mynewtotpr = parseFloat(flthotpr) + parseFloat(newamnt);
mynewtotpr = r2(mynewtotpr);

document.emailme.newtotalprice.value = mynewtotpr;
document.getElementById(pricediv).innerHTML=mynewtotpr;
document.getElementById(baskettot).innerHTML=mynewtotpr;
document.getElementById(baskettr).innerHTML=amount;
document.getElementById(basketty).innerHTML=trantype;

}

// Round to 2 decimal places 
function r2(n) { 
  ans = n * 1000 
  ans = Math.round(ans /10) + "" 
  while (ans.length < 3) {ans = "0" + ans} 
  len = ans.length 
  ans = ans.substring(0,len-2) + "." + ans.substring(len-2,len)
  return ans 
} 
///////////////////////////////////////////////////////////////////////////
function updateccard(type){							/// Visa

if (type == '1'){
	cctype = 'Visa';
	rate = '2';
}
if (type == '2'){
	cctype = 'MASTERCARD';
	rate = '2';
}
if (type == '3'){
	cctype = 'VISADEBIT';
	rate = '0';
}
if (type == '4'){
	cctype = 'SWITCH';
	rate = '0';
}
if (type == '5'){
	cctype = 'SOLO';
	rate = '0';
}
if (type == '6'){
	cctype = 'DELTA';
	rate = '0';
}
if (type == '7'){
	cctype = 'ELECTRON';
	rate = '0';
}
if (type == '8'){
	cctype = 'JCB';
	rate = '0';
}

flthotpr = document.emailme.flthotprice.value;
amount = parseFloat(flthotpr) * parseFloat(rate) /100;

newamnt = parseFloat(amount);
newamnt = r2(newamnt);
pricediv1 = 'newtotprice';
pricediv2 = 'totalprice2';
var newtotalprice = 'newtotalprice';
var ccardprice = 'ccardprice';
var ccardtype = 'ccardtype';


mynewtotpr = parseFloat(flthotpr) + parseFloat(newamnt);
mynewtotpr = r2(mynewtotpr);

document.getElementById(newtotalprice).value=mynewtotpr;
document.getElementById(ccardprice).value=newamnt;
document.getElementById(ccardtype).value=cctype;

document.getElementById(pricediv1).innerHTML=mynewtotpr;
//document.getElementById(pricediv2).innerHTML=mynewtotpr;

}

// Round to 2 decimal places 
function r2(n) { 
  ans = n * 1000 
  ans = Math.round(ans /10) + "" 
  while (ans.length < 3) {ans = "0" + ans} 
  len = ans.length 
  ans = ans.substring(0,len-2) + "." + ans.substring(len-2,len)
  return ans 
} 
////////////////////////////////////////////////////////////////////////
// Check the form before submitting
function packcheckForm(sitelink)
{
	var eTxt = "";
	if(document.emailme.r1ad1fname.value.length<=1 || document.emailme.r1ad1fname.value=="Firstname")
	{ eTxt = eTxt + "\n- Your first name is required"; }
	
	if(document.emailme.r1ad1sname.value.length<=1 || document.emailme.r1ad1sname.value=="Surname")
	{ eTxt = eTxt + "\n- Your surname is required"; }
	
	if(document.emailme.send_email.value.indexOf("@")<1 || document.emailme.send_email.value.indexOf(".")<1 )
	{ eTxt = eTxt + "\n- A valid email address is required"; }
	
	 	if (document.emailme.send_tele.value == "")
		{ eTxt = eTxt + "\n- A contact telephone number is required   "; }
	
	 	if (document.emailme.add11.value == "")
		{ eTxt = eTxt + "\n- Address first line is required   "; }

	 	if (document.emailme.town1.value == "")
		{ eTxt = eTxt + "\n- Town in address is required   "; }

	 	if (document.emailme.postcode1.value == "")
		{ eTxt = eTxt + "\n- Postcode in address is required   "; }

	 	if (document.emailme.country1.value == "")
		{ eTxt = eTxt + "\n- Country in address is required   "; }

	 	if (document.emailme.type.value == "")
		{ eTxt = eTxt + "\n- Credit Card type is required   "; }

	 	if (document.emailme.number.value == "")
		{ eTxt = eTxt + "\n- Credit Card Number is required   "; }

	if (document.emailme.thistype.value == "no"){
	 	if (document.emailme.add10.value == "")
		{ eTxt = eTxt + "\n- Credit Card Address first line is required   "; }

	 	if (document.emailme.town0.value == "")
		{ eTxt = eTxt + "\n- Credit Card Town in address is required   "; }

	 	if (document.emailme.postcode0.value == "")
		{ eTxt = eTxt + "\n- Credit Card Postcode in address is required   "; }

	 	if (document.emailme.country0.value == "")
		{ eTxt = eTxt + "\n- Credit Card Country in address is required   "; }

	 	if (document.emailme.startdate1.value == "")
		{ eTxt = eTxt + "\n- Credit Card Startmonth is required   "; }

	 	if (document.emailme.startdate2.value == "")
		{ eTxt = eTxt + "\n- Credit Card Startyear is required   "; }

	 	if (document.emailme.expdate1.value == "")
		{ eTxt = eTxt + "\n- Credit Card Expirymonth is required   "; }

	 	if (document.emailme.expdate2.value == "")
		{ eTxt = eTxt + "\n- Credit Card Expiryyear is required   "; }

	 	if (document.emailme.sec.value == "")
		{ eTxt = eTxt + "\n- Credit Card Security Code is required   "; }
	}

		if(document.emailme.termscheck.checked==false )
		{ eTxt = eTxt + "\n- Please tick the box to state you agree to the Terms and Conditions   "; }

	
	if(eTxt=="")
	{ 
		  document.emailme.action = sitelink;
		  document.emailme.submit();
	}
	else
	{ 
		alert("The following error(s) occurred:" + eTxt); 
		return false; 
	}
}
///////////////////////////////////////////////////////////////////////////
function right(e) {
if (navigator.appName == 'Netscape' &&
(e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' &&
(event.button == 2 || event.button == 3)) {
alert('KwikData the UKs premier travel database');
return false;
}
return true;
}
document.onmousedown=right;
document.onmouseup=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
window.onmousedown=right;
window.onmouseup=right;

///////////////////////////////////////////////////////////////////////////














