/****** GLOBAL VARIABLES ******/

var rPath="images/";
var ints;
var speed=9;

/****** IMAGE RESIZING ******/

function resize(element)
{
clearInterval(ints);
var size = document.getElementById(element).width;
if 	(size<345)
	{
	ints=setInterval("big('"+element+"')", 10);
	}
else
	{
	ints=setInterval("small('"+element+"')", 10);
	}
}

function big(element)
{
var size = document.getElementById(element).width;
if (size<345)
	{
	size=size+speed;
	document.getElementById(element).width=size;
	document.getElementById(element).height=size;
	}
}

function small(element)
{
var size = document.getElementById(element).width;
if (size>100)
	{
	size=size-speed;
	document.getElementById(element).width=size;
	document.getElementById(element).height=size;
	}
}

/****** NAVIGATION ******/

function hide(element) 
{
	document.getElementById(element).style.visibility = "hidden";
}

function show(element) 
{
	document.getElementById(element).style.visibility = "visible";
}

function changeClass(element, newClass){
	document.getElementById(element).className= newClass;
}




/****** WINDOW OPENER ******/

function openindex(element) { 
var pic= new Image();
pic.src = rPath + element +".jpg";
var up1 = pic.height;
var across1 = pic.width;
var up2 = up1+80;
var across2 =across1+40;
var OpenWindow=window.open("", "new"+element, "height="+up2+", width="+across2+","); 
OpenWindow.document.writeln("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
OpenWindow.document.writeln("<html>");
OpenWindow.document.writeln("<head>");
OpenWindow.document.writeln("<title>Natural Magic</title>");
OpenWindow.document.writeln("<link rel=\"stylesheet\" type=\"text/css\" href=\"nmstyles.css\" />");
OpenWindow.document.writeln("</head>");
OpenWindow.document.writeln("<body>");
OpenWindow.document.writeln("</br>"); 
OpenWindow.document.writeln("<p style=\"text-align:center\"><img src=\"images/" + element + ".jpg\" id=\""+ element +"\" height=\""+ up1 +"\" width=\""+ across1 +"\" /></p>"); 
//OpenWindow.document.writeln("<p style=\"text-align:center\"><a href=\"javascript:self.close()\" target=\"_self\">Close</a></p>");
OpenWindow.document.writeln("<p style=\"text-align:right\"><a href=\"javascript:self.close()\" target=\"_self\"><img src=\"images/close.gif\" border=\"0\"></a></p>");
OpenWindow.document.writeln("</br>"); 
OpenWindow.document.writeln("</body>");
OpenWindow.document.writeln("</html>");
OpenWindow.document.close();
}

function errorCheck() {	
		
	if ((document.email_form.name.value=="")||(document.email_form.name.value==" ")){
		alert("Please fill in the 'your name' field");
		return false;
	}
	
	if ((document.email_form.visitormail.value=="")||(document.email_form.visitormail.value==" ")){
		alert("Please fill in the 'your email' field");
		return false;
	}
		
	if ((document.email_form.subject.value=="")||(document.email_form.subject.value==" ")){
		alert("Please fill in the 'subject' field");
		return false;
	}
	if ((document.email_form.notes.value=="")||(document.email_form.notes.value==" ")){
		alert("Please type a message");
		return false;
	}		
	else {			
		document.email_form.submit();		
		//alert("email okay");
	}
}

//name number generator

function Namenumber(){
	var xname= document.namnumform.namenum.value;
	var namearray = new Array(xname.length);    
	  for (var i=0; i < xname.length; i++) {
	    var letter = xname.charAt(i).toLowerCase();	
		if (letter==" "){namearray[i]=0;}		
		if (letter=="a"){namearray[i] = 1;}
		if (letter=="b"){namearray[i] = 2;}
		if (letter=="c"){namearray[i] = 3;}
		if (letter=="d"){namearray[i] = 4;}
		if (letter=="e"){namearray[i] = 5;}
		if (letter=="f"){namearray[i] = 6;}
		if (letter=="g"){namearray[i] = 7;}	
		if (letter=="h"){namearray[i] = 8;}	
		if (letter=="i"){namearray[i] = 9;}	
		if (letter=="j"){namearray[i] = 1;}	
		if (letter=="k"){namearray[i] = 2;}	
		if (letter=="l"){namearray[i] = 3;}	
		if (letter=="m"){namearray[i] = 4;}	
		if (letter=="n"){namearray[i] = 5;}	
		if (letter=="o"){namearray[i] = 6;}	
		if (letter=="p"){namearray[i] = 7;}	
		if (letter=="q"){namearray[i] = 8;}	
		if (letter=="r"){namearray[i] = 9;}	
		if (letter=="s"){namearray[i] = 1;}	
		if (letter=="t"){namearray[i] = 2;}	
		if (letter=="u"){namearray[i] = 3;}	
		if (letter=="v"){namearray[i] = 4;}	
		if (letter=="w"){namearray[i] = 5;}	
		if (letter=="x"){namearray[i] = 6;}	
		if (letter=="y"){namearray[i] = 7;}	
		if (letter=="z"){namearray[i] = 8;}	
	  }
	  
	  var xnumber=0;
	  	for (var j=0; j < xname.length; j++) {
	  		xnumber = xnumber + namearray[j];    	
	  	}
	 
	var fnumber=xnumber;
			
	while (fnumber > 9){
	   	var f1= Math.floor(fnumber/100);
		var f2= Math.floor((fnumber/10)-(f1*10));
		var f3= fnumber - (f1*100)-(f2*10);
		fnumber = f1+f2+f3;
	   }
	alert("Your name number is "+fnumber);	
		
}

