﻿// perform JavaScript after the document is scriptable.
$(document).ready(function() {
	//default search field text
	var active_color = '#000'; // Colour of user provided text
	var inactive_color = '#858585'; // Colour of default text
	$("input.ow_sbox").css("color", inactive_color);
	var default_values = new Array();
	$("input.ow_sbox").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];
			}
		});
	});
	$("input.ow_sbutton").click(function() {
		var ow_sbox = $(this).siblings("input.ow_sbox")[0];
		if (ow_sbox && (!default_values[ow_sbox.id] || ow_sbox.value == default_values[ow_sbox.id])) {
			return false;
		}
	});

	if (typeof OneWeb.Admin === "undefined") {
		//do stuff only when NOT logged in to OW
		$('.slideshow').cycle({ fx: 'fade' });
		// if ($('.resources_intro').length > 0) {
		//if this block is empty, remove the negative top margin
		//     if ($('.bookshelf_cnt').length <= 0 && $('.bookshelf_img').length <= 0) {
		//         $('.resources_intro').css({ "margin-top": "0" });
		//     }
		// }
		$("#ebook-tabs").tabs({ fx: { opacity: "toggle", effect: "fade", fadeOutSpeed: 2} });
	} else {
		//don't run these scripts when logged in to OW
		// setup ebbok tabs blocks for editing mode
		$(".admin_header").css({ 'display': 'block' });
		$("#fragment-1,#fragment-2,#fragment-3,#fragment-4,#fragment-5,#fragment-6,#fragment-7").removeClass("ui-tabs-hide");
		//show page docs
		$("#page_docs").removeClass("hidden");
		//expand partners slideshow block
		$('.h_partners').css({ "height": "auto", "overflow": "inherit" });
		//reset css for e-bookshelf intro blocks
		//        if ($('.resources_intro').length > 0) {
		//            $('.resources_intro').css({ "margin-top": "0" });
		//            $('.bookshelf_img').css({ "position": "static" });
		//            $('.bookshelf_cnt').css({ "padding-top": "0" });
		//        }
	}
});

