/* ENABLE SEARCHING */
function sendSearchHelper(searchURL,formId,searchDropDownId) { 
	sendSearchRedirect2('http://www.cnet.com', 'http://www.search.com/redirect', formId, 'target', '2001-1_1-0', '1');
};

function trapSearchKey(e, keyToCheck, enterFunction){
	if (!e) e = window.event;
	if (e.keyCode == keyToCheck){
		enterFunction();
		return false;
	} else {
		return true;
	}
};


/* EXPANDING BIOS */
function showHide(elementid){
	if ($(elementid).style.display == 'none'){
		$(elementid).style.display = '';
	} else {
		$(elementid).style.display = 'none';
	}
}

/* GO TO... DROPDOWN MENU */
/*
Class: Fx.Slide
	The slide effect; slides an element in horizontally or vertically, the contents will fold inside. Extends <Fx.Base>, inherits all its properties.

Note:
	This effect works on any block element, but the element doesnt allow absolute positions. To position the element, put it inside another element (a wrapper div, for instance) and position that instead.

Options:
	mode - set it to vertical or horizontal. Defaults to vertical.
	and all the <Fx.Base> options

Example:
	(start code)
	var mySlider = new Fx.Slide('myElement', {duration: 500});
	mySlider.toggle() //toggle the slider up and down.
	(end)
*/

Fx.Slide = Fx.Base.extend({

	options: {
		mode: 'vertical'
	},

	initialize: function(el, options){
		this.element = $(el);
		this.wrapper = new Element('div', {'styles': $extend(this.element.getStyles('margin'), {'overflow': 'hidden'})}).injectAfter(this.element).adopt(this.element);
		this.element.setStyle('margin', 0);
		this.setOptions(options);
		this.now = [];
		this.parent(this.options);
	},

	setNow: function(){
		for (var i = 0; i < 2; i++) this.now[i] = this.compute(this.from[i], this.to[i]);
	},

	vertical: function(){
		this.margin = 'margin-top';
		this.layout = 'height';
		this.offset = this.element.offsetHeight;
	},

	horizontal: function(){
		this.margin = 'margin-left';
		this.layout = 'width';
		this.offset = this.element.offsetWidth;
	},

	/*
	Property: slideIn
		slides the elements in view horizontally or vertically, depending on the mode parameter or options.mode.
	*/

	slideIn: function(mode){
		this[mode || this.options.mode]();
		return this.start([this.element.getStyle(this.margin).toInt(), this.wrapper.getStyle(this.layout).toInt()], [0, this.offset]);
	},

	/*
	Property: slideOut
		slides the elements out of the view horizontally or vertically, depending on the mode parameter or options.mode.
	*/

	slideOut: function(mode){
		this[mode || this.options.mode]();
		return this.start([this.element.getStyle(this.margin).toInt(), this.wrapper.getStyle(this.layout).toInt()], [-this.offset, 0]);
	},

	/*
	Property: hide
		Hides the element without a transition.
	*/

	hide: function(mode){
		this[mode || this.options.mode]();
		return this.set([-this.offset, 0]);
	},

	/*
	Property: show
		Shows the element without a transition.
	*/

	show: function(mode){
		this[mode || this.options.mode]();
		return this.set([0, this.offset]);
	},

	/*
	Property: toggle
		Slides in or Out the element, depending on its state
	*/

	toggle: function(mode){
		if (this.wrapper.offsetHeight == 0 || this.wrapper.offsetWidth == 0) return this.slideIn(mode);
		return this.slideOut(mode);
	},

	increase: function(){
		this.element.setStyle(this.margin, this.now[0]+this.options.unit);
		this.wrapper.setStyle(this.layout, this.now[1]+this.options.unit);
	}

});

Element.extend({

	slideIn: function(options){
		return new Fx.Slide(this, options).slideIn();
	},

	slideOut: function(options){
		return new Fx.Slide(this, options).slideOut();
	}

});


var GoToSlider = {};
window.addEvent("domready", function() {
	GoToSlider = new Fx.Slide('goToLinks').hide();
	$('goToLinks').setStyle("visibility","visible");
	$('goToMore').addEvent('click',function() {
		GoToSlider.toggle();
	});
	if (window.ie) {
		var lastItem = $E("#goToLinks li.last");
		if (window.ie7) {
			lastItem.addEvent('mouseover', function() {
				this.setStyle("backgroundImage","url(http://img.com.com/i/about/go2menu/goToBackLast_g.png)");
			});
			lastItem.addEvent('mouseout', function() {
				this.setStyle("backgroundImage","url(http://img.com.com/i/about/go2menu/goToBackLast_w.png)");
			});
		} else {
			lastItem.addEvent('mouseover', function() {
				this.setStyle("backgroundImage","url(http://img.com.com/i/about/go2menu/goToBackLast_g.gif)");
			});
			lastItem.addEvent('mouseout', function() {
				this.setStyle("backgroundImage","url(http://img.com.com/i/about/go2menu/goToBackLast_w.gif)");
			});
			$('buttonShell').setStyle("backgroundImage","url(http://img.com.com/i/about/go2menu/goToBack.gif)");
			$ES('#goToLinks li').each(function (anLI) {
				anLI.setStyle("backgroundImage","url(http://img.com.com/i/about/go2menu/goToBackSides.gif)");
			});
			$E('#goToLinks li.last').setStyle("backgroundImage","url(http://img.com.com/i/about/go2menu/goToBackLast_w.gif)");
		}
	}
});

//function to draw out the navugational tabs
function drawAboutTabNavigation(contentID) {
	
	if(contentID == "undefined" || contentID == "" || contentID == null)
		{contentID = '6722448';}
	var about_navID = about_navObj[contentID].nav;	
	for (var i=0;i<5;i++) {
		if (i == about_navID) {
			document.write ('<div class=\"rb_tab_l on_l\"></div><div class=\"rb_tab_r on_r\">' + aboutTabNavigation[i][0] + '</div>');
		} else {
			document.write ('<div class=\"rb_tab_l off_l\"></div><div class=\"rb_tab_r off_r\"><a href=\"' + aboutTabNavigation[i][1] + '?tag=top_nav\">' + aboutTabNavigation[i][0] + '</a></div>');
		}
	}
}
//function to draw out the sub navs of each tab
function drawAboutSubNavigation(contentID) {

	if(contentID == "undefined" || contentID == "" || contentID == null)
		{contentID = '6722448';}
	var about_navID = about_navObj[contentID].nav;
	var about_subNavID = about_navObj[contentID].subnav;
	
	for(var j=0; j < aboutSubNavigation[about_navID].length; j++) {
		if(j == about_subNavID) {
			document.write('<span class=\"current\">' + aboutSubNavigation[about_navID][j][0] + '</span>');
		} else {
			document.write('<a href=\"' + aboutSubNavigation[about_navID][j][1] + '\">' + aboutSubNavigation[about_navID][j][0] + '</a>');
		}
		if( j != ((aboutSubNavigation[about_navID].length) - 1)) {
			document.write('&nbsp;|&nbsp;');
		}
	}
}
//function to draw out the right sub navs
function drawAboutRightNavigation(contentID,pageNum) {

	if(contentID == "undefined" || contentID == "" || contentID == null)
		{contentID = '6722448';}
	if(pageNum == "undefined" || pageNum == "" || pageNum == null)
		{pageNum = '1';}	
	var page_num = pageNum;
	var about_navID = about_navObj[contentID].nav;
	var about_rightNavID = about_navObj[contentID].rightnav;
	
	document.write('<li class=\"cat\">' + aboutRightNavigation[about_rightNavID][0][0] + '</li>');
	
	for(var n=1; n < aboutRightNavigation[about_rightNavID].length; n++) {
		if(aboutRightNavigation[about_rightNavID][n][0] != null && aboutRightNavigation[about_rightNavID][n][0] != "" && aboutRightNavigation[about_rightNavID][n][0] != "undefined"){
			if(n == page_num) {
				document.write('<li class=\"off\">' + aboutRightNavigation[about_rightNavID][n][0] + '</li>');
			} else {
				document.write('<li><a href=\"' + aboutRightNavigation[about_rightNavID][n][1] + '\">' + aboutRightNavigation[about_rightNavID][n][0] + '</a></li>');
			}	
		}
	}
}

