
 var limit;
 var text;
 var category;
 var group;
 var itemNumber;
 var rowNumber;
 var columnNumber;
 var counter=0;
 var timerID="notSet";
 var fadeID="notSet";
 var xCo=0;
 var yCo=0;
 var output;
 var fadeStatus="notSet";
 var filterID;
 var currentMenu="notSet";
 var currentSubMenu="notSet";
 var subMenuItems=0;
 var buildingMenu=0;
 var removeImmediatley=0;
 var objectHeight;
 var startPoint;
 var tItems;
 var dimension=new Array(2);
 var add;
 var textID;
 var lineDirection;
 var lineLength;
 var lineLengthAccurate;
 var textContent;
 var textAlignment="";
 var lineRunning=0;
 var currentLineLength=0; 
 var lineTimer="notSet";
 var lineCounter=0;
 var lineStep;
 var lineID;
 var dimensions;
 var textMenuOpen=0;
 var availImg=0;
 var cColumn=0;
 var cRow=0;
 var emptySpaces;
 var xCords;
 var yCords;
 var xPos;
 var yPos;
 var tmp;
 var invalidYCords;
 var invalidXCords;
 var oTMP;
 var xReset;
 var yReset;
 var resetCounter;
 var currentImgID="notSet";
 var popupWindow;

 function showMenu(id)	{

  if(id!=currentMenu)	{

   if(timerID!="notSet")	{

    clearTimeout(timerID);
    counter=0;
 
   }

   if(fadeID!="notSet")	{

    clearTimeout(fadeID);
 
   } 

   for(var m=0; m<mainMenu.length; m++)	{

    text=mainMenu[m].substring(0,mainMenu[m].indexOf("=>"));
    limit=parseInt(mainMenu[m].substring(mainMenu[m].indexOf("=>")+2,mainMenu[m].length));

    for(var i=1; i<=limit; i++)	{

     document.getElementById(text+i).style.visibility="hidden";
     document.getElementById(text+i).style.background=backgroundColors[backgroundColors.length-1];
 
    }

    document.getElementById("subMenu").style.visibility="hidden";
    currentSubMenu="notSet";

    hideText();

   }

   xCo=document.getElementById("mainTable").offsetLeft;
   xCo+=document.getElementById("mainRightTD").offsetLeft;
   xCo+=document.getElementById("subMenuTable").offsetLeft;

   yCo=document.getElementById("mainTable").offsetTop;
   yCo+=document.getElementById("mainRightTD").offsetTop;
   yCo+=document.getElementById("subMenuTable").offsetTop;

    text=mainMenu[id].substring(0,mainMenu[id].indexOf("=>"));
    limit=parseInt(mainMenu[id].substring(mainMenu[id].indexOf("=>")+2,mainMenu[id].length));

    yCo+=document.getElementById(text+(limit)).offsetTop;

    if(isSafari3)	{

     yCo-=41;

     if(id==5)	{

      yCo+=6;

     }

    //Safari 3 bug, offsetHeight = 95 terwijl offsetTop 13 (m.u.v. rij 5, [26]) meet

    }

   if(isSafari4)	{
    yCo += 41;
   }

   if(!isIE)	{

    document.getElementById("fadeBar").innerHTML="";
    output="";

    if(document.getElementById(text+(limit)).offsetHeight<95)	{

     objectHeight=document.getElementById(text+(limit)).offsetHeight;

     if((objectHeight%2)==0)	{

      objectHeight++;    

     }

     yCo-=((95-objectHeight)/2);

    }

    for(var i=1; i<=limit; i++)	{

     document.getElementById(text+i).style.visibility="hidden";
     output+="<img src=\""+tFilters[0]+"\" class=\"tFilter\"";

     if(i==1)	{

      output+=" style=\"width:95px;\"";

     }

     output+=" onmouseover=\"pauseHiding('"+text+i+"'),changeBack('"+text+i+"','up')\" onmouseout=\"counter=0,hideMenu(),changeBack('"+text+i+"','std')\"  onclick=\"subMenu('"+text+i+"')\">";
 
    }

    document.getElementById("dotLine").style.left=(xCo-1);
    document.getElementById("dotLine").style.top=(yCo);
    document.getElementById("dotLine").style.width="1px";
    document.getElementById("dotLine").style.height="95px";
    document.getElementById("dotLine").style.visibility="visible";
  
    document.getElementById("fadeBar").innerHTML=output;
    document.getElementById("fadeBar").style.left=(xCo-2);
    document.getElementById("fadeBar").style.top=(yCo-1);

   }

   else	{

    document.getElementById("dotLine").style.left=(xCo-1);
    document.getElementById("dotLine").style.top=(yCo);
    document.getElementById("dotLine").style.width="1px";
    document.getElementById("dotLine").style.height="95px";
    document.getElementById("dotLine").style.visibility="visible";

    text=mainMenu[id].substring(0,mainMenu[id].indexOf("=>"));
    limit=parseInt(mainMenu[id].substring(mainMenu[id].indexOf("=>")+2,mainMenu[id].length));

    for(var i=1; i<=limit; i++)	{

     document.getElementById(text+i).filters.item("DXImageTransform.Microsoft.Alpha").apply();
 
    }

    document.getElementById("dotLine").filters.item("DXImageTransform.Microsoft.Alpha").apply();

   }

   fadeStatus=0;
   currentMenu=id;
   buildingMenu=1;
   removeImmediately=0;
   fadeMenu(id);

  }

  else	{

   removeImmediately=0;
   
   if(timerID!="notSet")	{

    clearTimeout(timerID);

   }   

  }

 }


 function fadeMenu(id)	{

  if(fadeID!="notSet")	{

   clearTimeout(fadeID);

  } 

  text=mainMenu[id].substring(0,mainMenu[id].indexOf("=>"));
  limit=parseInt(mainMenu[id].substring(mainMenu[id].indexOf("=>")+2,mainMenu[id].length));

  if((fadeStatus-limit)<tFilters.length)	{

   if(!isIE)	{

    output="";

    for(var i=1; i<=limit; i++)	{

     filterID=fadeStatus-(i-1);

     if(filterID<0)	{

      filterID=0;

     }

     if(filterID>=tFilters.length)	{

      filterID=tFilters.length-1;

     }

     output+="<img src=\""+tFilters[filterID]+"\" class=\"tFilter\"";

     if(i==1)	{

      output+=" style=\"width:95px;\"";

     }

     output+=" onmouseover=\"pauseHiding('"+text+i+"'),changeBack('"+text+i+"','up')\" onmouseout=\"counter=0,hideMenu(),changeBack('"+text+i+"','std')\"  onclick=\"subMenu('"+text+i+"')\">";

     if(filterID>0)	{

      document.getElementById(text+i).style.visibility="visible";

     }

    }

    document.getElementById("fadeBar").innerHTML=output;

   }

   else	{

    for(var i=1; i<=limit; i++)	{

     filterID=fadeStatus-(i-1);

     if(filterID<0)	{

      filterID=0;

     }

     if(filterID>=tFilters.length)	{

      filterID=tFilters.length-1;

     }

     document.getElementById(text+i).filters.item("DXImageTransform.Microsoft.Alpha").opacity=((100/(tFilters.length-1))*filterID);

     if(filterID>0)	{

      document.getElementById(text+i).style.visibility="visible";

     }

    }

   if(filterID>0)	{

    document.getElementById("dotLine").style.visibility="visible";

   }

   document.getElementById("dotLine").filters.item("DXImageTransform.Microsoft.Alpha").opacity=((100/(tFilters.length-1))*(fadeStatus));

   }

   fadeStatus++;

   fadeID=setTimeout("fadeMenu("+id+");", 100);

  }

  else	{

   if(!isIE)	{

    document.getElementById("fadeBar").innerHTML="";

   }

   else	{

    for(var i=1; i<=limit; i++)	{

     document.getElementById(text+i).filters.item("DXImageTransform.Microsoft.Alpha").opacity=100;

    }

   }

   buildingMenu=0;

   if(removeImmediately)	{

    counter=2;
    hideMenu();

   }

  }

 }


 function hideMenu()	{

  if(!buildingMenu && !textMenuOpen)	{

   if(timerID!="notSet")	{

    clearTimeout(timerID);

   }

   if(counter==4)	{

    counter=0;

    for(var m=0; m<mainMenu.length; m++)	{
 
     text=mainMenu[m].substring(0,mainMenu[m].indexOf("=>"));
     limit=parseInt(mainMenu[m].substring(mainMenu[m].indexOf("=>")+2,mainMenu[m].length));

     for(var i=1; i<=limit; i++)	{

      document.getElementById(text+i).style.visibility="hidden";
 
     }

     document.getElementById("subMenu").style.visibility="hidden";
     document.getElementById("dotLine").style.visibility="hidden";
     currentSubMenu="notSet"
     currentMenu="notSet";
     hideText();

    }

   }

   else	{

    counter++;
    timerID=setTimeout("hideMenu();", 300);

   }

  }

  else	{

   removeImmediately=1;

  }

 }

 function pauseHiding(id)	{

  text=mainMenu[currentMenu].substring(0,mainMenu[currentMenu].indexOf("=>"));
  limit=parseInt(mainMenu[currentMenu].substring(mainMenu[currentMenu].indexOf("=>")+2,mainMenu[currentMenu].length));
  itemNumber=parseInt(id.substring(text.length,(text.length+1)));

  if((id.indexOf(text)!=-1 && itemNumber<=limit) || id=="subMenu")	{

   if(timerID!="notSet")	{

    clearTimeout(timerID);

   }

   counter=0;
   removeImmediately=0;

  }

 }

 function changeBack(id,action)	{

  if(action!="std")	{

   itemNumber=((parseInt(id.substring(id.length-2,id.length-1))-1)*5)+parseInt(id.substring(id.length-1,id.length))-1;

   if(backgroundColors[itemNumber].length==7)	{

    document.getElementById(id).style.background=backgroundColors[itemNumber];

   }

  }

  else	{

   if(id!=currentSubMenu && id!=lineID)	{

    if(backgroundColors[backgroundColors.length-1].length==7)	{
 
     document.getElementById(id).style.background=backgroundColors[backgroundColors.length-1];

    }

   }

   else	{

    if(subMenuItems==0 && id!=lineID)	{

     if(backgroundColors[backgroundColors.length-1].length==7)	{
 
      document.getElementById(id).style.background=backgroundColors[backgroundColors.length-1];

     }

    }

   }

  }

 }


 function subMenu(id)	{

  hideText();

  currentSubMenu=id;

  for(var m=0; m<mainMenu.length; m++)	{

   text=mainMenu[m].substring(0,mainMenu[m].indexOf("=>"));
   limit=parseInt(mainMenu[m].substring(mainMenu[m].indexOf("=>")+2,mainMenu[m].length));

   for(var i=1; i<=limit; i++)	{

    if((text+i)!=currentSubMenu)	{

     document.getElementById(text+i).style.background=backgroundColors[backgroundColors.length-1];

    }
 
   }

  }

  rowNumber=parseInt(id.substring(id.length-2,id.length-1));
  columnNumber=parseInt(id.substring(id.length-1,id.length));

  if(rowNumber<=2)	{
   
   startPoint=4-(4-(rowNumber-1));

  }

  else	{

   if(rowNumber>(mainMenu.length-2))	{

    startPoint=4-(mainMenu.length-rowNumber);

   }

   else	{

    startPoint=2;

   }

  }

  xCo=document.getElementById("mainTable").offsetLeft;
  xCo+=document.getElementById("mainRightTD").offsetLeft;
  xCo+=document.getElementById("subMenuTable").offsetLeft;
  xCo+=document.getElementById(id).offsetLeft;

  if(parseInt(id.substring(id.length-1,id.length))==1)	{

   xCo++;

  }

  yCo=document.getElementById("mainTable").offsetTop;
  yCo+=document.getElementById("mainRightTD").offsetTop;
  yCo+=document.getElementById("subMenuTable").offsetTop;
  yCo+=document.getElementById(id).offsetTop;

  if(isSafari3)	{

   yCo-=41;

   if(id=="subMenuItem62" || id=="subMenuItem65")	{

    yCo+=6;

   }

   //Safari 3 bug, offsetHeight = 95 terwijl offsetTop 13 (m.u.v. subMenuItems 62 en 65 [26]) meet

  }

  if( isSafari4 )  {

   yCo += 41;

  }

  if(document.getElementById(id).offsetHeight<95)	{

  objectHeight=document.getElementById(id).offsetHeight;

  if((objectHeight%2)==0)	{

   objectHeight++;

  }

  yCo-=((95-objectHeight)/2);

 }

 yCo-=(startPoint*94);

  if(rowNumber<=2 || rowNumber>=6)	{
 
   if(rowNumber==1 || rowNumber==7)	{

    dimension[0]=4;

   }

   else	{

    dimension[0]=3;

   }

  }
  
  else	{

    dimension[0]=2;

  }

  if(columnNumber<=2 || columnNumber>=4)	{
 
   if(columnNumber==1 || columnNumber==5)	{

    dimension[1]=4;

   }

   else	{

    dimension[1]=3;

   }

  }

  else	{

   dimension[1]=2;   

  }

  itemNumber=(((rowNumber-1)*5)+(columnNumber-1));
  category=subMenus[itemNumber].substring(0,subMenus[itemNumber].indexOf("=>"));
  group=subMenus[itemNumber].substring(subMenus[itemNumber].indexOf("=>")+2,subMenus[itemNumber].indexOf("::"));
  tItems=parseInt(subMenus[itemNumber].substring(subMenus[itemNumber].indexOf("::")+2,subMenus[itemNumber].length));
  subMenuItems=0;

  if(category!="" && group!="")	{

   add=0;

   if(startPoint>2 && tItems<5)	{

    add=startPoint-2;

   }

   output="<table id=\"subMenuInnerTable\" cellpadding=0 cellspacing=0>";

   for(var i=1; i<=5; i++)	{
  
    itemNumber="0"+i.toString();

    if(document.getElementById(group+itemNumber) || i==(startPoint+1))	{

     output+="<tr><td id=\"sub"+id.charAt(0).toUpperCase()+id.substring(1,id.length)+i+"\"";

     if(i==(1+(Math.floor((5-tItems)/2))+add))	{

      output+=" class=\"subMenuImageTDNR1\"";

     }

     else	{

      output+=" class=\"subMenuImageTD\"";

     } 

     if(document.getElementById(group+itemNumber))	{

      output+=" onmouseover=\"pauseHiding('"+text+i+"')\" onmouseout=\"counter=0,hideMenu()\"";

      if(typeof(textMenus[(rowNumber.toString()+columnNumber.toString()+i.toString())])!="undefined")	{

       output+=" onclick=\"";

       if(document.getElementById("img"+id.charAt(0).toUpperCase()+id.substring(1,id.length)+i.toString()))	{

        output+="availImg=1,";

       }

       else	{

        output+="availImg=0,";

       }

       output+="textMenu(this.id)\"";

      }

      output+="><img src=\"subImg/"+category+"/"+group+"/"+group+itemNumber+".jpg\"";

      if(i==(1+(Math.floor((5-tItems)/2))+add))	{

       output+=" class=\"subMenuImageNR1\"";

      }

      else	{

       output+=" class=\"subMenuImage\"";

      }

      if(typeof(textMenus[(rowNumber.toString()+columnNumber.toString()+i.toString())])!="undefined")	{

       output+=" style=\"cursor:hand;\"";

      }

      output+=" galleryimg=\"no\">";

      subMenuItems++;

     } 

     else	{

      output+=" onmouseover=\"pauseHiding('"+text+i+"')\" onmouseout=\"counter=0,hideMenu(),changeBack('"+id+"','std')\">&nbsp;";

     }

     output+="</td></tr>";

    }

   }

   output+="</table>";

   if(isIE)	{

    document.getElementById("subMenu").style.width="95px";

   }

   else	{

    document.getElementById("subMenu").style.width="93px";

   }

   if(tItems<5)	{

    yCo+=(Math.floor((5-tItems)/2)*94);

    if(startPoint>2)	{

     yCo+=(startPoint-2)*94;
 
     }

     else	{

      for(var i=(2-Math.floor((5-tItems)/2));i<(2-startPoint);i++)	{

       yCo-=94;

      }

     }

   }

   document.getElementById("subMenu").style.top=yCo;

   if(columnNumber==1)	{

    xCo-=1;

   }

   document.getElementById("subMenu").style.left=(xCo-1);
   document.getElementById("subMenu").style.visibility="visible";
   document.getElementById("subMenu").innerHTML=output;

  }

  else	{

   output="";
   document.getElementById("subMenu").style.visibility="hidden";
   document.getElementById("subMenu").innerHTML=output;

  }

  document.getElementById("subMenuInnerTable").style.height=((tItems*93)+(tItems-1))+"px";
  document.getElementById("subMenu").style.height=((tItems*93)+(tItems-1))+"px";

 }


 function textMenu(id)	{

  if(!lineRunning && id!=lineID)	{

   hideText();

   for(var m=0; m<mainMenu.length; m++)	{

    text=mainMenu[m].substring(0,mainMenu[m].indexOf("=>"));
    limit=parseInt(mainMenu[m].substring(mainMenu[m].indexOf("=>")+2,mainMenu[m].length));

    for(var i=1; i<=limit; i++)	{

     if((text+i)!=id && id.indexOf(((text.substring(1,text.length)+i).toString()))==-1)	{

      document.getElementById(text+i).style.background=backgroundColors[backgroundColors.length-1];

     }
 
    }

   }

   if(id.indexOf("subSubMenuItem")!=-1)	{

    textID=id.substring(14,id.length);

   }

   else	{

    rowNumber=parseInt(id.substring(id.length-2,id.length-1));
    columnNumber=parseInt(id.substring(id.length-1,id.length));

    textID=rowNumber.toString()+columnNumber.toString();

    textMenuOpen=1;
 
    cRow=rowNumber;
    cColumn=columnNumber;

   }

   if(typeof(textMenus[textID])!="undefined")	{

    lineDirection=textMenus[textID].substring(0,textMenus[textID].indexOf("::"));
    lineLength=parseInt(textMenus[textID].substring(textMenus[textID].indexOf("::")+2,textMenus[textID].indexOf("=>")));
    textContent=textMenus[textID].substring(textMenus[textID].indexOf("=>")+2,textMenus[textID].indexOf("<="));
    textAlignment=textMenus[textID].substring(textMenus[textID].indexOf("<=")+2,textMenus[textID].indexOf("$$"));
    dimensions=textMenus[textID].substring(textMenus[textID].indexOf("$$")+2,textMenus[textID].length);

    lineLengthAccurate=lineLength;

    lineStep=3;

    lineLength=lineLength-(lineLength%lineStep);

    xCo=document.getElementById("mainTable").offsetLeft;
    xCo+=document.getElementById("mainRightTD").offsetLeft;
    xCo+=document.getElementById("subMenuTable").offsetLeft;

    if(id.indexOf("subSubMenuItem")!=-1)	{

     xCo+=document.getElementById("s"+id.substring(4,(id.length-1))).offsetLeft;
     xCo+=(document.getElementById(id).offsetWidth/2);

     cColumn=Math.floor(1+(document.getElementById("s"+id.substring(4,(id.length-1))).offsetLeft/94));
     cRow=Math.floor(1+((document.getElementById(id).offsetTop+1)/94));

    }

    else	{

     xCo+=document.getElementById(id).offsetLeft;
     xCo+=(document.getElementById(id).offsetWidth/2);

    }

    if(parseInt(id.substring(id.length-1,id.length))==1)	{

     xCo++;

    } 

    yCo=document.getElementById("mainTable").offsetTop;
    yCo+=document.getElementById("mainRightTD").offsetTop;
    yCo+=document.getElementById("subMenuTable").offsetTop;
    yCo+=document.getElementById(id).offsetTop;

    if(isFirefox || isOpera || isNav || isIE)	{
 
     yCo+=((document.getElementById(id).offsetHeight-16)/2);

     if(lineDirection=="up")	{

      yCo++;
 
     }

     if(isOpera || isIE)	{

      yCo++;

     }

    }

   if(isSafari4)	{
    yCo += 41;
   }

    currentLineLength=lineStep;

    document.getElementById("textArea").innerHTML=textContent;
 
    if(textAlignment=="left")	{

     document.getElementById("textArea").style.left=(xCo+10)+"px";

    }

    else	{

     document.getElementById("textArea").style.left=(xCo-10-parseInt(dimensions.substring(0,dimensions.indexOf("x"))))+"px";

    }

    document.getElementById("textArea").style.width=parseInt(dimensions.substring(0,dimensions.indexOf("x")))+"px";
    document.getElementById("textArea").style.height=parseInt(dimensions.substring(dimensions.indexOf("x")+1,dimensions.length))+"px";

    if(lineDirection=="up")	{

     document.getElementById("dashedLineArea").style.top=yCo-(25+currentLineLength);
     document.getElementById("dashCross").style.top=yCo-(25+lineLengthAccurate+10);
     document.getElementById("textArea").style.top=yCo-(25+lineLengthAccurate+13);

    }

    if(lineDirection=="down")	{

     document.getElementById("dashedLineArea").style.top=yCo+25;
     document.getElementById("dashCross").style.top=yCo+(25+lineLengthAccurate+3);
     document.getElementById("textArea").style.top=yCo+(25+lineLengthAccurate+1);

    }

    if(lineDirection=="left")		{
  
     xCo-=(document.getElementById(id).offsetWidth/2);

     document.getElementById("dashedLineArea").style.left=xCo-6;
     document.getElementById("dashCross").style.left=xCo-6-lineLengthAccurate-10;
     document.getElementById("textArea").style.left=xCo-6-lineLengthAccurate-parseInt(dimensions.substring(0,dimensions.indexOf("x")))-18;

    }

    if(lineDirection=="right")	{

     xCo+=(document.getElementById(id).offsetWidth/2);
 
     document.getElementById("dashedLineArea").style.left=xCo+4;
     document.getElementById("dashCross").style.left=xCo+4+lineLengthAccurate+3;
     document.getElementById("textArea").style.left=xCo+4+18+lineLengthAccurate;

    }

    if(lineDirection=="down" || lineDirection=="up")	{

     document.getElementById("dashedLineArea").style.height=currentLineLength;
     document.getElementById("dashedLineArea").style.width=1;
     document.getElementById("dashedLineArea").style.borderLeft="dashed 1px black";
     document.getElementById("dashedLineArea").style.left=xCo;
     document.getElementById("textArea").style.textAlign=textAlignment;

    }

    else	{

     document.getElementById("dashedLineArea").style.height=1;
     document.getElementById("dashedLineArea").style.width=currentLineLength;
     document.getElementById("dashedLineArea").style.borderTop="dashed 1px black"; 
 
     if(!isSafari3)	{

      yCo+=(document.getElementById(id).offsetHeight/2);
      //Safaribug

     }

   if(isSafari4)	{
    yCo += 41;
   }

     if(id.indexOf("subSubMenuItem")!=-1)	{

      yCo=document.getElementById("subMenu").offsetTop;
      yCo+=document.getElementById(id).offsetTop;
      yCo+=Math.floor(document.getElementById(id).offsetHeight/2);
      yCo+=1;

     }

     document.getElementById("dashedLineArea").style.top=yCo;
     document.getElementById("dashCross").style.top=yCo-3;
     document.getElementById("textArea").style.top=yCo-5;

     if(lineDirection=="left")	{

     document.getElementById("textArea").style.textAlign="right";

     }

     else	{

     document.getElementById("textArea").style.textAlign="left";

     }

    }

    document.getElementById("dashedLineArea").style.visibility="visible";
    document.getElementById("dashedLineArea").style.zIndex=4;

    lineID=id;
    lineRunning=1;
    lineCounter=-1;
    moveDashedLine();

   }

  }

 }


 function moveDashedLine()	{

  if(lineTimer!="notSet")	{

   clearTimeout(lineTimer);

  }

  lineCounter++;

  if((currentLineLength+(lineStep*Math.pow(1.5, lineCounter)))>=lineLength)	{

   showText();

  }

  else	{

   currentLineLength+=(lineStep*Math.pow(1.5, lineCounter));

   if(lineDirection=="up")	{

    document.getElementById("dashedLineArea").style.top=yCo-(25+currentLineLength)

   }

   if(lineDirection=="down")	{

    document.getElementById("dashedLineArea").style.top=yCo+25;

   }

   if(lineDirection=="left")	{

    document.getElementById("dashedLineArea").style.left=xCo-6-currentLineLength;

   }

   if(lineDirection=="right")	{

    document.getElementById("dashedLineArea").style.left=xCo+4;

   }

   if(lineDirection=="up" || lineDirection=="down")	{

    document.getElementById("dashedLineArea").style.height=currentLineLength;

   }

   else	{

    document.getElementById("dashedLineArea").style.width=currentLineLength;

   }

   lineTimer=setTimeout("moveDashedLine();", 100);

  }

 }


 function showText()	{

  if(lineDirection=="up")	{

   document.getElementById("dashedLineArea").style.top=yCo-(25+lineLengthAccurate)

  }

  if(lineDirection=="down")	{

   document.getElementById("dashedLineArea").style.top=yCo+25;

  }

  if(lineDirection=="left")	{

   document.getElementById("dashedLineArea").style.left=xCo-6-lineLengthAccurate;

  }

  if(lineDirection=="right")	{

   document.getElementById("dashedLineArea").style.left=xCo+4;

  }

  if(lineDirection=="up" || lineDirection=="down")	{

   document.getElementById("dashedLineArea").style.height=lineLengthAccurate;
   document.getElementById("dashCross").style.left=xCo-3;

  }

  else	{

   document.getElementById("dashedLineArea").style.width=lineLengthAccurate;

   if(lineDirection=="left")		{

    document.getElementById("dashCross").style.left=xCo-6-lineLengthAccurate-10;

   }
 
  }

  document.getElementById("dashCross").style.visibility="visible";
  document.getElementById("dashCross").style.zIndex=4;
  document.getElementById("textArea").style.visibility="visible";
  document.getElementById("textArea").style.zIndex=4;

  if(availImg)	{

   enlargeImg();

  }

  else	{

   lineRunning=0;

  }

 }


 function hideText()	{

   document.getElementById("dashedLineArea").style.visibility="hidden";
   document.getElementById("dashedLineArea").style.zIndex=1;
   document.getElementById("dashedLineArea").style.border="none";
   document.getElementById("dashCross").style.visibility="hidden";
   document.getElementById("dashCross").style.zIndex=1;
   document.getElementById("textArea").style.visibility="hidden";
   document.getElementById("textArea").style.zIndex=1;

   if(lineTimer!="notSet")	{

    clearTimeout(lineTimer);

   }

   lineRunning=0;

   lineID="notSet";

   if(currentImgID!="notSet")	{

    document.getElementById(currentImgID).style.zIndex=1;
    document.getElementById(currentImgID).style.visibility="hidden";
    currentImgID="notSet";

   }

   textMenuOpen=0;
 
 }

 function enlargeImg()	{

  emptySpaces=new Array(4);
  emptySpaces[0]=cColumn-1;
  emptySpaces[1]=5-cColumn;
  emptySpaces[2]=startPoint;
  emptySpaces[3]=5-(startPoint+1);

//  alert("L"+emptySpaces[0]+" - R"+emptySpaces[1]+" - T"+emptySpaces[2]+" - B"+emptySpaces[3]+" || "+lineDirection);

  xCords=new Array(0);
  yCords=new Array(0);

  if(emptySpaces[0]>=2)	{

   for(xPos=1;(xPos+1)<cColumn;xPos++)	{

    tmp=xCords;

    xCords=new Array((xCords.length+1));
    
    for(i=0;i<tmp.length;i++)	{

     xCords[i]=tmp[i];

    }

    xCords[(xCords.length-1)]=xPos+"-"+(xPos+1);

   }

  }

  if(emptySpaces[1]>=2)	{

   for(xPos=(cColumn+1);(xPos+1)<=5;xPos++)	{

    tmp=xCords;

    xCords=new Array((xCords.length+1));
    
    for(i=0;i<tmp.length;i++)	{

     xCords[i]=tmp[i];

    }

    xCords[(xCords.length-1)]=xPos+"-"+(xPos+1);

   }

  }

  if(emptySpaces[2]>=2)	{

   for(yPos=1;(yPos+1)<=startPoint;yPos++)	{

    tmp=yCords;

    yCords=new Array((yCords.length+1));
    
    for(i=0;i<tmp.length;i++)	{

     yCords[i]=tmp[i];

    }

    yCords[(yCords.length-1)]=yPos+"-"+(yPos+1);

   }

  }

  if(emptySpaces[3]>=2 && lineDirection!="down")	{

   for(yPos=(startPoint+2);(yPos+1)<=5;yPos++)	{

    tmp=yCords;

    yCords=new Array((yCords.length+1));
    
    for(i=0;i<tmp.length;i++)	{

     yCords[i]=tmp[i];

    }

    yCords[(yCords.length-1)]=yPos+"-"+(yPos+1);

   }

  }

  if(subMenuItems<4)	{

   if(startPoint==3)	{
 
    cRow+=(Math.floor((4-subMenuItems)/2)+1);

   }

   else	{

    if(startPoint==4)	{

      cRow+=(Math.floor((4-subMenuItems)/2)+2);

    }

    else	{

      cRow+=(Math.floor((4-subMenuItems)/2));

    }

   }

  }

  if(lineDirection=="left" || lineDirection=="right")	{

   invalidYCords=new Array(0);

   for(i=0;i<yCords.length;i++)	{

    if(yCords[i].indexOf(cRow)!=-1)	{

     tmp=invalidYCords;

     invalidYCords=new Array((invalidYCords.length+1));
    
     for(var I=0;I<tmp.length;I++)	{

      invalidYCords[I]=tmp[I];

     }

     invalidYCords[(invalidYCords.length-1)]=yCords[i];

    }

   }

   oTMP=cColumn+Math.ceil((parseInt(dimensions.substring(0,dimensions.indexOf("x")))+lineLengthAccurate+10+10)/94);

   if(lineDirection=="right")	{

    invalidXCords=new Array(0);

    for(xPos=(cColumn+1);(xPos+0)<=oTMP;xPos++)	{

     tmp=invalidXCords;

     invalidXCords=new Array((invalidXCords.length+1));
    
     for(i=0;i<tmp.length;i++)	{

      invalidXCords[i]=tmp[i];

     } 

     invalidXCords[(invalidXCords.length-1)]=xPos+"-"+(xPos+1);

    }

   }

   oTMP=cColumn-Math.ceil((parseInt(dimensions.substring(0,dimensions.indexOf("x")))+lineLengthAccurate+10+10)/94)-1;

   if(lineDirection=="left")	{

    invalidXCords=new Array(0);

    for(xPos=(cColumn-1);(xPos-1)>=oTMP;xPos--)	{

     tmp=invalidXCords;

     invalidXCords=new Array((invalidXCords.length+1));
    
     for(i=0;i<tmp.length;i++)	{

      invalidXCords[i]=tmp[i];

     } 

     invalidXCords[(invalidXCords.length-1)]=(xPos-1)+"-"+(xPos);

    }

   }

  }

  resetCounter=0;

  xReset=1;
  yReset=1;

  for(;;)	{

   if(xReset)	{

    xPos=xCords[Math.floor(Math.random()*xCords.length)];
    xReset=0;

   }

   if(yReset)	{

    yPos=yCords[Math.floor(Math.random()*yCords.length)];
    yReset=0;

   }

   for(i=0;i<invalidXCords.length;i++)	{

    if(invalidXCords[i]==xPos)	{

     xReset=1;
     break;
  
    }

   }

   for(i=0;i<invalidYCords.length;i++)	{

    if(invalidYCords[i]==yPos)	{

     yReset=1;
     break;
  
    }

   }

   if(!(xReset && yReset) || resetCounter==10)	{
//alert("xPos:"+xPos+" - yPos:"+yPos+" - invalidXCords:"+invalidXCords+" - invalidYCords:"+invalidYCords);
    break;

   }

   else	{

    resetCounter++;

   }

  }

  if(resetCounter==10)	{

   alert("10 x error");

  }

  yCo=document.getElementById("subMenu").offsetTop;
  yCo+=(parseInt(yPos.charAt(0))-1)*94;

  if(subMenuItems<4)	{

   if(startPoint==3)	{
 
    yCo+=-94*(Math.floor((4-subMenuItems)/2)+1);

   }

   else	{

    if(startPoint==4)	{

      yCo+=-94*(Math.floor((4-subMenuItems)/2)+2);

    }

    else	{

      yCo+=-94*(Math.floor((4-subMenuItems)/2));

    }

   }

  }

  xCo=document.getElementById("subMenu").offsetLeft;
  xCo-=((cColumn-1)*94)
  xCo+=(parseInt(xPos.charAt(0))-1)*94;

  currentImgID="img"+lineID.substring(3,lineID.length);

  document.getElementById(currentImgID).style.top=yCo;
  document.getElementById(currentImgID).style.left=xCo;
  document.getElementById(currentImgID).style.visibility="visible";
  document.getElementById(currentImgID).style.zIndex=4;
  document.getElementById(currentImgID).style.border="solid 1px #d1d3d4";

  lineRunning=0;

  availImg=0;

 }


 function contactWindow()		{

  popupWindow=window.open('contact/index.html','popup','channelmode=no,directories=no,fullscreen=no,menubar=no,resizable=yes,status=yes,titlebar=no,toolbar=no,scrollbars=yes,height=450,width=400');popupWindow.resizeTo($width+15,$height+62);popupWindow.focus();

 } 
