// JScript source code
<!--
var arrImages = new Array();
var drawImage = 0;
arrImages[0] = new Image();
arrImages[1] = new Image();
arrImages[2] = new Image();
arrImages[0].src = 'images/draw.jpg';
arrImages[1].src = 'images/draw1.jpg';
arrImages[2].src = 'images/draw2.jpg';
	
function cycleImages() {
	drawImage++;
	if ( drawImage > 2 ) {
		drawImage = 0;
	}
	if ( document.images ) {
		if ( arrImages[drawImage] != null ) {
			if ( arrImages[drawImage].complete ) {
				document.drawImg.src = arrImages[drawImage].src;
			}
		}
	}
}
	
var picIndex = 0;
var aPics = new Array("PixIntel Logo.jpg", "SceneShifts1.jpg", "SceneShifts2.jpg");
function changepic(idelay)
{
//	alert("ChangePic");
	if(picIndex >= aPics.length)
	{
		picIndex = 0;
	}
	setTimeout("changepic(2000)", 8000);

	document["img"].src = aPics[picIndex];

	picIndex++;
}

function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

function inspect(elm)
{
  var str = "";
  alert("inspect");
  for (var i in elm)
  {
    elem = elm.getAttribute(i);
    if(elem != null)
  		str += i + ": " + elm.getAttribute(i) + "\n";

  }
  alert(str);
}

function inspectStyle(elm)
{
  if (elm.style)
  {
  	alert("element style");
    var str = "";
    for (var i in elm.style)
    {
	  elem = elm.style[i];
	  if(elem != null)    
	  	str += i + ": " + elem  + "\n";
	}
	alert(str);
  }
  else alert("No style for this element");
}

function getStyle(elem)
{
	elem = "mainPic";
	alert(elem);
	var header = document.getElementById(elem);
	inspectStyle(header);
}

var secs = 0;
var timerID = null;
var timerRunning = false;
var delay = 1000;

function InitializeTimer(timeout)
{
    // Set the length of the timer, in seconds
    secs = timeout;
    StopTheClock();
    StartTheTimer();
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID);
    timerRunning = false;
}

function StartTheTimer()
{
   if (secs==0)
    {
        StopTheClock();
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
    }
    else
    {
       self.status = secs;
        secs = secs - 1;
        timerRunning = true;
        timerID = self.setTimeout("StartTheTimer()", delay);
    }
}

function getSize(pic) 
{
alert("Picture Loaded");
//	var img = document.images.pic;

/*	var DHTML = (document.getElementById || document.all || document.layers);
	if (!DHTML) 
	{
		alert("No DHTML Support");
		return;
	}
*/
//alert (document["mainPicture"].id);  //works
//alert(document["mainPicture"].width + ' ' + document["mainPicture"].height); //Works
/*myimage = new Image();
myimage = pic;
*/
//alert('name = ' + myimage.name);		// gives undefined
//	alert('Current dimensions: ' + myimage.width + ' ' + myimage.height);  //gives undefined
}
var p;
var once = false;
function loadimage(mimg)
{
	if (!once)
	{
		once = true;
		p = document.getElementById("mainPic");
		p.src = mimg;
	}
}

function showmainpic(p, myimage)
{
	self.setTimeout("p.src = myimage", 100);
//		document["mainPicture"].src = myimage;	// Works
}


function showpic(pic, artist, description, narrative, year, reference, width, height, pf, pfname, thumbnail, searchString, picIndex)
{
	g_name = artist;
	g_description = description;
	g_reference = reference;
	g_year = year;
	re = /!c/g;
	narrative = narrative.replace(re,",");
	re = /!a/g;
	narrative = narrative.replace(re,"'");
	picIndex--;
	
	var DHTML = (document.getElementById || document.all || document.layers);
	if (!DHTML) 
	{
		alert("No DHTML Support");
		return;
	}
/*
	document.getElementById("artist").firstChild.data = artist;
	document.getElementById("description").firstChild.data = description;
	//document.getElementById("medium").firstChild.data = medium;
//	document.getElementById("year").firstChild.data = year;
	document.getElementById("reference").firstChild.data = "Ref: " + reference;
	document.getElementById("imageDescription").firstChild.data = narrative;
	
*/
/*
if(secs == 0)
{
	InitializeTimer(5);

} else
	alert("Please wait ... image loading");
*/	
/*
myimage = new Image();

myimage = pic;
*/
pic = "../" + pic;

var ww = Number(width) + 100;
var hh = Number(height) + 300;

var surl = "portfolio/popup.php?picture=" + pic + "&width=" + width + "&height=" + height + "&description=" + description + "&reference=" + reference + "&narrative=" + narrative + "&pf=" + pf + "&pfname=" + pfname + "&thumbnail=" + thumbnail + "&searchString=" + searchString + "&picIndex=" + picIndex;

myref = window.open(surl, '_self', 'left = 0, top = 0, resizable=no,menubar=0,toolbar=0,statusbar=0,location=0,directories=0,width=' + ww +', height=' + hh);
//document["mainPicture"].src = 'images/blank.jpg';
p = document.getElementById("mainPic");
p.onload = onloadp;					// Define onload event function
p.src = 'images/blank.jpg';



}

function onloadp()
{
	showmainpic(p,myimage);
}


function popUp(url)
{
	window.open(url,'','resizable=0,menubar=0,toolbar=0,statusbar=0,location=1,directories=1,width=1600, height=1200');

}

//	var dis = document.getElementById('description');
//  dis.style.visibility="visible":
//	inspect(dis.obj);
//	dis.innerText="LJOFDJFL";//document["mainPicture"].src = myimage;

//alert(myimage.style.width);
//document["mainPicture"].width=50;				THIS WORKS
//document["mainPicture"].height=50;

//w=pic.style.width;
//alert(w);
//	document["description"].text = description;
// For IE this works
//	if (document.all) 
//	{
//			document.all['edition'].innerText = edition;
//			document.all['description'].innerText = description;
//			document.all['medium'].innerText = medium;
//			document.all['size'].innerText = size;


//	}

// For Netscape, something like this	
//	p = document.getElementById["picdesc"];
//	alert (p.innerHTML);

//----------------------------------------------------------------------------------------------------------------------------------
//
// These functions are used for the cart
//
//----------------------------------------------------------------------------------------------------------------------------------
// This function loads frame2 - can be called by any frame including frame2 if it wants to reload itself or load another page
function loadframe2(url) 
{
//parent.myvar = 0;  // Just as example
  parent.document.all("TopFrame").rows="67%,*";
  parent.frame2.location.href= url;
}

// This function is called by frame2 - for example if it wants to get the calling frame to reload itself.
function OnFrame2Load(p)
{
//	alert("Parent OnFrame2Load " + p);				// This would just display the parameter which was passed to frame2 in the url (see loadframe2 line below).
//	parent.frame1.location.href = 'Cart.php';		// Reload myself
//	parent.TopFrame.rows = "67%, *";
//	parent.document.all("TopFrame").rows="67%,*";
}

function imageObject()
{
	
	this.name = document.getElementById("edition").firstChild.data;
	this.description = document.getElementById("description").firstChild.data;
	this.reference = document.getElementById("size").firstChild.data;
}

var arr = new Array();
var index = 0;
function addToCart(nm, ds, rf)
{
	if(g_name == "") g_name = nm;
	if(g_description == "") g_description = ds;
	if(g_reference == "") g_reference = rf;
	//alert(document.getElementById('reference').value);
	newImage = new imageObject();
	arr[0] = newImage;
//	alert(newImage.name);
//	alert(arr[0].name);
//	alert("Top Layer Frameset rows: " + parent.document.all("TopFrame").rows);

	loadframe2('Cart.php?name=' + g_name + '&description=' + g_description + '&reference=' + g_reference);
}


//-->