//common functions
	function  switchimage(imagename,newimage){
		if (document.images) {
			eval("document."+imagename+".src=\""+newimage+"\";");
		}
	}
	
	function  rollover(imagename,newimage){
		switchimage(imagename,newimage);
	}

//Pre-load images
	if (document.images) {
		//header
		mpa_logo_over = new Image(93,40);
		mpa_logo_over.src = 'images/nzfact_logo_over.gif';
		
		//menu
		menu_piracy_over = new Image(121,16);
		menu_piracy_over.src = 'images/menu_piracy_over.gif';
				
		menu_copyright_over = new Image(145,16);
		menu_copyright_over.src = 'images/menu_copyright_over.gif';
		
		menu_beingdone_over = new Image(153,16);
		menu_beingdone_over.src = 'images/menu_beingdone_over.gif';
		
		menu_tome_over = new Image(129,16);
		menu_tome_over.src = 'images/menu_tome_over.gif';	
		
		menu_cando_over = new Image(120,16);
		menu_cando_over.src = 'images/menu_cando_over.gif';	
		
		menu_protect_over = new Image(196,16);
		menu_protect_over.src = 'images/menu_protect_over.gif';	
		
		menu_suspect_over = new Image(240,16);
		menu_suspect_over.src = 'images/menu_suspect_over.gif';
		
		report_piracy_over = new Image(210,90);
		report_piracy_over.src = 'images/report_piracy_over.gif';	
	}

	function putMessage(error_message){
		alert(error_message);
		return false;
	}

	function hasValue(obj, obj_type){
   	 if (obj_type == "TEXT" || obj_type == "PASSWORD"){
    		if (obj.value.length == 0) 
      			return false;
    		else 
      			return true;
	    } else if (obj_type == "SINGLE_VALUE_RADIO" || obj_type == "SINGLE_VALUE_CHECKBOX") {
			if (obj.checked)
				return true;
			else
       			return false;	
		} else if (obj_type == "RADIO" || obj_type == "CHECKBOX") {
			for (i=0; i < obj.length; i++){
				if (obj[i].checked)
					return true;
			}
			return false;	
		}else  if (obj_type == "SELECT") {
			if (obj.selectedIndex == 0)
				return false;
			else
				return true;
		}
	}
	
	function checkEmail(email){
		var email_string = email.value; 
		var at_position = email_string.indexOf('@'); 
		var dot_position = email_string.indexOf('.', at_position); 
		var extension = email_string.substring(dot_position+1,email_string.length); 
		
		if(at_position<0){
			return false; 
		} else if (dot_position<0){
			return false; 
		} else if (extension.length<=0){
			return false; 
		} 
		return true; 
	}

	function checkForm(this_form){
		
		//Name
		if  (!hasValue(this_form.anonymous, "SINGLE_VALUE_CHECKBOX" )) {
			if  (!hasValue(this_form.name, "TEXT" )) {
				if  (!putMessage("Please enter your name.")){
					return false; 
				}
			}
		}

		//suspects		
		if  (!hasValue(this_form.suspects, "TEXT" )) {
			if  (!putMessage("Please provide the detail of the suspected pirate.")){
					return false; 
			}
		}		
		 //suspectedActivity
		if  (!hasValue(this_form.suspectedActivity, "TEXT" )) {
			if  (!putMessage("Please provide the detail of the suspected piracy activity.")){
					return false; 
			}
		}		
				
		
		
		//piracyType
		var piracyTypeGroup = this_form.piracyType;
		var piracyTypeSelectionMode=false; 
		for (i=0; i < piracyTypeGroup.length; i++){
			if (piracyTypeGroup[i].checked){
				piracyTypeSelectionMode = true;
			}
		}
		if (!piracyTypeSelectionMode){
			if  (!putMessage("Please specify the type of piracy.")){
					return false; 
			}
		}		

		//contact
		var contactMethodGroup = this_form.contactMethod;
		var contactMethodSelectionMode=false;
		var contactMethodChoice = "";
		for (i=0; i < contactMethodGroup.length; i++){
			if (contactMethodGroup[i].checked){
				contactMethodChoice = contactMethodGroup[i].value;
				contactMethodSelectionMode = true;
			}
		}
		if (!contactMethodSelectionMode){
			if  (!putMessage("Please specify the method of contact.")){
					return false; 
			}
		} else {
			if (contactMethodChoice == "Telephone"){
				if  (!hasValue(this_form.contactDetail, "TEXT" )) {
					if  (!putMessage("Please provide Contact details.")){
							return false; 
					}
				}	
			} else if (contactMethodChoice == "Email") {
				if  (!hasValue(this_form.email, "TEXT" )) {
					if  (!putMessage("Please provide your email address.")){
							return false; 
					}
				} else if (!checkEmail(this_form.email)) {
					if  (!putMessage("Your email address seems to be incorrect.")){
							return false; 
					}	
				}
			}
		}
				
		return true;
	}
