 var globalnum = 1;

function showamb(num){
	
	inner = "<img src='images/pic" + num + ".gif' alt='' />";
	inner = inner + "<span>[ ";
	if (num == 1)		
		inner = inner + "<font class='sel' onClick='showamb(1)'>1</font> ";
	else
		inner = inner + "<font onClick='showamb(1)'>1</font> ";

	if (num == 2)		
		inner = inner + "<font class='sel' onClick='showamb(2)'>2</font> ";
	else
		inner = inner + "<font onClick='showamb(2)'>2</font> ";
	
	if (num == 3)		
		inner = inner + "<font class='sel' onClick='showamb(3)'>3</font> ";
	else
		inner = inner + "<font onClick='showamb(3)'>3</font> ";
	if (num == 4)		
		inner = inner + "<font class='sel' onClick='showamb(4)'>4</font> ";
	else
		inner = inner + "<font onClick='showamb(4)'>4</font> ";
	if (num == 5)		
		inner = inner + "<font class='sel' onClick='showamb(5)'>5</font> ";
	else
		inner = inner + "<font onClick='showamb(5)'>5</font> ";
	if (num == 6)		
		inner = inner + "<font class='sel' onClick='showamb(6)'>6</font> ";
	else
		inner = inner + "<font onClick='showamb(6)'>6</font> ";
	if (num == 7)		
		inner = inner + "<font class='sel' onClick='showamb(7)'>7</font> ";
	else
		inner = inner + "<font onClick='showamb(7)'>7</font> ";
	if (num == 8)		
		inner = inner + "<font class='sel' onClick='showamb(8)'>8</font> ";
	else
		inner = inner + "<font onClick='showamb(8)'>8</font> ";
	if (num == 9)		
		inner = inner + "<font class='sel' onClick='showamb(9)'>9</font> ";
	else
		inner = inner + "<font onClick='showamb(9)'>9</font> ";

		
	inner = inner + "]</span>";
		
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
		document.all.pictures.innerHTML = inner;
	}
	if (document.getElementById && !document.all) {
	}
	
}

function moveForward(img, quantity){
	
	if (globalnum != quantity) 
		globalnum = globalnum + 1;
	inner = "<img src='images/" + img + globalnum + ".jpg' alt='' />";
	
	id = "picture" + img;
	
	document.getElementById(id).innerHTML = inner;
	
}


function moveBackward(img){
	if (globalnum != 1)
	globalnum = globalnum - 1;
	inner = "<img src='images/" + img + globalnum + ".jpg' alt='' />";
	
	id = "picture" + img;
	
	document.getElementById(id).innerHTML = inner;
	
}

function closebtn(img){
	
	globalnum = 1;
	inner = "<img src='images/" + img + "1.jpg' alt='' />";
	
	id = "picture" + img;
	
	document.getElementById(id).innerHTML = inner;
	
	
}



function hidepwait(){	
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
		document.all.pwait.style.display = "none";	
	}
	if (document.getElementById && !document.all) {
		document.getElementById("pwait").style.display= "none";	
	}
	
}

function showpwait(){	
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
		document.all.pwait.style.display = "block";	
	}
	if (document.getElementById && !document.all) {
		document.getElementById("pwait").style.display= "block";	
	}
	
}

function showlist(num){
	
	innfile = "p1_1.gif";
	
	
	inner =	"<img onClick='showimg(\"p" + num +"_1.gif\");hidepwait()' src='images/p" + num + "_1_s.gif' />";
	inner = inner + "<img onClick='showimg(\"p" + num +"_2.gif\");hidepwait()' src='images/p" + num + "_2_s.gif' />";
	inner = inner + "<img onClick='showimg(\"p" + num +"_3.gif\");hidepwait()' src='images/p" + num + "_3_s.gif' />";
	inner = inner + "<img onClick='showimg(\"p" + num +"_4.gif\");hidepwait()' src='images/p" + num + "_4_s.gif' />";
	inner = inner + "<img onClick='showimg(\"p" + num +"_5.gif\");hidepwait()' src='images/p" + num + "_5_s.gif' />";
	inner = inner + "<img onClick='showimg(\"p" + num +"_6.gif\");hidepwait()' src='images/p" + num + "_6_s.gif' />";
	inner = inner + "<img onClick='showimg(\"p" + num +"_7.gif\");hidepwait()' src='images/p" + num + "_7_s.gif' />";
	inner = inner + "<img onClick='showimg(\"p" + num +"_8.gif\");hidepwait()' src='images/p" + num + "_8_s.gif' />";
	inner = inner + "<span>[ ";
	if (num == 1)		
		inner = inner + "<font class='sel' onClick='showlist(1);hidepwait();'>1</font> ";
	else
		inner = inner + "<font onClick='showlist(1);hidepwait();'>1</font> ";

	if (num == 2)		
		inner = inner + "<font class='sel' onClick='showlist(2);hidepwait();'>2</font> ";
	else
		inner = inner + "<font onClick='showlist(2);hidepwait();'>2</font> ";
	
	if (num == 3)		
		inner = inner + "<font class='sel' onClick='showlist(3);hidepwait();'>3</font> ";
	else
		inner = inner + "<font onClick='showlist(3);hidepwait();'>3</font> ";
	if (num == 4)		
		inner = inner + "<font class='sel' onClick='showlist(4);hidepwait();'>4</font> ";
	else
		inner = inner + "<font onClick='showlist(4);hidepwait();'>4</font> ";
	if (num == 5)		
		inner = inner + "<font class='sel' onClick='showlist(5);hidepwait();'>5</font> ";
	else
		inner = inner + "<font onClick='showlist(5);hidepwait();'>5</font> ";
	inner = inner + "]</span>";
	
	file = "p" + num + "_1.gif";
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
		document.all.productsLeft.innerHTML = "<div id='pwait'><img src='images/wait.gif' alt='' /></div><img src='images/" + file + "' alt='' />";
		document.all.productsRight.innerHTML = inner;		
	}
	if (document.getElementById && !document.all) {
		document.getElementById("productsLeft").innerHTML = "<div id='pwait'><img src='images/wait.gif' alt='' /></div><img src='images/" + file + "' alt='' />";
		document.getElementById("productsRight").innerHTML = inner;		
	}
	
	
}


function showimg(file){
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
		document.all.productsLeft.innerHTML = "<div style='display:block;' id='pwait'><img src='images/wait.gif' alt='' /></div><img src='images/" + file + "' alt='' />";
		
		
	}
	if (document.getElementById && !document.all) {
		document.getElementById("productsLeft").innerHTML = "<div style='display:block;' id='pwait'><img src='images/wait.gif' alt='' /></div><img src='images/" + file + "' alt='' />";
		
	}
}


var morepic = 2;

function morePic(){		
	
	if (morepic > 8)
		morepic = 1;
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
		document.all.pictures.innerHTML = "<img src='images/pic" + morepic + ".gif' alt='' />";
	}
	if (document.getElementById && !document.all) {
		document.getElementById("pictures").innerHTML = "<img src='images/pic" + morepic + ".gif' alt='' />";
	}
	morepic = morepic + 1 ;
}

var move = -330;
var direction = -100;
function bounce(layer_ref, x){	
		
		
		move = move + direction;
		
		if (move <= -660)
			direction = +100;
		if (move >= 0)
			direction = -100;
			
		var state = move + "px";
		
		
		
		if (document.all) { //IS IE 4 or 5 (or 6 beta)
			//alert ("IE");
			eval( "document.all." + layer_ref + ".style.left = state");
		}
		
		if (document.getElementById &&!document.all) {
			//alert("FIREFOX");
			document.getElementById(layer_ref).style.left= state;	
		}
			
}


function goLeft(layer_ref, pos){	
		
		
		move = move - 40;
		
		if (move <= pos)
			move = 0;
		
			
		var state = move + "px";
		
		
		
		if (document.all) { //IS IE 4 or 5 (or 6 beta)
			//alert ("IE");
			eval( "document.all." + layer_ref + ".style.left = state");
		}
		
		if (document.getElementById &&!document.all) {
			//alert("FIREFOX");
			document.getElementById(layer_ref).style.left= state;	
		}
			
}

function goRight(layer_ref, pos){	
		
		
		move = move + 40;
		
		if (move > pos)
			move = -660;
		
			
		var state = move + "px";
		
		
		
		if (document.all) { //IS IE 4 or 5 (or 6 beta)
			//alert ("IE");
			eval( "document.all." + layer_ref + ".style.left = state");
		}
		
		if (document.getElementById &&!document.all) {
			//alert("FIREFOX");
			document.getElementById(layer_ref).style.left= state;	
		}
			
}


// Taken from lightbox implementation found at http://www.huddletogether.com/projects/lightbox/
function getScroll(){
	if (self.pageYOffset) {
		this.yPos = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){
		this.yPos = document.documentElement.scrollTop; 
	} else if (document.body) {
		this.yPos = document.body.scrollTop;
	}
}

// Ie requires height to 100% and overflow hidden or else you can scroll down past the lightbox
function prepareIE(height, overflow){
    bod = document.getElementsByTagName('body')[0];
    bod.style.height = height;
    bod.style.overflow = overflow;

    htm = document.getElementsByTagName('html')[0];
    htm.style.height = height;
    htm.style.overflow = overflow; 
}

function setScroll(x, y){
	window.scrollTo(x, y); 
}

// In IE, select elements hover on top of the lightbox
function hideSelects(visibility){
	selects = document.getElementsByTagName('select');
	for(i = 0; i < selects.length; i++) {
		selects[i].style.visibility = visibility;
	}
}

function alertSize() {
  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 );
}

function getHeight() {
  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;
  }
  return myHeight;
}

function getWidth() {
  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;
  }
  return myWidth;
}

function fullscreen(){
	var layer_ref = "container";
	var top = 0;	
	
	
	
	top = (getHeight() - 500) / 2;

	getScroll();
	prepareIE('100%', 'hidden');
	setScroll(0,0);
	hideSelects('hidden');		
	
	waitcenter();
		
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
		//alert ("IE");		
		document.all.container.style.top = top + "px";
		document.all.container.style.display = "block";
		document.all.wait.style.display = "none";
		document.all.pwait.style.display = "none";	
		
	}		
	if (document.getElementById &&!document.all) {
		//alert("FIREFOX");		
		document.getElementById("container").style.top= top + "px";	
		document.getElementById("container").style.display= "block";	
		document.getElementById("wait").style.display= "none";	
		document.getElementById("pwait").style.display= "none";	
	}
}


function waitcenter(){
	var layer_ref = "wait";
	var top = 0;	
	
	top = (getHeight() - 100) / 2;
	left = (getWidth() - 100) / 2;


	if (document.all) { //IS IE 4 or 5 (or 6 beta)
		//alert (top);		
		document.all.wait.style.top = top + "px";
		document.all.wait.style.left = left + "px";
	}		
	if (document.getElementById &&!document.all) {
		//alert("FIREFOX");		
		document.getElementById("wait").style.top= top + "px";	
		document.getElementById("wait").style.left= left + "px";	
	}
}

function msgcenter(){
	var layer_ref = "msg";
	var top = 0;	
	
	top = (getHeight() - 70) / 2;
	left = (getWidth() - 700) / 2;


	getScroll();
	prepareIE('100%', 'hidden');
	setScroll(0,0);
	hideSelects('hidden');		
		
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
		//alert (top);		
		document.all.msg.style.top = top + "px";
		document.all.msg.style.left = left + "px";
	}		
	if (document.getElementById &&!document.all) {
		//alert("FIREFOX");		
		document.getElementById("msg").style.top= top + "px";	
		document.getElementById("msg").style.left= left + "px";	
	}
}

function showbg(){
	//Show message
	var inner = "<div id='msginner'><a class='link' onClick='hidebg();' href='#'>OK</a></div>";

	if (document.all) { //IS IE 4 or 5 (or 6 beta)
		//alert (document.all.msg.style);		
		document.all.overlay.style.visibility = "visible";
		document.all.msg.style.visibility = "visible";
		eval( "document.all.msg.innerHTML = inner");

	}		
	if (document.getElementById && !document.all) {
		//alert("FIREFOX");		
		document.getElementById("overlay").style.visibility= "visible";
		document.getElementById("msg").style.visibility= "visible";	
		document.getElementById("msg").innerHTML = inner;
	}
	
	msgcenter();
	
}

function hidebg(){
	var inner = ""
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
		//alert ("IE");		
		document.all.overlay.style.visibility = "hidden";
		document.all.msg.style.visibility = "hidden";
		eval( "document.all.msg.innerHTML = inner");


	}		
	if (document.getElementById &&!document.all) {
		//alert("FIREFOX");		
		document.getElementById("overlay").style.visibility= "hidden";	
		document.getElementById("msg").style.visibility= "hidden";	
		document.getElementById("msg").innerHTML = inner;
	}
}

function show(id){	
	document.getElementById(id).style.visibility= "visible";	
	
}

function hide(id){	
	document.getElementById(id).style.visibility= "hidden";	
	
}


function moveStore(store, fx, tx, fy, ty){
	
	
	var fromPos = new Spry.Effect.Utils.Position();
	fromPos.x = fx;
	fromPos.y = fy;
	
	var toPos = new Spry.Effect.Utils.Position();
	toPos.x = tx;
	toPos.y = ty;

	Spry.Effect.makePositioned(document.getElementById(store));
	var move_av = new Spry.Effect.Move(store, fromPos, toPos, {duration: 1000, toggle: false});

	move_av.start(); 
}

function shake(store){
	var shake_effect = new Spry.Effect.Shake(store, {duration: 150});
	shake_effect.start();
}

function fade(store){
	var fade = new Spry.Effect.Fade(store, {duration:1000, from:100, to:00, toggle:false});
	fade.start();
}

function showStore(store){
	var show = new Spry.Effect.Fade(store, {duration:1000, from: 00, to: 100, toggle:false});
	show.start();
}

function squish(store){
	var squish = new Spry.Effect.Squish(store, {from:"100%", to:"0%", toggle:false});
	squish.start();
}

function unsquish(store){
	var unsquish = new Spry.Effect.Squish(store, {from:"0%", to:"100%", toggle:false});
	unsquish.start();
}



