
		var page="";
		var opensubnav="";
		
		function getNav( page ) {
		
			if (page) path = page.split("|");
			
			//IF ANOTHER NAV IS ITEM IS OPEN
			if ( opensubnav ) {

				openpath = opensubnav.split("|");

				for ( i=0; i<openpath.length; i++ ) {
					//
					if ( i == 0 && path[0] != openpath[0] ) {
						document.getElementById(openpath[0] + "-parent").className = 'nav navnotselected';
						document.getElementById(openpath[0]).style.display = 'none';
					}
					
					if ( i == 1 ) {
						document.getElementById(openpath[0]+"|"+ openpath[1] + "-parent").className = 'nav navnotselected';
						document.getElementById(openpath[0]+"|"+ openpath[1]).style.display = 'none';
					}
				}
			}
			
			if (page && path.length) {
				for ( i=0; i<path.length; i++ ) {
					
					if ( i == 0 ) {
						document.getElementById(path[0] + "-parent").className = 'nav navselected';
						document.getElementById(path[0]).style.display = 'block';
					}
					
					if ( i == 1 ) {
						document.getElementById(path[0]+"|"+ path[1]).style.display = 'block';
						document.getElementById(path[0]+"|"+ path[1] + "-parent").className = 'nav navselected';
					}
				}
			}
			opensubnav=page;
		}
		
		
		/*
		* Scroll Gallery images
		*/
		function ScrollLeft(image) {
			var sum = 0;
		  	for(var x=0;x<image-1;x++) {
				sum+=imageWidthArray[x]+15;
			}
			
			for (var i=0;i<imageWidths.length;i++) {
				if (i==image-1) {
					document.getElementById('project_images').scrollLeft = sum;	
				}
			}
		}
		
		function ScrollLeftShowroom(image) {
			var sum = 0;
		  	for(var x=0;x<image-1;x++) {
				sum+=imageWidthArray[x]+15;
			}
			
			for (var i=0;i<imageWidths.length;i++) {
				if (i==image-1) {
					document.getElementById('showroom_images').scrollLeft = sum;	
				}
			}
		}
		
		/*
		* Product images
		*/
		function changeImage(image, size) {
			var imageContainer  = document.getElementById('container');
			
			imageContainer.innerHTML = "<img src='/imgs/products/" + image + "' width='"+ size +"'>";
		}
		
		/*
		* Pop ups
		*/
		function popPrintVersion( id ) {
			var w = 620;
			var h = 500;
			var x = screen.width;
			var y = screen.height;
			fromLeft = ((x/2) - (w/2))
			fromTop = ((y/2) - (h/2))
			
			window.open( 'http://www.viaduct.co.uk/popup_print.php?id=' + id , 'print_version', 'left='+ fromLeft +', top='+ fromTop +', width='+ w +', height='+ h +', scrollbars=1,resizable=1,menubar=1,toolbar=0,status=0,location=0,directories=0' );	
		}
		
		function popProductImages( id ) {
			var w = 570;
			var h = 600;
			var x = screen.width;
			var y = screen.height;
			fromLeft = ((x/2) - (w/2))
			fromTop = ((y/2) - (h/2))
			
			window.open( 'http://www.viaduct.co.uk/popup_images.php?id=' + id , 'print_version', 'left='+ fromLeft +', top='+ fromTop +', width='+ w +', height='+ h +', scrollbars=1,resizable=1,menubar=1,toolbar=0,status=0,location=0,directories=0' );	
		}
		
		
		
		function popShowroom( id ) {
			var w = 800;
			var h = 740;
			var x = screen.width;
			var y = screen.height;
			fromLeft = ((x/2) - (w/2))
			fromTop = ((y/2) - (h/2))
			
			if (id) {
				window.open( '/vshowroom.php?id=' + id , 'vshowroom', 'left='+ fromLeft +', top='+ fromTop +', width='+ w +', height='+ h +', scrollbars=0,resizable=0,menubar=0,toolbar=0,status=0,location=0,directories=0' );	
			} else {
				window.open( '/vshowroom.php?mode=showroomhome', 'vshowroom', 'left='+ fromLeft +', top='+ fromTop +', width='+ w +', height='+ h +', scrollbars=0,resizable=0,menubar=0,toolbar=0,status=0,location=0,directories=0' );	
			}
		}
		
		
		
		
		/**
		* Clientside Validation of registration form
		*/
		function validate_register() {
			
			fo = document.forms['register_form'];
			e = new Array();
			if (fo.firstname.value == '' || fo.firstname.value == 'Firstname') e.push('Missing Firstname');
			if (fo.lastname.value == '' || fo.lastname.value == 'Surname') e.push('Missing Surname');
			if (fo.email.value == '' || fo.email.value == 'E-Mail Address') e.push('Missing E-Mail Address');
			if (fo.email.value != fo.email_confirm.value) e.push('E-Mail Addresses do not match');
			//if (fo.password.value == '' || fo.password.value == 'Password') e.push('Missing Password');
			//if (fo.password.value != fo.password_confirm.value) e.push('Passwords do not match');
			
			if(e.length) {
				alert("There were a number of problems with your registration:\n\n" + e.join("\n"));
			} else {
				if (fo.telephone.value=='Telephone (Optional)') fo.telephone.value='';
				if (fo.country.value=='Country (Optional)') fo.country.value='';
				if (fo.profession.value=='Profession (Optional)') fo.profession.value='';
				fo.submit();
			}
			
		}