<!--
// globale value
count = 1;
countF = 1;
countM = 1;
countBoth = 1;
currGender = 1;

// defaulte values
intervalInterruptPage2 = 11;
intervalInterruptPage1 = 21;
intrpCount = intervalInterruptPage1;
brand = 'r';
community = 'd';
context = 'anrr';
isInterrupt = true;
isSmall = false;
domain = 'www.lavalife.com';
script = '/jumpto.epl';
clickthru = 'http://www.lavalife.com/clickthru/clickthru.act';
photo_path = 'http://www.lavalife.com/pictures/cool/';
suffix = 'ss.jpeg'; 
femaleAdcode = 'female';
maleAdcode = 'male';
registerAdcode = 'register';

// browser type.
isIE = false;
isNetscape4 = false;
isNetscape6 = false;
ismacNetscape = false;

function init(myDomain){

  // set the maxium no of picture
  maxPicF = slideShowPics[1].length - 1;
  maxPicM = slideShowPics[2].length - 1;
  maxPicBoth = maxPicF ;
  if (maxPicM < maxPicF)
   maxPicBoth = maxPicM ;

 if (brand != null && community != null){
  context = 'a' + community + brand + brand;
 }
 if (myDomain != null){
  domain = myDomain;
 }

 photo_directory = photo_path + 'a' + community + '/';

 if (isSmall){
  suffix = 'ess.jpeg'; 
 }else{
   suffix = 'ss.jpeg'; 
 }
  if (document.all) {
    isIE = true;
  } else if (document.getElementById) {
    isNetscape6 = true;
  } else if (document.layers) {
    isNetscape4 = true;
  }

  document.write('<style>');
  if (navigator.platform.indexOf('Win') > -1) {
    if (isNetscape4) {
      document.write('.ss_text {color:#FFFFFF; font-size:9px; font-family:Arial, Helvetica, sans-serif;}');
    } else {
      document.write('.ss_text {color:#000000; font-size:9px; font-family:Arial, Helvetica, sans-serif;}');
    }
  } else {
    if (isNetscape4) {
      ismacNetscape = true;
      document.write('.ss_text {color:#000000; font-size:8px; font-family:Arial, Helvetica, sans-serif;}');
    }
    else if (isIE) {
      document.write('.ss_text {color:#000000; font-size:8px; font-family:Arial, Helvetica, sans-serif;}');
    } else {
      document.write('.ss_text {color:#000000; font-size:9px; font-family:Arial, Helvetica, sans-serif;}');
    }
  }
  document.write('</style>');
}

function link(n) {
  if ( n == 1 ) {
    seeking = '?i_am=M&seeking=F'; 
    adcode = femaleAdcode; 
    window.open(clickthru +  seeking + '&idname=' + escape(slideShowIds[1][countF]) + '&id=externalSlideshow&context=' + context + '&a=' + adcode + '&furl=' + domain + script, 'slideShow');
  } else if ( n == 2 ){
    seeking = '?i_am=F&seeking=M'; 
    adcode = maleAdcode; 
    window.open(clickthru + seeking + '&idname=' + escape(slideShowIds[2][countM]) + '&id=externalSlideshow&context=' + context + '&a=' + adcode + '&furl=' + domain + script, 'slideShow');
  }else {
   if (currGender==1){
      seeking = '?i_am=F&seeking=M'; 
      adcode = femaleAdcode; 
    }else{
      seeking = '?i_am=M&seeking=F'; 
      adcode = maleAdcode; 
    }
    window.open(clickthru + seeking + '&idname=' + escape(slideShowIds[currGender][countBoth]) + '&id=externalSlideshow&context=' + context + '&a=' + adcode + '&furl=' + domain + script, 'slideShow');
  }
}

// 'dir' is th direction of the slideshow, 1 means to the right, -1 means to the left
function slideshow(dir, n) {
  var myGender = 'female';
  if (n==2) {
    myGender = 'male';
  }else if(n==3){
    myGender = 'both';
  }

  ss_picture = 'ss_picture_' + myGender;
  ss_name    = 'ss_name_' + myGender;
 
  if(intrpCount == intervalInterruptPage2){
     intrpCount--;
     styleChange(ss_picture).innerHTML = '<a href="' + clickthru + '?context=an' + brand + brand + '&a=' + registerAdcode + '&furl=' + domain + '%2fguest%2fregister%2eact' + '" target="_pop"><img src="http://' + domain + '/images/splash/interrupt01-new.gif" width="93" height="85" border=0></a>';
     styleChange(ss_name).innerHTML = '<img src="http://' + domain + '/images/xxxx-pixel.gif" width="1" height="1" border=0></a>';
  } else if(intrpCount == 0){
     intrpCount = intervalInterruptPage1 ;
     styleChange(ss_picture).innerHTML = '<a href="' + clickthru + '?context=an' + brand + brand + '&a=' + registerAdcode + '&furl=' + domain + '%2fguest%2fregister%2eact' + '" target="_pop"><img src="http://' + domain + '/images/splash/interrupt02-new.gif" width="93" height="85" border=0></a>';
     styleChange(ss_name).innerHTML = '<img src="http://' + domain + '/images/xxxx-pixel.gif" width="1" height="1" border=0></a>';
  } else {
   intrpCount--; 
   if (n == 1) {
     count  = countF + dir;
     if (count > maxPicF) count = 1;
     if (count < 1) count = maxPicF; 
     countF = count;
     currGender =1;
   } else if (n==2){
     count  = countM + dir;
     if (count > maxPicM) count = 1;
     if (count < 1) count = maxPicM;
     countM = count;
     currGender = 2;
   } else {
     if ((currGender == 2 && dir == 1) || (currGender == 1 && dir == -1))
      count  = countBoth + dir;
 
      if (count > maxPicBoth && currGender == 2) count = 1;
      if (count < 1 && currGender == 1) count = maxPicBoth;
     countBoth = count;

     if (currGender ==1)
       currGender = 2 ;
     else
       currGender = 1 ;
   } 
   if (isNetscape4) {
     //change the User ID
     ssPic  = 'ssPic'  + n;
     ssName = 'ssName' + n;
     writeLayer(ssPic,  writeTable(count, currGender));
     writeLayer(ssName, writeName(count, currGender));
   } else {
     styleChange(ss_picture).innerHTML = '<a href="javascript:link(' + n + ')"><img name=p src="' + photo_directory + slideShowPics[currGender][count] + suffix + '" border=0></a>';
     styleChange(ss_name).innerHTML = slideShowIds[currGender][count];
   }
  }
}

function styleChange(id) {
  if (isIE) {
    return document.all[id];
  } else if(isNetscape6) {
    return document.getElementById(id);
  }
}

//netscape stuff 
function writeLayer(id, text) {
  var x;
  if (internalLayer.length > 0) {
    x  = document.layers[internalLayer].layers[id];
  } else {
    x  = document.layers[id];
  }
  x.document.open();
  x.document.write(text);
  x.document.close();
}

function writeTable(count, n) {
  return '<table border=0 cellpadding=0 cellspacing=0 ' + bg_color + ' width=163><tr><td align=center width=' + width + ' height=' + height + '><a href="javascript: link(' + n + ')"><img src=' + slideShowPics[currGender][count] + ' border=0></a></td></tr></table>';
}

function writeName(count, n) {
  return '<table border=0 cellpadding=0 cellspacing=0 ' + bg_color + ' width=120><tr><td align=center width=120><a href="javascript:link(' + n +');" style="color:#CC0033;font:9pt;" id="ss_name1">' + slideShowIds[currGender][count] + '</a></td></tr></table>';
}

