// JavaScript Document

var delay = 2000;
var start_frame = 0;
function init() {
	var lis = $('slide-images').getElementsByTagName('li');
	for( i=0; i < lis.length; i++){
		if(i!=0){
			lis[i].style.display = 'none';
		}
	}
	end_frame = lis.length -1;
	start_slideshow(start_frame, end_frame, delay, lis);
	new Effect.Fade('loader_e');
	
}

function start_slideshow(start_frame, end_frame, delay, lis) {
	setTimeout(fadeInOut(start_frame,start_frame,end_frame, delay, lis), delay);
}
var lastimg = 'nope';
function fadeInOut(frame, start_frame, end_frame, delay, lis) {
	return (function() {
		lis = $('slide-images').getElementsByTagName('li');
		imgtest = $('slide-images').getElementsByTagName('img');
		//nextimg = $('slide-images').getElementsByTagName('img')[frame+1].getAttribute('title');
		Effect.Fade(lis[frame]);
		if (frame == end_frame) { 
		frame = start_frame; 
		} else {
			frame++;
		}
		lisAppear = lis[frame];
		/*
		var myimg = $('slide-images').getElementsByTagName('img')[frame].getAttribute('title');
		
		if (myimg == 'portrate' && lastimg != 'portrate' || myimg == 'portrate' && lastimg == 'nope'){
					new Effect.MoveBy('slide-images', -70, 0 );
		}
	    if (myimg == 'landscape' && lastimg != 'landscape' && lastimg != 'nope'){
					new Effect.MoveBy('slide-images', 70, 0);
					
		}*/
		//lastimg = myimg;
		//alert('current image =' + myimg + "  last image = " +lastimg ); 
		setTimeout("Effect.Appear(lisAppear);", 0);
		setTimeout(fadeInOut(frame, start_frame, end_frame, delay), delay + 1850);
	})
	
}

function addflash(flashfile,feed,xheight,xwidth){
	//alert(flashfile + feed  +  xheight +  xwidth);
	var flashvars = {};
	flashvars.myimg = feed;
	var params = {};
	params.wmode = "transparent";
	params.scale = "noscale";
	var attributes = {};
	swfobject.embedSWF(flashfile, "flashcontent", xheight, xwidth, "9", "expressInstall.swf", flashvars, params, attributes);
	
	var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  $('flashcontent').style.height = myHeight-50+'px';
  $('flashcontent').style.width = myWidth+'px';
  $('flashcontent').style.display = 'block';
  $('killflash').style.display = 'block';
 // $('imgcontainer').style.display = 'none';
  
	}
	
  function killflash (){
	    $('flashcontent').innerHTML = '';
	    $('flashcontent').style.display = 'none';
		$('killflash').style.display = 'none';
	    $('imgcontainer').style.display = 'block';
	    return false;
   }
