function rel_path (root, from_root, filen) {
rel_to_root = ''
	path = window.location.pathname
	to_root = path.substring (root.length + 1)
	dirs = to_root.split('/')
	for (i = 0; i < dirs.length -1; i++) {
		rel_to_root += '../'	
	}
return rel_to_root + from_root + filen
}

function img_path (filen) {
	return rel_path ('', 'images/button/', filen)
}

function preload_images (page) {
	if (document.images) //test if images enabled
	{
		//Home
		home_u = new Image(); home_u.src = img_path ('home_u.jpg');
		home_m = new Image(); home_m.src = img_path ('home_m.jpg');
		if (page == 'h') { home = new Image(); home.src = img_path ('home.jpg') }	
		
		//About
		about_u = new Image(); about_u.src = img_path ('about_u.jpg');
		about_m = new Image(); about_m.src = img_path ('about_m.jpg');
		if (page == 'a') { about = new Image(); about.src = img_path ('about.jpg') }	
	
		//Products
		products_u = new Image(); products_u.src = img_path ('products_u.jpg');
		products_m = new Image(); products_m.src = img_path ('products_m.jpg');
		if (page == 'p') { products = new Image(); products.src = img_path ('products.jpg') }
	
		//Gallery
		gallery_u = new Image(); gallery_u.src = img_path ('gallery_u.jpg');
		gallery_m = new Image(); gallery_m.src = img_path ('gallery_m.jpg');
		if (page == 'g') { gallery = new Image(); gallery.src = img_path ('gallery.jpg') }	
		
		//Contact
		contact_u = new Image(); contact_u.src = img_path ('contact_u.jpg');
		contact_m = new Image(); contact_m.src = img_path ('contact_m.jpg');
		if (page == 'c') { contact = new Image(); contact.src = img_path ('contact.jpg') }	

	}	
}

function do_over(imagename)
{
	 if (document.images) 
	 {
	 	document.images[imagename].src = eval(imagename+"_m.src") 
	 }
}

function do_out(imagename, f)
{
	 if (document.images) 
	 {
	 	if (f) {
	 		document.images[imagename].src = eval(imagename+".src")
	 	} else {
	 	document.images[imagename].src = eval(imagename+"_u.src") 
	 	}
	 }
}

