// Current Page Reference
// copyright Stephen Chapman, 1st Jan 2005
// you may copy this function but please keep the copyright notice with it
function getURL(uri) {
	uri.dir = location.href.substring(0,location.href.lastIndexOf('\/'));
	uri.dom = uri.dir; if (uri.dom.substr(0,7) == 'http:\/\/') uri.dom = uri.dom.substr(7);
	uri.path = ''; var pos = uri.dom.indexOf('\/'); if (pos > -1) {uri.path = uri.dom.substr(pos+1); uri.dom = uri.dom.substr(0,pos);}
	uri.page = location.href.substring(uri.dir.length+1,location.href.length+1);
	pos = uri.page.indexOf('?');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
	pos = uri.page.indexOf('#');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
	uri.ext = ''; pos = uri.page.indexOf('.');if (pos > -1) {uri.ext =uri.page.substring(pos+1); uri.page = uri.page.substr(0,pos);}
	uri.file = uri.page;
	if (uri.ext != '') uri.file += '.' + uri.ext;
	if (uri.file == '') uri.page = 'index';
	uri.args = location.search.substr(1).split("?");
	return uri;
}

var uri = new Object();
getURL(uri);

function CreateHomepageLink(dash) {
	if (document.all){
		document.write('<a href="javascript:history.go(0);" onclick="this.style.behavior=\'url(#default#homepage)\';this.setHomePage(\'http://www.earthle.com\');">Make this my Homepage</a>');
		if (dash=='true'){
			document.write(' - ');
		}
	}
	else if (document.getElementById){
		document.write('<a href="http://www.earthle.com" onclick="javascript:leaving=false;">Drag to set as Homepage</a>');
		if (dash=='true'){
			document.write(' - ');
		}
	}
}

function CreateBookmark() {
	title = "Earthle - The Energy Saving Google Custom Search Engine"; 
	url = "http://www.earthle.com";
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; 
	}
}

function CreateBookmarkLink(dash) {
	if (window.external) {
		document.write('<a href="javascript:CreateBookmark()");">Add to Favorites</a>'); 
		if (dash=='true'){
			document.write(' - ');
		}
	} else  if (window.sidebar) {
		document.write('<a href="javascript:CreateBookmark()");">Add to Bookmarks</a>'); 
		if (dash=='true'){
			document.write(' - ');
		}
	} else if (window.opera && window.print) {	
		document.write('<a href="javascript:CreateBookmark()");">Add Bookmark</a>');
		if (dash=='true'){
			document.write(' - ');
		}
	} 
}