//	open external links in a new window - replaces target="_blank"
	function externalLinks () { 
		if ( ! document.getElementsByTagName ) return; 
		var anchors = document.getElementsByTagName("a"); 
		for ( var i=0; i < anchors.length; i++ ) { 
			var anchor = anchors[i]; 
			if ( anchor.getAttribute("href") && anchor.getAttribute("rel") == "external" ) anchor.target = "_blank"; 
		} 
	} 

//	preload images
	function preload_images () {
		arImageSrc = new Array ('media/images/nav_home_o.jpg','media/images/nav_collections_o.jpg','media/images/nav_categories_o.jpg','media/images/nav_manufacturers_o.jpg','media/images/nav_designers_o.jpg','media/images/nav_offers_o.jpg','media/images/nav_about_o.jpg','media/images/nav_contact_o.jpg');
		arImageList = new Array ();
		for (counter in arImageSrc) {
			arImageList[counter] = new Image();
			arImageList[counter].src = arImageSrc[counter];
		}
	}

//	SEARCH FIELD RECEIVED FOCUS
	function search_focus() {
		if ( document.getElementById('q').value == 'SEARCH...' ) {
			document.getElementById('q').value = '';
		}
	
	}

//	SEARCH FIELD LOSES FOCUS
	function search_blur() {
		if ( document.getElementById('q').value == '' ) {
			document.getElementById('q').value = 'SEARCH...';
		}
	}




//	add given page to favourites (bookmark)
	function setBookmark ( url, str ) {
		if ( str == '' ) str = url;
		if ( document.all ) window.external.AddFavorite( url, str );
		else alert( 'Sorry, this function only works in Internet Explorer.\n\nPlease press CTRL and D to add a bookmark to \n"' + str + '".' );
	}

//	toggle a given elements visibility
	function toggle (el) {
		if ( document.getElementById(el).style.display == 'none' ) {
			document.getElementById(el).style.display = '';
		} else {
			document.getElementById(el).style.display = 'none';
		}
	}

//	show a given element
	function show (el) {
		if ( document.getElementById(el) != undefined ) document.getElementById(el).style.display = '';
	}

	function activate_nav() {
		var fullpath = location.pathname;
		var patharray = fullpath.split('/');
		var fileposition = patharray.length - 1;
		var filename = patharray[fileposition];
		
		var filebasearray = filename.split('.');
		var filebase = filebasearray[0];
		
		if ( filebase == '' ) filebase = 'index';

		
	}

//	perform the following functions when the page loads
	window.onload = function(e) {
		externalLinks();
		preload_images();
		if ( document.getElementById('map') != undefined ) {
			load();
		}
	}
	
//	perform the following functions when the page loads
	window.onunload = function(e) {
		if ( document.getElementById('map') != undefined ) {
			GUnload();
		}
	}