var found_pos = "init";

function isSet( variable )
{
  return( typeof( variable ) != 'undefined' );
}

function showSubnav(el,elc) {

  var elm = document.getElementsByClassName('subnav');
  for (var i=0; i<elm.length; i++) {
    Element.hide(elm[i]);
  }

  var elm = document.getElementsByClassName('subnav_container');
  for (var i=0; i<elm.length; i++) {
    elm[i].style.zIndex = 98;
  }

  Effect.Appear($(el));
  //$(el).style.zIndex = 99;
}

function hideSubnav() {
  var elm = document.getElementsByClassName('subnav');
  for (var i=0; i<elm.length; i++) {
    Element.hide(elm[i]);
  }
}


function fade(pics_small,pics_big,pics_header,pics_flash,pic_high) {

var pic_array_small=pics_small.split(",");
var pic_array_big=pics_big.split(",");
var pic_array_header=pics_header.split(",");


found_pos = pic_array_small.indexOf($('model_selector_image').alt);

var size_array = pic_array_small.length ;

if (found_pos+1==size_array) {
  var pic_small_to_show = pic_array_small[0];
  var pic_big_to_show = pic_array_big[0];
  var header_to_show = pic_array_header[0];
} else {
  var pic_small_to_show = pic_array_small[found_pos+1];
  var pic_big_to_show = pic_array_big[found_pos+1];
  var header_to_show = pic_array_header[found_pos+1];
}


$('selector_01').style.opacity = .30;$('selector_01').style.MozOpacity = .30;$('selector_01').style.filter = "alpha(opacity=30)";
$('selector_02').style.opacity = .30;$('selector_02').style.MozOpacity = .30;$('selector_02').style.filter = "alpha(opacity=30)";
$('selector_03').style.opacity = .30;$('selector_03').style.MozOpacity = .30;$('selector_03').style.filter = "alpha(opacity=30)";
$('selector_04').style.opacity = .30;$('selector_04').style.MozOpacity = .30;$('selector_04').style.filter = "alpha(opacity=30)";


$(pic_high).style.opacity = 1;
$(pic_high).style.MozOpacity = 1;
$(pic_high).style.filter = "alpha(opacity=100)";


  if ($('model_selector_image_div').style.display=='none') {
    new Effect.Appear('model_selector_image_div',{from:0.1,to:1.0});
  }
  else
  {

    new Effect.Fade('model_selector_image_div',{
      from:1.0,
      to:0.1,
      afterFinish: function() {
        $('model_selector_image').src = pic_small_to_show;
        $('model_selector_image').alt = pic_small_to_show;
        $('fullsize_pic').src = pic_big_to_show;

        writeFlash (pics_flash,found_pos,pics_header);
        new Effect.Appear('model_selector_image_div');
      }

    });

  }

}

function writeFlash (pics_flash,position,pics_header) {

  var pic_array_flash=pics_flash.split(",");
  var pic_array_header=pics_header.split(",");
  var size_array = pic_array_flash.length;

  if(position == "init") {
    position = size_array-1;
  }

  if (position+1==size_array) {
    var flash_to_show = pic_array_flash[0];
    var header_to_show = pic_array_header[0];
  } else {
    var flash_to_show = pic_array_flash[position+1];
    var header_to_show = pic_array_header[position+1];
  }


if (flash_to_show!="") {

  var sodetail = new SWFObject(flash_to_show, "detail_flash", "780", "214", "8", "#421E1E");
  sodetail.addParam("wmode", "opaque");
  if (sodetail.write("model_pic")) {

  } else {
      $('model_pic_head').src = header_to_show;
      $('txt_noflash').style.display = "block";
  }

}
else {
      $('model_pic_head').src = header_to_show;

  }

}