
	var fo=0;
	var winWidth=1000;
	var si=0;
	var i=0;
	var o=100;
	var p="";
	function preview(play){
		//	CHECK FOR IPHONE, IPOD, IPAD AND REROUTE
		if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))){
//			confirm("iPhone/iPad version coming soon");
			location.replace("http://www.davidkuriodesigns.com/index.ios.html");
			return;
		}
		p=document.getElementById('overlay');
		getSrc();
		getSize();
		if (play == 'false'){ switchBack();}
			else {
			document.getElementById('sign').style.top=myHeight/2-85+'px';
			document.getElementById('sign').style.left=myWidth/2-450+'px';
			document.getElementById('sign').style.display='block';
			si=setInterval("move()",10);
			}
		
	}

	function move(){
		if(i<winWidth){
			i=i+5;
			p.style.left=i+'px';
			}
		else {
		clearInterval(si);
		setTimeout("switchBack()",2000);
		}
		
	}
	
	function switchBack(){
		document.getElementById('sign').style.display="none";
		document.getElementById('sign').style.width='1px';
		document.getElementById('container').style.display="block";
		startShow('slides');
	}
	
var myWidth = 0, myHeight = 0;
function getSize() {
  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;
  }
}

//********** Music Section **********

var soundPlaying = true;
var soundFile = "";
var srcFile = "";
var dataFile = "";

function getSrc() {
	if (document.getElementById("bgMusic").src) {soundFile = document.getElementById("bgMusic").src;
		srcFile = true;
		dataFile = false;
	}
	else if (document.getElementById("bgMusic").data) {soundFile = document.getElementById("bgMusic").data;
		dataFile = true;
		srcFile = false;
	}
}
function toggleSound() {
	if (soundPlaying) {
		
		if (srcFile) {
			document.getElementById("bgMusic").src = "silence.mp3";
//			document.getElementById("bgMusic").pause();
			}
		if (dataFile) {
			document.getElementById("bgMusic").data = "silence.mp3";
//			document.getElementById("bgMusic").pause();
		}
		soundPlaying = false;
		document.getElementById("toggle").src = "images/play.png";
	}

	else {
		if (srcFile) {
			document.getElementById("bgMusic").src = soundFile;
		}
		if (dataFile) {
			document.getElementById("bgMusic").data = soundFile;
		}
		soundPlaying = true;
		document.getElementById("toggle").src = "images/stop.png";
	}
}

//********** Slideshow Section **********

function T$(i){
	return document.getElementById(i)
	}
function T$$(e,p){
	return p.getElementsByTagName(e)
	}

	function startShow(pid){
		// listID=ID for the slideshow
		this.first=1; //set first image flag
		var listID=T$(pid);
		var u=this.u=T$$('li',listID); //list array
		var ui=this.ui=T$$('img',listID); //image array 
		var l=u.length; //length of the array
		var i=this.l=this.c=this.z=this.u.ai=0;
		listID.style.overflow='hidden'; 
		this.a=7; // seconds to display a slide
		this.p=true;
		//Setup the array of images
		for(i;i<l;i++){
			if(u[i].parentNode==listID){
				u[i].style.position='absolute'; 
				u[i].style.left='0';
				var imgHeight=ui[i].height;
				var offset=10+myHeight/2-(imgHeight/2);
				u[i].style.top=offset+'px';
				this.l++; 
				u[i].o=0;
				u[i].style.opacity=0; 
				u[i].style.filter='alpha(opacity=0)';
			}
			
			var mainOver=T$('mainOverlay');
			var mainID=T$('mainEvents');
			mainOver.style.minHeight=(imgHeight+offset-47)+'px';
			mainID.style.minHeight=(imgHeight+offset-47)+'px';
		}
		// call function pos
		pos(0,this.a?1:0);
	}
	//start the automatic slide show
function auto() {
		this.u.ai=setInterval('moveNext(1,1)',this.a*1000)
	}
	
function moveNext(d,a){
		// set up the next immage
		var n=this.c+d;
		var i=d==1?n==this.l?0:n:n<0?this.l-1:n;
		var done=i+1;
		if (done==this.l) {this.p=false};	
		pos(i,a);
	}

function pos(i,a){
		var p=this.u[i]; 
		this.z++; 
		p.style.zIndex=this.z;
		clearInterval(p.si); 
		clearInterval(this.u.ai);  
		this.u.ai=0; 
		this.c=i;
		p.si=setInterval('fade('+i+','+a+')',1);
	}
	
function fade(i,a){
		var p=this.u[i];
		if(p.o>=100){
			clearInterval(p.si);
			this.first=0; //clear flag for first image
			//if auto enabled then continue
			if((a||(this.a&&this.p))&&!this.u.ai){
				if(this.p==false) {return};
				auto();			
			}			
		}else{
			p.o+=5;
			p.style.opacity=p.o/100; 
			p.style.filter='alpha(opacity='+p.o+')';
		}
} 
