﻿// Changes the font size for the elements
function changeFontSize(direction)
{
    if (document.getElementById("mainContentWell").style.fontSize == "")
    {
        document.getElementById("mainContentWell").style.fontSize = "100%";
    }

    if (document.getElementById("clearSealFullWidth") != null) {
        if (document.getElementById("clearSealFullWidth").style.fontSize == "") document.getElementById("clearSealFullWidth").style.fontSize == "100%";
    }

    var navID = "";

    if (document.getElementById("navSealOnly") != null) navID = "navSealOnly";
    else if (document.getElementById("nav") != null) navID = "nav";
    
    if (navID != "") {
        if (document.getElementById(navID).style.fontSize == "") {
            document.getElementById(navID).style.fontSize = "100%";
        }
    }
    // parse out the current font size and increase/decrease by 10% points
    var newSize = parseInt(document.getElementById('mainContentWell').style.fontSize.replace("%", ""));
    newSize += 10 * direction;

    if (newSize >= 50 && newSize <= 150)
    {
        document.getElementById('mainContentWell').style.fontSize = newSize.toString() + "%";
        if (navID != "") document.getElementById(navID).style.fontSize = newSize.toString() + "%";
        if (document.getElementById("clearSealFullWidth") != null) document.getElementById("clearSealFullWidth").style.fontSize = newSize.toString() + "%";
    }
}


// Show/Hides an element based on it's current visibility
function showhideDiv(id)
{ 
	if (document.getElementById)
	{ 
		obj = document.getElementById(id); 
		
		if (obj.style.display == "none")
		{	

			obj.style.display = "";
		}
		else 
		{ 
			obj.style.display = "none";
		} 
	}
}


function changeSheriffPhoto(thePicture, theTitle) {
    document.SheriffPhoto.src = "/uploadedImages/Global_Image_Library/Categories/Sheriff/Sheriffs/" + thePicture
    document.getElementById("SheriffTitle").innerHTML = theTitle
}







//Library Catalog Search Preform Search on Enter Key
function PreformCatalogSearch(field, event, criteria, type)
{
    var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
    if (keyCode == 13)
    {
        CatalogSearch(criteria, type);
        return false;
    }
}

//Library Catalog Search
function CatalogSearch(criteria, type ) {

	var link = 'http://snapweb.snap.lib.ca.us/cgi-bin/cw_cgi?10000+REDIRX+useDatabase_240_' + type + '_' + criteria;

	window.open(link,'mywindow');
	
	return true;
}

// Auto-resizes an iFrame to fit the height of the browser window. Just supply an offset of where on the page
// the iFrame starts from the top of the browsing area
function autoResizeiFrame(id, offset) {
    var winH = 450;

    if (parseInt(navigator.appVersion) > 3) {
        if (navigator.appName == "Netscape") {
            winH = window.innerHeight;
        }
        if (navigator.appName.indexOf("Microsoft") != -1) {
            winH = document.documentElement.clientHeight;

        }
    }

    document.getElementById(id).height = (winH - offset) + "px";
}

