// JavaScript Document

function get_edress()
{
	var edress = 'enquire_at_deepstream_dot_com_dot_au';	
	var re= /_dot_/gi;
	edress = edress.replace(re,'.');	
	var re= /_at_/gi;		
	edress = edress.replace(re,'@');	
	return edress;
}

	
function send_generic_mail()
{	
	var the_link="mai" + "lto" +":"+get_edress()+
				  "?subject=Deepstream%20Enquiry"+
				  "&body=Thank%20you%20for%20contacting%20me.%0D%0A"+
				  "Please%20provide%20as%20much%20information%20as%20possible%20so%20I%20can%20deal%20with%20your%20enquiry%20efficiently." ;
	window.location=the_link;	
}



function showImage(fileName, title, caption)
{	
	newWin = window.open('', 'image_win', 'resizable=yes, width=800, height=600');	
	newWin.document.write('<html><head><title>' + title + '</title></head>');	
	newWin.document.write('<body><p align="center">');
	newWin.document.write('<img src="' + fileName + '"><br><br>');
	newWin.document.write('<font face="verdana" size=1><b>' +  caption + '</b></font>');
	newWin.document.write('</p></body>');
	newWin.document.write('</html>');
	newWin.document.close();	
}

function validateRegistration(form)
{
	if (form.name.value == "") { //This checks to make sure the field is not empty
	   alert("Name field is empty."); //Informs user of empty field
	   form.name.focus( ); //This focuses the cursor on the empty field
	   return false; //This prevents the form from being submitted
	   }
	else if (form.company.value == "") { //This checks to make sure the field is not empty
	   alert("Company field is empty."); //Informs user of empty field
	   form.company.focus( ); //This focuses the cursor on the empty field
	   return false; //This prevents the form from being submitted
	   }
	else if (form.email.value == "") { //This checks to make sure the field is not empty
	   alert("Email field is empty."); //Informs user of empty field
	   form.email.focus( ); //This focuses the cursor on the empty field
	   return false; //This prevents the form from being submitted
	   } 
	else if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.email.value)){
	alert("Email field is not valid"); //Enter a valid e-mail address";
	   form.email.focus( ); //This focuses the cursor on the empty field
	   return false; //This prevents the form from being submitted
	}
	else if (form.industry.selectedIndex==0)	   	
	{ //This checks to make sure the field is not empty
	   alert("Please select a valid Industry preference."); //Informs user of empty field
	   form.industry.focus( ); //This focuses the cursor on the empty field
	   return false; //This prevents the form from being submitted
	}	  
	else if (form.country.selectedIndex==0)	   	
	{ //This checks to make sure the field is not empty
	   alert("Please select a valid Country."); //Informs user of empty field
	   form.country.focus( ); //This focuses the cursor on the empty field
	   return false; //This prevents the form from being submitted
	}	 
}

function validateEmailForm(form) 
{ //Check form script
	if (form.name.value == "") { //This checks to make sure the field is not empty
	   alert("Name field is empty."); //Informs user of empty field
	   form.name.focus( ); //This focuses the cursor on the empty field
	   return false; //This prevents the form from being submitted
	   }
	else if (form.company.value == "") { //This checks to make sure the field is not empty
	   alert("Company field is empty."); //Informs user of empty field
	   form.company.focus( ); //This focuses the cursor on the empty field
	   return false; //This prevents the form from being submitted
	   }
	else if (form.phone.value == "" && form.prefcontact.selectedIndex == 2) { //This checks to make sure the field is not empty
	   alert("Phone field is empty."); //Informs user of empty field
	   form.phone.focus( ); //This focuses the cursor on the empty field
	   return false; //This prevents the form from being submitted
	   }
	else if (form.email.value == "" && form.prefcontact.selectedIndex == 1) { //This checks to make sure the field is not empty
	   alert("Email field is empty."); //Informs user of empty field
	   form.email.focus( ); //This focuses the cursor on the empty field
	   return false; //This prevents the form from being submitted
	   } 
	// validate an e-mail address
	else if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.email.value) &&
	form.prefcontact.selectedIndex == 1){
	alert("Email field is not valid"); //Enter a valid e-mail address";
	   form.email.focus( ); //This focuses the cursor on the empty field
	   return false; //This prevents the form from being submitted
	}
	
	else if (form.prefcontact.selectedIndex==0)	   	
	{ //This checks to make sure the field is not empty
	   alert("Please select a valid Contact preference."); //Informs user of empty field
	   form.prefcontact.focus( ); //This focuses the cursor on the empty field
	   return false; //This prevents the form from being submitted
	}
	   
	else if (form.prefsubject.selectedIndex==0)
	{ //This checks to make sure the field is not empty
	   alert("Please select a valid Subject heading."); //Informs user of empty field
	   form.prefsubject.focus( ); //This focuses the cursor on the empty field
	   return false; //This prevents the form from being submitted
	}
	
	else if (form.message.value == "") { //This checks to make sure the field is not empty
	   alert("Message field is empty."); //Informs user of empty field
	   form.message.focus( ); //This focuses the cursor on the empty field
	   return false; //This prevents the form from being submitted
	}
	   
}