// JavaScript Document

function management_login(){
	
	var username = document.login.username.value;
	var password = document.login.password.value;
	
	if(username == "" || password == ""){
		alert("Please enter the Username and Password.");
		return;
	}
	
	document.login.submit();
}

function search_products(){
	window.location.href='/search.php?keywords='+$('#keywords').val();
}


function submitReview(){
	$('#which_action').val('add_review');
	$('#product_form').submit();
}



function getURL(url){
	window.location.href=url;
}

function goto(url){
	window.location.href=url;
}

function record_rating(rating){
	$('#product_rating').val(rating);
	$('#which_action').val('record_rating');
	$('#product_form').submit();
}

function validate(o,error_div){
	var bad = 0;
	$(error_div).hide('fast');
	for(i = 0; i < o.length; i++){
		$(o[i]).removeClass('error_field');
	}
	for(i = 0; i < o.length; i++){
		if($(o[i]).val() == ""){bad = 1;$(o[i]).addClass('error_field')}
	}
	
	if(bad == 1){
		$(error_div).show('fast');
		return false;
	}
	
	return true;
}	


$(function() {
	//new BasketAdaptor().LoadBasket();
	
	$('#keywords').keydown(function(event){
			if(event.keyCode == 13){
				search_products();
			}	
		}
	);
	
	
	$('#password-clear').show();
	$('#header_password').hide();
	
	$('#password-clear').focus(function() {
		$('#password-clear').hide();
		$('#header_password').show();
		$('#header_password').focus();
	});
	$('#header_password').blur(function() {
		if($('#header_password').val() == '') {
			$('#password-clear').show();
			$('#header_password').hide();
		}
	});	
});

