// Navigation related //

var currentNavID = '';

var timing = 1;



function showSubNav(id) {

  cancelTimer();

  if (currentNavID != id) {

    hideSubNav(currentNavID);

  }

  //document.getElementById('nav'+id).className = 'hover';

  if (document.getElementById('subnav'+id) != null) {

    document.getElementById('subnav'+id).style.display = 'block';

  }

  imageOn(id);

  currentNavID = id;

}



function hideSubNav(id) {

  if (currentNavID == '') { return }

  //document.getElementById('nav'+id).className = 'ed';

  if (document.getElementById('subnav'+id) != null) {

    document.getElementById('subnav'+id).style.display = 'none';

  }

  imageOff(id);

}



function navOut() {

  doTimer(currentNavID);

}



function navOver() {

  cancelTimer();

}



function doTimer(id) { 

  clearTimeout(timing);

  ref = id;

  timing = setTimeout('hideSubNav(ref);', 1);

}



function cancelTimer() {

  clearTimeout(timing);

}



function getResultsPage(frm, i) {

  frm.start.value = i;

  frm.submit();

  return false;

}



function newWindow(url, name, width, height) {

  photoWindow = window.open(url, name,"location=no,directories=no,menubar=no,status=no,toolbar=no,scrollbars=yes,height=" +height+ ",width=" +width+ ",resizable=yes");

  photoWindow.resizeTo(width,height);

  photoWindow.focus();

  return false;

}



function printWindow(url, name, width, height) {

  photoWindow = window.open(url, name,"location=no,directories=no,menubar=yes,statusbar=no,toolbar=yes,scrollbars=yes,height=" +height+ ",width=" +width+ ",resizable=yes");

  photoWindow.resizeTo(width,height);

  photoWindow.focus();

  return false;

}



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



var features = new Array;

var fid = 0;



function initFeatures() {

  for (var i=0; i<features.length; i++) {

    preLoadFeature('I'+i, features[i].image);

  }

  doNextFeature();

}



function doNextFeature() {

  fid++;

  if (fid >= features.length) {

    fid = 0;

  }

  switchContent('theAdvert', features[fid].theValue());

  setTimeout("doNextFeature()", 10000);

}



function switchContent(id, value) {

  document.getElementById(id).innerHTML = value;

  return false;

}



function preLoadFeature(id, imageFile) {

  eval(id + " = new Image(); " + id + ".src = '"+ imageFile + "';");   

}

/*

function cycleImages () {

  if (document.images && random_loaded) {

    j = (j >= randomImgs.length) ? 1 : j;

    document.images['randomI'].src = randomImgs[j].src;

    j++;

  }

   // cycle every 10 secs

}

*/

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

function preLoad(imageFile) {

  eval(imageFile + "_on = new Image(); " + imageFile + "_on.src = 'images/nav_" + imageFile + "_on.gif';");   

}



preLoad('buying');

preLoad('carica');

preLoad('selling');

preLoad('rentals');

preLoad('finance');  

preLoad('about');

preLoad('register');

preLoad('intas');

preLoad('contact_us');





while (false) {  

  alert('Get back to work!');

}





function imageOn(item) {

  eval("document.getElementById('" + item + "I').src = " + item + "_on.src;");

}



function imageOff(item) {

  eval("document.getElementById('" + item + "I').src = 'images/nav_" + item + ".gif';");

}



function goBack() {

  alert("go back method becuase Safari, and Mac's in general are crap, and dont support standards propertly");

  window.history.go(-2);

}