﻿var active_color = '#000000'; // Colour of the user provided text
var inactive_color = '#959598'; // Colour of the default text

$(document).ready(function() {
	$("input.SearchText").css("color", inactive_color);
	var default_values = new Array();
	$("input.SearchText").focus(function() {
		if (!default_values[this.id]) {
			default_values[this.id] = this.value;
		}
		if (this.value == default_values[this.id]) {
			this.value = '';
			this.style.color = active_color;
		}
		$(this).blur(function() {
			if (this.value == '') {
				this.style.color = inactive_color;
				this.value = default_values[this.id];
			}
		});
    });

	$("#txtISBNSearch").keypress(function(e) {
	    if (e.which == 13 && jQuery("#txtISBNSearch").valid()) SearchByISBN();
	});
	$("#txtInstructorSearch").keypress(function(e) {
	    if (e.which == 13 && jQuery("#txtInstructorSearch").valid()) SearchByMaster();
	});
	$(".lnkCategory").click(function(event) {
		window.location.hash = this.hash;
	});
});

function SearchByISBN() {
var text = jQuery.trim($("#txtISBNSearch").val());
	if (text.length > 0 && ($("#txtISBNSearch").css('color') != 'rgb(149, 149, 152)' && $("#txtISBNSearch").css('color') != inactive_color))
		window.location = ('/Search.aspx?sType=1&sQuery=' + $("#txtISBNSearch").val());
}
function SearchByMaster() {
var text = jQuery.trim($("#txtInstructorSearch").val());
	if (text.length > 0 && ($("#txtInstructorSearch").css('color') != 'rgb(149, 149, 152)' && $("#txtInstructorSearch").css('color') != inactive_color))
		window.location = ('/Search.aspx?sType=2&sQuery=' + $("#txtInstructorSearch").val());
}



