
var timeperiod = 2;
var max_layer = 4;
var layer_array = new Array(0, 0, 0, 0, 0);

var current_layer = 0;
var last_layer    = current_layer;


function next() {

  last_layer = current_layer;
  current_layer++;

  if (current_layer > max_layer) {
    current_layer = 0;
  }

  if (document.layers) {
    document.layers['personals_profile'+last_layer].visibility = "hide";
    document.layers['personals_profile'+current_layer].visibility = "show";
  } else if (document.all) {
    document.all['personals_profile'+last_layer].style.visibility = "hidden";
    document.all['personals_profile'+current_layer].style.visibility = "visible";
  } else if (document.getElementById) {
    document.getElementById('personals_profile'+last_layer).style.visibility = "hidden";
    document.getElementById('personals_profile'+current_layer).style.visibility = "visible";
  }
  setTimeout("next()",1000 * timeperiod);
}


function reposition(max) {
  if (max>=0) {
    var count = 0;
    max_layer=max;

    var run_script = true;
    var browser = '' ;
    if (window.opera) { browser = 'opera'; }
    if (document.layers) { browser = 'ns4'; }
    if (document.all) { browser = 'ie'; }
    if (document.getElementById && (browser=='')) { browser = 'ns6'; }
    while (count <= max_layer) {
      if (browser == 'ns4') {
        document.layers['personals_profile'+count].left = document.layers['positioner'].pageX;
        document.layers['personals_profile'+count].top  = 115;
        document.layers['positioner'].visibility = "hide";
        if (count == 0 ) {
          document.layers['personals_profile'+count].visibility = "show";
        }
      } else if (browser == 'ie') {
        document.all['personals_profile'+count].style.top  = 120;
        document.all['personals_profile'+count].style.left = document.all['maindiv1'].offsetLeft + 15;
        document.all['positioner'].style.visibility = "hidden";
        if (count == 0 ) {
          document.all['personals_profile'+count].style.visibility = "visible";
        }
      } else if (browser == 'ns6') {
        var pos_obj = getComputedStyle(document.getElementById("positioner"), '');
        document.getElementById('personals_profile'+count).style.top  = 120;
        document.getElementById('personals_profile'+count).style.left = pos_obj.getPropertyValue('left');
        // Netscape 7 doesn't compute style values, so don't run slideshow.
        if (pos_obj.getPropertyValue('left') == '0px') { run_script = false; }
        if (count == 0 && run_script ) {
          document.getElementById('positioner').style.visibility = "hidden";
          document.getElementById('personals_profile0').style.visibility = "visible";
        }
      } else if (browser == 'opera') {
        // Do nothing - Opera doesn't handle this well.
        run_script = false;
      }
      count++;
    }
    if (run_script) { setTimeout("next()",1000 * timeperiod); }
  }
}

// Because of ads, add 90 in vertical position
function reposition_ad(max) {
  if (max>=0) {
    var count = 0;
    max_layer=max;

    var run_script = true;
    var browser = '' ;
    if (window.opera) { browser = 'opera'; }
    if (document.layers) { browser = 'ns4'; }
    if (document.all) { browser = 'ie'; }
    if (document.getElementById && (browser=='')) { browser = 'ns6'; }
    while (count <= max_layer) {
      if (browser == 'ns4') {
        document.layers['personals_profile'+count].left = document.layers['positioner'].pageX;
        document.layers['personals_profile'+count].top  = 205;
        document.layers['positioner'].visibility = "hide";
        if (count == 0 ) {
          document.layers['personals_profile'+count].visibility = "show";
        }
      } else if (browser == 'ie') {
        document.all['personals_profile'+count].style.top  = 210;
        document.all['personals_profile'+count].style.left = document.all['maindiv1'].offsetLeft + 15;
        document.all['positioner'].style.visibility = "hidden";
        if (count == 0 ) {
          document.all['personals_profile'+count].style.visibility = "visible";
        }
      } else if (browser == 'ns6') {
        var pos_obj = getComputedStyle(document.getElementById("positioner"),'');
        document.getElementById('personals_profile'+count).style.top  = 210;
        document.getElementById('personals_profile'+count).style.left = pos_obj.getPropertyValue('left');
        // Netscape 7 doesn't compute style values, so don't run slideshow.
        if (pos_obj.getPropertyValue('left') == '0px') { run_script = false; }
        if (count == 0 && run_script ) {
          document.getElementById('positioner').style.visibility = "hidden";
          document.getElementById('personals_profile0').style.visibility = "visible";
        }
      } else if (browser == 'opera') {
        // Do nothing - Opera doesn't handle this well.
        run_script = false;
      }
      count++;
    }
    if (run_script) { setTimeout("next()",1000 * timeperiod); }
  }
}

function next_new() {
	
  // random_5 has a range from 1 to 5
  var random_5=Math.round(Math.random()*4) + 1; 
  var array_index = random_5 - 1;
  current_layer = layer_array[array_index];
  last_layer = current_layer;
  current_layer++;
  
  if (current_layer > max_layer) {
    current_layer = 0;
  }
  layer_array[array_index] = current_layer;

  if (document.layers) {
    document.layers['personals_profile'+random_5+last_layer].visibility = "hide";
    document.layers['personals_profile'+random_5+current_layer].visibility = "show";
  } else if (document.all) {
    document.all['personals_profile'+random_5+last_layer].style.visibility = "hidden";
    document.all['personals_profile'+random_5+current_layer].style.visibility = "visible";
  } else if (document.getElementById) {
    document.getElementById('personals_profile'+random_5+last_layer).style.visibility = "hidden";
    document.getElementById('personals_profile'+random_5+current_layer).style.visibility = "visible";
  }
  setTimeout("next_new()",1000 * timeperiod);
}

function reposition_new(max) {
  if (max>=0) {
    var count = 0;
    max_layer=max;

    var run_script = true;
    var browser = '' ;
    if (window.opera) { browser = 'opera'; } 
    if (document.layers) { browser = 'ns4'; } 
    if (document.all) { browser = 'ie'; } 
    if (document.getElementById && (browser=='')) { browser = 'ns6'; } 

    while (count <= max_layer) {
      if (browser == 'ns4') {
        for (var k=1; k<=5; k++) {
          document.layers['personals_profile'+k+count].left = document.layers['positioner'+k].pageX;
          document.layers['personals_profile'+k+count].top  = document.layers['positioner'+k].top;
          document.layers['positioner'+k].visibility = "hide";
          if (count == 0 ) {
            document.layers['personals_profile'+k+count].visibility = "show";
          }
        }
      } else if (browser == 'ie') {

        for (var k=1; k<=5; k++) {
          //if (document.all['positioner'+k].offsetTop) {
          if (document.all['home_container'].offsetTop) {
            document.all['positioner'+k].style.top  = document.all['home_container'].offsetTop;
             document.all['personals_profile'+k+count].style.top = document.all['positioner'+k].offsetTop;
            //document.all['personals_profile'+k+count].style.top = document.all['home_container'].offsetTop + 50;
          }
          else {
            document.all['positioner'+k].style.top = '64px';
            document.all['personals_profile'+k+count].style.top  = '64px';
          }
	  // if (document.all['positioner'+k].offsetLeft) {
	  if (document.all['home_container'].offsetLeft) {
            document.all['positioner'+k].style.left = document.all['home_container'].offsetLeft;
            document.all['personals_profile'+k+count].style.left = document.all['positioner'+k].offsetLeft;
            //document.all['personals_profile'+k+count].style.left = document.all['home_container'].offsetLeft + 50 + $k*90;
          }
          else {
            var l_offset = 168 + k*100;
            document.all['positioner'+k].style.left  = l_offset + 'px';
            document.all['personals_profile'+k+count].style.left  = l_offset + 'px';
          }
          document.all['positioner'+k].style.visibility = "hidden";
          if (count == 0 ) {
            document.all['personals_profile'+k+count].style.visibility = "visible";
          }          
        }
      } else if (browser == 'ns6') {
        for (var k=1; k<=5; k++) {
          var pos_obj = getComputedStyle(document.getElementById('positioner'+k), '');

          //document.getElementById('personals_profile'+k+count).style.top  = pos_obj.getPropertyValue('top');
          document.getElementById('personals_profile'+k+count).style.top  = '78px';
          document.getElementById('personals_profile'+k+count).style.left = pos_obj.getPropertyValue('left');
          
          // Netscape 7 doesn't compute style values, so don't run slideshow.
          if (pos_obj.getPropertyValue('left') == '0px') { run_script = false; }


          if (count == 0 && run_script ) {
            document.getElementById('positioner'+k).style.visibility = "hidden";
            document.getElementById('personals_profile'+k+count).style.visibility = "visible";
          }

        }
      } else if (browser == 'opera') {
        // Do nothing - Opera doesn't handle this well.
        run_script = false;
      }
      count++;
    }
    if (run_script) { setTimeout("next_new()",1000 * timeperiod); }
  }
} 


function goTo(page) {
  var mutual_interest = 'http://www.love.org/love/mutual_interest.zhtml';
  var register_page = 'https://secure.love.org/love/register.zhtml';
  var mc_profile = 'http://www.love.org/love/profile.zhtml?pid=104';
  window.open(eval(page), '_blank');
}

function viewProfile(profile_id) {
  window.open('http://www.love.org/love/profile.zhtml?pid='+profile_id, 'profileview');
}

function copy_values() {
 document.register.username.value = document.login.username.value; 
 document.register.password.value = document.login.password.value; 
 document.register.password2.value = document.login.password.value; 
}


