function nai(n,d){
	    this.location.href = 'mailto:'+n+'@'+d; 
 }
function validatecontact() {

	var f = document.forms.contact_form;		
	var txt = '';

	if (f.contact_name.value=='') {
		txt = txt +"Namn\n";		
	}
	var str = f.contact_email.value;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i	
	if (str == '') {
		if (f.contact_tel.value=='') {
			txt = txt + "E-post eller telefon\n";
		}
	} else {
		if (!filter.test(str)) {						
			txt = txt +"E-postadress\n";		
		}
	}
	

	if (txt == "") { 
		return true;	
	} else {
		alert("Obligatoriska uppgifter:\n\n"+txt);
		return false;		
	}
					
}

function timedCount() {	

	t=setTimeout("timedCount()",tspeed);
	if (showimg == myimgs.length) {
		showimg = 0;
	}
	
	initImage(myimgs[showimg]);
	showimg = showimg + 1;
}	


function initImage(img) {
  imageId = 'thephoto';
  fadeOut(img,imageId,100);

}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    obj.style.display = '';
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 2;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 10);
    }
  }
}


function fadeOut(img,objId,opacityOut) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacityOut >= 0) {
      setOpacity(obj, opacityOut);
      opacityOut-= 2;
      window.setTimeout("fadeOut('"+img+"','"+objId+"',"+opacityOut+")", 10);
    } else {
      image = document.getElementById(objId);
//      image.style.display='hidden';      //
      image.src = img;	
      fadeIn(objId,0);	
    }
  }
}