function selectorJump(jumpURL,id) {
	this.location.href=jumpURL + document.getElementById(id).options[document.getElementById(id).selectedIndex].value;
}

// Open/close toggle for a div with the passed id
function openclose(id) {
	if (document.getElementById(id).style.display=="none") {
  	document.getElementById("img"+id).src="/img/minus.gif";
  	document.getElementById(id).style.display="block";
	} else {
  	document.getElementById("img"+id).src="/img/plus.gif";
  	document.getElementById(id).style.display="none";
	}
}

// for the about page
function quovad() {
	if (document.getElementById('qv-text').style.display=="none") {
		document.getElementById('ex-text').style.display="none";
		document.getElementById('ex-logo').style.display="none";
		document.getElementById('qv-text').style.display="block";
		document.getElementById('qv-logo').style.display="block";
	} else {
		document.getElementById('qv-logo').style.display="block";
		document.getElementById('ex-logo').style.display="block";
		document.getElementById('qv-text').style.display="none";		
	}
}

function exacomp() {
	if (document.getElementById('ex-text').style.display=="none") {
		document.getElementById('qv-text').style.display="none";
		document.getElementById('qv-logo').style.display="none";
		document.getElementById('ex-text').style.display="block";
		document.getElementById('ex-logo').style.display="block";
	} else {
		document.getElementById('ex-logo').style.display="block";
		document.getElementById('qv-logo').style.display="block";
		document.getElementById('ex-text').style.display="none";		
	}
}
	
// for the perfect search

function perfect(parent,who) {

	// remove all classes from all elements in this row
	$("#"+parent+" img").removeClass("selected");

	// add class=selected to the item just clicked on
	$("#"+parent+" #"+who).addClass("selected");
	
	// add the right value to the hidden input field
	$("#data"+parent).val(who);
	
}

// for Quo Vadis Advantages

$(document).ready(function(){
	$(".advantages-box h3").click(function () { 
		myID = jQuery(this).parent().attr('id');
		if ($("#"+myID+" .intro").is(':visible')) {
			$("#"+myID+" .intro").hide();
			$("#"+myID+" .more").show();
		} else {
			$("#"+myID+" .intro").show();
			$("#"+myID+" .more").hide();		
		}
	});
	$(".advantages-box .closebox").click(function () { 
		$("#"+myID+" .intro").show();
		$("#"+myID+" .more").hide();
	});
});

// for Catalog Home 2009

$(document).ready(function(){
	$(".cat_home_item .fakelink").click(function () { 
		myID = jQuery(this).parent().attr('id');
		if ($("#"+myID+" .fulllist").is(':visible')) {
			$("#"+myID+" .fulllist").slideUp();
			$("#"+myID+" .fakelink .action").html('List');
		} else {
			$("#"+myID+" .fulllist").slideDown();
			$("#"+myID+" .fakelink .action").html('Close list of');
		}
	});
});

// for local search

function localsearch() {
	zip = document.getElementById('RetailerZip').value;
	if (zip.length < 1) zip = 'null';
	state = document.getElementById('RetailerState').value;
	if (state.length < 1) state = 'null';
	this.location.href='/buy/local2/'+state+'/'+zip;
	return false;
}

// rounded corners on homepage
jQuery(function(){
	jQuery('#homepage #fourthrow a').corner();
	$('.colorbox').colorbox();
	$('.cbox_inline').colorbox({inline: true});
});

// for customization wizard

$(document).ready(function(){
	$('#tabs').tabs();
//	$('#tabs').tabs("select", 2);

	$('.page-wizard #sendrequest').submit(function() {
		str = '';
		$('.required').each(function() {
			if ($(this).find('input').val()=='' || $(this).find('select').val()=='Please select...')
				str += ' - ' + $(this).find('label').text() + '\n';
		});
		if (str != '') {
			alert('You left these required fields blank:\n\n'+str+'\nPlease fill them out and try again.');
			return false;
		} else {
			return true;		
		}
	});

	watchThumbs();

});

function watchThumbs() {
	$('.miniview').colorbox({width: '600', height: '650'});

	$(".page-wizard .thumblist img").click(function () { 

		// highlight chosen item
		var theULID = $(this).parent().parent().parent().attr('id');
		$('#'+theULID+' li').removeClass('chosen');
		$(this).parent().parent().addClass('chosen');

		// place chosen information into final tab
		var info = $(this).parent().parent().html();
		if (theULID=='coversul') {
			$('#chosencover').html(info);
			$('#Chosen_Cover').val($(this).attr('title'));
			
			jQuery.ajax({
				type: "get",
				url: "/wizard/ajax_get_planners/"+$(this).attr('title'),
				context: document.body,
				success: function(html) {
					$("#plannersul").html(html);    // load in available planners
					$('#chosenplanner').html('<div class="itemimage"></div><i>Nothing yet</i>'); // clear out any formerly chosen planner
					$('#Chosen_Planner').val('');
					watchThumbs();
				}
			});
			$('#tabs').tabs("select", 1);
		}
		else if (theULID=='plannersul') {
			$('#chosenplanner').html(info);
			$('#Chosen_Planner').val($(this).attr('title'));
			$('#tabs').tabs("select", 2);
		}
	});
}
