function buildFooter() {
	document.write(
		"<form>" +
		"<span>Visit other CNET Networks sites:</span>" +
		"<select id=\"cnetMenu\" >" +
		"<option selected value=\"\">Select Site</option>" +
		"<option value=\"http://www.bnet.com\">BNET</option>" +
		"<option value=\"http://www.chow.com\">CHOW</option>" +
		"<option value=\"http://www.cnet.com\">CNET.com</option>" +
		"<option value=\"http://www.cnetchannel.com\">CNET Channel</option>" +
		"<option value=\"http://www.gamespot.com\">GameSpot</option>" +
		"<option value=\"http://www.cnetnetworks.com/advertise/properties/international.html\">International Media</option>" +
		"<option value=\"http://www.mp3.com\">MP3.com</option>" +
		"<option value=\"http://www.mysimon.com\">mySimon</option>" +
		"<option value=\"http://www.search.com\">Search.com</option>" +
		"<option value=\"http://techrepublic.com.com/\">TechRepublic</option>" +
		"<option value=\"http://www.tv.com\">TV.com</option>" +
		"<option value=\"http://www.zdnet.com\">ZDNet</option>" +
		"</select><a href=\"javascript:cnetFooter();\">Go</a>" +
		"</form>"
	);
}

function cnetFooter() {
	var cnetMenu = $('cnetMenu');
	var selIndex = cnetMenu.selectedIndex;
	window.location = cnetMenu.options[selIndex].value;
}

function searchSwitch() {
	var srchForm = $E('form', 'search');
	var searchList = $('searchList');
	var searchIndex = searchList.selectedIndex;
	var hiddenExists = $('newfield');

	function addHidden(contentType) {
		var newfield = document.createElement("input");
		newfield.setAttribute("type","hidden");
		newfield.setAttribute("name","t");
		newfield.setAttribute("value", contentType);
		newfield.setAttribute("id","newfield");
		srchForm.appendChild(newfield);
	}

	function rmHidden() {
		if (hiddenExists) {
			srchForm.removeChild(hiddenExists);
		}
	}

	function changeQuery(queryLetter){
		srchForm.elements[0].name = queryLetter;
	}

switch (searchIndex) {
	case 0: //All of ZDNet
	srchForm.action = "http://search.zdnet.com/index.php";
	changeQuery('q');
	rmHidden();
	if (!hiddenExists) {
		addHidden(0);
	}
	break;

	case 1: //Blogs
	srchForm.action = "http://search.zdnet.com/index.php";
	changeQuery('q');
	if (hiddenExists) {
		hiddenExists.value = 1;
	} else {
		addHidden(1);
	}
	break;
	
	case 2: //News
	srchForm.action = "http://search.zdnet.com/index.php";
	changeQuery('q');
	if (hiddenExists) {
		hiddenExists.value = 7;
	} else {
		addHidden(7);
	}
	break;

	case 3: //Downloads
	srchForm.action = "http://downloads.zdnet.com/search.aspx";
	changeQuery('q');
	rmHidden();
	break;

	case 4: //Reviews
	srchForm.action = "http://reviews-search.zdnet.com/search";
	changeQuery('q');
	rmHidden();
	break;

	case 5: //Whitepapers
	srchForm.action = "http://whitepapers.zdnet.com/search.aspx";
	changeQuery('q');
	rmHidden();
	break;

	case 6:
	srchForm.action = "http://dictionary.zdnet.com/index.php";
	changeQuery('d');
	rmHidden();
	break;
	}

} //searchSwitch

function quickPoll_results(action,theURL,winName,winWidth,winHeight,features) {      
    var w = (screen.width - winWidth)/2;
    var h = (screen.height - winHeight)/2 - 20;
    features = features+',width='+winWidth+',height='+winHeight+',top='+h+',left='+w;
    var poll_ident = self.document.quickPoll.poll_ident.value;
    var template_set = self.document.quickPoll.template_set.value;
    option_id = '';
    for (i=0; i<self.document.quickPoll.option_id.length; i++) {
        if(self.document.quickPoll.option_id[i].checked == true) {
            option_id = self.document.quickPoll.option_id[i].value;
            break;
        }
    }
    option_id = (option_id != '') ? '&option_id='+option_id : '';
    if (action=='results' || (option_id != '' && action=='vote')) {
        theURL = theURL+'?action='+action+'&poll_ident='+poll_ident+option_id+'&template_set='+template_set;
        poll_popup = window.open(theURL,winName,features);
        poll_popup.focus();
          
    }
     return false;
} //quickPoll


function getrelatedContent() {
	try {
		var assets = relassets();
		var impressions = relimpressions();
		if (assets.length > 0) {
			document.writeln('<h2>People who read this, also read...</h2>');
			document.writeln('<ul class="relatedContent">');
			for (var i = 0; i < assets.length; i++) {
				document.writeln('<li><a href="' + assets[i].url + '">' + assets[i].title + '</a></li>');  			 		
  			 }
			document.writeln('</ul>');
		}
		if (impressions.length > 0) {
			for (var i = 0; i < impressions.length; i++) {
  			 	document.writeln( impressions[i] );
  			 }	
		}			
	} catch(ex) { }
}

function selector() {
	var selector = $$('div.selector li');
	var selectBox = $$('div.selectBox');
	var name = selector[0].getText().replace(/[ \t]/g, "");
	var tab = Cookie.get(name);
	
	if (tab) {
		selectBox.each(function(el2, i2){
			selectBox[i2].removeClass('on');selectBox[tab].addClass('on');
		});
	}
	
	selector.each(function(el1, i1){ 
		if (tab) {
			selector[i1].removeClass('on');
			selector[tab].addClass('on');
		}	
		
		el1.addEvent('click', function(e){	
			e = new Event(e).stop();				
			selectBox.each(function(el2, i2){ 
				if (i1 == i2) {
					selector[i2].addClass('on');
					selectBox[i2].addClass('on');
					Cookie.set(name, i1, {duration: 15});
				} else {
					selector[i2].removeClass('on');
					selectBox[i2].removeClass('on');
				}
			});		
		});
	})
} //selector

function popular() {
	var popTab = $('tpop');
	var popBox = $('popular');
	var popFix = new Element('iframe', {'id': 'popFix'});
	
	function popRmv() {
		popBox.removeClass('drill');
		popFix.removeClass('drill');
		popTab.removeClass('on');
	}
	
	function popAdd() {
		popBox.addClass('drill');
		popFix.addClass('drill');
		popTab.addClass('on');
	}
	
	popFix.injectAfter(popBox);	
	popTab.addEvent('click', function(e) { e = new Event(e).stop(); });
	popTab.addEvent('mouseenter', function() { popAdd(); });
	popTab.addEvent('mouseleave', function() { popRmv(); });
	popBox.addEvent('mouseenter', function() { popAdd(); });
	popBox.addEvent('mouseleave', function() { popRmv(); });
} //popular

function toolbar() {
	if ($$('.email')) {
		var email = $$('li.email a');
		email.each(function(el){ 
			el.addEvent('click', function(e){
				e = new Event(e).stop();				
				location.href='mailto:?subject='+encodeURIComponent(document.title)+'&body='+encodeURIComponent(location.href); 
			});
		})
	}
	
	if ($$('.print')) {
		var print = $$('li.print a'); 
		print.each(function(el){ 
			el.addEvent('click', function(e){
				e = new Event(e).stop();				
				window.print (); 
			});
		})
	}
	
	if ($$('.pops')) {
		var pops = $$('li.pops');
		pops.each(function(el, i){ 
			el.addEvent('mouseenter', function(e){ pops[i].addClass('drill'); });
			el.addEvent('mouseleave', function(e){ pops[i].removeClass('drill'); });
		})
	}
	
	if ($('embed')) {
		var link = $$('#embed a');
		var cont = $('embed');
		link.addEvent('click', function(e){ 
			e = new Event(e).stop();
			cont.toggleClass('drill');
		});
	}
} //toolbar

function vidChanger() {
	var cont = $$('#vidChanger li');
	var thumb = $$('#vidChanger span a');

	thumb.each(function(el1, i1){ 
		el1.addEvent('mouseenter', function(){	
			cont.each(function(el2, i2){ 
				if (i1 == i2) {
					cont[i2].addClass('on');
				} else {
					cont[i2].removeClass('on');
				}
			});		
		});
	})
} //vidChanger

window.addEvent('domready', function() {		
	if ($$('.selector') && $$('.selector') != "") selector();
	if ($$('.toolbar') && $$('.toolbar') != "") toolbar();
	if ($('vidChanger')) vidChanger();
})

