function tab(n) {	$('#featureTabsContainer .tab').removeClass('tab_selected');	$($('#featureTabsContainer .tab')[n]).addClass('tab_selected');	$('#featureElementsContainer .feature').hide();	$($('#featureElementsContainer .feature')[n]).show();}function newWindow(url) {	$('#opt').attr('value','');	if (url != '') {window.open(url);}}function editBook(url) {$.facebox({ajax:url});}function manageBook(v) {	var redirectArray = v.split("|");	var type = redirectArray[0];	var url = redirectArray[1];	if (type == 'switch') {			var bookInfo = url.split("&");			var bookUniq = bookInfo[0];			var bookActive = bookInfo[1];			$.post('edit_book.php', {				action: 'switch',				book_uniq_id: bookUniq,				active: bookActive			},			function(data) {				if (data == 'sent') {					if (bookActive == '0') {var status = 'Listed';var bookActiveNew = '1';var statusNew = 'Do Not List';}					if (bookActive == '1') {var status = 'Not Listed';var bookActiveNew = '0';var statusNew = 'List';}					var status_id = '#status_'+bookUniq;					var action_id = '#action_'+bookUniq;					var switch_id = '#switch_'+bookUniq;					$(action_id).attr("value","");					$(switch_id).attr("value","switch|"+bookUniq+"&"+bookActiveNew);					$(switch_id).text(statusNew);					$(status_id).hide();					$(status_id).html(status);					$(status_id).show();					$(status_id).animate({color: '#ba5a21',fontSize: '13px'}, 200).animate({fontSize: '11px'}, 200).animate({color: '#000000',fontSize: '11px'}, 4800);				}					if (data == 'fail') {					$.facebox("<div style='width:350px'><span><img src='images/status_head.png' border='0' /></span><hr size='2' color='000000' width='100%' align='left'><div id='success_p' style='width:350px;padding:10px 0px 10px 0px;'><span style='font-size:8pt;display:block;' class='fail'>The status of your book could not be changed. Please try again.</span></div></div>");					setTimeout(function() {$.facebox.close();},3000);				}			}			);	} else if (type == 'edit') {		var bookInfo = url.split("&");		var bookId = bookInfo[0];		var bookUniq = bookInfo[1];		var editUrl = 'edit_book.php?book=' + bookId + '|' + bookUniq;		editBook(editUrl);	}}
function show_isbn() {
	$('#isbn').html('ISBN:&nbsp;<input type="text" style="font-size:12px;" name="isbnField" id="isbnField" class="drop" /><br><input type="checkbox" onClick="showCustom()" />&nbsp;This is a custom material');
	$('#step1').attr('disabled','');
}
function IsNumeric(input) {	return (input - 0) == input && input.length > 0;}
function valAddBasket() {var cond = $('#cond').val();var price = $('#price').val();
if (cond == '' || price == '' || !IsNumeric(price) || price == '0') {
	if (cond == '' || price == '') {
		alert("All fields are required.");		return false;
	}
	if (!IsNumeric(price) && price != '') {
		alert("You must enter a numeric price value. No symbols.");		return false;
	}
	if (price == '0') {
		alert("You must enter a price value greater than 0.");		return false;
	}	return false;
} 
}

function valAddBasketCustom() {
var cond = $('#custCond').val();
var price = $('#custPrice').val();
if (cond == '' || price == '' || !IsNumeric(price) || price == '0') {
	if (cond == '' || price == '') {
		alert("All fields are required.");		return false;
	}
	if (!IsNumeric(price) && price != '') {
		alert("You must enter a numeric price value. No symbols.");		return false;
	}
	if (price == '0') {
		alert("You must enter a price value greater than 0.");		return false;
	}	return false;
} 
}

function mess() {	var message = $('#message').val();		if (message == '') {		alert("Please enter your message.");		return false;	} else {		document.send.submit();	}		return false;
}

function showDetails(bookUniqId) {
	window.open("details.php?book_uniq="+bookUniqId, 'details', 'resizable=no,menubar=no,toolbar=no,directories=no,status=no,scrollbars=yes,location=no,width=350,height=450');
}

function togCriteria(criteriaId) {
	var c = document.getElementById(criteriaId);
	if (criteriaId == 'class_cri') {
		var imgId = 'class_arrow';
	}
	if (criteriaId == 'ISBN_cri') {
		var imgId = 'ISBN_arrow';
		var fieldId = 'search_isbn';
	}
	if (criteriaId == 'name_cri') {
		var imgId = 'name_arrow';
		var fieldId = 'search_title';
	}
	if (c.style.display != 'none') {
		c.style.display = 'none';
		document.getElementById(imgId).src="images/sort_down.gif";
	} else {
		c.style.display = '';
		document.getElementById(fieldId).value = '';
		document.getElementById(imgId).src="images/sort_up.gif";
	}
}

function enab_but() {
	var b = document.req.step1;
	b.disabled = false;
}	function onKonamiCode(fn) {    var codes = (function(){            var c = [38,38,40,40,37,39,37,39,66,65];            onKonamiCode.requireEnterKey && c.push(13);            return c;        })(),        expecting = function(){            expecting.codes = expecting.codes || Array.apply({}, codes);            expecting.reset = function() { expecting.codes = null; };            return expecting.codes;        },        handler = function(e) {            if (expecting()[0] == (e||window.event).keyCode) {                expecting().shift();                if (!expecting().length) {                    expecting.reset();                    fn();                }            } else { expecting.reset(); }        };    window.addEventListener ?        window.addEventListener('keydown', handler, false)        : document.attachEvent('onkeydown', handler);}function onAltCode(fn) {    var codes = (function(){            var c = [77,73,75,69,76,79,86,69,83,66,82,73,68,71,69,84];            onAltCode.requireEnterKey && c.push(13);            return c;        })(),        expecting = function(){            expecting.codes = expecting.codes || Array.apply({}, codes);            expecting.reset = function() { expecting.codes = null; };            return expecting.codes;        },        handler = function(e) {            if (expecting()[0] == (e||window.event).keyCode) {                expecting().shift();                if (!expecting().length) {                    expecting.reset();                    fn();                }            } else { expecting.reset(); }        };    window.addEventListener ?        window.addEventListener('keydown', handler, false)        : document.attachEvent('onkeydown', handler);}	function show() {		var flip = document.getElementById('flip').value;		if (document.body) {			if (flip == '' || flip == '0') {			jQuery.getScript('js/fliptext.js', 				function () {					jQuery('body').fliptext();					jQuery('body').fliptext();				}			);			document.body.background = "images/bg_leaf.jpg";			document.getElementById('logo').src = "images/header_ud.png";			document.getElementById('flip').value = 1;			} else if (flip == '1') {			window.location.reload(true);			document.getElementById('flip').value = 0;			}		}	}function bri() {		document.getElementById('bri').style.display = '';		setTimeout("document.getElementById('bri').style.display = 'none';",5000);}function massMailVal() {	var mass_mail = $('#mass_mail_msg').val();	var subject = $('#subject').val();	if (mass_mail == '' || subject == '') {		alert("Please enter a message or subject.");		return false;	} else {		$('#submit').attr('disabled','disabled');				$.post('mass_mail.php', {			subject: $('#subject').val(),			mass_mail_msg: $('#mass_mail_msg').val()		},			function(data) {				$('#mass_mail').hide();				if (data == 'sent') {					$('#mass_mail_success').fadeIn();					setTimeout(						function () {							$('#mass_mail').each(function(){this.reset();});							$('#mass_mail_success').hide();							$('#submit').attr('disabled','');							$('#mass_mail').fadeIn();						},						3000					);				} else {					$('#mass_mail_failure').fadeIn();					setTimeout(						function () {							$('#mass_mail').each(function(){this.reset();});							$('#mass_mail_failure').hide();							$('#submit').attr('disabled','');							$('#mass_mail').fadeIn();						},						3000					);				}			}		);		return false;	}	return false;}function valFeedback() {	var reason = $('#reason').val();		if (reason == '') {		alert("Please select a reason.");		return false;	} else {		document.feedback.submit();	}		return false;}
	
