		/* navigation */
		//parts of Peter-Paul Koch's excellent quirksmode
		//rest of a script I found without copyright.
		
		var DDSPEED = 5;
		var DDTIMER = 10;
		
		function ddMenu(id,d){
		  var h = document.getElementById(id + '-ddheader');
		  var c = document.getElementById(id + '-ddcontent');
		  
		  //added by GC - get the header dimensions
		  var hWidth = $j('#' + id + '-ddheader').width();
		  var hHeight = $j('#' + id + '-ddheader').css('height');
		  
		  clearInterval(c.timer);
		  if(d == 1){
			
			clearTimeout(h.timer);
			if(c.maxh && c.maxh <= c.offsetHeight){return}
			else if(!c.maxh){
			  c.style.display = 'block';
			  c.style.height = 'auto';
			  c.maxh = c.offsetHeight;
			  c.style.height = '0px';
			  //added by GC - places menu on header's position
			  c.style.left = findPosX(h) + 'px';
			  c.style.top = findPosY(h) + hHeight + 'px';  
			}
			c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
		  }else{
			h.timer = setTimeout(function(){ddCollapse(c)},50);
			//added by GC - Removes the class
			h.className = ''; 
		  }
		
		}
		
		function ddCollapse(c){
		  c.timer = setInterval(function(){ddSlide(c,-1)},DDTIMER);
		  
		}
		
		function cancelHide(id){
		  var h = document.getElementById(id + '-ddheader');
		  var c = document.getElementById(id + '-ddcontent');
		  //added by GC - Keeps the class active
		  h.className = 'active'; 
		  clearTimeout(h.timer);
		  clearInterval(c.timer);
		  if(c.offsetHeight < c.maxh){
			c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
		  } 
		
		}
		
		function ddSlide(c,d){
		  var currh = c.offsetHeight;
		  var dist;
		  
		  if(d == 1){
			dist = (Math.round((c.maxh - currh) / DDSPEED));
		  }else{
			dist = (Math.round(currh / DDSPEED));
		  }
		  if(dist <= 1 && d == 1){
			dist = 1;
		  }
		  c.style.height = currh + (dist * d) + 'px';
		  c.style.opacity = currh / c.maxh;
		
		  if (currh < 5 && d != 1) {
			c.style.display = 'none';
		  }
		 else {
			c.style.display = 'block';
		  }
		  
		  c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
		  if((currh < 2 && d != 1) || (currh > (c.maxh - 2) && d == 1)){
			clearInterval(c.timer);
		  }
		}
		
		
		//events
		$j(document).ready(function() {
			$j('#quotesLoc1').mouseup( function() { dom.quotesSetCity('Las Vegas, NV');});			
			$j('#quotesLoc2').mouseup( function() { dom.quotesSetCity('New York, NY');});
			$j('#quotesLoc3').mouseup( function() { dom.quotesSetCity('Phoenix, AZ');});
			$j('#quotesLoc3').mouseup( function() { dom.quotesSetCity('Washington, DC');});
			$j('#quotesLoc3').mouseup( function() { dom.quotesSetCity('Los Angeles, CA');});
			$j('#quotesClose').mouseup( function() { dom.quotesClose()}	);
			
			$j("#loader").ajaxError(function() { $j(this).html('Error'); });
			$j("#loader").ajaxStart(function(){ $j(this).html('<img src="/images/loading.gif" border="0" alt="loading..." title="loading..." />'); });		 
			$j("#loader").ajaxComplete(function(){ $j(this).html('');});	
			
		});
		
		//ajax events
			
		
		dom = {  		
			  
			  currPanel : 1,
			  nextPanel : 1,			  
			  panelTimer : null,
			  panelDelay : 6,
			  panelSpeed : 10, 
			  panelButtons : true,
			  panelTotal : 0,
			  blackOut: function(){
				//set blackout div width and height
				var winWidth = document.documentElement.offsetWidth;
				var winHeight = document.documentElement.scrollHeight;
				$j('#blackout').css('display','block');
				$j('#blackout').css('height',winHeight + 'px');
				$j('#blackout').css('width',winWidth + 'px');
			  },
			
			  playVideo: function(){
				if(navigator.userAgent.indexOf('Safari') != -1) {
					$j('#movieSm').hide();
				}				
				this.blackOut();
				$j('#blackout').css('display','block');
				$j('#movie').css('display','block');
				$j('#VideoFlash').get(0).Gotoframe(1);
			  },
			  
			  stopVideo: function() {
				  if($j('#movieSm').length > 0) {
					  if(navigator.appName.indexOf("Microsoft") != -1) {
						$j('#SmVideo').get(0).stopIt();
					  } else {
						document['SmVideo'].stopIt();  
					  }
				  }
			  },
			  
			  //Fade in/out scroller by www.gcwebstudio.com
			  //free for everyone to use
			  fadeIn: function(w,m) {
				  
				   var c;				   
				   var opacity = 0;
				   var timer = 0;
				   var speed = Math.round(500/100);
				   c = $j('#panel-' + w).get(0);
				   if(dom.panelButtons) {
					   b = $j('#panel-button-' + w).get(0);
				   }
				   
				   $j('#panel-' + dom.currPanel).hide();
				   if(dom.panelButtons) {
				       $j('#panel-button-' + dom.currPanel).removeClass('ison');
				   }
				   c.style.opacity = opacity; 
				   c.style.MozOpacity = opacity; 
				   c.style.KhtmlOpacity = opacity; 
				   c.style.filter = "alpha(opacity="+opacity+")"; 
			       $j('#panel-' + w).show();
				   if(dom.panelButtons) {
					   $j('#panel-button-' + w).addClass('ison');
				   }
				  			   
				   for(i=0;i<=100;i++) {
					   setTimeout("dom.showIt("+i+","+w+")",(timer*speed));
					   timer++;
				   }
				  
				  dom.currPanel = w;				  
				  if(m == 1) {
					  clearInterval(dom.panelTimer);
					  dom.initFades();
				  }
				 
			  },
			
			  showIt : function(o,w) {	
			    var c;
				c = $j('#panel-' + w).get(0);
				c.style.opacity = (o / 100); 
				c.style.MozOpacity = (o / 100); 
				c.style.KhtmlOpacity = (o / 100); 
				c.style.filter = "alpha(opacity=" + o + ")"; 
			  },
			  
			  rotateFades: function() {
				var total = dom.panelTotal;
				if(total == 1) { return false; }
				if(dom.nextPanel == total) {
					dom.nextPanel = 1;
				} else {
					dom.nextPanel = dom.currPanel + 1;
				}
				dom.fadeIn(dom.nextPanel,2);
			
			  },
			  
			  initFades: function() {
				  dom.panelTimer = setInterval("dom.rotateFades()",(dom.panelDelay*1000));
			  },
			  
			  
			 // NEWSLETTER
			 registerNewsletter:function() {
					if($j('#form_newsletter').get(0).email.value == '') { alert('Please enter a valid email'); return false;}
					if($j('#form_newsletter').get(0).state.value == '') { alert('Please select a state'); return false;}
					var formVals = $j('#form_newsletter').serialize();
					
					$j.ajax({
						type:"POST",
						url:"/js/ajax/newsletter.php",
						data:"action=newsletter&"+formVals,
						success:function(r) {
							 var output = r || 'Error 1';	
							 alert(output);
							 $j('#form_newsletter').get(0).email.value = '';
						}
					}); 
					
				},
				
				unregisterNewsletter:function() {
					if($j('#form_newsletter').get(0).email.value == '') { alert('Please enter a valid email'); return false;}
					if(!window.confirm('Are you sure you want to opt out of our newsletter?')) { 
						$j('#form_newsletter').get(0).email.value = '';
						return false; 
					}
					var formVals = $j('#form_newsletter').serialize();
					
					$j.ajax({
						type:"POST",
						url:"/js/ajax/newsletter.php",
						data:"action=unsubscribe&"+formVals,
						success:function(r) {
							 var output = r || 'Error 1';	
							 alert(output);
							 $j('#form_newsletter').get(0).email.value = '';
						}
					}); 
				},
				
				/* 4wall.com Quotes 
				 * Author: GC - GC Web Studio. www.gcwebstudio.com
				 * Shoppint cart type quotes (AJAX)
				 */
				inc:0,
				quotesAtStep : 0,
				quotesInterval:null,
				quotesIntervalDone:false,
				quotesGetAvailableWinProps:function() {
					var aw = 0, ah = 0;
					if( typeof( window.innerWidth ) == 'number' ) {
						aw = window.innerWidth;
						ah = window.innerHeight;
					} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
						aw = document.documentElement.clientWidth;
						ah = document.documentElement.clientHeight;
					} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
						aw = document.body.clientWidth;
						ah = document.body.clientHeight;
					}
					return[aw,ah];
				},
				
				quotesBegin:function() {
					
					//start by positioning the first screen
					//get body size
					var aw,ah,ad;
					ad = dom.quotesGetAvailableWinProps();
					aw = ad[0];
					ah = ad[1];
					//get quotes div dimensions
					var quoteDivHeight, quoteDivWidth, quoteDivDimensions;
					quoteDivDimensions = new Array();
					quoteDivDimensions['width'] = $j('#quotes').width();
					quoteDivDimensions['height'] = $j('#quotes').height();
					quoteDivWidth = quoteDivDimensions.width;
					quoteDivHeight = quoteDivDimensions.height;
					
					//get scrolled pos
					var scTop = document.documentElement.scrollTop || document.body.scrollTop || window.pageYOffset;
					var scLeft = document.documentElement.scrollLeft || document.body.scrollLeft || window.pageXOffset;
					scTop = !scTop ? 0 : scTop; //undefined means IE didnt find it, but it will when scrolled
					scLeft = !scLeft ? 0 : scLeft; //same here			
					
					//establish position
					var quoteDivX, quoteDivY;
					quoteDivX = ((aw-quoteDivWidth)/2)+scLeft;
					quoteDivY = ((ah-quoteDivHeight)/2)+scTop;

					dom.blackOut();					
					$j('#quotes').css({left:quoteDivX+'px',top:quoteDivY+'px'});
					$j('#quotes').show();

				},
				
				quotesStep1:function() {					
					$j.post('/index.php', {action:'ajax.quotes',func:'step1'}, function(data) { $j('#quotesContainer').html(data);});					
					
				},
				quotesSetCity:function(city) {
					$j.post('/index.php', {action:'ajax.quotes',func:'step2', theCity:city}, function(data) { $j('#quotesContainer').html(data);});	
					dom.quotesAtStep = 2;
					
					
				},
				quotesSetType:function(type) {
					$j.post('/index.php', {action:'ajax.quotes',func:'step3',quoteType:type}, function(data) { $j('#quotesContainer').html(data);});	
					dom.quotesAtStep = 3;
					
				},
				
				quotesSetBuildType:function(type) {					
					$j('#quotesContainer').html('<img src="/images/loading.gif" border="0" alt="loading..." title="loading..." />');
					dom.quotesInterval = setInterval(function() { dom.quotesExpandWindow(type,'expand') },10);					
				},
				
				quotesRentalsByFilter:function() {
					var cid = $j('#category').val();
					var mid = $j('#manufacturer').val();
					$j.post('/index.php', {action:'ajax.quotes', func:'rentalsByFilter',category:cid,manufacturer:mid}, function(data) { $j('#rentalsEntries').html(data);});
					
				},
				quotesRentalsByFilterUser:function() {
					$j.post('/index.php', {action:'ajax.quotes', func:'rentalsByFilter',user:'sess'}, function(data) { $j('#rentalsEntries').html(data);});
				},
				
				quotesRentalsSetQuantity:function(n,id) {
					$j.post('/index.php', {action:'ajax.quotes', func:'rentalsSetQty',qty:n,rental:id}, function(data) { $j('#quotesLoader').html(data);});
					
				},
				quotesRentalsPrepare:function() {
					
					$j.ajax({
						type:"POST",
						url:"/index.php",
						data:"action=ajax.quotes&func=rentalsPrepare&comments="+$j('#comments').val(),
						success:function(r) {
							if(r <= 0) {
								alert('Error, please select at least one item from our inventory');
								return false;
						    } else {
							   $j('#quotesContainer').html(r);
						    }
						}
					}); 
					
				},
				quotesExpandWindow:function(type,way) {
					var ww, wh, exh = 680, ch = 0, aw, ah, ad;
					ad = dom.quotesGetAvailableWinProps();
					aw = ad[0];
					ah = ad[1];
					//get scrolled pos
					var scTop = document.documentElement.scrollTop || document.body.scrollTop || window.pageYOffset;
					var scLeft = document.documentElement.scrollLeft || document.body.scrollLeft || window.pageXOffset;
					scTop = !scTop ? 0 : scTop; //undefined means IE didnt find it, but it will when scrolled
					scLeft = !scLeft ? 0 : scLeft; //same here	
					var quoteDivX, quoteDivY;
					ww = $j('#quotes').width();
					wh = $j('#quotes').height();
					var nX, nY;
					var speed = Math.round(500/100);
					//start expanding	
					if(wh < exh) {
						dom.inc++;
						nX = ((aw-ww)/2)+scLeft;
						nY = ((ah-(ch+wh))/2)+scTop;
						$j('#quotes').css({left:nX+'px',top:nY+'px'});
						ch = Math.round((exh - wh)/speed);
						$j('#quotes').css({height:(ch+wh+dom.inc)+'px'});	
						$j('#quotesContainer').css({height:(ch+wh+dom.inc)+'px'});						
						
					} else {
						clearInterval(dom.quotesInterval);	
						$j.post('/index.php', {action:'ajax.quotes', func:'step4',buildType:type}, function(data) { $j('#quotesContainer').html(data);});						
						return true;						 
					}			
					
				},
				
				quotesCollapseWindow:function() {
					var ww, wh, exh = 215, ch, aw, ah, ad;
					ad = dom.quotesGetAvailableWinProps();
					aw = ad[0];
					ah = ad[1];
					//get scrolled pos
					var scTop = document.documentElement.scrollTop || document.body.scrollTop || window.pageYOffset;
					var scLeft = document.documentElement.scrollLeft || document.body.scrollLeft || window.pageXOffset;
					scTop = !scTop ? 0 : scTop; //undefined means IE didnt find it, but it will when scrolled
					scLeft = !scLeft ? 0 : scLeft; //same here	
					var quoteDivX, quoteDivY;
					ww = $j('#quotes').width();
					wh = $j('#quotes').height();
					var nX, nY;
					var speed = Math.round(500/100);
					//start expanding	
					if(wh == exh) { clearInterval(dom.quotesInterval);	}
					if(wh > exh) {
						ch = Math.round((wh)/speed);
						$j('#quotes').css({height:wh-ch+'px'});	
						$j('#quotesContainer').css({height:wh-ch+'px'});
						nX = ((aw-ww)/2)+scLeft;
						nY = ((ah-(ch+wh))/2)+scTop;
						$j('#quotes').css({left:nX+'px',top:nY+'px'});
					} else {
						clearInterval(dom.quotesInterval);						
						return true;						 
					}			
					
				},
				
				quotesInit:function() {
					dom.quotesBegin();
					switch(dom.quotesAtStep) {						

						case 2:
						dom.quotesSetCity();
						break;
						
						case 3:
						dom.quotesSetType();
						break;
						
						default:
						dom.quotesStep1();
							
					}
				},
				
				quotesUploadListRefresh:function() {
					$j.post('/index.php', {action:'ajax.quotes', func:'uploadListRefresh'}, function(data) { $j('#uploadedFiles').html(data);});
				},
				
				quotesUploadDeleteFile:function(f) {
					$j.post('/index.php', {action:'ajax.quotes', func:'uploadDeleteFile',file:f}, function(data) { $j('#uploadedFiles').html(data);});					
				},
				
				quotesSubmit:function(type) {
					
					$j.ajax({
						type:"POST",
						url:"/index.php",
						data:"action=ajax.quotes&func=quotesSubmit&type="+type+"&"+$j('#quotesInfoForm').serialize(),
						success:function(r) {
							if(r == 1 || r == true) {		
								$j('#quotesContainer').html('<img src="/images/loading.gif" border="0" alt="loading..." title="loading..." />');
								$j.post('/index.php', {action:'ajax.quotes', func:'quotesThanks'}, function(data) { $j('#quotesContainer').html(data);});	
								dom.quotesInterval = setInterval(function() { dom.quotesCollapseWindow() },10);
								dom.quotesAtStep = 0;							 
						   } else {
						   	   alert(r);
						   }
						}
					});
										
				},
				
				quotesClose:function() {
					$j('#quotes').hide();
					$j('#blackout').hide();	
				}				
			}
			
