
// Hide toolbar on Iphone browser

addEventListener("load", function() { 
			setTimeout(hideURLbar, 0); }, false);
			function hideURLbar(){
			window.scrollTo(0,1);
		}
// Replace text in form

function textInInput (inp,Focus) {
	if (Focus) {
		if (inp.value==inp.defaultValue) 
			inp.value="";
			
	} else {
		if (inp.value=="") {
			inp.value=inp.defaultValue;
			
		}
	}
}

// Detect Iphone orientation

window.onload = function initialLoad() {
    updateOrientation();
}

function updateOrientation(){
    var contentType = "";
    switch(window.orientation){
        case 0:
	contentType += "portrait";
	break;

	case -90:
	contentType += "landscape";
	break;

	case 90:
	contentType += "landscape";
	break;

	case 180:
	contentType += "portrait";
	break;
    }
    document.getElementById("page_wrapper").setAttribute("class", contentType);
}

window.addEventListener("load", function() { setTimeout(loaded, 100) }, false);
	
		function loaded() {
			document.getElementById("page_wrapper").style.visibility = "visible";
			window.scrollTo(0, 1); // pan to the bottom, hides the location bar
		}

// jQuery stuff

$(document).ready(function() {
    $("#main-nav").hide();
	$("#search-form").hide();
	$("#loginform-container").hide();
	$("#menu a").toggle( function () { $(this).addClass("up");},function () {$(this).removeClass("up");
  }
);
    $("#menu a").click(function() { $("#main-nav").slideToggle(400);return false;});
  	$("#search a").click(function() { $("#search-form").slideToggle(400);return false;});
	$("#login a").click(function() { $("#loginform-container").slideToggle(400);return false;});
	
		//bookmark-it
	$('.bookmark-it a').click(function(){
		var pageName=window.location.href;
		var nameArr =pageName.split("?");
		pageName=nameArr[0] + "?" + nameArr[1];

		if (window.sidebar){
			window.sidebar.addPanel(document.title,pageName,"");
		} else if(document.all){ 
			window.external.AddFavorite(pageName,document.title);
		} else if(navigator.userAgent.toLowerCase().indexOf('iphone')!=-1) {
			alert('please press the \'+\' button on your browser to bookmark this site.');
		} else if(navigator.userAgent.toLowerCase().indexOf('webkit')!=-1) {
			alert('please press ctrl + D to bookmark');
		} else {
			return true;
		}
	});
});
