function changePage(page) {
	document.searchform.startrow.value = (page-1)*25;
	liveSearchStart();
}
	
function updateSearch() {
	
	document.searchform.startrow.value = 0;	
	mypages.refresh(myajaxbook);
	liveSearchStart();
		
}

function goURL(s) {       
	var d = s.options[s.selectedIndex].value
    window.top.location.href = d
    s.selectedIndex=0
}

function getPage(page){
	var xmlhttp=false; //Clear our fetching variable
	try {
		xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
	} catch (e) {
		try {
			xmlhttp = new
			ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
							} catch (E) {
									xmlhttp = false;
													}
					}
					if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
									xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
					}
					var file = 'text.php?page='; //This is the path to the file we just finished making *
			xmlhttp.open('GET', file + page, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
			xmlhttp.onreadystatechange=function() {
					if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
									var content = xmlhttp.responseText; //The content data which has been retrieved ***
									if( content ){ //Make sure there is something in the content variable
												document.getElementById('content').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
									}
					}
					}
					xmlhttp.send(null) //Nullify the XMLHttpRequest
	return;
}

//-----------------------------
 //dropout tree menu script //
//---------------------------- 
/*
if (document.getElementById){  //sets initial state of the menu to hidden - block this code to initially show
	document.write('<style type="text/css">\n')
	document.write('.submenu{display: none;margin-bottom: 15px;}\n')
	document.write('</style>\n')
}
*/

function showHide(obj) { //onclick either shows or hides the current dropout
	
	var showEl = document.getElementById(obj);
	var showAr = document.getElementById("navMenu").getElementsByTagName("span");
	if(showEl.style.display != "block"){ 
		showEl.style.display = "block";
	} else {
		showEl.style.display = "none";
	}
}

function openWin(theURL,winName,w,h,scroll) { 

	if ((screen.width<=1024) && (screen.height<=768)) {
		settings = 'height='+screen.height*.89+',width='+screen.width*.89+',scrollbars='+scroll+',resizable=no';
	} else {
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	    TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	    settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=no';
	}
	window.open(theURL,winName,settings);
}

function swapImageViewed(image){
	//var newImage = selectedView + currentImage;
	window.document.imageViewed.src = 'images/catalog/'+image;
}

function userFormCheck(formobj){
	// name of mandatory fields
	var fieldRequired = Array("name", "username", "password", "password2", "permission", "email");
	// field description to appear in the dialog box
	var fieldDescription = Array("Name", "Username", "Password", "Verify Password", "permission", "Email");
	// dialog message
	var alertMsg = "Please complete the following fields:\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}

/*
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

*/


function loggingIn() {
	if (document.getElementById('loginEmail').value!="" && document.getElementById('loginPass').value!="") {
		document.getElementById('loginSubmit').disabled=false;
	} else {
	  document.getElementById('loginSubmit').disabled=true;
	}
}