function deleteJob(jobId, job){
	if(confirm("do you really want to delete the job " + job + " \n(and all its corresponding images)?")){
		document.editJobsForm.jobId.value = jobId;
		document.editJobsForm.jobAction.value = "delete";
		document.editJobsForm.submit();
	}
}
function editJob(jobId){
		document.editJobsForm.jobId.value = jobId;
		document.editJobsForm.jobAction.value = "edit";
		document.editJobsForm.submit();
}
function editImages(jobId){
		document.editJobsForm.jobId.value = jobId;
		document.editJobsForm.jobAction.value = "editImages";
		document.editJobsForm.submit();
}
function editVideos(jobId){
		document.editJobsForm.jobId.value = jobId;
		document.editJobsForm.jobAction.value = "editVideos";
		document.editJobsForm.submit();
}
function addImageToJob(jobId){
		document.editJobsForm.jobId.value = jobId;
		document.editJobsForm.jobAction.value = "addImageToJob";
		document.editJobsForm.submit();
}
function addVideoToJob(jobId){
		document.editJobsForm.jobId.value = jobId;
		document.editJobsForm.jobAction.value = "addVideoToJob";
		document.editJobsForm.submit();
}
function deleteImage(imageId, jobId, job){
	if(confirm("do you really want to remove this image\n from the job " + job + "?")){	
		document.editJob.jobId.value = jobId;
		document.editJob.jobImageId.value = imageId;
		document.editJob.submit();
	}
}
function deleteVideo(videoId, jobId, job){
	if(confirm("do you really want to remove this video\nfrom the job " + job + "?")){	
		document.editJob.jobId.value = jobId;
		document.editJob.jobVideoId.value = videoId;
		document.editJob.submit();
	}
}
function checkNewJobForm(){
	var valid = true;
	if(document.createJobForm.clientName.value == ""){
		valid = false;
		alert("please enter client.");
	}
	if(document.createJobForm.teasertextDeu.value == ""){
		valid = false;
		alert("please enter german teaser text.");
	}
	if(document.createJobForm.teasertextEng.value == ""){
		valid = false;
		alert("please enter english teaser text.");
	}
	if(document.createJobForm.teasertextPor.value == ""){
		valid = false;
		alert("please enter portuguese teaser text.");
	}
	if(valid){
		document.createJobForm.submit();
	}
}
function checkContactForm(){
	var valid = true
	if(document.contactForm.emailAddress.value == ""){
		valid = false;
		alert("please enter email address.");
	}else{
		if(!validateEmail(document.contactForm.emailAddress.value,true,false)){
			valid = false;
			alert("please enter valid email address.");
		}
	}
	if(document.contactForm.helloFrom.value == ""){
		valid = false;
		alert("please enter your name.");
	}
	if(document.contactForm.emailSubject.value == ""){
		valid = false;
		alert("please enter email subject.");
	}
	if(document.contactForm.emailMessage.value == ""){
		valid = false;
		alert("please write me a message.");
	}
	if(valid){
		document.contactForm.submit();
	}
}

function checkVideoUploadForm(){
	var valid = true;
	formObject = document.videoUploadForm;
	if(formObject.image1.value == ""){
		valid = false;
		alert("please choose video.");
	}
	if(formObject.width.value == ""){
		valid = false;
		alert("please enter width.");
	}
	if(formObject.height.value == ""){
		valid = false;
		alert("please enter height.");
	}
	if(valid){
		formObject.submit();
	}
}

// Email Validation Javascript
// copyright 23rd March 2003, by Stephen Chapman, Felgall Pty Ltd

// You have permission to copy and use this javascript provided that
// the content of the script is not changed in any way.

function validateEmail(addr,man,db) {
/*if (addr == '' && man) {
   if (db) alert('email address is mandatory');
   return false;
}*/
var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
for (i=0; i<invalidChars.length; i++) {
   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
      if (db) alert('email address contains invalid characters');
      return false;
   }
}
for (i=0; i<addr.length; i++) {
   if (addr.charCodeAt(i)>127) {
      if (db) alert("email address contains non ascii characters.");
      return false;
   }
}

var atPos = addr.indexOf('@',0);
if (atPos == -1) {
   if (db) alert('email address must contain an @');
   return false;
}
if (atPos == 0) {
   if (db) alert('email address must not start with @');
   return false;
}
if (addr.indexOf('@', atPos + 1) > - 1) {
   if (db) alert('email address must contain only one @');
   return false;
}
if (addr.indexOf('.', atPos) == -1) {
   if (db) alert('email address must contain a period in the domain name');
   return false;
}
if (addr.indexOf('@.',0) != -1) {
   if (db) alert('period must not immediately follow @ in email address');
   return false;
}
if (addr.indexOf('.@',0) != -1){
   if (db) alert('period must not immediately precede @ in email address');
   return false;
}
if (addr.indexOf('..',0) != -1) {
   if (db) alert('two periods must not be adjacent in email address');
   return false;
}
var suffix = addr.substring(addr.lastIndexOf('.')+1);
if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
   if (db) alert('invalid primary domain in email address');
   return false;
}
return true;
}