function validateForm(theForm) {
 var fname = theForm.firstname.value;
 var lname = theForm.lastname.value;
 var email = theForm.email.value;
 var pass = theForm.password.value;

 if (fname == "") {
   alert("Please provide your first name.");
   theForm.firstname.focus();
   return false;
 }
 
 if (lname == "") {
   alert("Please provide your last name.");
   theForm.lastname.focus();
   return false;
 }
 
 if (email == "") {
   alert("Please provide an email address.");
   theForm.email.focus();
   return false;
 } 
 
 if (pass == "") {
   alert("Please provide a password.");
   theForm.password.focus();
   return false;
 } 
 
 if (!theForm.terms.checked) {
 	alert("You must accept the Terms and Conditions.")
 	return false;
 }
 
 return true;
 
}

function validateForm2(theForm) {
 var fname = theForm.firstname.value;
 var lname = theForm.lastname.value;

 if (fname == "") {
   alert("Please provide your first name.");
   theForm.firstname.focus();
   return false;
 }
 
 if (lname == "") {
   alert("Please provide your last name.");
   theForm.lastname.focus();
   return false;
 }
 
 return true;
 
}

function validateContactForm(theForm) {
 var f_name = theForm.name.value;
 var f_email = theForm.email.value;

 if (f_name == "") {
   alert("Please provide your name.");
   theForm.name.focus();
   return false;
 }
 
 if (f_email == "") {
   alert("Please provide your your email.");
   theForm.email.focus();
   return false;
 }
 
 return true;
 
}

function uploadPhotos() {
    
	document.getElementById('theImage').innerHTML = '<img id="submitImage" name="submitImage" src="/images/up.gif" alt="Uploading">';
	document.uploadform.submit();
}

function openwin(theURL, w, h){
	ver = parseInt(navigator.appVersion.substring(0,1));       
	newWin=window.open(theURL,"Rimfire","width="+w+",height="+h+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,");
}

var xmlHttp

function showFeatured(str) 
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="/getfeatured.php"
	url=url+"?q="+str
	url=url+"&lang="+lang
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		// Split the comma delimited response into an array
    	results = xmlHttp.responseText.split("|");
    	document.getElementById('headlines').innerHTML = results[0];
 	 	document.getElementById('featured').innerHTML = results[1];
	} 
}

function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest) {
		objXMLHttp=new XMLHttpRequest()
	} else if (window.ActiveXObject) {
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}



// DF1.1 :: domFunction 
// *****************************************************
// DOM scripting by brothercake -- http://www.brothercake.com/
// GNU Lesser General Public License -- http://www.gnu.org/licenses/lgpl.html
//******************************************************


	function myFunction()
	{
		showFeatured('0');
	};
	var foobar = new domFunction(myFunction, { 'featured' : 'id'});


//DOM-ready watcher
function domFunction(f, a)
{
	//initialise the counter
	var n = 0;
	
	//start the timer
	var t = setInterval(function()
	{
		//continue flag indicates whether to continue to the next iteration
		//assume that we are going unless specified otherwise
		var c = true;

		//increase the counter
		n++;
	
		//if DOM methods are supported, and the body element exists
		//(using a double-check including document.body, for the benefit of older moz builds [eg ns7.1] 
		//in which getElementsByTagName('body')[0] is undefined, unless this script is in the body section)
		if(typeof document.getElementsByTagName != 'undefined' && (document.getElementsByTagName('body')[0] != null || document.body != null))
		{
			//set the continue flag to false
			//because other things being equal, we're not going to continue
			c = false;

			//but ... if the arguments object is there
			if(typeof a == 'object')
			{
				//iterate through the object
				for(var i in a)
				{
					//if its value is "id" and the element with the given ID doesn't exist 
					//or its value is "tag" and the specified collection has no members
					if
					(
						(a[i] == 'id' && document.getElementById(i) == null)
						||
						(a[i] == 'tag' && document.getElementsByTagName(i).length < 1)
					) 
					{ 
						//set the continue flag back to true
						//because a specific element or collection doesn't exist
						c = true; 

						//no need to finish this loop
						break; 
					}
				}
			}

			//if we're not continuing
			//we can call the argument function and clear the timer
			if(!c) { f(); clearInterval(t); }
		}
		
		//if the timer has reached 60 (so timeout after 15 seconds)
		//in practise, I've never seen this take longer than 7 iterations [in kde 3 
		//in second place was IE6, which takes 2 or 3 iterations roughly 5% of the time]
		if(n >= 60)
		{
			//clear the timer
			clearInterval(t);
		}
		
	}, 250);
};