// scripts.js
var undefined;
var imageObj;
var pictureObj;
var frameDetailObj;
var textWindowObj;
var frameTextWindowObj;
var pictureTextWindowObj;
var viewsObj;
var imageInfoObj;
var imageInfoBuyObj;
var pegboardObj;
var collectionImageObj;
var splashImageObj;
var splashTextObj;
var contextImageObj;
var shopWindowObj;
var noResultsObj;
var basketObj;
var errorObj;
var admin = false;

var contextPath;

var splashTexts;

// newFunction
function viewPicture() {
	frameDetailObj.hideIt();
	imageObj.hideIt();
	frameTextWindowObj.hideIt();
	textWindowObj.hideIt();
	
	if (!(contextImageObj === undefined))
	{
		contextImageObj.hideIt();
	}
	pictureObj.showIt();
	pictureTextWindowObj.showIt();
	//frameTextWindowObj.showIt();

}

function viewFrameDetail() {
	pictureObj.hideIt();
	imageObj.hideIt();
	pictureTextWindowObj.hideIt();
	textWindowObj.hideIt();
	if (!(contextImageObj === undefined))
	{	
		contextImageObj.hideIt();
	}
	frameDetailObj.showIt();
	frameTextWindowObj.showIt();
}

function viewImage() {
	pictureObj.hideIt();
	frameDetailObj.hideIt();
	
	pictureTextWindowObj.hideIt();
	frameTextWindowObj.hideIt();	
	if (!(contextImageObj === undefined))
	{	
		contextImageObj.hideIt();
	}
	imageObj.showIt();
	textWindowObj.showIt();
}

function viewContext() {
	pictureObj.hideIt();
	frameDetailObj.hideIt();
	imageObj.hideIt();

	pictureTextWindowObj.hideIt();		
	frameTextWindowObj.hideIt();	
	textWindowObj.hideIt();
	
	contextImageObj.showIt();	
}

/*
function buyPicture(imageId, pictureId) {
	var path = contextPath+"/pictures/details.do?imageId="+imageId+"&pictureId="+pictureId;
	openWindow(path);
	return false;
}
*/

function buyPicture(path)
{
	openWindow(path);
	return false;
}

function buyCanvas(path)
{
	openWindow(path);
	return false;
}

/*
function buyPrint(imageId, printId) {
	var path = contextPath+"/prints/details.do?imageId="+imageId+"&printId="+printId;
	openWindow(path);
	return false;
}
*/

function buyPrint(path)
{
	openWindow(path);
	return false;
}

function openWindow(path,winName,width,height) {
	if (width === undefined) width=570;
	if (height === undefined) height=460;
	if (winName === undefined) winName='buyWin';
	win = window.open(path,winName,'width='+width+',height='+height);	
	win.focus();	

	if (window.screen)
	{
		var leftPos = screen.width/2-200;
		var topPos  = screen.height/2-300;
		win.moveTo(leftPos,topPos);	
	}
}

function basketImagePopup(imageName)
{
	var path=contextPath+"/jsp/basketImagePopup.jsp?imageName="+imageName;
	openWindow(path, 'basketImageWin', 375,375);
}

function disable(element){element.disabled=true;}

function AddressDetails()
{
	this.title='';
	this.forename='';
	this.surname='';
	this.telephone='';
	this.address1='';
	this.address2='';
	this.town='';
	this.county='';
	this.postcode='';
	this.countryId='';
	
	this.getTitle=AddressDetails_getTitle;
	this.getForename=AddressDetails_getForename;
	this.getSurname=AddressDetails_getSurname;
	this.getTelephone=AddressDetails_getTelephone;
	this.getAddress1=AddressDetails_getAddress1;
	this.getAddress2=AddressDetails_getAddress2;
	this.getTown=AddressDetails_getTown;
	this.getCounty=AddressDetails_getCounty;
	this.getPostcode=AddressDetails_getPostcode;
	this.getCountryId=AddressDetails_getCountryId;
}

function AddressDetails_getTitle() { return this.title; }
function AddressDetails_getForename() { return this.forename; }
function AddressDetails_getSurname() { return this.surname; }
function AddressDetails_getTelephone() { return this.telephone; }
function AddressDetails_getAddress1() { return this.address1; }
function AddressDetails_getAddress2() { return this.address2; }
function AddressDetails_getTown() { return this.town; }
function AddressDetails_getCounty() { return this.county; }
function AddressDetails_getPostcode() { return this.postcode; }
function AddressDetails_getCountryId() { return this.countryId; }


function help()
{
	win = window.open(modulePath+'/jsp/help.jsp','helpWin','width=570,height=450,scrollbars=0');	
	win.focus();	

	if (window.screen)
	{
		var leftPos = screen.width/2-200;
		var topPos  = screen.height/2-300;
		win.moveTo(leftPos,topPos);	
	}
	return false;
}

function contactUs()
{
	win = window.open(modulePath+'/jsp/contactUs.jsp','contactWin','width=570,height=450,scrollbars=0');	
	win.focus();	

	if (window.screen)
	{
		var leftPos = screen.width/2-200;
		var topPos  = screen.height/2-300;
		win.moveTo(leftPos,topPos);	
	}
	return false;	
}

function termsAndConditions()
{
	win = window.open(modulePath+'/jsp/termsAndConditions.jsp','contactWin','width=570,height=450,scrollbars=0');	
	win.focus();	

	if (window.screen)
	{
		var leftPos = screen.width/2-200;
		var topPos  = screen.height/2-300;
		win.moveTo(leftPos,topPos);	
	}
	return false;	
}

function hideSplashTexts()
{
	if (!(splashTexts === undefined))
	{
		for (i=0; i< splashTexts.length; i++)
		{
			eval('splashText'+splashTexts[i]+'Obj.hideIt()');
		}
	}
}

var currentCollectionObj;
function collectionClicked(collectionId, imageName)
{//return;
	if (!admin)
	{
		if (imageName != null && imageName != '' && !(collectionId === undefined) && !(imageName === undefined))
		{
			hideSplashTexts();
			loadCollectionImage(imageName);	
			if (!(noResultsObj === undefined))
			{
				noResultsObj.hideIt();
			}
			if (!(imageObj === undefined))
			{
				imageObj.hideIt();
			}
			if (!(pictureObj === undefined))
			{
				pictureObj.hideIt();	
			}
			if (!(contextImageObj === undefined))
			{
				contextImageObj.hideIt();	
			}				
			if (!(frameDetailObj === undefined))
			{
				frameDetailObj.hideIt();
			}
			if (!(textWindowObj === undefined))
			{
				textWindowObj.hideIt();
			}
			if (!(frameTextWindowObj === undefined))
			{
				frameTextWindowObj.hideIt();
			}
			if (!(pictureTextWindowObj === undefined))
			{
				pictureTextWindowObj.hideIt();
			}
			if (!(viewsObj === undefined))
			{
				viewsObj.hideIt();
			}	
			if (!(imageInfoObj === undefined))
			{
				imageInfoObj.hideIt();
			}
			if (!(imageInfoBuyObj === undefined))
			{
				imageInfoBuyObj.hideIt();
			}			
			if (!(pegboardObj === undefined))
			{
				pegboardObj.hideIt();
			}	
			if (!(shopWindowObj === undefined))
			{
				//shopWindowObj.hideIt();
			}				
			if (!(splashImageObj === undefined))
			{
				splashImageObj.hideIt();
			}
			if (!(splashTextObj === undefined))
			{
				splashTextObj.hideIt();
			}					
			if (!(basketObj === undefined))
			{
				basketObj.hideIt();
			}		
			if (!(errorObj === undefined))
			{
				errorObj.hideIt();
			}						
			eval('collectionObj = categoryText'+collectionId+'Obj');
			if (!(currentCollectionObj === undefined))
			{
				currentCollectionObj.hideIt();
			}
			currentCollectionObj = collectionObj;	
			eval('categoryText'+collectionId+'Obj.showIt()');
		}
	}
}

function loadCollectionImage(imageName)
{
	if (typeof collectionImageObj != 'undefined' && !(collectionImageObj === undefined))
	{
		collectionImageObj.writeIt('<table cellpadding="0" cellspacing="0" border="0" width="370" height="370"><tr><td valign="middle" align="center"><img src="'+imageName+'" border="0"/></td></tr></table>');
		collectionImageObj.showIt();
	}
}

// mm.js

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_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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];}
}