	var current_tab = 'solutions';
	var solutions_default = 'receivers';
	var products_default = '2700';
	var fx_speed = 180;
	var slider_interval = 30; //in seconds
	var slider_timer;
	var panel_max = 4;
	var panel_w = 966;
	var products = new Object();
	var solutions = new Object();
	var data_array;
	
	function init_content_data() {
		
		var base_url = "";
		
		var request_url = base_url+"/ajax_json_solutions.html";
		
		new Request.JSON({
			url: request_url, 
			method: "get",
			onComplete: function(obj) {
				
				// loop through products
				//
				for ( var c in obj ) {
        			
        			var solution = obj[c];
						
					if(solution != undefined) {
					
						solutions[solution.code] = new Object();
						solutions[solution.code].name = solution.title;
						solutions[solution.code].body = solution.tagline;
						solutions[solution.code].img;
						// preload images
						//
						for ( var x in solution.images ) {
							
							if(solution.images[x].w == 163 && solution.images[x].h == 104) {
								
								solutions[solution.code].img = new Image();
								solutions[solution.code].img.src = solution.images[x].path;
								break;
							}
						}
					
					}
				}
				
				
				// load in the first product by default
				//
				init_content_default(solutions_default);
			}
		}).send({'type': 'solutions','context': 'hp_block2'});
		
		request_url = base_url+"/ajax_json_products.html";
		
		new Request.JSON({
			url: request_url, 
			method: "get",
			onComplete: function(obj) {
				
				// loop through products
				//
				for ( var c in obj ) {
        			
        			var product = obj[c];
						
					if(product != undefined) {
					
						products[product.code] = new Object();
						products[product.code].name = product.title;
						products[product.code].body = product.tagline;
						products[product.code].img;
						// preload images
						//
						for ( var x in product.images ) {
							
							if(product.images[x].w == 163 && product.images[x].h == 64) {
								
								products[product.code].img = new Image();
								products[product.code].img.src = product.images[x].path;
								break;
							}
						}
					
					}
				}
				
				// load in the first product by default
				//
				//init_content_default(products_default);
			}
		}).send({'type': 'products','context': 'hp_block2'});
		
		
		
	
	}
	
	function do_tab(type) {
		
		switch(type) {
								
			case 'solutions':
				
				$('tab_solutions').removeClass('off');
				$('tab_products').addClass('off');
				$('preview_'+current_tab).set('opacity',0);
				
				current_tab = 'solutions';
				$('tab_container_solutions').setStyles({ display: 'block' });
				$('tab_container_products').setStyles({ display: 'none' });
				init_content_default(solutions_default);
				break;
			
			case 'products':
				
				$('tab_products').removeClass('off');
				$('tab_solutions').addClass('off');
				$('preview_'+current_tab).set('opacity',0);
				
				current_tab = 'products';
				$('tab_container_products').setStyles({ display: 'block' });
				$('tab_container_solutions').setStyles({ display: 'none' });
				init_content_default(products_default);
				
				break;
		}
	}
	
	function init_href_listeners() {
		
		/**
		* bullet lists
		*/
			$$('.c2 .wrap .mid div ul li a').each(function(el) {
                          /*
				el.addEvent('click', function(){
					if(el.id != "") {
						do_preview(el.id,false);
						return false;
					}
				});
                                */
				el.addEvent('mouseover', function(){
					if(el.id != "") {
						do_preview(el.id,false);
						return false;
					}
				});
			});
		
		/**
		* tabs
		*/
			$('tab_products').addEvent('click',function(el) {
				do_tab('products');
				return false;
			});
			$('tab_solutions').addEvent('click',function(el) {
				do_tab('solutions');
				return false;
			});
			
		/**
		* main image slider nav
		*/
			$$('.home .c1 p a').each(function(el) {
				
				el.addEvent('click', function(){
					
					/*
					if($defined(slider_timer)) {
						slider_timer = $clear(slider_timer);
						slider_timer.periodical(slider_interval*1000);
					}
					*/

					if(this.hasClass("prev"))
						slider(this,'prev');
					else if(this.hasClass("next"))
						slider(this,'next');
					else {
						pos = parseFloat(this.getProperty('class').replace(/n/,""));
						slider(this,pos);
					}
					return false;
				});
					
			});
	}
	
	function do_preview(item_code,init) {
		$$('.c2 .wrap .mid div ul li a').each(function(el) {
			el.removeClass('red');
		});
		
		$(item_code).addClass('red');
		
		$$('.'+current_tab+'_preview_link').each(function(el) {
			el.setProperty('href','/'+current_tab+'/'+item_code);
		});
		
		data_array = current_tab == 'products' ? products : solutions;
		
		$('preview_'+current_tab).set('tween', {
			duration: fx_speed,
			onComplete: function(e) {
					$(e.id).set('tween', { onComplete: Class.empty });
					
					if($(current_tab+'_preview_img'))
						$(current_tab+'_preview_img').setProperties({ src: data_array[item_code].img.src, alt: data_array[item_code].name });
					
					if($(current_tab+'_preview_name'))
						$(current_tab+'_preview_name').set('text',data_array[item_code].name);
					
					if($(current_tab+'_preview_body'))
						$(current_tab+'_preview_body').set('html',"<span><\/span>"+data_array[item_code].body);
					
					$(e.id).tween('opacity', 1);
				}
			}
		);
		
		$('preview_'+current_tab).tween('opacity', '0');
	}
	
	function init_content_default(item_code) {
		
		do_preview(item_code,true);
	}
	
	var panel=1;
	
	function slider(obj,pos) {
		
		// setup next panel value and make sure it
		// stays within our range of 1 - panel_max
		//
		if(pos > 0)
			panel = pos;
		else if(pos == "prev")
			panel--;
		else
			panel++;
		
		if(panel>panel_max)
			panel = 1;
		else if(panel < 1)
			panel = panel_max;
			
		
		// Update the passed obj to be accurate in case
		// we clicked an arrow which is really reference 
		// the next or prev obj, not the arrow itself
		//
		$$('.n'+panel).each(function(el) { obj = el; },obj);
			
		// debugging
		//
		$$('search').value = panel;
		
		// the next spot to move our slider panel to
		//
		var position = (((panel-1) * panel_w) * -1);
		
		// since we don't have an ID, we are using $$ to
		// target an element
		//
		$$('.home .c1 .slider').each(function(el) {
			
			el.set('tween', {
				duration: (fx_speed*3.5),
				onComplete: function(e) {
						this.set('tween', { onComplete: Class.empty });

						$$('.home .c1 p a').each(function(el) {
							
							if(!el.hasClass("next") && !el.hasClass("prev")) {
								
								if(el == obj)
									el.addClass("on");
								else
									el.removeClass("on");
							}
						
						});
					}
				}
			);
			
			el.tween('left', position+'px');
		});
	}
	
	slider_timer = function() { 
	
		slider(false,'next'); 
		
	}
	
	
	window.addEvent('domready', function() {
    	
    	$('preview_'+current_tab).set('opacity',0);
    	slider_timer.periodical(slider_interval*1000);
    	
    	init_content_data();
    	init_href_listeners();
    	
   });