var g_intSubmenuDisplayed=null,
    g_intSubmenuTimeout=null,
    g_bolStartLink=false,
    g_arrSubmenus=new Array(),
    ie5_5=false,
    g_intCornerX,
    g_intCornerY,
    g_bolReady=false,
    g_intResizeTimeout=null,
    g_intFlashVersion=-1;


function resize() {
  if(g_intResizeTimeout) clearTimeout(g_intResizeTimeout);
  g_intResizeTimeout=setTimeout("resizeDone()",800);
}

function resizeDone() {
  g_intResizeTimeout=null;
  window.location=window.location;
}


function resetDHTMLVariables() {
  if(!lay && document.layers) {
    doc=document;
    agt=navigator.userAgent;
    lay=doc.layers;
    ie4=doc.all;
    dom=doc.getElementById;
    ope=agt.match(/opera/gi);
    mac=agt.match(/mac/gi);
  }
}
function errorHandler() {
  return false;
}
function openSubmenu(id, x) {
  if(!g_bolReady) return;
  if(g_bolStartLink) return;
  if(g_intSubmenuTimeout) {
    clearTimeout(g_intSubmenuTimeout);
    g_intSubmenuTimeout=null;
  }
  if(g_intSubmenuDisplayed==id) {
    if(getV(g_arrSubmenus[id])) return;
    else {
      g_intSubmenuDisplayed=null;
      showE(g_arrSubmenus[id]);
      if(ie5_5) g_arrSubmenus[id].style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity=100)';
    }
  }
  if(g_intSubmenuDisplayed!=null) {
    hideSubmenu(g_intSubmenuDisplayed);
  }
  var intW=getW(g_arrSubmenus[id]);
  var intX=15+g_intCornerX;
  if(intW) {
    intX=g_mouseX-(intW/2);
    if(intX+intW-g_intCornerX>724) {intX=724-intW+g_intCornerX;}
    if(intX-g_intCornerX<15) intX=15+g_intCornerX;
  }
  if(x) {
    intX = g_intCornerX + x;
  }
  setX(g_arrSubmenus[id],intX);
  g_intSubmenuDisplayed=id;
  if(ie5_5) {
    g_arrSubmenus[id].style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity=0)';
    showE(g_arrSubmenus[id]);
    var idString=(typeof(id)=="number")?id:"'"+id+"'";
    for(var i=1;i<9;i++) {
      setTimeout("g_arrSubmenus["+idString+"].style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity="+(i*12.5)+")'",10*i)
    }
  } else  {
    showE(g_arrSubmenus[id]);
  }
}

function closeSubmenu(id) {
  id=(typeof(id)=="number")?id:"'"+id+"'";
  if(!g_bolStartLink) g_intSubmenuTimeout=setTimeout("hideSubmenu("+id+")",1500);
}

function hideSubmenu(id) {
  if(!g_arrSubmenus[id]) return;
  g_intSubmenuDisplayed=null;
  g_intSubmenuTimeout=null;
  if(ie5_5) {
    g_arrSubmenus[id].style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity=100)';
    var idString=(typeof(id)=="number")?id:"'"+id+"'";
    for(var i=8;i>=0;i--) {
      setTimeout("g_arrSubmenus["+idString+"].style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity="+(i*12.5)+")'",10*(9-i))
    }
    setTimeout("hideE(g_arrSubmenus["+idString+"])",100);
  } else {
    hideE(g_arrSubmenus[id]);
  }
}

function rollover(name,id,state) {
  if(typeof(g_arrImgRollover)=="undefined") return;
  getI(name).src=(state==1)?g_arrImgRollover[id].on.src:g_arrImgRollover[id].off.src;
}

function ImageRollover(strOff, strOn) {
  this.off=new Image();
  this.off.src=strOff;
  this.on=new Image();
  this.on.src=strOn;
}

function showWarning() {
  if(typeof(detectFlash)=='function') {
    detectFlash(20);
  } else {
    g_intFlashVersion=-2;
  }
  var oWindow=window.open("/warning.lbl?h="+screen.Height+"&w="+screen.Width+"&f="+g_intFlashVersion,"warning","width=310,height=390,top=50,left=50,scrollbars=yes");
}
function showLegal() {
  var oWindow=window.open("/legal.lbl","legal","width=450,height=400,top=60,left=60,scrollbars=yes");
}
function openSportvision() {
 var oWindow=window.open('/sportvision/redirect.lbl','sportvision','resizable=no,width=762,height=500,top=70,left=70');
}
function openVideo(strURL, intWidth, intHeight) {
  var oWindow=window.open(strURL,"video","width="+intWidth+",height="+intHeight+",top=80,left=80,scrollbars=no");
}
function openWeather() {
  var oWindow=window.open("/sailing/LVC/weather.lbl","weather","width=332,height=190,top=90,left=90,scrollbars=no");
}

function openLive(str) {
  switch(str) {
    case 'ladies':
      var oWindowWomen=window.open('http://www.fisski.com/live/2003/w.html','women','height=400,width=550,status=no,toolbar=no,menubar=no,location=no');
      break;
    default:
      var oWindowMen=window.open('http://www.fisski.com/live/2003/m.html','men','height=400,width=550,status=no,toolbar=no,menubar=no,location=no');
      break;
  }
}
function openKiriumTrophy() {
 sQ=(UU!='')?('&uid='+UU):'';
 if(UE) sQ+=(UE!='null')?('&uidenlive='+UE):'';
 var oWindow=window.open('http://62.210.181.107/tag/?lang='+UL+sQ,'kiriumtrophy','resizable=no,width=800,height=568,top=20,left=10');
}

function openSurvey(uS, sW) {
  var oWindow=window.open('/watches/survey.lbl?survey='+uS+'&watch='+sW,'survey','resizable=no,width=440,height=500,top=30,left=20');
}

function openTWTeasing() {
  var oWindow=window.open("/popups/tw_teasing.lbl","tw_teasing","width=550,height=300,top=30,left=30,scrollbars=no");
}

function openTWWAYMOVideo() {
  var top,left;
  if (typeof(screen.Width)!='undefined' && typeof(screen.Height)!='undefined') {
    top=Math.ceil(screen.Height-350)/2;
    left=Math.ceil(screen.Width-750)/2;
  } else {
    left=30;
  }
  var oWindow=window.open("/popups/tw_waymo_video.lbl","tw_waymo_video","width=750,height=350,top="+top+",left="+left+",scrollbars=no");
}

function openPDF(uidWatch) {
  var oWindow=window.open("/popups/pdf.lbl?uidWatch="+uidWatch,"pdf","width=780,height=600,top=0,left=0,resizable=1");
}

function emailPDFToFriend(uidWatch){
  var oWindow=window.open("/popups/emailpdftofriend.lbl?uidWatch="+uidWatch,"emailpdf","width=450,height=450,top=0,left=0,resizable=1");
}

function openRacerTeasing() {
  var oWindow=window.open("/popups/racer_teasing.lbl","racer_teasing","width=550,height=300,top=30,left=30,scrollbars=no");
}

function openBasel2004Teasing() {
  var oWindow=window.open("/popups/basel04_teasing.lbl","basel04_teasing","width=550,height=300,top=30,left=30,scrollbars=no");
}

function openInesSastreVideo() {
  var oWindow=window.open("/whatsnew/women_coll.lbl","ines_sastre","width=370,height=275,top=30,left=30,scrollbars=no");
}

function openLadiesGolf() {
  var oWindow=window.open("/whatsnew/ladies_golf.lbl","ladies_golf","width=320,height=260,top=30,left=30,scrollbars=no");
}

function openChat() {
  var oWindow=window.open("http://www.canalchat.com/tagheuer/","ladies_golf","width=250,height=321,top=30,left=30,scrollbars=no");
}

function openPopupImage(uid, from) {
  if(!from) from = 'img';
  var oWindow=window.open("/popupImage.lbl?"+from+"="+uid,"popupImage","width=100,height=100,top=50,left=50,scrollbars=no");
}

function openV4Presentation() {
  var oWindow=window.open("/basel2004/v4_presentation.lbl","v4_presentation","width=345,height=273,top=30,left=30,scrollbars=no");
}

function openVIPCarrera() {
  var oWindow=window.open("/whatsnew/vipcarrera.lbl","Carrera","width=370,height=270,top=30,left=30,scrollbars=no");
}

function openLinkChallenge() {
  var oWindow=window.open("/whatsnew/events/link_challenge.lbl","Link_Challenge","width=260,height=192,top=30,left=30,scrollbars=no");
}

function openTHisHot() {
  var oWindow=window.open("/whatsnew/tag_heuer_is_hot.lbl","TAG_Heuer","width=320,height=255,top=30,left=30,scrollbars=no");
}

function openChatROC(l) {
  if(l=='fr') {
    var oWindow=window.open("http://www.canalchat.com/tagheuer/race/fr/","chatROC","width=312,height=321,top=30,left=30,scrollbars=no");
  } else {
    var oWindow=window.open("http://www.canalchat.com/tagheuer/race/en/","chatROC","width=312,height=321,top=30,left=30,scrollbars=no");
  }
}

function openCarreraExhibit() {
  var oWindow=window.open("/carreraexhibition/video.lbl","Carrera_Exhibition","width=320,height=255,top=30,left=30,scrollbars=no");
}

function openMariaSharapova() {
  var oWindow=window.open("/whatsnew/events/maria_sharapova.lbl","Maria_Sharapova","width=260,height=192,top=30,left=30,scrollbars=no");
}

function openYaoMing() {
  var oWindow=window.open("/whatsnew/events/yao_ming.lbl","Yao_Ming","width=260,height=192,top=30,left=30,scrollbars=no");
}

function open11jan2005() {
  var oWindow=window.open("/whatsnew/events/11jan05.lbl","11jan2005","width=365,height=275,top=30,left=30,scrollbars=no");
}

function openGolfWatch() {
  var oWindow=window.open("/whatsnew/events/golf_watch.lbl","GolfWatch","width=365,height=275,top=30,left=30,scrollbars=no");
}

function open11jan2005_london() {
  var oWindow=window.open("/whatsnew/events/11jan05_london.lbl","11jan2005_london","width=365,height=275,top=30,left=30,scrollbars=no");
}

function open360JPM() {
  var oWindow=window.open("/popups/calibre_360_jpm.lbl","360JPM","width=365,height=275,top=30,left=30,scrollbars=no");
}

function open360Launch() {
  var oWindow=window.open("/popups/360_basel_2005_launch.lbl","360Launch","width=365,height=275,top=30,left=30,scrollbars=no");
}
function openMobileF1() {
  var oWindow=window.open("/multimedia/mobile/f1/index.lbl","mobilegamesf1","width=600,height=490");
}
function openMobileIndy() {
  var oWindow=window.open("/multimedia/mobile/indy500/index.lbl","mobilegamesindy","width=600,height=490");
}

function openPopupURL(URL, w, h) {
  var oWindow=window.open(URL,"popup","width="+w+",height="+h);
}
function openScrollablePopupURL(URL, w, h) {
  var oWindow=window.open(URL,"popup","width="+w+",height="+h+",scrollbars=yes");
}
