// Function groups are written in order of increasing specificity.


// ##########     Text Size Functions
function decreaseText(){ textSize(-1); }
function resetText(){ textSize(0); }
function increaseText(){ textSize(1); }

var c = 0; //number of clicks positive or negative.

function textSize(d){
if (!d){
	c = 0;
	}
else if ((1+d) && (c<6)){
	c = c + d;
	}
else if (!(1+d) && (c>-3)){
	c = c + d;
	}
var size = 100 + 5*c;
document.body.style.fontSize = size + "%";	
return false;
}


// ##########     Form Validation
function validate(){
frm = document.forms[0];
num = frm.elements.length
for(i=0; i<=num; i++){
	if(!frm.elements[i].value){
		alert("Please fill all fields.");
		return false;
		}
	}
return true;
}


// ##########     Print Function
function printpage(){ window.print(); return false;}


// ##########     Email Function
function hide(){
document.getElementById('emailwrapper').style.display = 'none';
}

var d = 0;

function show_email(){
if(!d){
	document.getElementById('emailwrapper').style.display = 'block';
	d = 1;
	}
else {
	document.getElementById('emailwrapper').style.display = 'none';
	d = 0;
	}
}


// ##########     Bookmark Function
var Title = document.title;
var Url = location.href;

function addBookmark(){
if (window.sidebar) { 
	window.sidebar.addPanel(Title, Url,""); 
	}
else if( document.all ){
	window.external.AddFavorite(Url, Title);
	}
else if( window.opera && window.print ){
	return true;
	}
return false
}


// ##########     Event handler set
function func_set(){

	/* If one of the properties defined bellow does not exist.
	 * for some reason the function stops executing and does not
	 * finish defining the event handlers. So the order of the
	 * statements is important. */

document.getElementById('decrease').onclick = decreaseText;
document.getElementById('reset').onclick = resetText;
document.getElementById('increase').onclick = increaseText;

document.forms[0].onsubmit = validate;

document.getElementById('func_print').onclick = printpage;
hide();
document.getElementById('func_email').onclick = show_email;
document.getElementById('func_bookmark').onclick = addBookmark;
}

window.onload = func_set;


