var s =true;
var d = document;
var j = d.links;
var FORM=0;
var theURL= location.href;
var Rand = Math.random().toString();
var Random = Rand.substring(2,6);
var index = (theURL.substring(theURL.length-1).indexOf('/')!=-1)?true:false;

function rollOn(i){if(i.title){i.bgColor='#993399';i.firstChild.style.color='#ffcf00';s=false;}}
function rollOff(i){i.bgColor = "";i.firstChild.style.color='';s=true;}
var live = (theURL.indexOf('index.htm')!=-1 || theURL.indexOf('cu.asp')!=-1)?true:false;
function init(){
if (s){

for (i in j){
//  if (theURL.indexOf('_live')!=-1){ alert(''+(j[i].href!='')?j[i].href:false);}
 if (j[i].href && j[i].href.match(theURL)!=null && !index){
  j[i].parentNode.bgColor='#993399';
  j[i].style.color='#ffcf00';//'ffcf00';
   }
  }   
 if (index){j[0].parentNode.bgColor='#993399';
  j[0].style.color='#ffcf00';
  }
 }
 if (FORM==1){document.forms[0].Name.focus();FORM++}
if (window.status!=document.title) window.status = document.title;
 return setTimeout("init()",400);

}
 
 


function gl(l){return document.getElementById(l)}
function trim(s){return s.replace(/\s/g,'')}
var newDate;

function checkStatus(){
D = document.forms[0].Start_Month;
StartMonth = D.options[D.options.selectedIndex].text;
Day = new Date(newDate).strDay(new Date(newDate).getDay())
document.forms[0].Start_WeekDay.value = Day;
//alert(StartMonth+'\n'+newDate)//new Date(newDate).toGMTString())//+'\n'+YEAR); 
//return false;

 if (new Date().getTime() > newDate){alert('You cannot reserve car hire in the past! \t\nPlease select a valid date...');
 return false;
 } else
 if (confirm('Is '+Day+', '+StartMonth+' '+newDay+', '+newYear+' the \t\ncorrect date to start your hire? ')){
 document.forms[0].StartMonth.value = StartMonth; return true;} else return false;
}

var sPrice=0;
var Selected;
function showCar(car){
Selected = car;
//alert(whichCar)
if (car != Selected){Selected = car}

T = new Date();
D = document.forms[0]//.elements;
newDay = D.Start_Day.options.selectedIndex+1;
newMonth = D.Start_Month.options[D.Start_Month.options.selectedIndex].value; 
newYear = D.Start_Year.options.selectedIndex;
newYear = D.Start_Year.options[newYear].text; 
newDate = new Date(newYear,newMonth,newDay,T.getUTCHours(),T.getUTCMinutes(),T.getUTCSeconds(),T.getUTCMilliseconds())
newDate = new Date().setTime(newDate)
//newDate = new Date(newDate).toGMTString()
season = (newMonth<6 || newMonth >8)?8:9;
c = cars[Selected].split('|');
gl('Model').innerHTML=trim(c[0])+' '+trim(c[1]);gl('Seats').innerHTML=trim(c[2]);
gl('Doors').innerHTML=trim(c[3]);gl('CC').innerHTML=trim(c[4]);gl('Conv').innerHTML=trim(c[5]);
gl('FWD').innerHTML=trim(c[6]);gl('AC').innerHTML=trim(c[7]);
sPrice = trim(c[season]).split(',');
sub=String(sPrice[gl('selPrice').selectedIndex]);
sub = (sub.indexOf('.')==-1)?sub+'.00':sub;sub = trim(sub);
d5=c[8];d7=c[9];d10=c[11];d14=c[12];xtra=c[13];
gl('Price').value = '€'+sub;
gl('Specials').innerHTML=(c[10]=='')?'&nbsp;':c[10];
document.searchCars.subTotal.value=sub;
carFeatures = trim(c[0])+' '+trim(c[1])+' '+trim(c[4])+'L, '+trim(c[3])+'dr';
carFeatures += (trim(c[5]).toLowerCase()=='yes')?', Convertible':'';
carFeatures += (trim(c[6]).toLowerCase()=='yes')?' with A/C':'';
document.searchCars.carModel.value=carFeatures;
document.searchCars.hireLength.value=gl('selPrice').value;
gl('DISPLAY_TABLE').style.visibility='visible'; document.searchCars.Bot.focus();
formStatus = true;
}

function toggleDisplay(r){
ARow = eval("gl('AccommRow').style.display");
FRow = eval("gl('FlightRow').style.display");
if (r == 'Accomm'){gl('FlightRow').style.display='none'; return gl('AccommRow').style.display = '';} 
if (r != 'Accomm'){gl('FlightRow').style.display=''; return gl('AccommRow').style.display = 'none';} 
//FRow = FRow(FRow=='')?'':'none'; return ARow='none';
}

function toggle(r){
el = r.split('_');
i = 1;
 while (i<10){
 if (gl(i)!=null ){
  if (r!=i){
   gl(i).style.display = 'none'
   gl(i+'_head').style.color = '';
   gl(i+'_top').style.display = 'none';
   gl(i+'_bot').style.display = 'none';
   }
  } else { break;}
 i++
 }
gl(r).style.display = (gl(r).style.display !='none')?'none':'';
gl(r+'_head').style.color = (gl(r+'_head').style.color != 'white')?'white':'';
gl(r+'_top').style.display = (gl(r+'_top').style.display !='none')?'none':'';
gl(r+'_bot').style.display = (gl(r+'_bot').style.display !='none')?'none':'';
}


function upDatePrice(a){
subPrice = (sPrice[a].indexOf('.')==-1)?sPrice[a]+'.00':sPrice[a];
gl('Price').value = '€'+subPrice;document.searchCars.subTotal.value=trim(subPrice);
document.searchCars.hireLength.value=gl('selPrice').value;
}

function setMsg(n){
thisContact = contacts[n].split('|');
thisSubject = thisContact[1];
thisMailTo = thisContact[0]
f = document.contact;
f.mailTo.value = thisMailTo;//contacts.options[n].selectedIndex.value;
//f.Comments.value = thisSubject;
f.Subject.value = thisSubject;//f.Contacts.options.selectedIndex.text;
}
function writeContacts(){
document.write('<select name="Contacts" id="Contacts" class="Contact" onChange="setMsg(this.selectedIndex)">');
for (i=0;i<contacts.length;i++){
 c = contacts[i].split('|');
 mail = trim(c[0]); subject = c[1];
 document.write('<option value="'+mail+'">'+subject+'</option>');
 }
 document.write('</select>');
 document.write('<input type="hidden" name="mailTo" value="'+contacts[0].split('|')[0]+'">');
 document.write('<input type="hidden" name="Subject" value="'+contacts[0].split('|')[1]+'">');
// document.write('<input type="text" name="SubjectBox" value="">')
 FORM=1;
}
var isEmail1    = /^\w+([\.\-]\w+)*\@\w+([\.\-]\w+)*\.\w+$/;
var isEmail2    = /^.*@[^_]*$/;
var ip = '(25[0-5]|2[0-4]\\d|1\\d\\d|\\d\\d|\\d)';
var ipdot = ip + '\\.';
isIPaddress = new RegExp('^'+ipdot+ipdot+ipdot+ip+'$');
function isEmail(s) {
  return (isEmail1.test(s) && isEmail2.test(s));
}
var Sent=false;
function checkForm(n){
if (Sent){alert('Your booking request is being processed, please wait...'); return false;}
 if (trim(gl('Rand').value)!=Random){alert('**Anti-Spam Measures**\n\nPlease enter '+Random+' to submit this form!\t');
  gl('Rand').focus();
  return false; 
 }
formName = document.forms[n];
 if (gl('Name').value.length < 2){
  alert('Please complete your name!\t'); gl('Name').focus();return false;
  }
 if (!isEmail(gl('Email').value)){
  alert('Please complete your email address!\t');gl('Email').focus();return false;
  }
  if (n == 'tstest'){
   if (gl('Time').value.length ==0 || gl("Time").value.indexOf('36')!=-1){
   alert('Please complete the hire start time!\t\n\n'); 
   gl('Time').focus();
   gl('Time').value= '21:36';
   return false;
   }
//  return alert(gl('Airport').checked+'\n'+gl('Accomm').checked+'\n'+gl('Flight_No').value)
  if (gl('Accomm').checked && (gl('Resort').value.indexOf('Example:')!=-1 || gl('Resort').value=='')) {
  alert("You want the car delivered to your Accomodation,\t\nbut you haven't given the name and location of it.");
  gl('Resort').focus();
  gl('Resort').value = 'Example: Olive Grove, Svoronata';
  return false;
  }
  
  if (gl('Airport').checked && (gl('Flight_No').value=='' || gl('Flight_No').value.indexOf('FCH')!=-1)) {
  alert("You want the car delivered to the Airport, but \t\nyou haven't given us your flight number.");
  gl('Flight_No').focus();
  gl('Flight_No').value = 'FCH2022A';
  return false;
  }

  gl('Extras').value = (gl('Extras').value.indexOf('etc.?')!=-1)?'':gl('Extras').value; 
  gl('Extras').wrap = (gl('Extras').value=='')?'soft':'hard';
  gl('Resort').value = (gl('Resort').value.indexOf('Example:')!=-1)?'':gl('Resort').value; 
  gl('Flight_No').value = (gl('Flight_No').value.indexOf('FCH')!=-1)?'':gl('Flight_No').value; 
 }//Close tstest form
 if (n == 'contact'){
 if (gl('Comments').value==''){alert('You have not made any comments!\t');gl('Comments').focus();
 return false;
  }
 } Sent = true; return true;
}

thisYEAR = new Date().getFullYear();
var min_year = thisYEAR-0; // defines lowest year in year menu
var max_year = thisYEAR + 3; // defines highest year in the year menu

// make this false to prevent the weekday element from being displayed
var weekday_showing = true;

// make this true to make dayofweek return a number (0-6)
var dayofweek_returned_as_number = false;

// make this true to make month return a number (0-11)
var month_returned_as_number = true;

if (min_year <= 400)
 alert("Minimum year must be higher than 400 for this algorithm to work.");
 
// The following code adds three methods to the built-in Date object
function _strMonth() {
 var months = new Array("January", "February", "March", "April",
    "May", "June", "July", "August", "September", "October", 
    "November", "December");
return months[this.getMonth()];
}

function _strDay() {
 var days= new Array("Sunday", "Monday", "Tuesday", "Wednesday", 
     "Thursday", "Friday", "Saturday");
return days[this.getDay()];
}

function _weekOf() {
 sunday = ((arguments[0]==null) || (!arguments[0])); // Check for optional argument
return (new Date(this - ((this.getDay() - ((sunday) ? 0 : 1)) *24*60*60*1000)));
}
T = new Date()
// Add these methods to all dates
Date.prototype.weekOf = _weekOf;
Date.prototype.strMonth = _strMonth;
Date.prototype.strDay = _strDay;
//if (theURL.indexOf('ch.htm')!=-1)  alert(T.strMonth())
function changeDays(numb,date_form,aname) {
 MonthCtrl = eval("date_form." + aname +"_Month");
 DayCtrl = eval("date_form." + aname +"_Day");
 YearCtrl = eval("date_form." + aname +"_Year");
 
 mth = eval(MonthCtrl.value);
 sel = eval(YearCtrl.selectedIndex);
 yr = eval(YearCtrl.options[sel].text);

 if (numb != 1) {
  numDays = numDaysIn(mth,yr);
  eval("date_form." + aname +"_Day.options.length="+numDays) ;
  for (i=27;i<numDays;i++) {
   j=i+1;
   eval("date_form." + aname +"_Day.options["+i+"].text = "+j);
  }
 }if (Selected >=0) showCar(Selected);
}
 
function numDaysIn(mth,yr) {
 if (mth==3 || mth==5 || mth==8 || mth==10) return 30;
 else if ((mth==1) && leapYear(yr)) return 29;
 else if (mth==1) return 28;
 else return 31;
}

function leapYear(yr) {
 if (((yr % 4 == 0) && yr % 100 != 0) || yr % 400 == 0)
  return true;
 else
  return false;
}

function arr() {
 this.length=arr.arguments.length;
 for (n=0;n<arr.arguments.length;n++) {
  this[n] = arr.arguments[n];
 }
}

weekdays = new arr("Sun.","Mon.","Tues.","Wed.", "Thurs.","Fri.","Sat.");
 
months = new arr("January","February","March","April","May","June","July","August","September","October","November","December");
 
var cur = new Date();

function getWeekDay(mth,day,yr) {
 first_day = firstDayOfYear(yr);
 for (num=0;num<mth;num++) {
  first_day += numDaysIn(num,yr);
 }
 first_day += day-1;
return first_day%7;
}

function firstDayOfYear(yr) {
 diff = yr - 401;
 return parseInt((1 + diff + (diff / 4) - (diff / 100) + (diff / 400)) % 7);
}

// fixes a Netscape 2 and 3 bug
function getFullYear(d) { // d is a date object
 yr = d.getYear();
 if (yr < 1000)
  yr+=1900;
 return yr;
}


function datedrop(myname,feeddate){
feeddate = '5/1/'+thisYEAR;
lastDate = '10/31/'+thisYEAR;
NOW = new Date().getTime();
feeddate = (NOW > new Date(feeddate) && NOW < new Date(lastDate))?NOW:feeddate;
 if(!feeddate)
 {
  d=new Date();
  edmonth=d.getMonth();
  edday=d.getDate();
  edyear=d.getFullYear();
 }
 else
 {
  d=new Date(feeddate)
  edmonth=d.getMonth();
  edday=d.getDate();
  edyear=d.getFullYear();
 }

 // write month element
 
 document.write("<select name="+myname+"_Month size=1 class='Select' style='width:80' onChange='changeDays(0,this.form,"+'"'+myname+'"'+")'>");
 for (i=4;i<10;i++)
  document.write("<option"+(month_returned_as_number?" value="+i:"")
   +(edmonth==i?" selected":"")+">"+months[i]+"\n");

 // write day element
 document.write("</select><select name="+myname+"_Day size=1 class='Select' style='width:40' onChange='changeDays(0,this.form,"+'"'+myname+'"'+")'>\n");
 for (i=1;i<=numDaysIn(d.getMonth(),getFullYear(d));i++)
  document.write("<option"+(edday==i?" selected":"")+">"+i+"\n");
 document.write('</select>')
// Write WeekDay element
 document.write('<input type="hidden" value="" name="'+myname+'_WeekDay">')

 // write year element
 document.write("<select name="+myname+"_Year size=1 class='Select' style='width:55' onChange='changeDays(0,this.form,"+'"'+myname+'"'+")'>\n");
 for (i=min_year;i<max_year;i++)
  document.write("<option"+(edyear==i?" selected":"")+">"+i+"\n");
 document.write("</select>");
 document.write('<INPUT TYPE="HIDDEN" name="StartMonth">')
} 


function copyRight(){
code = '<a href="javascript:;" title="Web site designed and maintained by G&A Marketing" class="copyRight"><font color="#CCCCCC">&copy; 1974 - '+new Date().getFullYear()+' Pefanis Travel &amp; Rent A Car - Car Hire - 23 Vironos Str 28100 Argostoli Kefalonia Greece. Tel: +30 2 6710 25 47 1/2</font></a>'
document.write(code)
}

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

try {
var pageTracker = _gat._getTracker("UA-10342485-3");
pageTracker._trackPageview();
} catch(err) {}