
$(document).ready(function(){
	var bodyTagId = document.getElementsByTagName('body').item(0).id;
	$("#menu-wrap ul").children("li").children("a").each(function() {   
		//alert($(this).width() + ' --');
		if($(this).width() < 50 && bodyTagId != 'lang_en'){
			$(this).width(50);
		}
	}); 
});

function selectWithin(){
 
 selectList = document.getElementById('selectWithin');
 selectedIndex = selectList['selectedIndex'];
 selected = selectList['options'][selectedIndex].value;
 
 if(selected == 'nothing'){
	//uncheck all the boxes but don't go anywhere
	var catTagForm = document.getElementById('categoryTagSelector');
	var tagChecks = catTagForm.getElementsByTagName('input');
	for (i=0; i<tagChecks.length; i++) {
		tagChecks[i].checked = false;
	}
 }
 else if(selected == 'custom'){
	// this is a dud checklist item that does nothing.
 }
 else{
	window.location.href=selected;
 }

}






// this function gets triggered whenever we click on a checkbox.
// it gathers all the currently checked items, and builds a url from them.
function goSomewhere(urlString){
	//find the form 
	var catTagForm = document.getElementById('categoryTagSelector');
	// get all the checkboxes
	var tagChecks = catTagForm.getElementsByTagName('input');
	// make a place to store the selected ones.
	var theTags =new Array();
	
	for (i=0; i<tagChecks.length; i++) {
		
		if (tagChecks[i].checked==true){
			theTags.push(tagChecks[i].name);
		}
	}
	window.location = urlString + theTags.join(',');
}

function goPopular(urlString){
	//find the form 
	var catTagForm = document.getElementById('categoryTagSelector');
	// get all the checkboxes
	var tagChecks = catTagForm.getElementsByTagName('input');
	// make a place to store the selected ones.
	var theTags =new Array();
	// for each div
	//tagChecks.length
	for (i=0; i<5; i++) {
		alert(tagChecks[i].className);
		if (tagChecks[i].className == 'popular'){
			tagChecks[i].checked = true;
			theTags.push(tagChecks[i].name);
		}
	}
	window.location = urlString + theTags.join(',');
}


function toggleHelpBox() {
	theBox = document.getElementById('helpBox');
	theButton = document.getElementById('helpBoxButton');
	if (theBox.style.display == 'none'){
		theBox.style.display = 'block';
		theButton.style.background = "url('/wp-content/themes/delegation/images/help-active.png') no-repeat center right";
	}
	else{
		theBox.style.display = 'none';
		theButton.style.background = "url('/wp-content/themes/delegation/images/help.png') no-repeat center right";
	}
}

