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_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_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_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 toggleAllOff(){
     for (var i = 0; i < answers.length; i++) {
        answers[i].className = 'hide';
     }
}

function toggleAllOn(){
     for (var i = 0; i < answers.length; i++) {
        answers[i].className = 'show';
     }
}


function displayToggle(){
     // calls the toggle all off function
     // to turn all the answers off when the page is loaded
     toggleAllOff();

     for (i=0; i<questions.length; i++) {  // loops through the questions
     
         questions[i].onclick=function() {  // shows the answers onclick
             var next = this.nextSibling;
             // if it gets to a non-element node, go to the next one
             while(next.nodeType != 1) next=next.nextSibling;
             
             next.className=((next.className=="hide") ? "show" : "hide");
          }
      }
      
}


//Function to show/hide the answer
function ShowAnswer(id)
{
var Imgid='q'+id;

var x = MM_findObj(Imgid);
var ansId='Answer'+id;

	if(x.src.indexOf("faqtriangle.gif")!=-1)
	{
		x.src = "images/faq/faqtriangleopen.gif";

		document.getElementById(ansId).className="show";
	}
	else
	{
		x.src = "images/faq/faqtriangle.gif";
		
		document.getElementById(ansId).className="hide";
	}
}
function swaparrow(n)
{

	var x = MM_findObj(n);


	if(x.src.indexOf("faqtriangle.gif")!=-1)
	{
		x.src = "images/faq/faqtriangleopen.gif";
	}
	else
	{
		x.src = "images/faq/faqtriangle.gif";
	}
}


//Function to add dynamic text boxes
var intTextBox=0;
function addElement()
{

intTextBox =document.getElementById('hdntotal').value;

intTextBox = parseInt(intTextBox) + 1;
document.getElementById('hdntotal').value=intTextBox;
var contentID = document.getElementById('contentDiv');
var newTBDiv = document.createElement('div');
newTBDiv.setAttribute('id','strDescription'+intTextBox);
newTBDiv.innerHTML = "<br><label>Rate Description "+intTextBox+": </label><input maxlength='50' size='50' title='Rate Description' type='text' id='txtratedecscript_" + intTextBox + "' name='txtratedecscript_" + intTextBox + "'/>";
contentID.appendChild(newTBDiv);


var newTBDiv = document.createElement('div');
newTBDiv.setAttribute('id','strRate'+intTextBox);
newTBDiv.innerHTML = "<label>Rate"+intTextBox+": </label><input type='text' maxlength='8' size='10' title='Rate' id='txtRate_" + intTextBox + "' name='txtRate_" + intTextBox + "'/>&nbsp;&nbsp;<input type='button' title='Remove' value='Remove' onclick='removeElement("+ intTextBox +")'/><input type='hidden' id='hdnExcPriceID_"+ intTextBox +"' name='hdnExcPriceID_"+ intTextBox +"' value='0' />";
contentID.appendChild(newTBDiv);



}


//Function to Get XmlHttp Object

function GetXmlHttpObject(handler)
{ 
var objXmlHttp=null;

if (navigator.userAgent.indexOf("MSIE")>=0)
{ 
var strName="Msxml2.XMLHTTP";
if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
{
strName="Microsoft.XMLHTTP";
} 
try
{ 
objXmlHttp=new ActiveXObject(strName);
objXmlHttp.onreadystatechange=handler;
return objXmlHttp;
} 
catch(e)
{ 
alert("Error. Scripting for ActiveX might be disabled");
return;
} 
} 
if (navigator.userAgent.indexOf("Mozilla")>=0)
{
objXmlHttp=new XMLHttpRequest();
objXmlHttp.onload=handler;
objXmlHttp.onerror=handler;
return objXmlHttp;
}
} 

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{

}
} 

//Function to remove a perticular record
function removeElement(Id)
{

if (confirm('Are you sure to delete this record from Database ?'))
{
   if (document.getElementById('hdnExcPriceID_'+Id).value > 0)
    {
    var url="DuplicateExcCode.asp?ExcPriceID=" + document.getElementById('hdnExcPriceID_'+Id).value;
    xmlHttp=GetXmlHttpObject(stateChanged);
    xmlHttp.open("GET", url , true);
    xmlHttp.send(null);
   }
    var contentID = document.getElementById('contentDiv');
    contentID.removeChild(document.getElementById('strRate'+Id));

    contentID.removeChild(document.getElementById('strDescription'+Id));

}
}

  
//Function to add dynamic text boxes
var intTextBox=0;
function addElement_EditCityTax()
{
 
intTextBox =document.getElementById('hdntotal').value;

intTextBox = parseInt(intTextBox) + 1;
document.getElementById('hdntotal').value=intTextBox;
var contentID = document.getElementById('contentDiv');
var newTBDiv = document.createElement('div');
newTBDiv.setAttribute('id','strCityName'+intTextBox);
newTBDiv.innerHTML = "<br><label class='required'>City Name "+intTextBox+": </label><input maxlength='50' size='50' title='City Name' type='text' id='txtcityname_" + intTextBox + "' name='txtcityname_" + intTextBox + "'/>";
contentID.appendChild(newTBDiv);


var newTBDiv = document.createElement('div');
newTBDiv.setAttribute('id','strRate'+intTextBox);
newTBDiv.innerHTML = "<label class='required'>Rate1 : </label><input type='text' maxlength='8' size='10' title='Rate' id='txtRate_" + intTextBox + "' name='txtRate_" + intTextBox + "'/>";
contentID.appendChild(newTBDiv);

var newTBDiv = document.createElement('div');
newTBDiv.setAttribute('id','strDescription'+intTextBox);
newTBDiv.innerHTML = "<label  class='required'>Tax Description1 : </label><input type='text' size='50' maxlength='300'id='txtDescription_" + intTextBox + "' name='txtDescription_" + intTextBox + "' />";
contentID.appendChild(newTBDiv);

var newTBDiv = document.createElement('div');
newTBDiv.setAttribute('id','strRate2'+intTextBox);
newTBDiv.innerHTML = "<label  class='required'>Rate2 : </label><input maxlength='8' size='10' title='Rate' type='text' id='txtRate2_" + intTextBox + "' name='txtRate2_" + intTextBox + "' />";
contentID.appendChild(newTBDiv);

var newTBDiv = document.createElement('div');
newTBDiv.setAttribute('id','strDescription2'+intTextBox);
newTBDiv.innerHTML = "<label  class='required'>Tax Description2 : </label><input type='text' maxlength='300' size='50' id='txtDescription2_" + intTextBox + "' name='txtDescription2_" + intTextBox + "' /><input type='hidden' id='hdnCityTaxID_" + intTextBox + "' name='hdnCityTaxID_" + intTextBox + "' value='0'/>&nbsp;&nbsp;<input type='button' onclick='removeElement_EditCityTax(" + intTextBox + ")' value='Remove' title='Remove this record from database'>";
contentID.appendChild(newTBDiv);

}


//Function to remove a perticular record
function removeElement_EditCityTax(Id)
{
if (confirm('Are you sure to delete this record from Database ?'))
{
if (document.getElementById('hdnCityTaxID_'+Id).value > 0 ){
var url="DeleteCityTax.asp?CityTaxID=" + document.getElementById('hdnCityTaxID_'+Id).value +"&ExcCode="+document.getElementById('hdnExcCode_'+Id).value;
xmlHttp=GetXmlHttpObject(stateChanged);
xmlHttp.open("GET", url , true);
xmlHttp.send(null);

//alert(document.getElementById('hdnCityTaxID_'+Id).value);
}
var contentID = document.getElementById('contentDiv');
contentID.removeChild(document.getElementById('strRate'+Id));
contentID.removeChild(document.getElementById('strRate2'+Id));
contentID.removeChild(document.getElementById('strCityName'+Id));
contentID.removeChild(document.getElementById('strDescription'+Id));
contentID.removeChild(document.getElementById('strDescription2'+Id));

}
 
}

/****EXTRAS SECTION WITH DYNAMIC ADD/DELTE ROWS WHILE EDITING THE EXTRAS****/


//Function to remove a perticular record from database in the Edit extras
function RemoveExtrasPrices(Id,type)
{

if (confirm('Are you sure to delete this record from Database ?'))
{
if (type=="0"){
   if (document.getElementById('hdnExtrasPriceID_'+Id).value > 0)
    {
    
     
    var url="DeleteExtrasPrices.asp?ExtrasPriceID=" + document.getElementById('hdnExtrasPriceID_'+Id).value;
    xmlHttp=GetXmlHttpObject(stateChanged);
    xmlHttp.open("GET", url , true);
    xmlHttp.send(null);
     }
   }
   if (type=="1"){
   if (document.getElementById('hdnGroupPriceID_'+Id).value > 0)
    {
    var url="DeleteExtrasPrices.asp?ExtrasPriceID=" + document.getElementById('hdnGroupPriceID_'+Id).value;
    xmlHttp=GetXmlHttpObject(stateChanged);
    xmlHttp.open("GET", url , true);
    xmlHttp.send(null);
    }
    }
    
    
}//END CONFIRM
   if (type=="0"){
    var contentID = document.getElementById('contentDiv');
    contentID.removeChild(document.getElementById('strPax'+Id));
    contentID.removeChild(document.getElementById('strPrice'+Id));
    }
    if (type=="1"){
    var contentID = document.getElementById('contentDivGroup');
    contentID.removeChild(document.getElementById('strgroupPax'+Id));
    contentID.removeChild(document.getElementById('strgroupPrice'+Id));
    }
}
  /***********EXTRAS SECTION END****************/
  
/****COMMON FUNCTIONS THAT ARE USING ON THE TOUR_DETAIL AND RELATED PAGES****/  

//Function to show/hide the cart
function ShowCartDiv()
{
document.getElementById('minibag').style.display='block';
}
function HideCartDiv()
{
document.getElementById('minibag').style.display='none';
}
//Function to change the class of the add to cart button
function fnAddtoCartover()
{
document.getElementById('btnAddtoCart').className='btn_InputAddtoCartOver';
}
function fnAddtoCartout()
{
document.getElementById('btnAddtoCart').className='btn_InputAddtoCart';
}
//Function to chaneg the images of the Top down your cart checkout/shopping_bag image
function fnShoppingcheckoutTopOver()
{
document.getElementById('btnCheckoutShoppingTop').src="images/CheckOutOver.jpg"
}
//Function to chaneg the images of the Top downyour cart checkout image on Mouse out, This function is using on the Shopping and checkout page
function fnShoppingcheckoutTopout()
{
document.getElementById('btnCheckoutShoppingTop').src="images/checkoutimg.jpg"
}
//Funtion for shopping checkout button change class on mouse Out, This fuction is using on the shopping bag page
function fnShoppingcheckoutout()
{
document.getElementById('btnCheckoutShopping').className='shoppingbag_checkout';
}
//Funtion for shopping checkout button change class on mouse over, This function is using on the Shopping bag page
function fnShoppingcheckoutOver()
{
document.getElementById('btnCheckoutShopping').className='shoppingbag_checkout_hover';
}

//Function to change the class,on the mouse over/out, This function is using on the shopping and checkout page
function fnCheckouttopover()
{
document.getElementById('btnCheckouttop').className='btn_InputCheckoutcartover';
}

function fnCheckouttopout()
{
document.getElementById('btnCheckouttop').className='btn_InputCheckoutcart';
}

//Funtion for changing the Sign in button on mouse over, This function is using on the checkout page
function fnSignInover()
{
document.getElementById('btnSignin').className='btn_InputSigninover';
}
//Funtion for changing the Sign in button on mouse out, This function is using on the checkout page
function fnSignInpout()
{
document.getElementById('btnSignin').className='btn_InputSignin';
}
//Function to block the non numeric key
function blockNonNumbers(obj, e, allowDecimal, allowNegative) {
    
    var key; var isCtrl = false; var keychar; var reg; if (window.event) { key = e.keyCode;isCtrl = window.event.ctrlKey }

    else if (e.which) { key = e.which; isCtrl = e.ctrlKey; }
    if (isNaN(key)) return true; keychar = String.fromCharCode(key); if (key == 8 || isCtrl) { return true; }
    reg = /\d/; var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false; var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false; return isFirstN || isFirstD || reg.test(keychar);
    
}
//Function to show the Long description of Extras on the MouseOver of the ? image
function fnShowDesc(divid)
{
document.getElementById(('div_'+divid)).style.display='';
}
//Function to Hide the Long description of Extras on the MouseOut of the ? image
function fnHideDesc(divid)
{

document.getElementById('div_'+divid).style.display='none';
}

//Function for the restore the image (mouse out) This function is using in the Topnav3

function MM_swapImageTopnave3() { //v3.0
    document.getElementById('minibag').style.display = '';
    var i, j = 0, x, a = MM_swapImageTopnave3.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_swapImgRestoreTopnave3() { //v3.0
    document.getElementById('minibag').style.display = 'none' ;
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;

    //document.getElementById('minibag').style.display = 'none' ;
}


//Function to check the MaxPaxAllowed value from the Admin section
function CheckMaxPaxAllowed()
{
var MaxPaxAllowed
var Nopassenger=document.getElementById('txtpassenger').value;
MaxPaxAllowed=document.getElementById('hdnMaxPaxAllowed').value;

if (document.getElementById('txtpassenger').value !="")
    { 
      //Check the condition Nopassenger > MaxPaxAllowed which is not allowed 
      if ( (parseInt(MaxPaxAllowed)>0) && (parseInt(Nopassenger) > parseInt(MaxPaxAllowed))){
          //alert("Sorry this service only allow Max "+ MaxPaxAllowed+" people");
          alert("We are very sorry but this service cannot be booked for groups larger then " + MaxPaxAllowed + " pax directly online.Please contact us for more information.");
        return false;
        }else{return true;}
     
    }
}

//***Function to get the Your card details from the Ajax (AjaxYourCard)***
var xmlHttpyourcard;
 function AjaxYourCardDetails()
 {
 
 var url="AjaxYourCard.asp";
//     if (window.XMLHttpRequest) {              
//        xmlHttpyourcard=new XMLHttpRequest();              
//      } else {                                  
//        xmlHttpyourcard=new ActiveXObject("Microsoft.XMLHTTP");
//      }
      xmlHttpyourcard=GetXmlHttpObject(stateChanged);
      //if (xmlHttpyourcard) {
      
         xmlHttpyourcard.open("GET", url, false);                             
         xmlHttpyourcard.send(null);
         
         //alert(xmlHttpyourcard.responseText);
          
         if (xmlHttpyourcard.responseText!=""){ 
         document.getElementById('contentcontainer').innerHTML=xmlHttpyourcard.responseText;
         }
         
         
        //}
}

//***functions using on the Booking form***
//Function to check the I agree is checked or not
    function fnActiveSubmit()
    {
        if(document.getElementById('chkIsagree').checked)
        {
         document.getElementById('btnSubmit').disabled=false;
        }else{document.getElementById('btnSubmit').disabled=true}
    }//End function
    //Function to show and hide the What is this ? section
    function fnShowWhat()
    {
    document.getElementById('div_Whatisthis').style.display='block';
    }
    //Function to hide the ? section
    function fnHideWhat()
    {
    document.getElementById('div_Whatisthis').style.display='none';
    }
    //***Function to show the password field on clieck on the Sign me up..***

    function fnShowpassword()
    {
        if(document.getElementById('chkSignmeup').checked)
        {
        document.getElementById('tblAccount').style.display='';
        }else{document.getElementById('tblAccount').style.display='none';}
    }
    //***Function to show the benefits div***
    function Showdivbenefits()
    {
    document.getElementById('divbenefits').style.display=''; 
    }
    //***Function to hide the benefits div***
    function HideDivBenefits()
    {
    document.getElementById('divbenefits').style.display='none'; 
    }

//***Function of the Registration guest form***
 //Accept and Reject policy
function reject_policy()
{
alert("We are sorry but if you will not accept the privacy policy you will not be able to register on our site.");
document.getElementById('btnRegister').disabled = true;
}

function accept_policy()
{
document.getElementById('btnRegister').disabled = false;
}

//Function to change the class of the Register button
function fnRegisterover()
{
document.getElementById('btnRegister').className='bgrnd_InputSendOver';
}
function fnRegisterout()
{
document.getElementById('btnRegister').className='bgrnd_InputSendout';
}

//Function to change the class of the Clear button
function fnClearover()
{
document.getElementById('btnClear').className='bgrnd_InputClearOver';
}
function fnClearout()
{
document.getElementById('btnClear').className='bgrnd_InputClear';
}
//***End***

//Function to change the class of the change password 
function fnChangePassover()
{
document.getElementById('btnChangePassword').className='btn_InputChangePassOver';
}
function fnChangePassout() 
{
document.getElementById('btnChangePassword').className='btn_InputChangePass';
}
//***End***

//Function to set the classes for the Send buttons

function fnResetover()
{
document.getElementById('btnReset').className='bgrnd_InputResetOver';
}
function fnResetout()
{
document.getElementById('btnReset').className='bgrnd_InputResetout';
}

//Function to set the classes for the Submit buttons

function fnSubmitover()
{
document.getElementById('btnSubmit').className='bgrnd_InputSendOver';
}
function fnSubmitout()
{
document.getElementById('btnSubmit').className='bgrnd_InputSendout';
}


//Function to change the class of the Register button
function fnEditInfoover()
{

document.getElementById('btnEdit').className='btn_InputEditInfo';
}
function fnEditInfoout()
{

document.getElementById('btnEdit').className='btn_InputEditInfoOver';
}
//***Functions of the EditReservation page 
//***Function to open the Booking form***
function GotoBooking()
{
window.location="http://www.benvenutolimos.com/BookingForm.asp";
	//window.location = "http://localhost/benvenutolimos/BookingForm.asp";
	
}

//Function to set the classes for the Ok/All Correct buttons

function fnCorrectover()
{
document.getElementById('btnok').className='bgrnd_InputCorrectOver';
}
function fnCorrectout()
{
document.getElementById('btnok').className='bgrnd_InputCorrectout';
}

//Function to set the classes for the Re-Edit buttons

function fnEditover()
{
document.getElementById('btnedit').className='bgrnd_InputEditOver';
}
function fnEditout()
{
document.getElementById('btnedit').className='bgrnd_InputEditout';
}

//***Function of the forgot password pages***
//Function to change the class of the Register button
function fnResetPassover()
{
document.getElementById('btnResetPass').className='btn_InputFogotPassOver';
}
function fnResetPassout() 
{
document.getElementById('btnResetPass').className='btn_InputFogotPass';
}

//***End***

//Function to set the classes for the Send buttons  on the QuoteRequestSelection.asp page

function fnSendover()
{
document.getElementById('btnSend').className='bgrnd_InputSendOver';
}
function fnSendout()
{
document.getElementById('btnSend').className='bgrnd_InputSendout';
}
//***Function of Login pages***
function fnLoginover()
{

document.getElementById('btnLogin').className='bgrnd_InputSignInOver';
}
function fnLoginout()
{
document.getElementById('btnLogin').className='bgrnd_InputSignInout';
}
//End if 

// Function to hide the Sign in menu option from the Menu if user is loged in already then Sign should not show , we are setting the style of the div as well

function fnhidesign()
{
document.getElementById('sign').style.display='none'; 
document.getElementById('MMMenu0804204214_tourenroute').style.left='112px'; 
document.getElementById('MMMenuContainer0804204214_0').style.left='609px';
}





