<!-- VITAL ONLINE STUDIO LIMITED -->				
<!-- The Tower -->					
<!-- Hornbeam Park -->					
<!-- Harrogate -->					
<!-- North Yorkshire UK	 -->			
<!-- HG2 8QT -->						
<!-- t: ++ (0)1423 855700 -->				
<!-- f: ++ (0)1423 855745 -->				
<!-- e: webmaster@vital.co.uk -->			
<!-- http://www.vital.co.uk -->				

<!-- COPYRIGHT -->				
<!-- Vital Online Studio Limited reserves copyright in all material -->	
<!-- including photographs and artwork appearing on these pages, -->	
<!-- except where an explicit statement to the contrary appears -->	
<!-- on any particular page, or where copyright is retained by -->	
<!-- third parties. -->						
								
<!-- You have the right to view this page and, where applicable, -->	
<!-- to copy this page and any images to a cache for reference by -->	
<!-- yourself only at a later time for your own personal and -->	
<!-- non-commercial use.  No further rights are granted to  -->	
<!-- reproduce or distribute any material appearing on these -->	
<!-- pages. -->							

<!-- TRADEMARKS -->				
<!-- All trademarks mentioned on these pages whether registered -->
<!-- or unregistered are the property of their respective owners -->
<!-- whose rights are acknowledged. -->
// variable init

var currenttab = 'search';
var scrolling = 'on';
var help = 'startup'
var site = ''
var cityid = ''
var distance = ''
var results = new Array()
var number = 0;
var pageend = 7
var allowclicks = 0;

function resize(pic,targetSize,direction) { // handles the proportions of the uploaded thumbs
	if (direction == 0) {
	proportion = pic.height / targetSize
	pic.height = pic.height / proportion
	if (pic.width >= 185) {
	proportion = pic.width / 185
	pic.width = pic.width / proportion
	pic.height = pic.height / proportion
	}
	}
	if (direction == 1) {
	proportion = pic.width / targetSize
	pic.width = pic.width / proportion
	}
}


function alerts(string) {
setTextOfLayer('error','',string)
}

function printimage() {
	if (allowclicks == 0) {
	alerts('Please use the search function above to find desired panels before continuing')
	}
	else {
	window.vista.print()
	}
}

function saveimage() {
	if (allowclicks == 0) {
	alerts('Please use the search function above to find desired panels before continuing')
	}
	else {
	window.vista.capture()
	}
}

function writeresults() {
	setTextOfLayer('numberfound','',found + ' SITES FOUND FOR')
	showHideLayers('helplayer','','hide')
	showHideLayers('vistalayer','','show')

	if (type == 'panel') {
		setTextOfLayer('searchstring','',site +'<br>Click on the text to select<br>')
	}
	if (type == 'city') {
		setTextOfLayer('searchstring','',city+'<br>Click on the text to select<br>')
	}
	if (type == 'distance') {
		setTextOfLayer('searchstring','',distance+'<br>Click on the text to select<br>')
	}
 	setTextOfLayer('Click on an image to select<br>','','')
	setTextOfLayer('res1','','')
	setTextOfLayer('res2','','')
	setTextOfLayer('res3','','')
	setTextOfLayer('res4','','')
	setTextOfLayer('res5','','')
	setTextOfLayer('res6','','')
	setTextOfLayer('res7','','')
	setTextOfLayer('res8','','')

	pageend = (pagestart+7)
	
	if (pageend >= found) {
		pageend = found
	}

	currentresult = 1
	for (var a=pagestart; a < (pageend); a++) {
		if (a < found) {
			var returnit = results[a]
			var rescode = mediaData[returnit][0]
			var resaddress = mediaData[returnit][4]
			var respanel = mediaData[returnit][2]
			var panelcode = mediaData[returnit][1]
			var vistastring = '../scenes/' + rescode + '-' + panelcode + '-' + respanel + '/index.html'
			// turn off the scroller buttons
			if (mediaData[returnit][4] != '48-Sheet Scrollers') {
			change('scrollcontrol', 'noscroll')
			scrVar = false
			}
			// if code is a '96s' (scroller) turn on the scroller buttons
			if (mediaData[returnit][4] == '48-Sheet Scrollers') {
			change('scrollcontrol', 'scrollon')
			scrVar = true
		
			}
			if (type == 'city') {
				setTextOfLayer('res' + currentresult,'','%3Cp onclick=%22parent.launchvista(%27' + rescode + '%27,%27' + vistastring + '%27,%27' + resaddress + '%27);showHideLayers(%27vistalayer%27,%27%27,%27show%27,%27helplayer%27,%27%27,%27hide%27);%22 class=%22clickable%22%3E%3Cstrong%3E%3Cfont color=%22#000000%22%3E' + rescode + '%3C/font%3E%3C/strong%3E%3Cspan class=%22listaddress%22%3E ' + resaddress + '%3C/span%3E%3C/p%3E')
			}
			if (type == 'panel') {
				setTextOfLayer('res' + currentresult,'','%3Cp onclick=%22parent.launchvista(%27' + rescode + '%27,%27' + vistastring + '%27,%27' + resaddress + '%27);showHideLayers(%27vistalayer%27,%27%27,%27show%27,%27helplayer%27,%27%27,%27hide%27);%22 class=%22clickable%22%3E%3Cstrong%3E%3Cfont color=%22#000000%22%3E' + rescode + '%3C/font%3E%3C/strong%3E%3Cspan class=%22listaddress%22%3E ' + resaddress + '%3C/span%3E%3C/p%3E')

			}
			if (type == 'distance') {
				setTextOfLayer('res' + currentresult,'','%3Cp onclick=%22parent.launchvista(%27' + rescode + '%27,%27' + vistastring + '%27,%27' + resaddress + '%27);showHideLayers(%27vistalayer%27,%27%27,%27show%27,%27helplayer%27,%27%27,%27hide%27);%22 class=%22clickable%22%3E%3Cstrong%3E%3Cfont color=%22#000000%22%3E' + rescode + '%3C/font%3E%3C/strong%3E%3Cspan class=%22listaddress%22%3E ' + resaddress + '%3C/span%3E%3C/p%3E')

			}

			

			currentresult += 1
		}
	}
	setTextOfLayer('paging','',(pagestart+1) + '-' + pageend + ' of ' + found)
}

function writeimage() {
	setTextOfLayer('numberfoundimg','',found + ' SITES FOUND FOR')

	if (type == 'panel') {
		setTextOfLayer('searchstringimg','',site +'<br>Click on an image to select<br>')
	}
	if (type == 'city') {
		setTextOfLayer('searchstringimg','',city +'<br>Click on an image to select<br>')
	}
	if (type == 'distance') {
		setTextOfLayer('searchstringimg','',distance +'<br>Click on an image to select<br>')
	}
 
	setTextOfLayer('img1','','')
	setTextOfLayer('img2','','')
	setTextOfLayer('img3','','')
	setTextOfLayer('img4','','')
	setTextOfLayer('img5','','')
	setTextOfLayer('img6','','')
	setTextOfLayer('img7','','')
	setTextOfLayer('img8','','')
	setTextOfLayer('img9','','')
	setTextOfLayer('img10','','')

	pageendimg = (pagestartimg+10)
	
	if (pageendimg >= found) {
		pageendimg = found
	}
	currentresultimg = 1
	
	
	for (var a=pagestartimg; a < (pageendimg); a++) {
		if (a < found) {
			var returnitimg = results[a]
			var rescodeimg = mediaData[returnitimg][0]
			var resaddressimg = mediaData[returnitimg][3]
			var respanelimg = mediaData[returnitimg][2]
			var panelcodeimg = mediaData[returnitimg][1]
			var vistastringimg = '../scenes/' + rescodeimg + '-' + panelcodeimg + '-' + respanelimg + '/index.html'
			var thumbnailstring = rescodeimg + '-' + panelcodeimg + '-' + respanelimg + '.jpg'
			
			
			
			setTextOfLayer('img' + currentresultimg,'','%3Cimg src=%22../images/thumbs/' + thumbnailstring + '%22 alt=%22' + resaddressimg + '%22 name=%22thumb1%22 width=%2290%22 height=%2274%22 hspace=%220%22 class=%22clickable%22 id=%22thumb1%22 onClick=%22parent.launchvista(%27' + rescodeimg + '%27,%27' + vistastringimg + '%27,%27' + resaddressimg + '%27);showHideLayers(%27vistalayer%27,%27%27,%27show%27,%27helplayer%27,%27%27,%27hide%27);%22 onabort=%22swapImage(%27thumb1%27,%27%27,%27../images/blank-thumb.gif%27,0)%22 onerror=%22swapImage(%27thumb1%27,%27%27,%27../images/blank-thumb.gif%27,0)%22%3E')
			
			
			currentresultimg += 1
		}
	}

	setTextOfLayer('pagingimg','',(pagestartimg+1) + '-' + pageendimg + ' of ' + found)
}

function preload() {
for (var a=0; a < (number); a++) {
if (a < number) {
var rescodeimg = mediaData[a][0]
var resaddressimg = mediaData[a][3]
var respanelimg = mediaData[a][2]
var panelcodeimg = mediaData[a][1]
var vistastringimg = '../scenes/' + rescodeimg + '-' + panelcodeimg + '-' + respanelimg + '/index.html'
var thumbnailstring = '../images/thumbs/' + rescodeimg + '-' + panelcodeimg + '-' + respanelimg + '.jpg'

preloadImages(thumbnailstring)
}
}
}

function nextbutton() {
	if (currenttab == 'thumbs') {
	if (pageendimg < found) {
	pagestartimg += 10;
	pagenumimg += 1;
	writeimage()
	}
	}
	if (currenttab == 'list') {
	if (pageend < found) {
	pagestart += 7;
	pagenum += 1;
	writeresults()
	}
	}
}

function backbutton() {
	if (currenttab == 'thumbs') {
	if (pagestartimg > 0) {
	pagestartimg -= 10;
	pagenumimg -= 1;
	writeimage()
	writeresults()
	}
	}
	if (currenttab == 'list') {
	if (pagestart > 0) {
	pagestart -= 7;
	pagenum -= 1;
	writeimage()
	writeresults()
	}
	}
}

function doSearch(){
	var results = new Array()		
	pagestart = 0;
	pageend = 7;
	pagenum = 1;
	pagestartimg = 0;
	pageendimg = 7;
	pagenumimg = 1;
		
	if (document.form.searchby[0].checked) {
		type = 'city';
		city = document.form.cityid.value;
		if (city == 'choose') {
			city = ''
		}
	}
	
	if (document.form.searchby[1].checked) {
		type = 'panel';
		site = document.form.site.value;
	}
	if (document.form.searchby[2].checked) {
		type = 'distance';
		distance = document.form.distance.value;
	}


	if (type == 'panel') {
		if (site == '') {
		alerts ('Please choose a format from the drop down menu above');
		}
		else {
			DoPanelSearch()
		}
	}	
	
	if (type == 'city') {
		if (city == '') {
		alerts ('Please choose a city or district from the drop down menu above');
		}
		else {
		DoCitySearch()
		}
	}		


	if (type == 'distance') {
		if (distance == '') {
		alerts ('Please choose a distance from the drop down menu above');
		}
		else {
		DoDistanceSearch()
		}
	}		
}


function DoPanelSearch() // was site id - changed to panel type (variables untouched for ease)
	{
	found = 0;
	j = 0
	for (var i=0; i<number; i++) {
		if ((mediaData[i][4] == site)) {
			results[j] = i;	
			found++;
			j += 1
			}
		}
		
	if (found == 0) {
	alerts('Sorry, no results were found for the Format you selected')
	allowclicks = 0;
	}	
	else {	
		allowclicks = 1;
		writeimage()
		writeresults()
		swapto('thumbs')
	}
}

function DoDistanceSearch() // new distance search
	{
	found = 0;
	j = 0
	for (var i=0; i<number; i++) {
		if ((mediaData[i][4] == distance)) {
			results[j] = i;	
			found++;
			j += 1
			}
		}
		
	if (found == 0) {
	alerts('Sorry, no results were found for the Distance you selected')
	allowclicks = 0;
	}	
	else {	
		allowclicks = 1;
		writeimage()
		writeresults()
		swapto('thumbs')
	}
}


function DoCitySearch()
	{
	found = 0
	j = 0
	
	if ((city == '01') || (city == '02') || (city == '03') || (city == '04') || (city == '05') || (city == '06') || (city == '07') || (city == '08')) {
		for (var i=0; i<number; i++) {
		
		var district=mediaData[i][0].charAt(0);
		district+=mediaData[i][0].charAt(1);
			if ((district == city)) {
				results[j] = i;	
				found++;
				j += 1
			}
		}
	}	
	else {	
		for (var i=0; i<number; i++) {
			if ((mediaData[i][0] == city)) {
			results[j] = i;	
			found++;
			j += 1
			}
		}	
	}	
		
	if (found == 0) {
	alerts('Sorry, no results were found for the city or district you chose. Please choose again.')
	allowclicks = 0;
	}
	else {	
	allowclicks = 1;
	writeimage()
	writeresults()
	swapto('thumbs')
	}
	}

function reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.pgW=innerWidth; document.pgH=innerHeight; onresize=reloadPage; }}
  else if (innerWidth!=document.pgW || innerHeight!=document.pgH) location.reload();
}
reloadPage(true);

function 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=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

function launchhelp()
	{ // turn help window on / off
	if (help == 'off') {
	showHideLayers('details','','hide','helplayer','','show','vistalayer','','hide');
	document.getElementById('help').src = 'help.htm';
	help = 'on'
	}
	else {
		if(document.getElementById('help').src == 'startup.htm') {
			document.getElementById('help').src = 'help.htm';
		}		
		else {
			showHideLayers('details','','show','helplayer','','hide','vistalayer','','show');
			help = 'off'
		}
	}
	}

function change(id, newClass)
	{ // css swap function
	identity=document.getElementById(id);
	identity.className=newClass;
	}

function uploadcreative(which) {
	if (allowclicks == 0) {
	alerts('Please use the search function above to find desired panels before continuing')
	}
	else {
	slot = which
	showHideLayers('thumbnails','','hide','upload','','show');
	}
	}

function togglescroll() {
	
	if (allowclicks == 0) {
	alerts('Please use the search function above to find desired panels before continuing')
	}
	
	else {
	if ((scrolling == 'on')){
	vista.vmp.StopAnim('scroller_on');
	vista.vmp.TriggerAnim('scroller_off');
	setTextOfLayer('scrollcontrol','','SCROLL ON / %3Cfont color=%22#000000%22%3EOFF%3C/font%3E')
	scrolling = 'off'
	}
	
	else {
	window.vista.vmp.TriggerAnim('scroller_on');
	setTextOfLayer('scrollcontrol','','SCROLL %3Cfont color=%22#000000%22%3EON%3C/font%3E %0D%0A / OFF')
	scrolling = 'on'
	}
	}
}

function launchvista(which, where, why) { // launch the vista and write the panel details
	setTextOfLayer('addresslayer','',why);
	//goToURL('vista',where)
	frames['vista'].location.href = where;
	
	if ((why != 'London - Scrolling 48-Sheet') || (why != 'Glasgow - Scrolling 48-Sheet') || (why != 'Birmingham - Scrolling 48-Sheet') ){
	change('scrollcontrol', 'noscroll')
	scrVar = false
	}
	if ((why == 'London - Scrolling 48-Sheet') || (why == 'Glasgow - Scrolling 48-Sheet') || (why == 'Birmingham - Scrolling 48-Sheet') ){
	change('scrollcontrol', 'scrollon')
	scrVar = true
	}
	if (why == '48-Sheet Scrollers') {
	change('scrollcontrol', 'scrollon')
	scrVar = true
	}
//	togglescroll()
}

function swapinputtype(which)
	{
	if ((which == 'panelid')) {
	showHideLayers('cityidlayer','','hide','panelidlayer','','show')
	}
	if ((which == 'location')) {
	showHideLayers('cityidlayer','','show','panelidlayer','','hide')
	}
	}

function checkradio(which) {
	if ((which == 'panelid')) {
	document.form.searchby[0].checked = false;
	document.form.searchby[1].checked = true;
	document.form.searchby[2].checked = false;
	swapinputtype('panelid')
	}
	if ((which == 'location')) {
	document.form.searchby[0].checked = true;
	document.form.searchby[1].checked = false;
	document.form.searchby[2].checked = false;
	swapinputtype('location')
	}
	if ((which == 'distanceid')) {
	document.form.searchby[0].checked = false;
	document.form.searchby[1].checked = false;
	document.form.searchby[2].checked = true;
	swapinputtype('distanceid')
	}
}

function swapto(which) {
	
	if (allowclicks != 0) {
	
	if ((which == 'search') && (currenttab != 'search')) {
	showHideLayers('searchlayer','','show','thumbslayer','','hide','listlayer','','hide');
	showHideLayers('helplayer','','show');
	showHideLayers('vistalayer','','hide');
	swapImage('tabs','','../images/search_tab.gif',1);
	currenttab = 'search';
	}
	if ((which == 'thumbs') && (currenttab != 'thumbs')) {
	showHideLayers('searchlayer','','hide','thumbslayer','','show','listlayer','','hide');
	showHideLayers('cityidlayer','','hide');
	showHideLayers('helplayer','','show');
	showHideLayers('vistalayer','','hide');
	swapImage('tabs','','../images/thumbnails_tab.gif',1);
	currenttab = 'thumbs';
	}
	if ((which == 'list') && (currenttab != 'list')) {
	showHideLayers('searchlayer','','hide','thumbslayer','','hide','listlayer','','show');
	showHideLayers('helplayer','','show');
	showHideLayers('vistalayer','','hide');
	swapImage('tabs','','../images/list_tab.gif',1);
	currenttab = 'list';
	}

	}
	
	else {
	alerts('Please use the search function above to find desired panels before continuing')
	}

}

function setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

function 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=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function showHideLayers() { //v6.0
  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

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


function swapImgRestore() { //v3.0
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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

function reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.pgW=innerWidth; document.pgH=innerHeight; onresize=reloadPage; }}
  else if (innerWidth!=document.pgW || innerHeight!=document.pgH) location.reload();
}
reloadPage(true);

function goToURL() { //v3.0
  var i, args=goToURL.arguments; document.returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MFXremoveFocus(e){var d=document,a=0,n=d.layers,m=window.sidebar;if((m||n)&&d.forms.length>0){return}
while(a<d.links.length){d.links[a].blur();++a}}document.onmouseup=MFXremoveFocus;

function jc_swapImgRestore(bVar) { //modded from v3.0 swapImgRestore
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) 
     if (document.all){
      x.style.filter='blendTrans(duration=' + bVar + ')'
      x.filters.blendTrans.Apply()      
   }
  x.src=x.oSrc;
     if (document.all){
      x.filters.blendTrans.Play()
 }
}

function jc_switchPics(targetPic,x,picSrc,bVar,y) { // modded from swapImage
  var i,j=0,x,a=jc_switchPics.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; 
	var blendVar = bVar
   if(!x.oSrc) {
   x.oSrc=x.src; 
   }
   if (document.all){
      x.style.filter='blendTrans(duration=' + bVar +')'
      x.filters.blendTrans.Apply()      
   }
  x.src=a[i+2];
   if (document.all){
      x.filters.blendTrans.Play()
 }
 }
 thumbnailframe.location = thumbnailframe.location.href;
}

function jc_interimPic(targetPic,x,picSrc,bVar,y) { // modded from swapImage
	alert(document.images[targetPic].src)
 
    if (document.all){
      document.images[targetPic].style.filter='blendTrans(duration=2)'
      document.images[targetPic].style.filter='blendTrans(duration=fadeDuration)'
      document.images[targetPic].filters.blendTrans.Apply()      
   }
  document.images[targetPic].src = 'blank-thumb.gif'
   if (document.all){
      document.images[targetPic].filters.blendTrans.Play()
   }	
   jc_switchPics(targetPic,x,picSrc,bVar,y)
}
