
function loadVowFavsNG( baseURLPath )
{
	var s = document.getElementById( 'vowToolbarNG_Favs' );
	if( s && s.value ) {
		document.cookie = "vowtoolbar=" + escape("fav=" + s.value) + "; path=/";
		window.location = baseURLPath + 'VowCategory.form?c=' + escape(s.value);
	}
	else {
		alert( "Please select a category first" );
	}
}

function loadVowSavedSearchNG( baseURLPath )
{
	var s = document.getElementById( 'vowToolbarNG_SavedSearches' );
	if( s && s.value ) {
		document.cookie = "vowtoolbar=" + escape("search=" + s.value) + "; path=/";
		window.location = baseURLPath + s.value + '.vowsearch?load=true';
		
	}
	else {
		alert( "Please select a search first" );
	}
}

function runVowSavedSearchNG( baseURLPath )
{
	var s = document.getElementById( 'vowToolbarNG_SavedSearches' );
	if( s && s.value ) {
		document.cookie = "vowtoolbar=" + escape("search=" + s.value) + "; path=/";
		window.location = baseURLPath + s.value + '.vowsearch';
	}
	else {
		alert( "Please select a search first" );
	}
}

function selectVowSavedSearchNG( searchId )
{
	if( !searchId ) {
		var s = document.getElementById( 'vowToolbarNG_SavedSearches' );
		if( s && s.value ) {
			searchId = s.value;
		}
		// no drop-down version
		// setting the cookie changes state
		document.cookie = "vowtoolbar=" + escape("search=" + searchId) + "; path=/";
	}
	
	if( searchId ) {
		call_vowtoolbar_comp( { 'vow.editsearch' : searchId }, 'VowToolbarNG' );
	}
	else {
		alert( "Please select a search first" );
	}
}

function updateVowSavedSearchNG( searchId )
{
	var name = document.getElementById( "vowToolbarNG_searchNameEditable" ).value;
	var enabled = document.getElementById( "vowToolbarNG_searchEnabledEditable" ).checked;
	call_vowtoolbar_comp( {
		"vow.savesearch" : searchId,
		"vow.searchName" : name,
		"vow.searchEnabled" : (enabled ? "true" : "false" )
	}, 'VowToolbarNG' );
}

function deleteVowSavedSearchNG( searchId )
{
	if( !searchId ) {
		var s = document.getElementById( 'vowToolbarNG_SavedSearches' );
		if( s && s.value ) {
			searchId = s.value;
		}
	}
	if( searchId ) {
		if( !confirm( "Are you sure you want to delete this search?" ) ) {
			return;
		}
		call_vowtoolbar_comp( { 'vow.deletesearch' : searchId }, 'VowToolbarNG' );
	}
	else {
		alert( "Please select a search first" );
	}
}

function changeVowPasswordNG()
{
	var p = document.getElementById( "vowToolbarNG_pass" );
	var cp = document.getElementById( "vowToolbarNG_passconfirm" );
	if( !p || !cp ) {
		return;
	}
	if( p.value != cp.value ) {
		alert( "The passwords don't match, please re-type" );
		return;
	}
	if( p.value == '' ) {
		alert( "Password cannot be empty" );
		return;
	}
	if( p.value.length < 4 ) {
		alert( "The password is too short" );
		return;
	}
	call_vowtoolbar_comp( { 'vow.changepass' : p.value }, 'VowToolbarNG' );
}


