function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function removeclassnames() {
	var lst=document.getElementById('menuproduct');
	if (lst) {
		var lst2 = lst.getElementsByTagName('li');
		if (lst2) {
			for (var i=0;i<lst2.length;i++) {
				var a=lst2[i].getElementsByTagName('a')[0];
				a.className = "";
			}	
		}
	}	
}

function categorie() {
	var lst=document.getElementById('menuproduct');
	if (lst) {
		var lst2 = lst.getElementsByTagName('li');
		if (lst2) {
			for (var i=0;i<lst2.length;i++) {
				var a=lst2[i].getElementsByTagName('a')[0];
				if (a.getAttributeNode('id').value != "no") {
					a.onclick = function() {
						do_pic(this,this.getAttributeNode('id').value);
						return false;
					}
				}
			}	
		}
	}	
}

function do_pic(a,str) {
	var foto = document.getElementById('photo');
	if (foto) {
		foto.src = str;
		removeclassnames();
		a.className = "active";
	}
}

function contact() {
	var frm = document.contactform;
	if (frm) {
		frm.onsubmit = function() {
			 return validate(frm);
		}
	}
}

function validate(theForm) {
	var msg = "";
	var error = 0;
	
	if(theForm.first_name.value=="") {
		error++;
		msg+="\n- " + lbl_contact_firstname;
	}
	if(theForm.last_name.value=="") {
		error++;
		msg+="\n- " + lbl_contact_lastname;
	}
	if(theForm.country.selectedIndex==0) {
		error++;
		msg+="\n- " + lbl_contact_country;
	}
	if(theForm.email.value=="") {
		error++;
		msg+="\n- " + lbl_contact_email;
	}
	if(theForm.message.value=="") {
		error++;
		msg+="\n- " + lbl_contact_message;
	}
	if(error) {
		alert(lbl_contact_fillout+": "+msg);
		return false;
	}
	theForm.x.value = "abc123";
	return true;
}	

//addLoadEvent(categorie);
addLoadEvent(contact);