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

countBoth = 1;
currGender = 1;

f = 1;
m = 2;
b = 3;

// defaulte values

brand = '9';
product ='a';
community = 'd';
context = 'ad99';

imagesBase= "http://www.lavalife.com/pictures/cool/";
photo_directory = imagesBase  + product + community + '/';

suffix = 'ess.jpeg'; 

id = 'nineMsnViewProfile';

a = '18904';
locale='en_AU';

function init() {
   // 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;
   }
}

function link(gender) {
   if (gender == 1) {
      seeking = '&i_am=M&seeking=F'; 
      adcode = femaleAdcode; 

      window.open(clickthru + '?id=' + id + '&idname=' + escape(slideShowIds[1][countF]) + '&context=' + context + '&a=' + adcode + seeking + '&locale=' + locale, 'slideShow');
   } else if (gender == 2) {
      seeking = '&i_am=F&seeking=M'; 
      adcode = maleAdcode; 

      window.open(clickthru + '?id=' + id + '&idname=' + escape(slideShowIds[2][countM]) + '&context=' + context + '&a=' + adcode + seeking + '&locale=' + locale, 'slideShow');
   } else {
      if (currGender == 1) {
         seeking = '&i_am=M&seeking=F'; 
         adcode = femaleAdcode; 
      } else {
         seeking = '&i_am=F&seeking=M'; 
         adcode = maleAdcode; 
      }

      window.open(clickthru + '?id=' + id + '&idname=' + escape(slideShowIds[currGender][countBoth]) + '&context=' + context + '&a=' + adcode + seeking + '&locale=' + locale, 'slideShow');
   }
}

function go(dir, gender) {
   ss_picture = 'ss_picture_both';
   ss_name = 'ss_name_both';

   if (intrpCount == 0) {
      if (dir != 0) {
         intrpCount = intervalInterruptPage;
	 setInterruptPage(1);
      }
   } else {
      if (dir != 0) {
         setInterruptPage(2);
         if (intervalInterruptPage != 0) intrpCount--;   
      }

      if (gender == 1) {
         count  = countF + dir;
         if (count > maxPicF) count = 1;
         if (count < 1) count = maxPicF; 

         countF = count;
         currGender =1;
      } else if (gender==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 ;
      }

      styleChange(ss_picture).innerHTML = getSSPicture(gender);
      styleChange(ss_name).innerHTML = getSSId(gender);
   }
}

// 'dir' is th direction of the slideshow, 1 means to the right, -1 means to the left
function slideshow(dir, gender) {
   var myGender = 'female';

   if (gender == 2) {
      myGender = 'male';
   } else if(gender == 3) {
      myGender = 'both';
   }

   ss_picture = 'ss_picture_' + myGender;
   ss_name    = 'ss_name_' + myGender;

  if (intrpCount == 0) {
     intrpCount = intervalInterruptPage ;
     setInterruptPage(1);
  } else {
     setInterruptPage(2);

     if (intervalInterruptPage != 0) intrpCount--;   

     if (gender == 1) {
        count  = countF + dir;

        if (count > maxPicF) count = 1;
        if (count < 1) count = maxPicF; 

        countF = count;
        currGender =1;
      } else if (gender == 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 ;
        }

        styleChange(ss_picture).innerHTML = getSSPicture(gender);
        styleChange(ss_name).innerHTML = getSSId(gender);
    }
}

function styleChange(id) {
   return element(id);
}

function element(elementId) {
   if (document.getElementById) {
      return document.getElementById(elementId);
   }
   else if (document.all) {
      return document.all[elementId];
   }
   else if (document.layers) {
      return document[elementId];
   }
   else {
      //alert( "no element: " + elementId )
   }
}
