﻿//New JavaScript

function OKProp(theForm)
{

  if (theForm.Property.value == "")
  {
    //alert("Please enter a value for the \"Property number\" field.");
    //theForm.Property.focus();
    return (true);
  }

  var checkOK = "0123456789";
  var checkStr = theForm.Property.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Property number\" field.");
    theForm.Property.focus();
    return (false);
  }

  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (chkVal != "" && !(prsVal >= "1"))
  {
    alert("Please enter a value greater than or equal to \"1\" in the \"Property number\" field.");
    theForm.Property.focus();
    return (false);
  }
  return (true);
}


function addBookmark(title, url) {
        if (window.sidebar) { // firefox
              window.sidebar.addPanel(title, url,"");
        } else if( document.all ) { //MSIE
                window.external.AddFavorite( url, title);
        } else {
               alert("Sorry, your browser doesn't support this");
        }
}

function addEventSimple(obj,evt,fn) {
	if (obj.addEventListener)
		obj.addEventListener(evt,fn,false);
	else if (obj.attachEvent)
		obj.attachEvent('on'+evt,fn);
}

function Checksite() {
var Url=document.forms[0].Website.value
var day = new Date();
var id = day.getTime();
window.open('https://bookholidayrentals.com/UrlCheck.asp?Website='+Url,id,'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=620,height=300,left=200,top=200');
}

function tel(event) {
Key=keypress_handler(event)
if (!its_a_tel(Key)) {
	//alert ('Only ()+-0123456789 and space accepted')
}
return (its_a_tel(Key))
}

function its_a_tel(character) {
    var digit_characters = " ()+-0123456789" + String.fromCharCode(8,46,37,39,96,97,98,99,100,101,102,103,104,105,107,109,32) 
    if (digit_characters.indexOf(character) == -1) {
        return false
    }
        return true
}
function integer(event) {
Key=keypress_handler(event)
if (!its_a_digit(Key)) {
	//alert ('only digits are accepted.')
}
return (its_a_digit(Key))
}
function FP_swapImg() {//v1.0
 var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
 n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
 elm.$src=elm.src; elm.src=args[n+1]; } }
}
function FP_preloadImgs() {//v1.0
 var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
 for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
}
function FP_getObjectByID(id,o) {//v1.0
 var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
 else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
 if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
 for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
 f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
 for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
 return null;
}
function get_cookie(name_to_get) {
var cookie_pair
var cookie_name
var cookie_value    
// Split all the cookies into an array
var cookie_array = document.cookie.split("; ")    
// Run through the cookies
for (counter = 0; counter < cookie_array.length; counter++) {   
	// Split the cookie into a name/value pair
	cookie_pair = cookie_array[counter].split("=")
	cookie_name = cookie_pair[0]
	cookie_value = cookie_pair[1]        
	// Compare the name with the name we want
	if (cookie_name == name_to_get) {       
		// If this is the one, return the value
		return unescape(cookie_value)}}
// If the cookie doesn't exist, return null
return null
}
function set_cookie(cookie_name, cookie_value, cookie_expire, cookie_path, cookie_domain, cookie_secure) {
    // Begin the cookie parameter string
    var cookie_string = cookie_name + "=" + cookie_value
    
    // Add the expiration date, if it was specified
    if (cookie_expire) {
        var expire_date = new Date()
        var ms_from_now = cookie_expire * 24 * 60 * 60 * 1000
        expire_date.setTime(expire_date.getTime() + ms_from_now)
        var expire_string = expire_date.toGMTString()
        cookie_string += "; expires=" + expire_string
    }
    
    // Add the path, if it was specified
    if (cookie_path) {
        cookie_string += "; path=" + cookie_path
    }

    // Add the domain, if it was specified
    if (cookie_domain) {
        cookie_string += "; domain=" + cookie_domain
    }
    
    // Add the secure boolean, if it's true
    if (cookie_secure) {
        cookie_string += "; true"
    }    
    // Set the cookie
    document.cookie = cookie_string
}
function radio_active(radio_group) {
    // Run through the group
    for (counter = 0; counter < radio_group.length; counter++) {    
        // When we find the activated button, return the index
        if (radio_group[counter].checked) {
            return counter}}
    // If no button is activated, return -1
    return -1
}
function Photo(Property) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open('ShowPicp.asp?Property=' + Property, + '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=340,left=0,top=0');");
}
function popUpBook(URL) {
var day = new Date();
var id = day.getTime();
window.open(URL,id,'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=840,height=760,left=100,top=100');
}
function AvailpopUp(URL) {
var day = new Date();
var id = day.getTime();
var l = (screen.availWidth-760) / 2;
var t = (screen.availHeight-20 - 474) / 2;
window.open(URL,id,'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=740,height=480,left = '+l+',top = '+t);
}
function popUp(URL) {
var day = new Date();
var id = day.getTime();
var l = (screen.availWidth-760) / 2;
var t = (screen.availHeight-20 - 474) / 2;
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=760,height=520,left = '+l+',top = '+t);");
}
function popUpRates(URL) {
var day = new Date();
var id = day.getTime();
var l = (screen.availWidth-760) / 2;
var t = (screen.availHeight-20 - 474) / 2;
window.open(URL,id,'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=500,height=360,left='+l+',top='+t);
}
function OpenFull(URL) {
var day = new Date();
var id = day.getTime();
var h=screen.availHeight
var w=screen.availWidth
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=' + screen.availWidth + ',height=' + screen.availHeight + ',left=0,top=0');");
}
function OpenFullW(URL) {
var h=screen.availHeight
var w=screen.availWidth-120
var o="toolbar,scrollbars,location,statusbar,menubar,resizable=1,width=" + w + ",height=" + h + ",left=60,top=0"
window.open(URL, "RN", o);
}
function popUpfriend(URL) {
var day = new Date();
var id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=720,height=500,left=0,top=0');");
}
function CalcpopUp() {
var day = new Date();
var id = day.getTime();
var l = (screen.availWidth-760) / 2;
var t = (screen.availHeight-20 - 474) / 2;
window.open('Calculator.asp',id,'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=740,height=470,left = '+l+',top = '+t);
}
function get_selections(current_list) {
var selected_array = new Array()
var current_index = 0
for (var counter = 0; counter < current_list.options.length; counter++) {
    if (current_list.options[counter].selected) {
        selected_array[current_index] = current_list.options[counter].index
        current_index++
    }
}
 return selected_array
}
function display_selected(current_list) {
var chosen_ones = new Array()
var val_sel
chosen_ones = get_selections(current_list)
for (counter = 0; counter < chosen_ones.length; counter++) {
    val_sel += current_list.options[chosen_ones[counter]].text
}
return (val_sel)
}

function display_selectedX(current_list) {
    var chosen_ones = new Array()
    chosen_ones = get_selections(current_list)
    var alert_message = "You chose the following items:\n\n"
    for (counter = 0; counter < chosen_ones.length; counter++) {
        alert_message += current_list.options[chosen_ones[counter]].text
    }
    alert(alert_message)
}
function RateLineAdd(yr, mth, mday, yr0, mth0, mday0) {
var err=0, fD, tD 
var fmd=new Date()
var tod=new Date()
document.forms[0].elements["Function"].value = 'Add'
fmd.setFullYear(yr.options[yr.selectedIndex].text)
fmd.setMonth(mth.options[mth.selectedIndex].index)
fmd.setDate(mday.options[mday.selectedIndex].text)
if (fmd.getDate() != (mday.selectedIndex + 1)) {err = 1; alert('From Day does not exist.')}
fD = yr.options[yr.selectedIndex].text 
if (fmd.getMonth() < 9) {fD = fD + '0'}
fD = fD + (fmd.getMonth() + 1) 
fD = fD + mday.options[mday.selectedIndex].text
tod.setFullYear(yr0.options[yr0.selectedIndex].text)
tod.setMonth(mth0.options[mth0.selectedIndex].index)
tod.setDate(mday0.options[mday0.selectedIndex].text)
if (tod.getDate() != (mday0.selectedIndex + 1)) {err = 1; alert('To Date does not exist')}
tD = yr0.options[yr0.selectedIndex].text
if (tod.getMonth() < 9) {tD = tD + '0'}
tD = tD + (tod.getMonth() + 1) 
tD = tD + mday0.options[mday0.selectedIndex].text
if (fmd > tod) {
	alert('From date cannot be greater than to date.');
	err=1;}
if (new Date() > tod) {alert('To date cannot be in the past.');
	err=1;}
if (document.forms[0].Amt.value == 0) {alert('Rate amount of zero not allowed.'); err=1 }

var checkOK = "0123456789";
  var checkStr = document.forms[0].Amt.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only numeric characters in the amount");
    err=1;
  }

if (err == 0) {document.forms[0].submit();}
}

function RateLineDelete(Startdate) {
document.forms[0].elements["Function"].value = 'Del'
	document.forms[0].elements["StartDate"].value = Startdate
    document.forms[0].submit();
}

function FormProcess(Which) {
	if (Which == 'AddnewProperty') {document.forms[0].action='AddnewProperty.asp'
		document.forms[0].B1.disabled='disabled'
		document.forms[0].submit()}
	else {
		GetTabDat()	
		if (Which == 'Availability') {document.forms[0].action='Availability.asp'}
		if (Which == 'MakeLive') {document.forms[0].action='MakeLive.asp'}
		if (Which == 'Photo') {document.forms[0].action='UploadImages.aspx'}
		if (Which == 'Dp') {document.forms[0].action='ShowProperty.asp'}
		if (Which == 'De') {document.forms[0].action='ShowExtra.asp'}
		if (Which == 'Rates') {document.forms[0].action='UpdRates.asp'}
		if (Which == 'Extra') {document.forms[0].action='Extra.asp'}
		if (Which == 'Multi') {document.forms[0].action='Multi.asp'}
		if (Which == 'Property') {document.forms[0].action='Property.asp'
			if (get_cookie('Offer') == '0') {document.forms[0].action='FProperty.asp'} 
		}		
		document.forms[0].action='Extra.asp';}
}

function tick() {
  var hours, minutes, seconds, ap;
  var intHours, intMinutes, intSeconds;
  var dayn, day, month, year
  var today, UTCdate, Offset;
  today = new Date();
  UTCdate = new Date();
//  UTCdate =	today.getUTCDate
  Offset = today.getTimezoneOffset
  
//  intHours = 1 + today.getUTCHours();
	intHours = today.getHours();
  intMinutes = today.getUTCMinutes();
  intSeconds = today.getUTCSeconds();
  
    day = day_name(today.getDay());
    dayn = today.getDate()
    month= month_name(today.getMonth());
	year=today.getFullYear();
  
  
  if (intHours > 23) {
	 intHours = 0}
	
     hours = intHours + ":";
     ap = "";

  if (intMinutes < 10) {
     minutes = "0"+intMinutes+":";
  } else {
     minutes = intMinutes+":";
  }

  if (intSeconds < 10) {
     seconds = "0"+intSeconds+" ";
  } else {
     seconds = intSeconds+" ";
  } 

	
  var timeString = day+", "+dayn+" "+" "+month+" "+year+" "+ hours+minutes+seconds+ap;
  
  document.getElementById('Clock2').innerHTML = timeString;
  window.setTimeout("tick();", 100);
}

function updateChrs(it, numb) {
document.forms[0].Ct1.value = numb - it.value.length;
}

function updateChrs2(numb) {
document.forms[0].Ct1.value = numb - document.forms[0].TextData.value.length;
}

function Prop_Click(OptID) {
set_cookie('Property',OptID.value)
document.forms[0].elements['Property'].value = OptID.value
var tbodynode = document.getElementById("T1")
var Rows = tbodynode.childNodes.length - 1
for (var row_counter = 1; row_counter <= Rows; row_counter++) {
	if (document.forms[0].Property.value == tbodynode.childNodes[row_counter].childNodes[0].childNodes[0].nodeValue) {
  	 	document.forms[0].Offer.value =	tbodynode.childNodes[row_counter].childNodes[5].childNodes[0].nodeValue
  	 	set_cookie('Offer',tbodynode.childNodes[row_counter].childNodes[5].childNodes[0].nodeValue)
		 if (tbodynode.childNodes[row_counter].childNodes[5].childNodes[0].nodeValue == '2') {
		 document.forms[0].B2.style.visibility='visible'}
	 else {document.forms[0].B2.style.visibility='hidden'}
	 	 if (tbodynode.childNodes[row_counter].childNodes[5].childNodes[0].nodeValue == '0') {
		document.forms[0].Avaimg.style.visibility='hidden'
		document.forms[0].RR.style.visibility='hidden'}
		 else {document.forms[0].Avaimg.style.visibility='visible'
		 	document.forms[0].RR.style.visibility='visible'}		
	 break }
} // End for
}

function Own_load() {
get_cookie('Offer')
if (get_cookie('Offer') == '2') {
	document.forms[0].B2.style.visibility='visible'}
else {document.forms[0].B2.style.visibility='hidden'}
if (get_cookie('Offer') == '0') {
	document.forms[0].RR.style.visibility='hidden'
	document.forms[0].Avaimg.style.visibility='hidden'}
else {document.forms[0].RR.style.visibility='visible'
	document.forms[0].Avaimg.style.visibility='visible'}
}

function GetTabDat() {
// Retrieve Data from table
var oRow, curr_row, curr_cell;
for (curr_row = 0; curr_row < Properties.rows.length; curr_row++)
{	oRow = Properties.rows[curr_row];
	idx = radio_active(document.forms[0].PropertyNo)	
		if ((radio_active(document.forms[0].PropertyNo)+1)==curr_row) {
}}}

function Owners(fm) {
X = FrontPage_Form1_Validator(document.forms[0])
if (X == (true)) {
	if (document.forms[0].PassWord.value != document.forms[0].PassWord2.value) {alert('Passwords do not match - please reenter');}
	else
		//document.forms[0].Next.disabled='disabled'
		document.forms[0].submit();
}}

function Owners2(fm) {
	X = FrontPage_Form1_Validator(document.forms[0])
if (X == (true)) {
	if (document.forms[0].PassWord.value != document.forms[0].PassWord2.value) {alert('Passwords do not match - please reenter');}
	else
		if (document.forms[0].Accept.checked) {document.forms[0].submit();
			document.forms[0].Next.disabled='disabled'}
		else
		{alert('You must accept the terms and conditions of use to register')}
}}

function Hover1(tbl,idx,cls) {
var t,d;
if(document.getElementById)t=document.getElementById(tbl);
else t=document.all(tbl);
if(t==null)return;
if(t.getElementsByTagName)d=t.getElementsByTagName("TD");
else d=t.all.tags("TD");
if(d==null)return;if(d.length<=idx)return;d[idx].className=cls;
}

function Search1() {
//var t;
//t=document.getElementById('SE1');
//t.className='Text';
}

function pp() {
document.forms[0].elements['Next'].value='PP.asp';
document.forms[0].submit();
}

function P1(Picture) {
document.forms[0].elements['Photo'].value = Picture;
if (Picture==9) document.forms[0].action='UploadLogo.asp';
else document.forms[0].action='UploadIMage.asp';
document.forms[0].submit()
}

function P2(Picture) {
document.forms[0].elements['Photo'].value = Picture;
if (Picture==9) {document.forms[0].elements['Next'].value='UploadLogo.asp';}
else {
document.forms[0].elements['Next'].value='UploadIMage.asp';}
document.forms[0].submit()
}

function cfm() {
var sub_ok = confirm('Are you very sure ?')
if (sub_ok) {
	document.forms[0].submit()
	}
}

function VTexts(Which) {
document.forms[0].elements['Texts'].value = Which
document.forms[0].action='Texts.asp'
document.forms[0].submit()
}

function VTexts2(Which) {
document.forms[0].elements['Texts'].value = Which
document.forms[0].elements['Next'].value = 'Texts.asp'
document.forms[0].action='PUpdate.asp'
document.forms[0].submit()
}

function VTexts2A(Which) {
document.forms[0].elements['Texts'].value = Which
document.forms[0].elements['Next'].value = 'Texts.asp'
document.forms[0].action='PUpdate.asp'
document.forms[0].submit()
}

function Sform_Validator(theForm)
{

  if (theForm.Property.value == "")
  {
    alert("Please enter a value for the \"Property number\" field.");
    theForm.Property.focus();
    return (false);
  }

  if (theForm.Property.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Property number\" field.");
    theForm.Property.focus();
    return (false);
  }

  var checkOK = "0123456789-";
  var checkStr = theForm.Property.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Property number\" field.");
    theForm.Property.focus();
    return (false);
  }

  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (chkVal != "" && !(prsVal >= "1"))
  {
    alert("Please enter a value greater than or equal to \"1\" in the \"Property number\" field.");
    theForm.Property.focus();
    return (false);
  }
  return (true);
}

function climate(Dept) {
day = new Date();
id = day.getTime();
l = (screen.availWidth-790) / 2;
t = (screen.availHeight-20 - 395) / 2;
eval("page" + id + " = window.open('http://www.meteofrance.com/FR/climat/tmd/' + Dept + '/zcdm24.jsp', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=790,height=395,left = '+l+',top = '+t);");
}

function GoodProp(theForm)
{

  if (theForm.Property.value == "")
  { return (true); }

  var checkOK = "0123456789";
  var checkStr = theForm.Property.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Property number\" field.");
    theForm.Property.focus();
    return (false);
  }

  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (chkVal != "" && !(prsVal >= "1"))
  {
    alert("Please enter a value greater than or equal to \"1\" in the \"Property number\" field.");
    theForm.Property.focus();
    return (false);
  }
  theForm.action='http://bookholidayrentals.com/SP.asp?Property=' + theForm.Property.value;
  theForm.submit();
  return (true);
}
             
function notme() {
document.forms[0].elements['Email'].value = ''
set_cookie('Email', '', -1)
}
function Edt(Prop, Pub) {
document.forms[0].elements["Property"].value = Prop
set_cookie('Property',Prop)
document.forms[0].elements["Pub"].value = Pub
document.forms[0].action='PUpdate.asp'
document.forms[0].submit();
}
function Edt9(Prop, Pub) {
document.forms[0].elements["Property"].value = Prop
set_cookie('Property',Prop)
document.forms[0].elements["Pub"].value = Pub
document.forms[0].action='Grpcfg.asp'
document.forms[0].submit();
}
function Edt2(Prop, Pub) {
document.forms[0].elements["Property"].value = Prop
set_cookie('Property',Prop)
document.forms[0].elements["Pub"].value = Pub
document.forms[0].action='PUpdate.asp'
document.forms[0].submit();
}
function Renew(Prop) {
document.forms[0].elements["Property"].value = Prop
set_cookie('Property',Prop)
document.forms[0].action='PP.asp'
document.forms[0].submit();
}
function Upg(Prop, Offer) {
document.forms[0].elements["Property"].value = Prop
set_cookie('Property',Prop)
document.forms[0].elements["Offer"].value = Offer
document.forms[0].action='Upgrade.asp?F=1'
document.forms[0].submit();
}
function LastRec(Prop) {
document.forms[0].elements['Next'].value = 'Yes'
document.forms[0].submit();
}
function Back(Prop) {
document.forms[0].elements['Back'].value = 'Yes'
document.forms[0].submit();
}

function FormProcess2(current_form) {
current_form.Search1.value = 'Yes'
current_form.submit()
}

function PreTheme(Property) {
day = new Date();
id = day.getTime();
var Theme = document.forms[0].elements["SS"].value
var Lay = document.forms[0].elements["Layout"].value
l = 0;
t = 0;
if (Lay==0) {eval("page" + id + " = window.open('ShowProperty.asp?Property='+Property+'&Live=0&ss='+Theme, '" + id + "', 'toolbar=0,scrollbars=1,location=1,statusbar=0,menubar=0,resizable=1,width=800,height=600,left = '+l+',top = '+t);");
}
else {eval("page" + id + " = window.open('ShowProperty' + Lay + '.asp?Property='+Property+'&Live=0&ss='+Theme, '" + id + "', 'toolbar=0,scrollbars=1,location=1,statusbar=0,menubar=0,resizable=1,width=800,height=600,left = '+l+',top = '+t);");
}}                
        function onGotRoute(route)
         { routed=route;
           var routeinfo="<font>Route info:<br/><br/>";
            routeinfo+="Total distance: ";
            routeinfo+=   route.Itinerary.Distance+" ";
            routeinfo+=   route.Itinerary.DistanceUnit+"</font><br/><br/>";
            
            var steps="";
            var len = route.Itinerary.Segments.length;
               for(var i = 0; i < len ;i++)
               {
                  steps+=i+" "+route.Itinerary.Segments[i].Instruction+" -- (";
                  steps+=route.Itinerary.Segments[i].Distance+") ";
                  steps+=route.Itinerary.DistanceUnit+"<br/>";
               }
            routeinfo+="Steps:<br>"+steps+'<br/>';
            document.getElementById('dir').innerHTML = routeinfo;
            //alert(routeinfo);
         }
         
function RatesH() {
if (document.forms[0].elements["AR"].checked == true) {
	document.getElementById('Rates1').style.display='none';}
else {document.getElementById('Rates1').style.display='inline';}
}

function Scfm() {
if (document.getElementById('Act').checked == false) 
	{alert ('You must also select the option.');}
else
{ var sub_ok = confirm('Are you sure ?');
	if (sub_ok) { document.forms[0].submit();}
}}

function toggle(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'inline';
	}
	else {
		el.style.display = 'none';
	}
}

function costit(offer) {
var mess=''
if (offer == '0') {
mess='You have selected our <b>Directory entry</b> offer (Free for the life of the add).' 
}
if (offer == '1') {
mess='You have selected <b>Premier Advertisement</b> annual subsciption £99:00 Discounts apply for multiple advertisements.' 
}
if (offer == '2') {
mess='You have selected <b>Create a website</b> annual subsciption £139:00. Discounts apply for multiple websites.' 
}
if (offer == '7') {
mess='You have selected a <b>Grouped Property Website</b> - Annual Subscription £40:00' 
}
if (offer == '8') {
mess='You have selected <b>Web Eco Option</b> annual subscription £69:00. Discounts apply for multiple advertisements.'; 
document.getElementById('URL').checked=false;
document.getElementById('mess2').style.display='none';
}
if (offer == '9') {
mess='You have selected a <b>Property Group</b> - Free while you have other eligible offers.' 
}
document.getElementById('mess').innerHTML=mess;
}

function Deletelink(Prop) {
document.forms[0].elements["DelProp"].value = Prop
    document.forms[0].submit();
}

function its_a_digit(character) {

    var digit_characters = "0123456789" + String.fromCharCode(8,46,37,39,96,97,98,99,100,101,102,103,104,105)

    // If it's not in the digit_characters string,
    // then it's not a digit so return false
    
    if (digit_characters.indexOf(character) == -1) {
        return false
    }
    
    // Otherwise, it's a digit, so return true
    return true
}

function its_integer(string_value) {

    // Run through each character in the string
    for (var counter = 0; counter < string_value.length; counter++) {
        
        // Get the current character
        current_char = string_value.charAt(counter)
        
        // If it's not a digit, return false
        if (!its_a_digit(current_char)) {
            return false
        }
    }
    
    // Otherwise, the string has nothing but digits, so return true
    return true
}

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) { // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
countfield.value = maxlimit - field.value.length; }
else {
countfield.value = maxlimit - field.value.length; }
}

function validate_email(field,alerttxt)
{
var apos=field.value.indexOf("@")
var dotpos=field.value.lastIndexOf(".")
if (apos<1||dotpos-apos<2) 
  {alert(alerttxt);return false}
else {return true}
}

function Payfor(Special,amount,order_id) {
document.getElementById('amount').value=amount
document.getElementById('SPECID').value='S'+order_id
document.getElementById('PayForm').submit();}

function AddSpecial(yr, mth, mday, yr0, mth0, mday0, amt) {
var err=0, fD, tD, dte 
dte=new Date();dte.setSeconds(0);
fmd=new Date();dte.setSeconds(0);
tod=new Date();dte.setSeconds(0);
document.forms[0].elements["Function"].value = 'Add'
fmd.setFullYear(yr.options[yr.selectedIndex].text)
fmd.setMonth(mth.options[mth.selectedIndex].index)
fmd.setDate(mday.options[mday.selectedIndex].text)
if (fmd.getDate() != (mday.selectedIndex + 1)) {err = 1; alert('Advertise from Date does not exist.')}
fD = yr.options[yr.selectedIndex].text 
if (fmd.getMonth() < 9) {fD = fD + '0'}
fD = fD + (fmd.getMonth() + 1) 
fD = fD + mday.options[mday.selectedIndex].text
tod.setFullYear(yr0.options[yr0.selectedIndex].text)
tod.setMonth(mth0.options[mth0.selectedIndex].index)
tod.setDate(mday0.options[mday0.selectedIndex].text)
if (tod.getDate() != (mday0.selectedIndex + 1)) {err = 1; alert('Rental start Date does not exist')}
tD = yr0.options[yr0.selectedIndex].text
if (tod.getMonth() < 9) {tD = tD + '0'}
tD = tD + (tod.getMonth() + 1) 
tD = tD + mday0.options[mday0.selectedIndex].text
if (fmd > tod) {
	alert('Advertise from date cannot be greater than rental start date.');
	err=1;}
if (dte > tod) {alert('Rental start date cannot be in the past.' + new Date() + tod);
	err=1;}
if (document.forms[0].Amt.value == 0) {alert('Empty period field not allowed.'); err=1 }
if (!its_integer(document.forms[0].Amt.value)) {alert('Non numberic period value.'); err=1 } 
if (err == 0) {document.forms[0].submit();}
}
function keypress_handler(key_event) {
    if (document.all) {
        //Probably Internet Explorer 4 and later
        Key = String.fromCharCode(event.keyCode)
        return Key
    }
    else if (document.getElementById) { 
        // Probably Netscape 6 and later
        Key = String.fromCharCode(key_event.which)
        return Key
    }
    else if (document.layers) {
        // Probably Netscape 4
        Key = String.fromCharCode(key_event.which)
        return Key
    }
    Key = String.fromCharCode(key_event.which)
    return Key

}
function hdays() {
if (document.getElementById('days').options[0].selected) { 
 document.getElementById('Price').value='';
 document.getElementById('HAS').style.color='silver';
 document.getElementById('Price').disabled='disabled';}
else { document.getElementById('Price').disabled='';
 document.getElementById('HAS').style.color='black';}
}
function ps() {
	document.getElementById('S0').style.display='inline';
}
function month_name(month_value) {
    switch (month_value) {
        case 0 : return "January"
        case 1 : return "February"
        case 2 : return "March"
        case 3 : return "April"
        case 4 : return "May"
        case 5 : return "June"
        case 6 : return "July"
        case 7 : return "August"
        case 8 : return "September"
        case 9 : return "October"
        case 10 : return "November"
        case 11 : return "December"
        default: return "Unknown"
    }
}
function day_name(day_value) {
    switch (day_value) {
case 0 : return "Sunday"
case 1 : return "Monday"
case 2 : return "Tuesday"
case 3 : return "Wednesday"
case 4 : return "Thursday"
case 5 : return "Friday"
case 6 : return "Saturday"
default: return "Unknown"

}}
function SetRegion(Region, mapname) {
set_selected(document.getElementById('Area'),Region)
document.getElementById('SelMap').value=mapname
FillDept(Region)
}
function delspec(Id) {
document.getElementById('ID').value=Id;
document.getElementById('F1').submit();
}

function Res() {
set_cookie('sHeight', screen.height, 7, null, 'bookholidayrentals.com')
set_cookie('sWidth', screen.width, 7, null, 'bookholidayrentals.com')
//document.cookie = "wHeight=" + screen.height + ";";
//document.cookie = "wWidth=" + screen.width + ";";
}
