﻿var isDOM = (typeof(document.getElementsByTagName) != 'undefined') ? 1 : 0;
var isIE4 = ((typeof(document.all) != 'undefined') && (parseInt(navigator.appVersion) >= 4)) ? 1 : 0;
var isNS4 = (typeof(document.layers) != 'undefined') ? 1 : 0;
var capable = (isDOM || isIE4 || isNS4) ? 1 : 0;

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 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_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function addToFavorite(favTitle){
  if ((navigator.appVersion.indexOf("MSIE") > 0) && (parseInt(navigator.appVersion) >= 4)) {
    window.external.AddFavorite(location.href, unescape(favTitle));
  }
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {
     if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
        document.MM_pgW=innerWidth;
        document.MM_pgH=innerHeight;
        onresize=MM_reloadPage;
     }
  } else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function close_window() {
    window.close();
}

function MM_showHideLayers() {
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
     if ((obj=MM_findObj(args[i]))!=null) {
        v=args[i+2];
        if (obj.style) {
           obj=obj.style;
           v=(v=='show')?'visible':(v='hide')?'hidden':v;
        }
        obj.visibility=v;
     }
}


/* $Id: left.js,v 1.15 2001/08/19 21:00:23 loic1 Exp $ */

// These scripts were originally found on cooltype.com.

var isExpanded = false;

var imgOpened    = new Image(9,9);
imgOpened.src    = 'images/minus.gif';
var imgClosed    = new Image(9,9);
imgClosed.src    = 'images/plus.gif';
var img2Opened    = new Image(0,0);
img2Opened.src    = 'images/spacer.gif';
var img2Closed    = new Image(0,0);
img2Closed.src    = 'images/spacer.gif';

/**
 * Do reloads the frame if the window has been resized under Netscape4+
 *
 * @access  private
 */
function reDo() {
  if (innerWidth != origWidth || innerHeight != origHeight) location.reload(true);
}


/**
 * Gets the id of the first collapsible room
 *
 * @param  string  the name of the first collapsible room
 *
 * @return  integer  the index number corresponding to this room
 *
 * @access  public
 */
function nsGetIndex(el) {
  var ind       = null;
  var theLayers = document.layers;
  var layersCnt = theLayers.length;
  for (var i = 0; i < layersCnt; i++) {
    if (theLayers[i].id == el) {
      ind = i;
      break;
    }
  }
  return ind;
} // end of the 'nsGetIndex()' function


/**
 * Positions layers under NS4+
 *
 * @access  public
 */
function nsArrangeList() {
  if (firstInd != null) {
    var theLayers = document.layers;
    var layersCnt = theLayers.length;
    var nextY = theLayers[firstInd].pageY + theLayers[firstInd].document.height;
    for (var i = firstInd + 1; i < layersCnt; i++) {
      if (theLayers[i].visibility != 'hide') {
        theLayers[i].pageY = nextY;
        nextY += theLayers[i].document.height;
      }
    }
  }
} // end of the 'nsArrangeList()' function


/**
 * Expand at startup
 *
 * @access  public
 */
function nsShowAll() {
  var theLayers = document.layers;
  var layersCnt = theLayers.length;
  for (i = firstInd; i < layersCnt; i++) theLayers[i].visibility = 'show';
} // end of the 'nsShowAll()' function


/**
 * Collapses at startup
 *
 * @access  public
 */
function initIt() {
  if (!capable || !isServer) return;

  if (isDOM) {
    var tempColl    = document.getElementsByTagName('DIV');
    var tempCollCnt = tempColl.length;
    for (var i = 0; i < tempCollCnt; i++) {
      if (tempColl[i].id == expandedDb) tempColl[i].style.display = 'block';
      else if (tempColl[i].className == 'child') tempColl[i].style.display = 'none';
    }
  } // end of the DOM case
  else if (isIE4) {
    tempColl        = document.all.tags('DIV');
    var tempCollCnt = tempColl.length;
    for (var i = 0; i < tempCollCnt; i++) {
      if (tempColl(i).id == expandedDb) tempColl(i).style.display = 'block';
      else if (tempColl(i).className == 'child') tempColl(i).style.display = 'none';
    }
  } // end of the IE4 case
  else if (isNS4) {
    var theLayers  = document.layers;
    var layersCnt  = theLayers.length;
    for (var i = 0; i < layersCnt; i++) {
      if (theLayers[i].id == expandedDb) theLayers[i].visibility   = 'show';
      else if (theLayers[i].id.indexOf('Child') != -1) theLayers[i].visibility   = 'hide';
      else theLayers[i].visibility   = 'show';
    }
    nsArrangeList();
  } // end of the NS4 case
} // end of the 'initIt()' function


/**
 * Collapses/expands a layer when the user require this to be done
 *
 * @param  string  the  name of the room to act on
 * @param  boolean whether to expand or to collapse the layer content
 *
 * @access  public
 */
function expandBase(el, unexpand) {
  if (!capable) return;

  if (isDOM) {
    var whichEl = document.getElementById(el + 'Child');
    var whichIm = document.getElementById(el + 'Img');
    if (whichEl.style.display == 'none' && whichIm) {
      whichEl.style.display  = 'block';
      if (whichIm.src.substring(whichIm.src.indexOf('images/'), whichIm.src.indexOf('gif') + 3) == imgClosed.src.substring(imgClosed.src.indexOf('images/'), imgClosed.src.indexOf('gif') + 3)) {
         whichIm.src            = imgOpened.src;
      } else {
         whichIm.src            = img2Opened.src;
      }
    } else if (unexpand) {
      whichEl.style.display  = 'none';
      if (whichIm.src.substring(whichIm.src.indexOf('images/'), whichIm.src.indexOf('gif') + 3) == imgOpened.src.substring(imgOpened.src.indexOf('images/'), imgOpened.src.indexOf('gif') + 3)) {
         whichIm.src            = imgClosed.src;
      } else {
         whichIm.src            = img2Closed.src;
      }
    }
  } // end of the DOM case
  else if (isIE4) {
    var whichEl = document.all(el + 'Child');
    var whichIm = document.images.item(el + 'Img');
    if (whichEl.style.display == 'none') {
      whichEl.style.display  = 'block';
      if (whichIm.src.substring(whichIm.src.indexOf('images/'), whichIm.src.indexOf('gif') + 3) == imgClosed.src.substring(imgClosed.src.indexOf('images/'), imgClosed.src.indexOf('gif') + 3)) {
         whichIm.src            = imgOpened.src;
      } else {
         whichIm.src            = img2Opened.src;
      }
    } else if (unexpand) {
      whichEl.style.display  = 'none';
      if (whichIm.src.substring(whichIm.src.indexOf('images/'), whichIm.src.indexOf('gif') + 3) == imgOpened.src.substring(imgOpened.src.indexOf('images/'), imgOpened.src.indexOf('gif') + 3)) {
         whichIm.src            = imgClosed.src;
      } else {
         whichIm.src            = img2Closed.src;
      }
    }
  } // end of the IE4 case
  else if (isNS4) {
    var whichEl = document.layers[el + 'Child'];
    var whichIm = document.layers[el + 'Parent'].document.images['imEx'];
    if (whichEl.visibility == 'hide') {
      whichEl.visibility  = 'show';
      if (whichIm.src.substring(whichIm.src.indexOf('images/'), whichIm.src.indexOf('gif') + 3) == imgClosed.src.substring(imgClosed.src.indexOf('images/'), imgClosed.src.indexOf('gif') + 3)) {
         whichIm.src            = imgOpened.src;
      } else {
         whichIm.src            = img2Opened.src;
      }
    } else if (unexpand) {
      whichEl.visibility  = 'hide';
      if (whichIm.src.substring(whichIm.src.indexOf('images/'), whichIm.src.indexOf('gif') + 3) == imgOpened.src.substring(imgOpened.src.indexOf('images/'), imgOpened.src.indexOf('gif') + 3)) {
         whichIm.src            = imgClosed.src;
      } else {
         whichIm.src            = img2Closed.src;
      }
    }
    nsArrangeList();
  } // end of the NS4 case
} // end of the 'expandBase()' function


function Add_Bookmark_Favorites() {
   if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4) && (navigator.appVersion.indexOf("AOL") == -1)) {
      var msg = '<a href="javascript:window.external.AddFavorite(\'http://www.less.gr\', \'Less.gr\');" class="small_black" onMouseOver="window.status=\'Προσθέστε το site μας στα αγαπημένα σας\'; return true;" onMouseOut="window.status=\' \'; return true;">Add To Favorites</a>';
   } else {
      var msg = "bookmark us!";
      if (navigator.appName == "Netscape") msg = "press (CTRL-D) to " + msg;
   }
   document.write(msg);
}

function openform(url) {
   var url = url + "?url=" + escape(document.location);
   var IE = (document.all) ? true : false;

   if (IE) {
      window.open(url,"","scrollbars=no,menubar=no,personalbar=no,width=400,height=228,left=160,top=40");
   } else {
      window.open(url,"","scrollbars=no,menubar=no,personalbar=no,width=400,height=228,screenX=160,screenY=40");
   }
}


//Begin dHTML Toolltip Timer
var tipTimer;
//End dHTML Toolltip Timer

function locateObject(n, d) { //v3.0
   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=locateObject(n,d.layers[i].document);

   return x;
}

function hideTooltip(object) {
   if (document.all) {
      locateObject(object).style.visibility="hidden";
      locateObject(object).style.left = 1;
      locateObject(object).style.top = 1;
      return false;
   } else if (document.layers) {
      locateObject(object).visibility="hide";
      locateObject(object).left = 1;
      locateObject(object).top = 1;
      return false;
   } else
      return true;
}

function showTooltip(object,e, tipContent, backcolor, bordercolor, textcolor, displaytime) {
   window.clearTimeout(tipTimer);

   if (document.all) {
      locateObject(object).style.top=document.body.scrollTop+event.clientY+20;
      locateObject(object).innerHTML='<table style="font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 11px; border: '+bordercolor+'; border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; background-color: '+backcolor+'" width="10" border="0" cellspacing="1" cellpadding="1"><tr><td nowrap><font style="font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 11px; color: '+textcolor+'">'+unescape(tipContent)+'</font></td></tr></table> ';
      if ((e.x + locateObject(object).clientWidth) > (document.body.clientWidth + document.body.scrollLeft)) {
         locateObject(object).style.left = (document.body.clientWidth + document.body.scrollLeft) - locateObject(object).clientWidth-10;
      } else {
         locateObject(object).style.left=document.body.scrollLeft+event.clientX;
      }
      locateObject(object).style.visibility="visible";
      tipTimer=window.setTimeout("hideTooltip('"+object+"')", displaytime);
      return true;
   } else if (document.layers) {
      locateObject(object).document.write('<table width="10" border="0" cellspacing="1" cellpadding="1"><tr bgcolor="'+bordercolor+'"><td><table width="10" border="0" cellspacing="0" cellpadding="2"><tr bgcolor="'+backcolor+'"><td nowrap><font style="font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 11px; color: '+textcolor+'">'+unescape(tipContent)+'</font></td></tr></table></td></tr></table>');
      locateObject(object).document.close();
      locateObject(object).top=e.y+20;
      if ((e.x + locateObject(object).clip.width) > (window.pageXOffset + window.innerWidth)) {
         locateObject(object).left = window.innerWidth - locateObject(object).clip.width-10;
      } else {
         locateObject(object).left=e.x;
      }
      locateObject(object).visibility="show";
      tipTimer=window.setTimeout("hideTooltip('"+object+"')", displaytime);
      return true;
   } else {
      return true;
   }
}



function auto_center() {
   var IE4 = (document.all) ? true : false;
   var NS4 = (document.layers) ? true : false;
   if (NS4) {
      LeftPosition = (screen.width) ? (screen.width-window.outerWidth)/2 : 0;
      TopPosition = (screen.height) ? (screen.height-window.outerHeight)/2 : 0;
   } else {
      LeftPosition = (screen.width) ? (screen.width-document.body.clientWidth)/2 : 0;
      TopPosition = (screen.height) ? (screen.height-document.body.clientHeight)/2 : 0;
   }
   window.moveTo(LeftPosition, TopPosition);
}



function showHide(el, elTotal) {
  if (!capable) return;

  for (k = 1; k <= elTotal; k++) {
     if (isDOM) {
        var whichEl = document.getElementById('el' + k + 'Child');
        var cellEl = document.getElementById('el' + k + 'Cell');
        var rowEl = document.getElementById('el' + k + 'Row');
     } else if (isIE4) {
        var whichEl = document.all('el' + k + 'Child');
        var cellEl = document.all('el' + k + 'Cell');
        var rowEl = document.all('el' + k + 'Row');
     }
     if (el == k) {
        if (isDOM) whichEl.style.display  = 'block';
        else if (isIE4) whichEl.style.display  = 'block';
        if ((cellEl.className == 'big') || (cellEl.className == 'selectedbig')) cellEl.className = 'selectedbig';
        else cellEl.className = 'selectedsmall';
        if (cellEl.className == 'selectedbig') rowEl.className = 'selecteddownbig';
        else rowEl.className = 'selecteddownsmall';
     } else {
        if (isDOM) whichEl.style.display  = 'none';
        else if (isIE4) whichEl.style.display  = 'none';
        if ((cellEl.className == 'small') || (cellEl.className == 'selectedsmall')) cellEl.className = 'small';
        else cellEl.className = 'big';
        rowEl.className = 'bordercolor';
     }
  }
}



// SEARCH FOR A TERM IN A TARGET STRING AND REPLACE IT
//
// replace(targetString,oldTerm,newTerm,caseSensitive,wordOrSubstring)
//
// where caseSenstive is a boolean value and wordOrSubstring is a boolean
// value and true means whole words, false means substrings
function replace(target,oldTerm,newTerm,caseSens,wordOnly) {
  var work = target;
  var ind = 0;
  var next = 0;

  if (!caseSens) {
    oldTerm = oldTerm.toLowerCase();
    work = target.toLowerCase();
  }

  while ((ind = work.indexOf(oldTerm,next)) >= 0) {
    if (wordOnly) {
      var before = ind - 1;
      var after = ind + oldTerm.length;
      if (!(space(work.charAt(before)) && space(work.charAt(after)))) {
        next = ind + oldTerm.length;
        continue;
      }
    }
    target = target.substring(0,ind) + newTerm + target.substring(ind+oldTerm.length,target.length);
    work = work.substring(0,ind) + newTerm + work.substring(ind+oldTerm.length,work.length);
    next = ind + newTerm.length;
    if (next >= work.length) { break; }
  }

  return target;
}
